From: João Távora Date: Thu, 3 May 2018 23:25:03 +0000 (+0100) Subject: Fix mode-line mouse-clicks from outside selected window X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~652 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=465635456c581a7bc667fc1333ce463e19262a35;p=emacs.git Fix mode-line mouse-clicks from outside selected window * eglot.el (eglot--mode-line-call): New helper. (eglot--mode-line-format): Use it. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 693535ac8b1..bdd339d9715 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -695,6 +695,13 @@ that case, also signal textDocument/didOpen." (put 'eglot--mode-line-format 'risky-local-variable t) +(defun eglot--mode-line-call (what) + "Make an interactive lambda for calling WHAT from mode-line." + (lambda (event) + (interactive "e") + (with-selected-window (posn-window (event-start event)) + (call-interactively what)))) + (defun eglot--mode-line-format () "Compose the mode-line format spec." (pcase-let* ((proc (eglot--current-process)) @@ -715,7 +722,7 @@ that case, also signal textDocument/didOpen." face eglot-mode-line keymap ,(let ((map (make-sparse-keymap))) (define-key map [mode-line down-mouse-1] - eglot-menu) + (eglot--mode-line-call 'eglot-menu)) map) mouse-face mode-line-highlight help-echo "mouse-1: pop-up EGLOT menu" @@ -726,9 +733,12 @@ that case, also signal textDocument/didOpen." ,name face eglot-mode-line keymap ,(let ((map (make-sparse-keymap))) - (define-key map [mode-line mouse-1] 'eglot-events-buffer) - (define-key map [mode-line mouse-2] 'eglot-shutdown) - (define-key map [mode-line mouse-3] 'eglot-reconnect) + (define-key map [mode-line mouse-1] + (eglot--mode-line-call 'eglot-events-buffer)) + (define-key map [mode-line mouse-2] + (eglot--mode-line-call 'eglot-shutdown)) + (define-key map [mode-line mouse-3] + (eglot--mode-line-call 'eglot-reconnect)) map) mouse-face mode-line-highlight help-echo ,(concat "mouse-1: go to events buffer\n" @@ -744,9 +754,9 @@ that case, also signal textDocument/didOpen." face compilation-mode-line-fail keymap ,(let ((map (make-sparse-keymap))) (define-key map [mode-line mouse-1] - 'eglot-events-buffer) + (eglot--mode-line-call 'eglot-events-buffer)) (define-key map [mode-line mouse-3] - 'eglot-clear-status) + (eglot--mode-line-call 'eglot-clear-status)) map)))) ,@(when (and doing (not done-p)) `("/" @@ -757,7 +767,7 @@ that case, also signal textDocument/didOpen." face compilation-mode-line-run keymap ,(let ((map (make-sparse-keymap))) (define-key map [mode-line mouse-1] - 'eglot-events-buffer) + (eglot--mode-line-call 'eglot-events-buffer)) map)))) ,@(when (cl-plusp pending) `("/" @@ -775,9 +785,9 @@ that case, also signal textDocument/didOpen." 'eglot-mode-line)) keymap ,(let ((map (make-sparse-keymap))) (define-key map [mode-line mouse-1] - 'eglot-events-buffer) + (eglot--mode-line-call 'eglot-events-buffer)) (define-key map [mode-line mouse-3] - 'eglot-forget-pending-continuations) + (eglot--mode-line-call 'eglot-forget-pending-continuations)) map))))))))) (add-to-list 'mode-line-misc-info