* Selecting *Compile-log* buffer automatically @ 2023-12-10 18:38 Kiso Katsuyuki 2023-12-10 19:32 ` Eli Zaretskii 2023-12-11 17:04 ` Juri Linkov 0 siblings, 2 replies; 12+ messages in thread From: Kiso Katsuyuki @ 2023-12-10 18:38 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 634 bytes --] Hi all, I often tweak my elisp codes and byte-compile them. I recently found that I had been moving focus to the *Compile-log* buffer and burying it after byte-compiling an elisp file. Selecting *Compile-log* buffer automatically reduces commands to do this. After my investigation on bytecomp.el and warning.el, there seems to be no option to select the *Compile-log* buffer automatically when it shows up in the active frame. Does it make sense to do - On byte-compiling an elisp file, select the byte-compile-log-buffer window automatically if the buffer is visible, and - Add a variable to switch the function enable/disable. ? [-- Attachment #2: Type: text/html, Size: 796 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-10 18:38 Selecting *Compile-log* buffer automatically Kiso Katsuyuki @ 2023-12-10 19:32 ` Eli Zaretskii 2023-12-11 1:07 ` Kiso Katsuyuki 2023-12-11 17:04 ` Juri Linkov 1 sibling, 1 reply; 12+ messages in thread From: Eli Zaretskii @ 2023-12-10 19:32 UTC (permalink / raw) To: Kiso Katsuyuki; +Cc: emacs-devel > From: Kiso Katsuyuki <katsuyuki2388@gmail.com> > Date: Sun, 10 Dec 2023 12:38:22 -0600 > > I often tweak my elisp codes and byte-compile them. > I recently found that I had been moving focus to the *Compile-log* buffer and burying it after > byte-compiling an elisp file. > Selecting *Compile-log* buffer automatically reduces commands to do this. Can you elaborate why you needed to select it? Emacs has commands to scroll non-selected windows, you should be able to view the compilation log without the need to select its window. We could, of course, provide an optional feature whereby the log window is selected. But in that case, I think it at least should not be selected unconditionally, only if there are some warnings or errors. Thanks. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-10 19:32 ` Eli Zaretskii @ 2023-12-11 1:07 ` Kiso Katsuyuki 2023-12-11 11:56 ` Eli Zaretskii 0 siblings, 1 reply; 12+ messages in thread From: Kiso Katsuyuki @ 2023-12-11 1:07 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 774 bytes --] Hi Eli, Thanks for the comments! >Can you elaborate why you needed to select it? Emacs has commands to >scroll non-selected windows, you should be able to view the >compilation log without the need to select its window. In almost all my byte-compile, warnings like "Warning: assignment to free variable...", "Warning: the function ‘foo’ might not be defined at runtime", and etc. occur. Warnings and Errors have Emacs display the *Compile-log* buffer (this is the default behavior). I usually ignores this kind of warnings, so I just move focus to the *Compile-log* buffer window, bury it (keybind "q" by default), and then I can restore the original window configuration. I want to skip the step to move focus to the *Compile-log* buffer window. [-- Attachment #2: Type: text/html, Size: 871 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-11 1:07 ` Kiso Katsuyuki @ 2023-12-11 11:56 ` Eli Zaretskii 2023-12-17 2:22 ` Kiso Katsuyuki 0 siblings, 1 reply; 12+ messages in thread From: Eli Zaretskii @ 2023-12-11 11:56 UTC (permalink / raw) To: Kiso Katsuyuki; +Cc: emacs-devel > From: Kiso Katsuyuki <katsuyuki2388@gmail.com> > Date: Sun, 10 Dec 2023 19:07:31 -0600 > Cc: emacs-devel@gnu.org > > >Can you elaborate why you needed to select it? Emacs has commands to > >scroll non-selected windows, you should be able to view the > >compilation log without the need to select its window. > > In almost all my byte-compile, warnings like "Warning: assignment to free variable...", > "Warning: the function ‘foo’ might not be defined at runtime", and etc. occur. > Warnings and Errors have Emacs display the *Compile-log* buffer > (this is the default behavior). I usually ignores this kind of warnings, > so I just move focus to the *Compile-log* buffer window, bury it (keybind "q" by default), > and then I can restore the original window configuration. I want to skip the step to move focus to > the *Compile-log* buffer window. So maybe we should indeed add an optional behavior, for those case. Do you agree that the compile log window should be only selected if there are actually warnings or errors during the last compilation? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-11 11:56 ` Eli Zaretskii @ 2023-12-17 2:22 ` Kiso Katsuyuki 0 siblings, 0 replies; 12+ messages in thread From: Kiso Katsuyuki @ 2023-12-17 2:22 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 259 bytes --] >Do you agree that the compile log window should be only selected if >there are actually warnings or errors during the last compilation? Yes. I'll be careful about the case when the *Compile-Log* buffer window is visible before byte-compile-file is invoked. [-- Attachment #2: Type: text/html, Size: 328 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-10 18:38 Selecting *Compile-log* buffer automatically Kiso Katsuyuki 2023-12-10 19:32 ` Eli Zaretskii @ 2023-12-11 17:04 ` Juri Linkov 2023-12-23 8:19 ` Kiso Katsuyuki 1 sibling, 1 reply; 12+ messages in thread From: Juri Linkov @ 2023-12-11 17:04 UTC (permalink / raw) To: Kiso Katsuyuki; +Cc: emacs-devel > I recently found that I had been moving focus to the *Compile-log* buffer > and burying it after byte-compiling an elisp file. > Selecting *Compile-log* buffer automatically reduces commands to do this. > After my investigation on bytecomp.el and warning.el, there seems to be no > option to select the *Compile-log* buffer automatically > when it shows up in the active frame. > > Does it make sense to do > - On byte-compiling an elisp file, select the byte-compile-log-buffer > window automatically if the buffer is visible, and > - Add a variable to switch the function enable/disable. > ? I believe this should be customizable with something like (setopt display-buffer-alist '(("\\*Compile-log\\*" nil (select-window . t)))) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-11 17:04 ` Juri Linkov @ 2023-12-23 8:19 ` Kiso Katsuyuki 2023-12-23 17:41 ` Juri Linkov 0 siblings, 1 reply; 12+ messages in thread From: Kiso Katsuyuki @ 2023-12-23 8:19 UTC (permalink / raw) To: Juri Linkov; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 334 bytes --] >I believe this should be customizable with something like > > (setopt display-buffer-alist > '(("\\*Compile-log\\*" nil (select-window . t)))) Hi Juri, Thank you for the advice, but I tried this and it didn't work. *Compile-log* buffer isn't selected. I used emacs 29.1 with no init files loaded. I'll consider a different way. [-- Attachment #2: Type: text/html, Size: 486 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-23 8:19 ` Kiso Katsuyuki @ 2023-12-23 17:41 ` Juri Linkov 2023-12-24 12:51 ` Kiso Katsuyuki 0 siblings, 1 reply; 12+ messages in thread From: Juri Linkov @ 2023-12-23 17:41 UTC (permalink / raw) To: Kiso Katsuyuki; +Cc: emacs-devel >>I believe this should be customizable with something like >> >> (setopt display-buffer-alist >> '(("\\*Compile-log\\*" nil (select-window . t)))) > > Thank you for the advice, but I tried this and it didn't work. > *Compile-log* buffer isn't selected. > I used emacs 29.1 with no init files loaded. This feature was discussed in bug#33258 and bug#46034, but not yet implemented. It should be easy to implement exactly the same way as 'windmove-display-in-direction' selects the old or new window in 'post-command-hook'. Ok, I will post a patch to bug-gnu-emacs. > I'll consider a different way. Until this is pushed, you could use such a simple advice that does the same: (define-advice dired-do-byte-compile (:after (&rest _args) select-window) (when-let ((window (get-buffer-window "*Compile-Log*" 0))) (select-window window))) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-23 17:41 ` Juri Linkov @ 2023-12-24 12:51 ` Kiso Katsuyuki 2023-12-24 17:28 ` Juri Linkov 0 siblings, 1 reply; 12+ messages in thread From: Kiso Katsuyuki @ 2023-12-24 12:51 UTC (permalink / raw) To: Juri Linkov; +Cc: emacs-devel [-- Attachment #1.1: Type: text/plain, Size: 1915 bytes --] >>>I believe this should be customizable with something like >>> >>> (setopt display-buffer-alist >>> '(("\\*Compile-log\\*" nil (select-window . t)))) >> >> Thank you for the advice, but I tried this and it didn't work. >> *Compile-log* buffer isn't selected. >> I used emacs 29.1 with no init files loaded. > >This feature was discussed in bug#33258 and bug#46034, >but not yet implemented. It should be easy to implement >exactly the same way as 'windmove-display-in-direction' >selects the old or new window in 'post-command-hook'. >Ok, I will post a patch to bug-gnu-emacs. There seems to be another problem with using display-buffer-alist. byte-compile-file repeats byte-compile, display-warning (this uses display-buffer) for each S-expression. Selecting *Compile-log* buffer before finishing byte-compiling the last S-expression causes an error. I checked the error using (defun select-visible-warning-buffer (_type _message &optional _level buffer-name) "Select the visible warning buffer" (unless buffer-name (setq buffer-name "*Warnings*")) (let ((window (get-buffer-window (get-buffer buffer-name)))) (if window (select-window window)))) (advice-add 'display-warning :after #'select-visible-warning-buffer) , and byte-compile causes "Error: End of file during parsing". display-buffer-alist should affect every display-buffer, so I think it leads to the same error. I think selecting the *Compile-Log* buffer separately from display-buffer is easier. I made the attached patch to select *Compile-Log* buffer for emacs 29.1 bytecomp.el. >> I'll consider a different way. > >Until this is pushed, you could use such a simple advice >that does the same: > >(define-advice dired-do-byte-compile (:after (&rest _args) select-window) > (when-let ((window (get-buffer-window "*Compile-Log*" 0))) > (select-window window))) Thanks. I referred to this when I made the above patch. [-- Attachment #1.2: Type: text/html, Size: 2331 bytes --] [-- Attachment #2: bytecomp.patch --] [-- Type: text/x-patch, Size: 2253 bytes --] diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 5df1205869c..b9b5b93d1a2 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1311,10 +1311,13 @@ where the problem was detected. FILL is a prefix as in `warning-fill-prefix'. LEVEL is the level of the problem (`:warning' or `:error'). FILL and LEVEL may be nil.") +(defvar byte-compile-warning-flag nil) + (defun byte-compile-log-warning (string &optional fill level) "Log a byte-compilation warning. STRING, FILL and LEVEL are as described in `byte-compile-log-warning-function', which see." + (setq byte-compile-warning-flag t) (funcall byte-compile-log-warning-function string (or (byte-compile--warning-source-offset) @@ -2118,6 +2121,9 @@ See also `emacs-lisp-byte-compile-and-load'." (y-or-n-p (format "Save buffer %s first? " (buffer-name b)))) (with-current-buffer b (save-buffer))))) + ;; Reset the warning flag + (setq byte-compile-warning-flag nil) + ;; Force logging of the file name for each file compiled. (setq byte-compile-last-logged-file nil) (let ((byte-compile-current-file filename) @@ -2244,6 +2250,11 @@ See also `emacs-lisp-byte-compile-and-load'." target-file)))))) (unless byte-native-compiling (kill-buffer (current-buffer)))) + + ;; select the byte compile log + (if byte-compile-select-log-buffer + (if byte-compile-warning-flag (select-visible-byte-compile-log))) + (if (and byte-compile-generate-call-tree (or (eq t byte-compile-generate-call-tree) (y-or-n-p (format "Report call tree for %s? " @@ -2263,6 +2274,17 @@ See also `emacs-lisp-byte-compile-and-load'." (load target-file)) t)))) +(defcustom byte-compile-select-log-buffer nil + "If non-nil, the `byte-compile-log-buffer' window in the selected frame +is selected when there are warnings." + :type 'boolean + :group 'bytecomp) + +(defun select-visible-byte-compile-log () + "Select the visible byte compile log buffer in the selected frame" + (when-let ((window (get-buffer-window byte-compile-log-buffer))) + (select-window window))) + ;;; compiling a single function ;;;###autoload (defun compile-defun (&optional arg) ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-24 12:51 ` Kiso Katsuyuki @ 2023-12-24 17:28 ` Juri Linkov 2023-12-25 13:03 ` Kiso Katsuyuki 0 siblings, 1 reply; 12+ messages in thread From: Juri Linkov @ 2023-12-24 17:28 UTC (permalink / raw) To: Kiso Katsuyuki; +Cc: emacs-devel >>>>I believe this should be customizable with something like >>>> >>>> (setopt display-buffer-alist >>>> '(("\\*Compile-log\\*" nil (select-window . t)))) >>> >>> Thank you for the advice, but I tried this and it didn't work. >>> *Compile-log* buffer isn't selected. >>> I used emacs 29.1 with no init files loaded. >> >>This feature was discussed in bug#33258 and bug#46034, >>but not yet implemented. It should be easy to implement >>exactly the same way as 'windmove-display-in-direction' >>selects the old or new window in 'post-command-hook'. >>Ok, I will post a patch to bug-gnu-emacs. > > There seems to be another problem with using display-buffer-alist. > byte-compile-file repeats byte-compile, display-warning (this uses > display-buffer) > for each S-expression. Selecting *Compile-log* buffer before finishing > byte-compiling the last > S-expression causes an error. I checked the error using > > (defun select-visible-warning-buffer (_type _message &optional _level > buffer-name) > "Select the visible warning buffer" > (unless buffer-name > (setq buffer-name "*Warnings*")) > (let ((window (get-buffer-window (get-buffer buffer-name)))) > (if window (select-window window)))) > > (advice-add 'display-warning :after #'select-visible-warning-buffer) > > , and byte-compile causes "Error: End of file during parsing". > > display-buffer-alist should affect every display-buffer, so I think > it leads to the same error. Indeed, you can't select arbitrary windows in every display-buffer, because code after every display-buffer expects certain buffers to be selected. This was discussed in bug#33258, and the only possible solution is to select the window when the current command finishes. This is implemented in bug#67993. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-24 17:28 ` Juri Linkov @ 2023-12-25 13:03 ` Kiso Katsuyuki 2024-02-17 18:20 ` Kiso Katsuyuki 0 siblings, 1 reply; 12+ messages in thread From: Kiso Katsuyuki @ 2023-12-25 13:03 UTC (permalink / raw) To: Juri Linkov; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 600 bytes --] >Indeed, you can't select arbitrary windows in every display-buffer, >because code after every display-buffer expects certain buffers >to be selected. This was discussed in bug#33258, and the only >possible solution is to select the window when the current command >finishes. This is implemented in bug#67993. I checked #67993, used the patch, and the *Compile-Log* buffer was selected successfully without the error. If #67993 is implemented, I'll use display-buffer-alist. Otherwise I'll modify bytecomp.el without using display-buffer-alist. I figured out that the post-command-hook is useful. [-- Attachment #2: Type: text/html, Size: 682 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Selecting *Compile-log* buffer automatically 2023-12-25 13:03 ` Kiso Katsuyuki @ 2024-02-17 18:20 ` Kiso Katsuyuki 0 siblings, 0 replies; 12+ messages in thread From: Kiso Katsuyuki @ 2024-02-17 18:20 UTC (permalink / raw) To: Juri Linkov; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 57 bytes --] I found the bug #67993 fixed. This is closed. Thank you! [-- Attachment #2: Type: text/html, Size: 117 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-02-17 18:20 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-12-10 18:38 Selecting *Compile-log* buffer automatically Kiso Katsuyuki 2023-12-10 19:32 ` Eli Zaretskii 2023-12-11 1:07 ` Kiso Katsuyuki 2023-12-11 11:56 ` Eli Zaretskii 2023-12-17 2:22 ` Kiso Katsuyuki 2023-12-11 17:04 ` Juri Linkov 2023-12-23 8:19 ` Kiso Katsuyuki 2023-12-23 17:41 ` Juri Linkov 2023-12-24 12:51 ` Kiso Katsuyuki 2023-12-24 17:28 ` Juri Linkov 2023-12-25 13:03 ` Kiso Katsuyuki 2024-02-17 18:20 ` Kiso Katsuyuki
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).