[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 949b4a47a4 10/18: magit-mouse-toggle-section: N
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 949b4a47a4 10/18: magit-mouse-toggle-section: New command |
Date: |
Fri, 25 Mar 2022 13:58:20 -0400 (EDT) |
branch: elpa/git-commit
commit 949b4a47a4351e22c4faa4bdb5ced4f5cdd03a35
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-mouse-toggle-section: New command
---
lisp/magit-section.el | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 4e28ab0a5f..0f682fd675 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -325,6 +325,9 @@ but that ship has sailed, thus this option."
(defvar magit-section-heading-map
(let ((map (make-sparse-keymap)))
+ (define-key map [double-down-mouse-1] 'ignore)
+ (define-key map [double-mouse-1] 'magit-mouse-toggle-section)
+ (define-key map [double-mouse-2] 'magit-mouse-toggle-section)
map)
"Keymap used in the heading line of all expandable sections.
This keymap is used in addition to the section-specifi keymap,
@@ -333,6 +336,8 @@ if any.")
(defvar magit-section-mode-map
(let ((map (make-keymap)))
(suppress-keymap map t)
+ (define-key map [left-fringe mouse-1] 'magit-mouse-toggle-section)
+ (define-key map [left-fringe mouse-2] 'magit-mouse-toggle-section)
(define-key map (kbd "TAB") 'magit-section-toggle)
(define-key map [C-tab] 'magit-section-cycle)
(define-key map [M-tab] 'magit-section-cycle)
@@ -802,6 +807,22 @@ Sections at higher levels are hidden."
(interactive)
(magit-section-show-level -4))
+(defun magit-mouse-toggle-section (event)
+ "Toggle visibility of the clicked section.
+Clicks outside either the section heading or the left fringe are
+silently ignored."
+ (interactive "e")
+ (let* ((pos (event-start event))
+ (section (magit-section-at (posn-point pos))))
+ (if (eq (posn-area pos) 'left-fringe)
+ (when section
+ (while (not (magit-section-content-p section))
+ (setq section (oref section parent)))
+ (unless (eq section magit-root-section)
+ (goto-char (oref section start))
+ (magit-section-toggle section)))
+ (magit-section-toggle section))))
+
;;;; Auxiliary
(defun magit-describe-section-briefly (section &optional ident)
- [nongnu] elpa/git-commit updated (b32521d543 -> f3afc117c2), ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 94aca04dc8 02/18: magit-module-section: Use correct keymap, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 70b34f08ab 03/18: Increase use of section type, keymap and binding inheritance, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit be371711f5 06/18: magit-section-at: New function, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 949b4a47a4 10/18: magit-mouse-toggle-section: New command,
ELPA Syncer <=
- [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