Subject: bug#47414: 26.1; [PATCH] compilation-goto-locus does not handle right display-buffer

From: pillule <[email-masked]>
Date: Fri, 26 Mar 2021 16:57:41 +0000

diff -u --label /usr/share/emacs/28.0.50/lisp/progmodes/compile.el.gz --label /home/user/src/patches/compile.el.gz /tmp/jka-comekeJLn /tmp/jka-com8N603U
--- /usr/share/emacs/28.0.50/lisp/progmodes/compile.el.gz
+++ /home/user/src/patches/compile.el.gz
@@ -2845,8 +2845,8 @@
     (when (and (not pre-existing) w)
       (compilation-set-window-height w))
 
-    (if from-compilation-buffer
-        ;; If the compilation buffer window was selected,
+    (if (or from-compilation-buffer (eq w (selected-window)))
+        ;; If the compilation buffer window is selected,
         ;; keep the compilation buffer in this window;
         ;; display the source in another window.
         (let ((pop-up-windows t))

Diff finished.  Fri Mar 26 17:24:14 2021

Hello,

I noticed that
  1. if you apply a custom rule to display-buffer-alist for grep, 
  occur or compilation buffers that automatically select its 
  window when the buffer if displayed ;
  2. call next-error or previous-error from an error-buffer, 
  3. compilation-goto-locus will call display-buffer for the 
  compilation buffer
  4. the selected-window have now changed, we are in the 
  compilation window, and nonetheless compilation-goto-locus will 
  call switch-to-buffer in this window instead of pop-to-buffer.

This patch is a trivial check aknowledge if we are in the 
compilation window before choosing what display function to use, 
so users can customize the behavior of compilation windows via 
display-buffer-alist without breaking the error navigation 
functionnalities.

In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 
3.24.5)
 of 2021-01-31, modified by Debian built on x86-csail-01
Windowing system distributor 'The X.Org Foundation', version 
11.0.12004000
System Description:	Debian GNU/Linux 10 (buster)

Recent messages:
Checking 70 files in /usr/share/emacs/26.1/lisp/erc...
Checking 34 files in /usr/share/emacs/26.1/lisp/emulation...
Checking 176 files in /usr/share/emacs/26.1/lisp/emacs-lisp...
Checking 24 files in /usr/share/emacs/26.1/lisp/cedet...
Checking 57 files in /usr/share/emacs/26.1/lisp/calendar...
Checking 87 files in /usr/share/emacs/26.1/lisp/calc...
Checking 105 files in /usr/share/emacs/26.1/lisp/obsolete...
Checking for load-path shadows...done
Message modified; kill anyway? (y or n) y
<select> is undefined

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr 
 --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib 
 --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build 
 x86_64-linux-gnu
 --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info 
 --mandir=/usr/share/man
 --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-9Yet8u/emacs-26.1+1=. 
 -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS 
NOTIFY ACL
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB 
TOOLKIT_SCROLL_BARS
GTK3 X11 THREADS LIBSYSTEMD LCMS2
Important settings:
  value of $LANG: en_US
  locale-coding-system: utf-8

Major mode: mu4e:main

Minor modes in effect:
  flyspell-lazy-mode: t
  save-place-mode: t
  global-so-long-mode: t
  winner-mode: t
  show-paren-mode: t
  ws-butler-global-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-flycheck-mode: t
  gcmh-mode: t
  which-key-mode: t
  better-jumper-mode: t
  better-jumper-local-mode: t
  global-company-mode: t
  ivy-prescient-mode: t
  prescient-persist-mode: t
  ivy-rich-mode: t
  ivy-mode: t
  volatile-highlights-mode: t
  savehist-mode: t
  recentf-mode: t
  solaire-global-mode: t
  global-magit-file-mode: t
  diff-auto-refine-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  hl-line-mode: t
  dired-async-mode: t
  taoline-mode: t
  pill/shift-parens-mode: t
  whole-line-or-region-global-mode: t
  whole-line-or-region-local-mode: t
  persp-mode: t
  delete-selection-mode: t
  projectile-mode: t
  +popup-mode: t
  general-override-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t
  overwrite-mode: overwrite-mode-binary

Load-path shadows:
/home/user/doom-emacs/.local/straight/build-26.1/lispy/elpa hides 
/home/user/doom-emacs/.local/straight/build-26.1/ivy/elpa

Features:
(shadow disp-table whitespace flycheck-popup-tip flyspell-lazy 
flyspell ispell
nav-flash pulse auto-minor-mode face-remap saveplace so-long 
smartparens-config
smartparens-text smartparens emacsbug char-fold cursor-sensor amx 
winner paren
ws-butler undo-tree diff flycheck gcmh which-key better-jumper 
company-capf
company ivy-prescient prescient etags ivy-xref ivy-rich counsel 
xdg swiper ivy
ivy-faces ivy-overlay colir xref project volatile-highlights 
org-agenda
doom-snippets doom-snippets-lib yasnippet elec-pair elisp-mode 
savehist recentf
tree-widget doom-themes-ext-org doom-themes-ext-treemacs 
solaire-mode
tao-yin-theme tao-theme all-the-icons all-the-icons-faces 
data-material
data-weathericons data-octicons data-fileicons data-faicons 
data-alltheicons
memoize format-all dtrt-indent mu4e-private.el hydra lv mu4e 
desktop frameset
mu4e-speedbar speedbar sb-image ezimage dframe mu4e-main mu4e-view 
browse-url
mu4e-headers mu4e-compose mu4e-context mu4e-draft mu4e-actions 
org-capture
org-refile rfc2368 mu4e-mark mu4e-message flow-fill mu4e-proc 
mu4e-utils
doc-view jka-compr image-mode mu4e-lists mu4e-vars orgit 
magit-todos pcre2el rxt
re-builder hl-todo f github-review s ghub-graphql treepy gsexp 
ghub url-http tls
url-gw nsm url-auth let-alist gnutls deferred a magit-autoloads 
magit-submodule
magit-obsolete magit-popup magit-blame magit-stash magit-reflog 
magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote 
magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge 
magit-branch
magit-reset magit-files magit-refs magit-status magit 
core-packages package
url-handlers magit-repos magit-apply magit-wip magit-log 
which-func imenu
magit-diff smerge-mode diff-mode magit-core magit-autorevert 
autorevert
filenotify magit-margin magit-transient magit-process magit-mode 
git-commit
transient magit-git magit-section magit-utils crm log-edit message 
rmc puny
rfc822 mml mml-sec gnus-util rmail rmail-loaddefs mm-decode 
mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader pcvs-util 
add-log with-editor
async-bytecomp shell server smartparens-org org-yt org-element 
avl-tree
generator org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro 
org-footnote
org-src ob-comint org-pcomplete org-list org-faces org-entities 
noutline outline
org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys 
org-compat
org-macs org-loaddefs format-spec find-func cal-menu calendar 
cal-loaddefs
hl-line cl smtpmail sendmail rfc2047 rfc2045 ietf-drums mm-util 
mail-prsvr
mail-utils google-translate google-translate-default-ui 
google-translate-core-ui
color popup ido google-translate-core google-translate-tk
google-translate-backend url url-proxy url-privacy url-expand 
url-methods
url-history url-cookie url-domsuf url-util url-parse auth-source 
eieio
eieio-core eieio-loaddefs password-cache url-vars json map mailcap 
qubes
dired-async async dired-aux dired dired-loaddefs epa-file epa epg 
cus-edit
cus-start cus-load wid-edit epg-config rx eshell-did-you-mean 
esh-var esh-io
esh-groups esh-help man dash em-unix eshell-z pcomplete em-dirs 
esh-cmd esh-proc
esh-arg esh-ext esh-opt eshell esh-module esh-mode esh-util 
taoline advice
whole-line-or-region smart-hungry-delete persp-mode delsel 
projectile grep
compile comint ansi-color ring ibuffer-vc ibuf-ext ibuffer 
ibuffer-loaddefs seq
byte-opt thingatpt mu4e-meta html2text ibuf-macs easy-mmode 
derived core-editor
core-projects core-ui edmacro kmacro core-keybinds pp general 
cl-extra help-mode
easymenu cl-seq use-package-core bytecomp byte-compile cconv 
core-modules core
core-lib pcase cl-macs gv cl-loaddefs cl-lib subr-x time-date 
mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel 
term/x-win
x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt 
fringe
tabulated-list replace newcomment text-mode prog-mode register 
page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock 
font-lock syntax
facemenu font-core term/tty-colors frame cl-generic cham georgian 
utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese 
eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian 
cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook 
help simple
abbrev obarray minibuffer cl-preloaded nadvice loaddefs button 
faces cus-face
macroexp files text-properties overlay sha1 md5 base64 format env 
code-pages
mule custom widget hashtable-print-readable backquote dbusbind 
inotify lcms2
dynamic-setting system-font-setting font-render-setting 
move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 609458 498872)
 (symbols 48 55638 55)
 (miscs 40 172 384)
 (strings 32 159919 40372)
 (string-bytes 1 4889576)
 (vectors 16 62594)
 (vector-slots 8 1118362 306502)
 (floats 8 1074 768)
 (intervals 56 8070 2120)
 (buffers 992 17))

--