[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 73a2cbe61f 09/18: magit-section-heading-map: Ne
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 73a2cbe61f 09/18: magit-section-heading-map: New keymap |
Date: |
Fri, 25 Mar 2022 13:58:20 -0400 (EDT) |
branch: elpa/git-commit
commit 73a2cbe61f9cac148237e8bd043edc5dfe577fd3
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-section-heading-map: New keymap
---
lisp/magit-section.el | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index b9721996c5..4e28ab0a5f 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -323,6 +323,13 @@ but that ship has sailed, thus this option."
(defvar symbol-overlay-inhibit-map)
+(defvar magit-section-heading-map
+ (let ((map (make-sparse-keymap)))
+ map)
+ "Keymap used in the heading line of all expandable sections.
+This keymap is used in addition to the section-specifi keymap,
+if any.")
+
(defvar magit-section-mode-map
(let ((map (make-keymap)))
(suppress-keymap map t)
@@ -1132,6 +1139,7 @@ anything this time around.
(put-text-property (point) next 'magit-section ,s)
(when map
(put-text-property (point) next 'keymap map)))
+ (magit-section-maybe-add-heading-map ,s)
(goto-char next)))))
(if (eq ,s magit-root-section)
(let ((magit-section-cache-visibility nil))
@@ -1208,6 +1216,7 @@ is explicitly expanded."
(oset ,s washer
(lambda ()
(funcall ,f)
+ (magit-section-maybe-remove-heading-map ,s)
(magit-section-maybe-remove-visibility-indicator ,s)))
(funcall ,f)))))
@@ -1233,7 +1242,29 @@ is explicitly expanded."
(oset 1st-header content (oref (car header-sections) start))
(oset 1st-header end (oref (car (last header-sections)) end))
(dolist (sub-header header-sections)
- (oset sub-header parent 1st-header)))))))
+ (oset sub-header parent 1st-header))
+ (magit-section-maybe-add-heading-map 1st-header))))))
+
+(defun magit-section-maybe-add-heading-map (section)
+ (when (magit-section-content-p section)
+ (let ((start (oref section start))
+ (map (oref section keymap)))
+ (when (symbolp map)
+ (setq map (symbol-value map)))
+ (put-text-property
+ start
+ (save-excursion
+ (goto-char start)
+ (line-end-position))
+ 'keymap (if map
+ (make-composed-keymap
+ (list map magit-section-heading-map))
+ magit-section-heading-map)))))
+
+(defun magit-section-maybe-remove-heading-map (section)
+ (with-slots (start content end keymap) section
+ (when (= content end)
+ (put-text-property start end 'keymap keymap))))
(defun magit-insert-child-count (section)
"Modify SECTION's heading to contain number of child sections.
- [nongnu] elpa/git-commit 5641d3749c 12/18: Completely rework magit-mode-menu, (continued)
- [nongnu] elpa/git-commit 5641d3749c 12/18: Completely rework magit-mode-menu, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 0168be9366 14/18: Add basic context-menu, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 38cb9372dc 17/18: Add section-specific context-menus, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit f3afc117c2 18/18: Bump dependencies on Melpa, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 91ef0822d3 04/18: magit-get-section: Compare constant values, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 8c53997121 05/18: magit-section-ident-value: Split up into more methods, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 4de514b84c 07/18: magit-section-content-p: New function, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 8eb43f8b23 13/18: Store keymap detected based on name in section object, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit bc065246b4 01/18: Remove duplicated command magit-help, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 5da6122160 08/18: magit-section-mode-map: Add docstring, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 73a2cbe61f 09/18: magit-section-heading-map: New keymap,
ELPA Syncer <=
- [nongnu] elpa/git-commit 7d15b1a041 11/18: magit-diff--region-range: New function, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit b7294344e3 15/18: Add context-menu utilities, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 95b432530a 16/18: Do not set point when invoking context-menu, ELPA Syncer, 2022/03/25