Subject: bug#38197: 26.3; File opened by find-file appears in other window

From: Johan Bengtsson <[email-masked]>
Date: Wed, 13 Nov 2019 14:03:53 +0100

If find-file is used on a file that already exists in a buffer and there
is than one window then the buffer will be displayed in one of the
non-active windows. If the file does not exist in a buffer it will be
opened and displayed in the current window as expected.

The problem seems to be related to the use of pop-to-buffer-same-window
in find-file. If the definition of find-file is changed to use
switch-to-buffer (as it was in emacs25) it works as expected.

In GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2019-09-16 built on lcy01-amd64-030
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.3 LTS

Recent messages:
Undo! [7 times]
if: Invalid function: (switch-to-buffer value)
Making completion list...
delete-backward-char: Text is read-only
Making completion list... [2 times]
Quit
Note: file is write protected
Type "q" in help window to restore its previous buffer.
previous-line: Beginning of buffer
Making completion list...

Configured using:
'configure --build=x86_64-linux-gnu --prefix=/usr
'--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
'--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
--disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
--disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
--program-suffix=26 --with-modules --with-file-notification=inotify
--with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets
--with-lcms2 'CFLAGS=-g -O2
-fdebug-prefix-map=/build/emacs26-TP6iDo/emacs26-26.3~1.git96dd019=.
-fstack-protector-strong -Wformat -Werror=format-security -no-pie'
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS
LIBSYSTEMD LCMS2

Important settings:
value of $LC_MONETARY: en_US.UTF-8
value of $LC_NUMERIC: en_US.UTF-8
value of $LC_TIME: en_US.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix

Major mode: Help

Minor modes in effect:
compilation-in-progress: (global)
ggtags-navigation-mode: t
global-magit-file-mode: t
diff-auto-refine-mode: t
magit-auto-revert-mode: t
global-git-commit-mode: t
async-bytecomp-package-mode: t
shell-dirtrack-mode: t
cl-old-struct-compat-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t

