abo-abo / ace-window

Quickly switch windows in Emacs
970 stars 86 forks source link

Add ace-window function for display-buffer #187

Closed jackkamm closed 4 years ago

jackkamm commented 4 years ago

I wrote a small function to use ace-window with the display-buffer framework for choosing windows to display buffers in. I was wondering if you'd be interested in this contribution.

My motivation was that, when I have many windows open, display-buffer and pop-to-buffer will open the buffer in some other window than the one I want. For example, this happens when calling *Help* functions (like describe-function) and following their links to elisp source files.

See this reddit post for a screenshot of ace-display-buffer in action.

The function can be used by adding it to display-buffer-alist and its relatives. Here's my config where I use ace-display-buffer as my default display-buffer action, with some tweaks to accommodate helm, magit, and ESS:

(setq display-buffer-base-action '((display-buffer-reuse-window
                                    ace-display-buffer))
      display-buffer-alist '(("\\*help\\[R" (display-buffer-reuse-mode-window
                                             ace-display-buffer))
                             ("\\*helm"
                              ;; see also: `helm-split-window-default-fn'
                              (display-buffer-pop-up-window))
                             ("magit-diff:" (ace-display-buffer)
                              (inhibit-same-window . t))))

I've already assigned my copyright for Emacs to the FSF and can send you my papers if you want, or you can also verify this by looking up my name ("Jack Kamm") in the list of copyrighted org-mode contributors.

abo-abo commented 4 years ago

A really nice feature! Thanks. Please review my rewrite of the pcase statement. I prefer not to depend on it since not every Emacs version has it.

jackkamm commented 4 years ago

Thank you! And thanks for the tip to prefer cl-case over pcase -- good to know.