Function: smart-magit

smart-magit is an interactive and byte-compiled function defined in hui-mouse.el.

Signature

(smart-magit)

Documentation

Use a key or mouse key to jump to source and to hide/show changes.

Invoked via a key press when in a magit mode and not on a button. It assumes that its caller has already checked that the key was pressed in an appropriate buffer and has moved the cursor to the selected buffer.

If key is pressed:
 (1) on the last line, quit from the magit mode ("q" key binding);
 (2) at the end of a line, scroll up a windowful;
 (3) in a magit-status-mode buffer on a merge conflict marker, keep
     either the upper, both or the lower version of the conflict.
 (4) on a line starting with a + char in magit-status-mode or
     magit-revision-mode go to the worktree file.
 (5) on an initial read-only header line, cycle visibility of diff sections;
 (6) anywhere else, hide/show the thing at point ("TAB" key binding)
     unless that does nothing in the mode, then jump to the thing at
     point ("RET" key binding) but display based on the value of
     hpath:display-where.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui-mouse.el
(defun smart-magit ()
  "Use a key or mouse key to jump to source and to hide/show changes.

Invoked via a key press when in a magit mode and not on a button.
It assumes that its caller has already checked that the key was
pressed in an appropriate buffer and has moved the cursor to the
selected buffer.

If key is pressed:
 (1) on the last line, quit from the magit mode (\"q\" key binding);
 (2) at the end of a line, scroll up a windowful;
 (3) in a `magit-status-mode' buffer on a merge conflict marker, keep
     either the upper, both or the lower version of the conflict.
 (4) on a line starting with a `+' char in `magit-status-mode' or
     `magit-revision-mode' go to the worktree file.
 (5) on an initial read-only header line, cycle visibility of diff sections;
 (6) anywhere else, hide/show the thing at point (\"TAB\" key binding)
     unless that does nothing in the mode, then jump to the thing at
     point (\"RET\" key binding) but display based on the value of
     `hpath:display-where'."
  (interactive)
  (let (op)
    (cond ((last-line-p)
	   (call-interactively (key-binding "q")))
	  ((eolp)
	   (smart-scroll-up))
          ((and
            (eq major-mode 'magit-status-mode)
            (save-excursion
              (beginning-of-line)
              (cond ((looking-at (regexp-quote "++>>>>>>>"))
                     (setq op 'magit-smerge-keep-lower))
                    ((looking-at (regexp-quote "++<<<<<<<"))
                     (setq op 'magit-smerge-keep-upper))
                    ((looking-at (regexp-quote "++======="))
                     (setq op 'magit-smerge-keep-all)))))
           (call-interactively op))
          ((and
            (memq major-mode '(magit-status-mode magit-revision-mode))
            (save-excursion
              (beginning-of-line)
              (looking-at-p "\\+")))
           (call-interactively #'magit-diff-visit-worktree-file))
	   (t
	   (let ((magit-display-buffer-function #'hpath:display-buffer))
	     (call-interactively #'smart-magit-tab))))))