Load-path shadows:
/home/johanb/.emacs.d/elpa/dsvn-20190316.2201/dsvn hides 
/usr/share/emacs/site-lisp/dsvn
/home/johanb/.emacs.d/elpa/psvn-20151103.1042/psvn hides 
/usr/share/emacs/site-lisp/psvn
/home/johanb/.emacs.d/elpa/ninja-mode-20181024.1439/ninja-mode hides 
/usr/share/emacs/site-lisp/ninja-mode
/home/johanb/.emacs.d/elpa/cmake-mode-20190710.1319/cmake-mode hides 
/usr/share/emacs/site-lisp/cmake-mode
/home/johanb/.emacs.d/elpa/yaml-mode-20190625.1740/yaml-mode hides 
/usr/share/emacs/site-lisp/yaml-mode/yaml-mode
/home/johanb/.emacs.d/elpa/dash-20190920.1035/dash-pkg hides 
/usr/share/emacs/site-lisp/elpa-src/dash-2.13.0/dash-pkg
/home/johanb/.emacs.d/elpa/dash-20190920.1035/dash-autoloads hides 
/usr/share/emacs/site-lisp/elpa-src/dash-2.13.0/dash-autoloads
/home/johanb/.emacs.d/elpa/dash-20190920.1035/dash hides 
/usr/share/emacs/site-lisp/elpa-src/dash-2.13.0/dash
/home/johanb/.emacs.d/elpa/git-commit-20190928.1746/git-commit-pkg hides 
/usr/share/emacs/site-lisp/elpa-src/git-commit-2.11.0/git-commit-pkg
/home/johanb/.emacs.d/elpa/git-commit-20190928.1746/git-commit-autoloads 
hides 
/usr/share/emacs/site-lisp/elpa-src/git-commit-2.11.0/git-commit-autoloads
/home/johanb/.emacs.d/elpa/git-commit-20190928.1746/git-commit hides 
/usr/share/emacs/site-lisp/elpa-src/git-commit-2.11.0/git-commit
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-obsolete hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-obsolete
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-autorevert hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-autorevert
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-submodule hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-submodule
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-commit hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-commit
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-pkg hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-pkg
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-repos hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-repos
/home/johanb/.emacs.d/elpa/magit-20190930.1815/git-rebase hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/git-rebase
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-utils hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-utils
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-worktree hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-worktree
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-section hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-section
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-sequence hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-sequence
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-diff hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-diff
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-files hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-files
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-autoloads hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-autoloads
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-blame hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-blame
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-ediff hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-ediff
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-margin hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-margin
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-bookmark hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-bookmark
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-log hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-log
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-core hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-core
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-mode hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-mode
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-refs hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-refs
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-remote hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-remote
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-branch hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-branch
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-extras hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-extras
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-subtree hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-subtree
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-wip hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-wip
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-stash hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-stash
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-process hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-process
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-bisect hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-bisect
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-apply hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-apply
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-notes hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-notes
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-status hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-status
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-git hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-git
/home/johanb/.emacs.d/elpa/magit-20190930.1815/magit-imenu hides 
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-imenu
/usr/share/emacs/site-lisp/elpa-src/magit-2.11.0/magit-popup hides 
/usr/share/emacs/site-lisp/elpa-src/magit-popup-2.11.0/magit-popup
/home/johanb/.emacs.d/elpa/with-editor-20190715.2007/with-editor-autoloads 
hides 
/usr/share/emacs/site-lisp/elpa-src/with-editor-2.6.0/with-editor-autoloads
/home/johanb/.emacs.d/elpa/with-editor-20190715.2007/with-editor-pkg 
hides /usr/share/emacs/site-lisp/elpa-src/with-editor-2.6.0/with-editor-pkg
/home/johanb/.emacs.d/elpa/with-editor-20190715.2007/with-editor hides 
/usr/share/emacs/site-lisp/elpa-src/with-editor-2.6.0/with-editor
/usr/share/emacs/site-lisp/rst hides 
/usr/share/emacs/26.3/lisp/textmodes/rst
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides 
/usr/share/emacs/26.3/lisp/textmodes/flyspell
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides 
/usr/share/emacs/26.3/lisp/textmodes/ispell
/home/johanb/.emacs.d/elpa/tuareg-20190805.958/ocamldebug hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/ocamldebug
/home/johanb/.emacs.d/elpa/cmake-mode-20190710.1319/cmake-mode hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/cmake-mode
/usr/share/emacs/26.3/lisp/progmodes/ruby-mode hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/ruby-mode
/home/johanb/.emacs.d/elpa/cmake-font-lock-20190728.1901/cmake-font-lock 
hides /home/johanb/.emacs.d/elisp/iar-modules/lisp/cmake-font-lock
/home/johanb/.emacs.d/elpa/yaml-mode-20190625.1740/yaml-mode hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/yaml-mode
/home/johanb/.emacs.d/elpa/dsvn-20190316.2201/dsvn hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/dsvn
/home/johanb/.emacs.d/elpa/ninja-mode-20181024.1439/ninja-mode hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/ninja-mode
/home/johanb/.emacs.d/elpa/tuareg-20190805.958/tuareg hides 
/home/johanb/.emacs.d/elisp/iar-modules/lisp/tuareg

Features:
(shadow sort mail-extr emacsbug sendmail apropos debug pp python
tramp-sh tramp tramp-compat tramp-loaddefs trampver ucs-normalize
parse-time rot13 disp-table ffap json-mode json-reformat json-snatcher
js sgml-mode dom json map cl-print completion dos-w32 find-cmd
find-dired eieio-opt speedbar sb-image ezimage dframe find-func
git-rebase vc magit-patch magit-subtree magit-ediff ediff-merg
ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff
pulse pcase vc-dispatcher cmake-font-lock cmake-mode yaml-mode burs-mode
make-mode ispell help-fns radix-tree sh-script executable tabify
inf-ruby ruby-mode smie groovy-mode cc-langs perl-mode magit-extras
dabbrev grep misearch multi-isearch asm-mode bug-reference gud magit-svn
man thingatpt vc-git autoinsert modern-cpp-font-lock c-indent-operator
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs elec-pair dot-region ggtags etags xref project compile
ewoc clang-format xml 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 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 transient git-commit magit-git
magit-section magit-utils crm log-edit easy-mmode message rmc puny dired
dired-loaddefs format-spec rfc822 mml mml-sec epa derived epg gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log with-editor cl-extra help-mode
async-bytecomp advice async shell pcomplete comint ansi-color ring
server subr-x dash time-stamp mic-paren jka-compr edmacro kmacro useful
finder-inf rx cl info package easymenu epg-config url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache url-vars seq byte-opt gv bytecomp byte-compile cconv
cl-loaddefs cl-lib site-start c-electric-operator vc-svn 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 elisp-mode lisp-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 threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 2511486 204390)
(symbols 48 58072 1)
(miscs 40 48414 25826)
(strings 32 194003 46774)
(string-bytes 1 15129971)
(vectors 16 91593)
(vector-slots 8 2438955 100868)
(floats 8 137 1002)
(intervals 56 344120 2039)
(buffers 992 273))