1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-23 22:20:24 -08:00

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.
This commit is contained in:
Lars Ingebrigtsen 2019-10-01 15:39:59 +02:00
parent 7b87e73ddc
commit ad33e3e549
2 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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))))