Skip to content

Commit

Permalink
[emacs] Support native compiled init file in ‘mpn-find-file-map’
Browse files Browse the repository at this point in the history
When init.el goes through native compilation, ‘user-init-file’ ends up
pointing at a *.eln file in its own directory.  Open init.el when that
happens.
  • Loading branch information
mina86 committed Jun 1, 2024
1 parent 8a3936b commit dd4b709
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions emacs/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,20 @@ If function given tries to `describe-function' otherwise uses

(defvar mpn-find-file-map
(let ((map (make-sparse-keymap))
(lst `(("i" . ,(cond ((not user-init-file) ; Called with -Q
"init.el")
((string-match "\\.elc$" user-init-file)
(substring user-init-file 0 -1))
(user-init-file)))
(lst `(("i" . ,(cond
;; Called with -Q
((not user-init-file)
"init.el")
;; Compiled file. Open the source.
((string-match "\\.elc$" user-init-file)
(substring user-init-file 0 -1))
;; Native compiled file. Finding the source isn’t as
;; simple as changing extension from .eln to .el. Just
;; open init.el.
((string-match "\\.eln$" user-init-file)
"init.el")
;; Open whatever init file we’re loading.
(user-init-file)))
("e" . "early-init.el")
("m" . "mail.el")
("c" . "customize.el")
Expand Down

0 comments on commit dd4b709

Please sign in to comment.