From: Lars Ingebrigtsen Date: Tue, 1 Oct 2019 13:39:59 +0000 (+0200) Subject: Add a new command in *Compile-Log* buffers to re-byte-compile X-Git-Tag: emacs-27.0.90~1341 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ad33e3e549e24c48259c6bdfb069e41be0a31f98;p=emacs.git Add a new command in *Compile-Log* buffers to re-byte-compile * lisp/emacs-lisp/bytecomp.el (emacs-lisp-compilation-recompile): New command (bug#4516). (emacs-lisp-compilation--current-file) (emacs-lisp-compilation-mode-map): New variables with new `g' binding. (byte-compile-log-file): Set variable so that `g' can recompile it. --- diff --git a/etc/NEWS b/etc/NEWS index ec40e5e2abe..1a5047f60a5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -582,6 +582,11 @@ This is because on the one hand it suffers from various misbehaviors in corner cases that have plagued it for years, and on the other experiments indicated that it doesn't bring any measurable benefit. +--- +*** The 'g' keystroke in *Compile-Log* buffers has been bound to a new +command that will recompile the file previously compiled with 'M-x +byte-compile-file' and the like. + ** compile.el --- *** In 'compilation-error-regexp-alist', 'line' (and 'end-line') can diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 44a65ed4c6a..2b26390b180 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1045,8 +1045,26 @@ message buffer `default-directory'." :type '(repeat (choice (const :tag "Default" nil) (string :tag "Directory")))) +(defvar emacs-lisp-compilation-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map compilation-minor-mode-map) + (define-key map "g" 'emacs-lisp-compilation-recompile) + map)) + +(defvar emacs-lisp-compilation--current-file nil) + (define-compilation-mode emacs-lisp-compilation-mode "elisp-compile" - "The variant of `compilation-mode' used for emacs-lisp compilation buffers.") + "The variant of `compilation-mode' used for emacs-lisp compilation buffers." + (setq-local emacs-lisp-compilation--current-file nil)) + +(defun emacs-lisp-compilation-recompile () + "Recompile the previously byte-compiled file." + (interactive) + (unless emacs-lisp-compilation--current-file + (error "No previously compiled file")) + (unless (stringp emacs-lisp-compilation--current-file) + (error "Only files can be recompiled")) + (byte-compile-file emacs-lisp-compilation--current-file)) (defvar byte-compile-current-form nil) (defvar byte-compile-dest-file nil) @@ -1236,6 +1254,7 @@ message buffer `default-directory'." ;; Do this after setting default-directory. (unless (derived-mode-p 'compilation-mode) (emacs-lisp-compilation-mode)) + (setq emacs-lisp-compilation--current-file byte-compile-current-file) (compilation-forget-errors) pt))))