emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 8ef773d 18/25: Add Action/Assist key support


From: Stefan Monnier
Subject: [elpa] externals/hyperbole 8ef773d 18/25: Add Action/Assist key support for magit modes
Date: Tue, 22 Sep 2020 10:29:29 -0400 (EDT)

branch: externals/hyperbole
commit 8ef773d9abe3d5f9db7824e7a6bf95bd10cfea9f
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Add Action/Assist key support for magit modes
---
 Changes           |  4 ++++
 hui-mouse.el      | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 man/hkey-help.txt |  1 +
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/Changes b/Changes
index 41f9b71..eaa0dba 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 2020-07-29  Bob Weiner  <rsw@gnu.org>
 
+* man/hkey-help.txt: Added magit modes.
+  hui-mouse.el (smart-magit, smart-magit-assist): Added.
+               (hkey-alist): Added support for magit modes.
+
 * kotl/kotl-mode.el (kotl-mode:eolp): Added optional 'next-char-visible' arg.
                     (kotl-mode:action-key, kotl-mode:assist-key):
   hui-mouse.el (hkey-alist): In kotl-mode, matched to eol only if following
diff --git a/hui-mouse.el b/hui-mouse.el
index a0c41d6..e0759a2 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -370,6 +370,9 @@ Its default value is #'smart-scroll-down."
     ((eq major-mode 'gomoku-mode) .
      ((gomoku-human-plays) . (gomoku-human-takes-back)))
     ;;
+    ((string-prefix-p "magit-" (symbol-name major-mode)) .
+     ((smart-magit) . (smart-magit-assist)))
+    ;;
     ;; Support the OO-Browser when available.  It is a separate Emacs
     ;; package not included with Hyperbole.  Hyperbole supplies a stub
     ;; `br-in-browser' test for use here.
@@ -1188,7 +1191,7 @@ buffer and has moved the cursor to the selected buffer."
 ;;; ************************************************************************
 
 (defun smart-imenu-display-item-where (item-name item-pos)
-  "Displays an ITEM-NAME defined at ITEM-POS within the current buffer.
+  "Display an ITEM-NAME defined at ITEM-POS within the current buffer.
 Uses the imenu library and the value of `hpath:display-where' to display."
   (hpath:display-buffer (current-buffer))
   (funcall imenu-default-goto-function item-name item-pos))
@@ -1250,6 +1253,53 @@ NO-RECURSE-FLAG non-nil prevents infinite recursions."
 ;;; ************************************************************************
 ;;; In "hmouse-info.el".
 
+
+;;; ************************************************************************
+;;; smart-magit functions
+;;; ************************************************************************
+
+(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) anywhere else, hide/show the thing at point (\"TAB\" key binding)."
+  (interactive)
+  (cond ((last-line-p)
+        (call-interactively (key-binding "q")))
+       ((eolp)
+        (smart-scroll-up))
+       (t
+        (call-interactively (key-binding "\t")))))
+
+(defun smart-magit-assist ()
+  "Use an assist key or mouse key to jump to source and to hide/show changes.
+
+Invoked via an assist key press when in a magit mode and not on a
+button.  It assumes that its caller has already checked that the
+assist-key was pressed in an appropriate buffer and has moved the
+cursor to the selected buffer.
+
+If assist-key is pressed:
+ (1) on the last line, quit from the magit mode (\"q\" key binding);
+ (2) at the end of a line, scroll down a windowful;
+ (3) anywhere else, jump to the thing at point (\"RET\" key binding)."
+  (interactive)
+  (cond ((last-line-p)
+        (call-interactively (key-binding "q")))
+       ((eolp)
+        (smart-scroll-down))
+       (t
+        (setq current-prefix-arg 1)
+        (let ((magit-display-file-buffer-function #'hpath:display-buffer))
+          (call-interactively (key-binding "\r"))))))
+
 ;;; ************************************************************************
 ;;; smart-man functions
 ;;; ************************************************************************
diff --git a/man/hkey-help.txt b/man/hkey-help.txt
index 1d1289e..0b8645d 100644
--- a/man/hkey-help.txt
+++ b/man/hkey-help.txt
@@ -103,6 +103,7 @@ Hyperbole Key Press/Click in Special Modes
     Include file                Jumps to Texinfo referent  Button help
     code/var reference          Displays doc for referent  Button help
   Org Mode                      Follows links and cycles outline views
+  Magit Modes                   Collapses and expands things
   Outline Major/Minor Modes     Collapses, expands, and moves outline entries
   Man Apropos                   Displays man page entry    <- same
   Man Pages                     Follows cross refs, file refs and C code refs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]