14
votes

Can someone help me make sense of list-buffer (aka Ctrlx - Ctrlb) behavior in emacs 25?

The behavior I'm used to seeing is that it opens the buffer list in another Emacs window (virtual Emacs window), splitting out a second window to do so, if necessary. In some versions it hasn't always been very deterministic which other window it used (if I had more than 2 up), but I could at least count on it not using the one the cursor was in.

I recently installed 25.0.50.1 to get around a remote file open bug (worked!), and now it isn't always doing this. Very often it opens the buffer list in the same window my cursor was in. Often it works the way it used to. I can't figure out any rhyme or reason behind which it choses to do.

Can someone enlighten me as to the algorithm it is using now? It makes managing multiple emacs Windows for reference viewing nearly impossible when I can't predict which window gets replaced.

1
After you get your answer, if you feel the doc or behavior is not clear or what you would prefer, consider filing a bug/enhancement request: M-x report-emacs-bug.Drew
If you are interested in making it work the way you want by creating your own function, there are a few threads [available by Googling] that discuss how to make it display left/right/above/below. However, most people seem to prefer advice'ing or display-buffer-alist'ing to workaround the default behavior of existing functions instead of simply creating new ones -- there are probably some threads for those methods also, but I haven't checked.lawlist
@lawlist - Before I decide on changing the default behavior, I'd like to know exactly what the default behavior currently is.T.E.D.
The question is really about ascertaining the default behavior of the function display-buffer. I suggest that you read the doc-string of that function, which can be viewed by typing: M-x describe-function RET display-buffer RET. The function list-buffers is one (1) line of code excluding the doc-string and interactive statement -- i.e., (display-buffer (list-buffers-noselect arg)). Noselect is self-explanitory -- i.e.., a buffer is generated containing the ingredients you are accustomed to seeing, and then it just sits there waiting to be displayed -- e.g., by display-buffer.lawlist
The doc of display-buffer and display-buffer-alist, as well as the behavior they try to describe and explain, is indeed "way far beyond my meer [sic] mortal perception (and understanding). FWIW, I'm with you on that one - I've never been able to fathom it either.Drew

1 Answers

5
votes

I would guess your primary concern is to have a convenient way to switch buffer, not to understand the emacs' source code, so I would strongly recommend to check helm package out: http://tuhdo.github.io/helm-intro.html It will take about 10 to 20 minutes to install and follow the tutorial, and it is well worth. I promise.

After installing helm and enabling it, the key sequence for you is Ctrl-x b: Shows open buffers, recently opened files

You will get a power pack of many other tools to work in emacs. I had the same problem with switching buffers, and seemingly 'chaotic' buffer popup. After helm installation, the problem is minimized to invisible because it is so easy to switch to the buffers you want.

Update:

To deal package installation errors and package compatibility: M-x list-load-path-shadows to see if there is any conflicting packages. And since you may not have many external packages, I suggest backup ~/.emacs.d and have a new empty one. Also, most of the case when install packages, I try to use emacs package manager. Benefits of using package manger:

  • help check dependencies
  • avoid to manual download and unpack.
  • can do batch update of installed packages

Following is a workflow of enabling melpa repo and installing packages

M-x customize-group RET package
# Click or move cursor to and enter: Package Archives
# Insert the melpa repository. 
Archive name: melpa
URL or directory name: http://stable.melpa.org/packages/
#Save above settings and then you can use the following to install packages:
M-x list-packages RET
f to filer package names
i to mark for installation
x for execution of installation
u for unmark package at cursor. 

# to avoid using load-path repeatedly,
# I have this in my .emacs before any 'require' command:
; Set path recursively to one folder
(let ((default-directory "~/.emacs.d/elpa/"))(normal-top-level-add-subdirs-to-load-path))