[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole aad4494 40/50: Add smart-magit-tab: Do what T
From: |
Stefan Monnier |
Subject: |
[elpa] externals/hyperbole aad4494 40/50: Add smart-magit-tab: Do what TAB or RET does |
Date: |
Wed, 17 Mar 2021 18:44:21 -0400 (EDT) |
branch: externals/hyperbole
commit aad4494633bc32cfeb71978f141e500094a52f55
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Add smart-magit-tab: Do what TAB or RET does
---
hib-social.el | 6 +++---
hui-mouse.el | 42 +++++++++++++++++++++++++++---------------
hypb.el | 19 ++++++++++++++++---
3 files changed, 46 insertions(+), 21 deletions(-)
diff --git a/hib-social.el b/hib-social.el
index 1d32247..5a54ac1 100644
--- a/hib-social.el
+++ b/hib-social.el
@@ -610,10 +610,10 @@ PROJECT value is provided, it defaults to the value of
"Display the diff for a git commit reference, e.g. \"commit a55e21\",
typically produced by git log."
(when (save-excursion
(beginning-of-line)
- (looking-at "\\s-*\\(commit
\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f]+\\)\\)\\s-"))
+ (looking-at "\\(^\\|\\s-+\\)\\(commit
#?\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f]+\\)\\)\\(\\s-\\|$\\)"))
(save-match-data
- (ibut:label-set (match-string-no-properties 1) (match-beginning 1)
(match-end 1)))
- (hact #'git-reference (match-string-no-properties 2))))
+ (ibut:label-set (match-string-no-properties 2) (match-beginning 2)
(match-end 2)))
+ (hact #'git-reference (match-string-no-properties 3))))
(defvar hibtypes-git-repos-cache
(expand-file-name "Local-Git-Repos" hbmap:dir-user)
diff --git a/hui-mouse.el b/hui-mouse.el
index 02ad2ce..8fef759 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -55,11 +55,6 @@
(defun assist-key-error ()
(hypb:error "(Hyperbole Assist Key): No action defined for this context; try
another location"))
-(defcustom smart-magit-listing-modes '(magit-blame-mode magit-log-mode)
- "*List of major modes for which the Action Key should run RET instead of
TAB."
- :type '(group 'function)
- :group 'hyperbole)
-
(defcustom action-key-default-function #'action-key-error
"*Function run by the Action Key in an unspecified context.
Set it to #'hyperbole if you want it to display the Hyperbole minibuffer menu."
@@ -1274,20 +1269,17 @@ 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) on a line within a `smart-magit-listing-modes' buffer, jump to
- the thing at point (\"RET\" key binding).
- (4) anywhere else, hide/show the thing at point (\"TAB\" key binding)."
+ (3) 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)."
(interactive)
(cond ((last-line-p)
(call-interactively (key-binding "q")))
((eolp)
(smart-scroll-up))
- ((memq major-mode smart-magit-listing-modes)
- (setq current-prefix-arg 1)
- (let ((magit-display-file-buffer-function #'hpath:display-buffer))
- (call-interactively (key-binding "\r"))))
(t
- (call-interactively (key-binding "\t")))))
+ (let ((magit-display-file-buffer-function #'hpath:display-buffer))
+ (call-interactively #'smart-magit-tab)))))
(defun smart-magit-assist ()
"Use an assist key or mouse key to jump to source and to hide/show changes.
@@ -1307,10 +1299,30 @@ If assist-key is pressed:
((eolp)
(smart-scroll-down))
(t
- (setq current-prefix-arg 1)
- (let ((magit-display-file-buffer-function #'hpath:display-buffer))
+ (let ((magit-display-file-buffer-function #'hpath:display-buffer)
+ (current-prefix-arg))
(call-interactively (key-binding "\r"))))))
+;; Thanks to Jonas Bernoulli <tarsius>, magit author, for this code.
+(defun smart-magit-tab (section)
+ ;; Usage: (define-key magit-section-mode-map "TAB" 'smart-magit-tab
+ "Toggle visibility of the body of the current section."
+ (interactive (list (magit-current-section)))
+ (cond ((eq section magit-root-section)
+ (user-error "Cannot hide root section"))
+ ((or (oref section content)
+ (oref section washer))
+ (goto-char (oref section start))
+ (if (oref section hidden)
+ (magit-section-show section)
+ (magit-section-hide section)))
+ (t
+ (if-let ((command (key-binding (kbd "RET"))))
+ (progn (setq last-command-event ?\()
+ (setq this-command command)
+ (call-interactively command))
+ (user-error "Nothing to visit either")))))
+
;;; ************************************************************************
;;; smart-man functions
;;; ************************************************************************
diff --git a/hypb.el b/hypb.el
index 520ce18..bd48db5 100644
--- a/hypb.el
+++ b/hypb.el
@@ -16,7 +16,7 @@
;;; Other required Elisp libraries
;;; ************************************************************************
-(eval-and-compile (mapc #'require '(hversion hact locate)))
+(eval-and-compile (mapc #'require '(compile hversion hact locate)))
;;; ************************************************************************
;;; Public variables
@@ -245,8 +245,21 @@ Global keymap is used unless optional KEYMAP is given."
(error msg)))
(defun hypb:fgrep-git-log (string)
- "Asynchronously list git log entries whose changesets include `string'."
- (compile (format "git log -S'%s' --line-prefix='commit ' --oneline" string)))
+ "Asynchronously list git log entries whose changesets include `string' for
selection and display.
+The current commit entry may be displayed with a press of RET, the Action Key
or the Assist Key."
+ (compile (format "git log -S'%s' --line-prefix='commit ' --oneline" string)
+ #'hypb:fgrep-git-log-mode))
+
+(defun hypb:fgrep-git-log-activate (ignore1 &optional ignore2)
+ "Display git commit for the current line when `compile-goto-error' {RET} is
used.
+Does not support use of next and previous error; simply displays the current
one."
+ (interactive '(nil))
+ (hkey-either nil))
+
+(define-derived-mode hypb:fgrep-git-log-mode compilation-mode "Fgrep-Git-Log"
+ "Major mode (derived from `compilation-mode' for listing a matching set of
git commits for selection and display.
+Turning on Fgrep-Git-Log mode runs the normal hook `compilation-mode-hook'."
+ (setq-local next-error-function #'hypb:fgrep-git-log-activate))
(defun hypb:file-major-mode (file)
"Return the major mode used by FILE.
- [elpa] externals/hyperbole a831ef9 36/50: Fix bug #46606 by replacing hkey-define-key with hkey-global-set-key, (continued)
- [elpa] externals/hyperbole a831ef9 36/50: Fix bug #46606 by replacing hkey-define-key with hkey-global-set-key, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 8969fe9 43/50: Merge branch 'master' of hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole c8947dd 47/50: Merge branch 'master' of hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole db73cf7 19/50: Use \0 for matched Nth substitution (see also commit #c0e48fb3), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 1826307 27/50: Resolve bug#43644 where final double quote was trimmed from strings., Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole f38a8dd 28/50: Fix Hyrolo logicial searches; bug fixes; handle file:// URLs better, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 3469ea3 29/50: Release defil and defal simpler implicit button type create macros, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 6a8154a 33/50: Add first unit tests (#46), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole a44b392 34/50: Add UNIX shell error implicit button support, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole aa6f2f6 38/50: Verify error message from hpath:find is correct (#50), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole aad4494 40/50: Add smart-magit-tab: Do what TAB or RET does,
Stefan Monnier <=
- [elpa] externals/hyperbole d1dcd54 41/50: * Disable magit-auto-revert-mode-enable-in-buffers in hyrolo buffer, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole c7d62e1 46/50: Make defil handle action type symbols and strings, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 6b2c073 49/50: Correct test cases failing on mac (#55), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 4eef4e9 50/50: Install with-simulated-input if not available (#54), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 25ba634 31/50: Add fast window link button creation via {M-o w} with Ace Window., Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 64579b0 30/50: Fix defil with function improper call to regexp-quote, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole fccc0e5 42/50: Limit Action Button function arg to parameter after function name, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 1219e12 35/50: Merge branch 'master' of hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 9ca5b0f 45/50: More tests for ib with labels (#53), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole cd36bea 39/50: Add more defal and defil tests (#51), Stefan Monnier, 2021/03/17