]> git.eshelyaron.com Git - emacs.git/commitdiff
Make "Compiling" in the mode line a clickable command
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 23 Jul 2019 17:49:48 +0000 (19:49 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 23 Jul 2019 17:49:56 +0000 (19:49 +0200)
* 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

index 4b2fc516c3d1e6a2dc4304f90e97d5e547adbe3c..f4750c00590abeb996808dc7f8843eac3b48057f 100644 (file)
@@ -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.")