summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-09-25 13:14:55 -0500
committerCase Duckworth2021-09-25 13:14:55 -0500
commit0858e45bacb602f3a8632dbd025911ec9e80ef98 (patch)
treee8ac2e91939d1ffa994d7d4ecd53874190052565
parentRot13 my email (diff)
downloademacs-0858e45bacb602f3a8632dbd025911ec9e80ef98.tar.gz
emacs-0858e45bacb602f3a8632dbd025911ec9e80ef98.zip
Set default major mode when visiting a non-file buffer
-rw-r--r--init.el24
1 files changed, 6 insertions, 18 deletions
diff --git a/init.el b/init.el index 5e20566..1d1ca39 100644 --- a/init.el +++ b/init.el
@@ -185,24 +185,12 @@ In short, DO NOT USE THIS FUNCTION!!!"
185 185
186(setup buffers 186(setup buffers
187 (:global "C-x k" #'acdw/kill-a-buffer) 187 (:global "C-x k" #'acdw/kill-a-buffer)
188 (defun buffer-list-update@set-major-mode () 188 ;; Set the right major mode based on buffer name, if not visiting a file.
189 "Set `major-mode' from buffer name, even when not visiting a file." 189 ;; http://ruzkuku.com/emacs.d.html#orgeab93c3
190 (let ((name (buffer-name))) 190 (setq-default major-mode (lambda ()
191 (unless (or (active-minibuffer-window) 191 (unless buffer-file-name
192 (string-prefix-p "*" name) 192 (let ((buffer-file-name (buffer-name)))
193 (not (eq major-mode 'fundamental-mode))) 193 (set-auto-mode))))))
194 (catch 'done
195 (dolist (cell auto-mode-alist)
196 (let ((regexp (car cell))
197 (mode (cdr cell)))
198 (when (string-match regexp name)
199 (let ((major-mode mode))
200 (funcall mode))
201 (throw 'done mode))))))))
202
203 ;; TODO: more testing, just in case.
204 ;;(add-hook 'buffer-list-update-hook #'buffer-list-update@set-major-mode)
205 )
206 194
207(setup calendar 195(setup calendar
208 (:option calendar-week-start-day 1)) 196 (:option calendar-week-start-day 1))