diff options
| author | Constantine Vetoshev <gepardcv@gmail.com> | 2020-03-08 19:03:15 -0700 |
|---|---|---|
| committer | Constantine Vetoshev <gepardcv@gmail.com> | 2020-03-08 19:03:15 -0700 |
| commit | c869e23c02c6339de998c573c72b34b27b72ec4e (patch) | |
| tree | 65e8b5e29a4a7d8f838e5248a08966e36f5c14de | |
| parent | be1aeb640996c2fb29b3a373cc75f1296edc5914 (diff) | |
Fix click events when displaying perspective in header line.
Thanks to FabArd (https://github.com/FabArd) for the suggestion!
| -rw-r--r-- | perspective.el | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/perspective.el b/perspective.el index f66dbb4..15fef7b 100644 --- a/perspective.el +++ b/perspective.el @@ -477,6 +477,11 @@ For example, (persp-intersperse '(1 2 3) 'a) gives '(1 a 2 a 3)." (define-key map [mode-line down-mouse-1] 'persp-mode-line-click) map)) +(defconst persp-header-line-map + (let ((map (make-sparse-keymap))) + (define-key map [header-line down-mouse-1] 'persp-mode-line-click) + map)) + (defun persp-mode-line-click (event) "Select the clicked perspective. EVENT is the click event triggering this function call." @@ -501,13 +506,18 @@ Has no effect when `persp-show-modestring' is nil." close))))) (defun persp-format-name (name) - "Format the perspective name given by NAME for display in the modeline." + "Format the perspective name given by NAME for display in the mode line or header line." (let ((string-name (format "%s" name))) (if (equal name (persp-current-name)) (propertize string-name 'face 'persp-selected-face) - (propertize string-name - 'local-map persp-mode-line-map - 'mouse-face 'mode-line-highlight)))) + (cond ((eq persp-show-modestring 'header) + (propertize string-name + 'local-map persp-header-line-map + 'mouse-face 'header-line-highlight)) + ((eq persp-show-modestring t) + (propertize string-name + 'local-map persp-mode-line-map + 'mouse-face 'mode-line-highlight)))))) (defun persp-get-quick (char &optional prev) "Return the name of the first perspective that begins with CHAR. |
