emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ad33e3e 1/2: Add a new command in *Compile-Log* buf


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master ad33e3e 1/2: Add a new command in *Compile-Log* buffers to re-byte-compile
Date: Tue, 1 Oct 2019 10:41:36 -0400 (EDT)

branch: master
commit ad33e3e549e24c48259c6bdfb069e41be0a31f98
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 etc/NEWS                    |  5 +++++
 lisp/emacs-lisp/bytecomp.el | 21 ++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index ec40e5e..1a5047f 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 44a65ed..2b26390 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))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]