From 3479ec7332a474b3400cbc6b681c2a1f5637db94 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 23 Jul 2019 19:49:48 +0200 Subject: [PATCH] Make "Compiling" in the mode line a clickable command * lisp/progmodes/compile.el (compilation-goto-in-progress-buffer): New command. (compilation-in-progress): Don't put the in-progress mode-line marker among the minor modes (because it's not a minor mode), and add a command that allows you to switch to the in-progress compilation buffer (bug#27252). --- lisp/progmodes/compile.el | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 4b2fc516c3d..f4750c00590 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -107,9 +107,30 @@ and a string describing how the process finished.") (defvar compilation-in-progress nil "List of compilation processes now running.") -(or (assq 'compilation-in-progress minor-mode-alist) - (setq minor-mode-alist (cons '(compilation-in-progress " Compiling") - minor-mode-alist))) +(or (assq 'compilation-in-progress mode-line-modes) + (add-to-list 'mode-line-modes + (list 'compilation-in-progress + (propertize "[Compiling] " + 'help-echo "Compiling; mouse-2: Goto Buffer" + 'mouse-face 'mode-line-highlight + 'local-map + (make-mode-line-mouse-map + 'mouse-2 + #'compilation-goto-in-progress-buffer))))) + +(defun compilation-goto-in-progress-buffer () + "Switch to the compilation buffer." + (interactive) + (cond + ((> (length compilation-in-progress) 1) + (switch-to-buffer (completing-read + "Several compilation buffers; switch to: " + (mapcar #'buffer-name compilation-in-progress) + nil t))) + (compilation-in-progress + (switch-to-buffer (process-buffer (car compilation-in-progress)))) + (t + (error "No ongoing compilations")))) (defvar compilation-error "error" "Stem of message to print when no matches are found.") -- 2.39.2