emacs-diffs
[Top][All Lists]
Advanced

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

master 3015af515e: Fix up warning links in elisp-byte-compile-buffer


From: Lars Ingebrigtsen
Subject: master 3015af515e: Fix up warning links in elisp-byte-compile-buffer
Date: Thu, 30 Jun 2022 08:29:18 -0400 (EDT)

branch: master
commit 3015af515eceb9d5901b6de4cc83f1874b53efcb
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix up warning links in elisp-byte-compile-buffer
    
    * lisp/progmodes/elisp-mode.el (elisp-byte-compile-buffer): Make
    warnings point to the correct place.
---
 lisp/progmodes/elisp-mode.el | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 7acf7316a9..65a76daf25 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2214,12 +2214,13 @@ interactively, this is the prefix argument."
   (when load
     (load (funcall byte-compile-dest-file-function buffer-file-name))))
 
-(defun elisp-byte-compile-buffer (&optional load)
+(defun elisp-byte-compile-buffero (&optional load)
   "Byte compile the current buffer, but don't write a file.
 If LOAD is non-nil, load byte-compiled data.  When called
 interactively, this is the prefix argument."
   (interactive "P")
-  (let (file elc)
+  (let ((bfn buffer-file-name)
+        file elc)
     (unwind-protect
         (progn
           (setq file (make-temp-file "compile" nil ".el")
@@ -2228,8 +2229,25 @@ interactively, this is the prefix argument."
           (let ((set-message-function
                  (lambda (message)
                    (when (string-match-p "\\`Wrote " message)
-                     'ignore))))
+                     'ignore)))
+                (byte-compile-log-warning-function
+                 (lambda (string position &optional fill level)
+                   (if bfn
+                       ;; Massage the warnings to that they point to
+                       ;; this file, not the one in /tmp.
+                       (let ((byte-compile-current-file bfn)
+                             (byte-compile-root-dir (file-name-directory bfn)))
+                         (byte-compile--log-warning-for-byte-compile
+                          string position fill level))
+                     ;; We don't have a file name, so the warnings
+                     ;; will point to a file that doesn't exist.  This
+                     ;; should be fixed in some way.
+                     (byte-compile--log-warning-for-byte-compile
+                      string position fill level)))))
             (byte-compile-file file))
+          (when (and bfn (get-buffer "*Compile-Log*"))
+            (with-current-buffer "*Compile-Log*"
+              (setq default-directory (file-name-directory bfn))))
           (if load
               (load elc)
             (message "Byte-compiled the current buffer")))



reply via email to

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