The Problems:
I just did a full re-install to Fedora 29, which included the dnf install emacs
command. This installed emacs 26-1; formerly I was using emacs 25.2. Formerly,
my emacs initialization concluded with :
(neotree-dir "/home/steve/")
;
(eww-open-file "~/emacs/neotree/EmacsWiki: Neo Tree.html")
(find-file "~/notes/notes_todo.txt")
(find-file "~/emacs/mywork/notes_todo.txt")
(find-file "~/emacs/mywork/elisp_notes_todo.txt")
(find-file "~/notes/notes_movies_to_download.txt")
(find-file "~/notes/notes_watched_tv.txt")
(find-file "~/math/misc/complex_analysis_01.tex")
In emacs 25.2, this worked fine, with the neotree
attached to the frame. In
emacs 26-1, the frame is split horizontally
into two windows, with the last file opened in the bottom window. Further, when
I navigate to the frame's bottom window, and then execute C-x 1
(delete-other-windows)
, the neotree is also deleted. In emacs 25.2, the neotree
would not be deleted here.
Also, sometimes when I open a file, it splits the frame into two windows rather than simply switching to the new file's buffer. I haven't been able to track down the pattern behind this behavior, so I can't be more precise here.
My kludgy temporary initialization workaround:
(eww-open-file "~/emacs/neotree/EmacsWiki: Neo Tree.html")
(find-file "~/notes/notes_todo.txt")
(find-file "~/emacs/mywork/notes_todo.txt")
(find-file "~/emacs/mywork/elisp_notes_todo.txt")
(find-file "~/notes/notes_movies_to_download.txt")
(find-file "~/notes/notes_watched_tv.txt")
(find-file "~/math/misc/complex_analysis_01.tex")
;
(delete-other-windows)
;
(neotree-dir "/home/steve/")
This resolves initialization but does not resolve the subsequent undesired splitting of a frame into windows. Also, it does not resolve preserving neotree when I delete a window from a split frame.
My Research
In emacs 25.2, the relevant code was :
(defun find-file (filename &optional wildcards)
"..."
(interactive
(find-file-read-args "Find file: "
(confirm-nonexistent-file-or-buffer)))
(let ((value (find-file-noselect filename nil nil wildcards)))
(if (listp value)
(mapcar 'switch-to-buffer (nreverse value))
;;else : this comment added by me
(switch-to-buffer value))))
In emacs 26.1, the relevant code is :
(defun find-file (filename &optional wildcards)
"..."
(interactive
(find-file-read-args "Find file: "
(confirm-nonexistent-file-or-buffer)))
(let ((value (find-file-noselect filename nil nil wildcards)))
(if (listp value)
(mapcar 'pop-to-buffer-same-window (nreverse value))
;;else : this comment added by me
(pop-to-buffer-same-window value))))
Either:
1. I have misunderstood the purpose of (pop-to-buffer-same-window)
or
2. (pop-to-buffer-same-window)
is not working as intended.
When I examine the emacs 26.1 code, I see no pertinent variables that I could initialize that would affect the code's behavior.
I did find 28.17 Dedicated Windows
in the elisp manual. However, if this can
solve my problems, any attempt by me to use this without guidance would be
blundering in the dark.
What I Want:
When I open a file, I never want the frame to split into windows. If I desire a split, I will subsequently execute C-x 2
(split-window-below)
.When I have neotree attached to a frame and my frame is also split into windows, when I use C-x 1
(delete-other-windows)
, I never want the neotree deleted. If I subsequently want to delete the neotree, I will execute(neotree toggle)
.
Addendum
Just exchanged emails with emacs-gnu-support, re possible bugs. My main problem was that I needed to change to the most recent copy of neotree. This change resolved most of my problems. Now, C-x 1 `(delete-other-windows) does not delete the neotree. I reported an underlying anomaly that (I think) might reasonably be construed as not a bug. Replication:
- At the end of your initialization, have find-file open a file, and then invoke neotree.
- Without mouse-clicking in the buffer area, use the mouse to take the menu <-> buffers menu option, and then use the mouse to open a file.
The frame will split into windows, perhaps because the pop-to-buffer-same-window
function regards the frame as belonging to neotree.
switch-to-buffer
. It's possible that you have a case where the simple replacement of it bypop-to-buffer-same-window
does not do the right thing - at least not what you expect/want. You might consider filing a bug report about this case:M-x report-emacs-bug
.