I tried running M-x eval-buffer
to reload my init.el, which looks like this (point was at top, most irrelevant commented-out sections trimmed):
(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
;; Bootstrap 'use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile (require 'use-package))
;; Use use-package to download and load theme
(use-package dracula-theme
:ensure t
:config (load-theme 'dracula t))
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'org-mode-hook #'visual-fill-column-mode)
(desktop-change-dir "~/.emacs.d/desktop")
(desktop-save-mode 1)
(eval-after-load 'org (define-key org-mode-map (kbd "C-M-i") 'pcomplete))
; This gets syntax-highlighted strangely as though the single quotes stop the comments
;; ;; Rebind the 'd' key in org-agenda (default: `org-agenda-day-view').
;; Refresh org-agenda after rescheduling a task.
(defun org-agenda-refresh ()
"Refresh all `org-agenda' buffers."
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (derived-mode-p 'org-agenda-mode)
(org-agenda-maybe-redo)))))
(defadvice org-schedule (after refresh-agenda activate)
"Refresh org-agenda."
(org-agenda-refresh))
(setq org-read-date-prefer-future 'time)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(fill-column 90)
'(git-commit-summary-max-length 50)
'(org-agenda-custom-commands
'(("n" "Agenda and my (or unassigned) TODOs"
((agenda "" nil)
(tags-todo "<irrelevant search string>" nil))
nil)))
'(org-agenda-files '("~/org/agenda.org"))
'(org-log-into-drawer t)
'(package-selected-packages
'(visual-fill-column paredit flycheck-clj-kondo org-recur cider magit use-package dracula-theme))
'(save-place-mode t)
'(visual-fill-column-enable-sensible-window-split nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
However, I got a prompt asking if I really wanted to kill the modified init.el
buffer; when I answered no, it had to recreate the buffer by "reading killed buffer" (presumably from the kill ring). When I tried it again, it instead picked a different modified buffer (an Org file) to kill and recreate when I answered no again.
Why is it even killing any buffers at all? How am I actually supposed to just do a simple reload of minor changes, if eval-buffer
is so wildly dangerous?
@whitetrillium suggested setting a breakpoint. Call stack from eval-buffer
up looks like this:
* kill-buffer(#<buffer *temp*>)
#f(compiled-function () #<bytecode -0x1c1d6e334ba0c627>)()
package-load-descriptor("/Users/ntuggy/.emacs.d/elpa/bind-key-20220910.2157")
package-load-all-descriptors()
package-initialize()
eval-buffer() ; Reading at buffer position 255
Nothing in the elisp source for that package explains why kill-buffer
is getting called.
M-x debug-on-entry RET kill-buffer
. And doM-x eval-buffer
again.*temp*
buffer is getting killed, which is probably OK. What happens if you continue withc
? Keep continuing until an interesting buffer is killed. It's that backtrace that you want.emacs -Q
(to skip any bugs in things installed at the system level)?package-initialize
has loaded some code from the packages you have installed. So the bug is likely in the initialization code of one of these packages. And so to find it you'll probably need to figure out exactly what's getting loaded. Maybe try copying your.emacs.d
and doing a binary search eliminating half the packages until you find the one problematic package (hoping it's a single package and not a combination).