Stop some buffers from opening in unexpected places

This commit is contained in:
Camden Dixie O'Brien 2021-01-01 00:00:36 +00:00
parent 58e713dabe
commit 75d062c5e6

View File

@ -142,6 +142,22 @@
(setq initial-frame-alist '((right-divider-width . 1)))
#+end_src
** Opening buffers in current window
There are several places where buffers open in different windows to
the currently selected one. I find this behaviour annoying and I
don't understand why anyone would like it. [[help:display-buffer-alist][display-buffer-alist]]
provides a mechanism for preventing this where there isn't a better
way, as seems to be the case with shell and help buffers.
#+begin_src emacs-lisp
(defun open-in-same-window-p (buffer-name action)
(or (string= (upcase buffer-name) "*SHELL*")
(string= (upcase buffer-name) "*HELP*")))
(setq display-buffer-alist
'((open-in-same-window-p . (display-buffer-same-window . nil))))
#+end_src
* Autocompletion
Enable =company-mode= globally, and hook it into =completion-at-point-functions=.
@ -352,6 +368,26 @@
'("~/org" "~/org/zet/daily" "~/.emacs.d/config.org"))
#+end_src
Also I find it really very annoying that the the current window
layout is destroyed when you run =org-agenda=. That behaviour is
changed by setting [[help:org-agenda-window-setup][org-agenda-window-setup]]:
#+begin_src emacs-lisp
(setq org-agenda-window-setup 'current-window)
#+end_src
** Habits
Habit tracking requires the habits org module to be loaded. This is
done by adding the symbol ~'habits~ to [[help:org-modules][org-modules]], if it's not in
there already. I originally didn't have the surrounding ~unless~,
but it causes problems when re-loading the config using
[[help:org-babel-load-file][org-babel-load-file]].
#+begin_src emacs-lisp
(unless (member 'habits org-modules)
(add-to-list 'org-modules 'habits))
#+end_src
* Language Integrations
** Generic
Generally, 8-character-wide tabs are not my thing.
@ -761,6 +797,32 @@
(setq git-commit-summary-max-length 72))
#+end_src
By default, =magit-status= will open itself in a different window
to the one you open it in. I really don't understand how this is
useful but thankfully this is Emacs so the behaviour can be
tweaked. The default behaviour does make sense for other magit
windows, just not magit-status.
The behviour I want can be achieved by setting
[[help:magit-display-buffer-function][magit-display-buffer-function]] to something which will open the
buffer in the current window if and only if it's a
=magit-status-mode= window.
#+begin_src emacs-lisp
(setq magit-display-buffer-function
(lambda (buffer)
(display-buffer
buffer
(when (eq (with-current-buffer buffer major-mode)
'magit-status-mode)
'(display-buffer-same-window)))))
#+end_src
Now I'm thinking it I could customise this further as I often am
annoyed by diffs opening in a different window but I think I'll
leave it at that for now as I'm not sure precisely what behaviour
I'd want.
** Docker
I use docker quite a lot, unfortunately, so it's nice to be able to
spawn containers etc from Emacs. The =docker= package provides a