mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
fix: nil load-file-name in package autoloads
Some packages do funky things in their autoloads, so care is needed to closely emulate an autoloading environment when loading them, however, in8cafbe4
, Doom wraps these autoloads in a function, thus ensuring they're executed without `load-file-name` or `load-in-progress` set, which some packages will expect these in their autoloads. This fixes the (wrong-type-argument stringp nil) error some folks see with certain packages doing said funky things in their autoloads (like realgun in the :tools debugger module). Fix: #8143 Amend:8cafbe4408
This commit is contained in:
@ -174,29 +174,29 @@ non-nil, treat FILES as pre-generated autoload files instead."
|
|||||||
(file-readable-p file))
|
(file-readable-p file))
|
||||||
(doom-log "loaddefs:scan: %s" file)
|
(doom-log "loaddefs:scan: %s" file)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(if literal
|
(let (subautoloads)
|
||||||
(insert-file-contents file)
|
(if literal
|
||||||
(doom-autoloads--scan-file file))
|
(insert-file-contents file)
|
||||||
(save-excursion
|
(doom-autoloads--scan-file file))
|
||||||
(while (re-search-forward "\\_<load-file-name\\_>" nil t)
|
(save-excursion
|
||||||
;; `load-file-name' is meaningless in a concatenated
|
;; Fixup the special #$ reader form and throw away comments.
|
||||||
;; mega-autoloads file, but also essential in isolation, so we
|
(while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move)
|
||||||
;; replace references to it with the file they came from.
|
(unless (ppss-string-terminator (save-match-data (syntax-ppss)))
|
||||||
(let ((ppss (save-excursion (syntax-ppss))))
|
(replace-match (if (match-end 1) "" pfile) t t))))
|
||||||
(or (nth 3 ppss)
|
(let ((load-file-name file)
|
||||||
(nth 4 ppss)
|
(load-path
|
||||||
(replace-match (prin1-to-string (abbreviate-file-name file)) t t)))))
|
(append (list doom-user-dir)
|
||||||
(let ((load-file-name file)
|
doom-module-load-path
|
||||||
(load-path
|
load-path)))
|
||||||
(append (list doom-user-dir)
|
(condition-case _
|
||||||
doom-module-load-path
|
(while t
|
||||||
load-path)))
|
(push (doom-autoloads--cleanup-form (read (current-buffer))
|
||||||
(condition-case _
|
(not literal))
|
||||||
(while t
|
subautoloads))
|
||||||
(push (doom-autoloads--cleanup-form (read (current-buffer))
|
(end-of-file)))
|
||||||
(not literal))
|
(push `(let* ((load-file-name ,file) (load-true-file-name load-file-name))
|
||||||
autoloads))
|
,@(delq nil subautoloads))
|
||||||
(end-of-file))))))))
|
autoloads)))))))
|
||||||
|
|
||||||
(provide 'doom-lib '(autoloads))
|
(provide 'doom-lib '(autoloads))
|
||||||
;;; autoloads.el end here
|
;;; autoloads.el end here
|
||||||
|
@ -397,24 +397,26 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
|||||||
|
|
||||||
(defun doom-profile--generate-doom-autoloads ()
|
(defun doom-profile--generate-doom-autoloads ()
|
||||||
`((defun doom--startup-module-autoloads ()
|
`((defun doom--startup-module-autoloads ()
|
||||||
,@(doom-autoloads--scan
|
(let ((load-in-progress t))
|
||||||
(append (doom-glob doom-core-dir "lib/*.el")
|
,@(doom-autoloads--scan
|
||||||
(cl-loop for dir
|
(append (doom-glob doom-core-dir "lib/*.el")
|
||||||
in (append (doom-module-load-path)
|
(cl-loop for dir
|
||||||
(list doom-user-dir))
|
in (append (doom-module-load-path)
|
||||||
if (doom-glob dir "autoload.el") collect (car it)
|
(list doom-user-dir))
|
||||||
if (doom-glob dir "autoload/*.el") append it)
|
if (doom-glob dir "autoload.el") collect (car it)
|
||||||
(mapcan #'doom-glob doom-autoloads-files))
|
if (doom-glob dir "autoload/*.el") append it)
|
||||||
nil))))
|
(mapcan #'doom-glob doom-autoloads-files))
|
||||||
|
nil)))))
|
||||||
|
|
||||||
(defun doom-profile--generate-package-autoloads ()
|
(defun doom-profile--generate-package-autoloads ()
|
||||||
`((defun doom--startup-package-autoloads ()
|
`((defun doom--startup-package-autoloads ()
|
||||||
,@(doom-autoloads--scan
|
(let ((load-in-progress t))
|
||||||
(mapcar #'straight--autoloads-file
|
,@(doom-autoloads--scan
|
||||||
(nreverse (seq-difference (hash-table-keys straight--build-cache)
|
(mapcar #'straight--autoloads-file
|
||||||
doom-autoloads-excluded-packages)))
|
(nreverse (seq-difference (hash-table-keys straight--build-cache)
|
||||||
doom-autoloads-excluded-files
|
doom-autoloads-excluded-packages)))
|
||||||
'literal))))
|
doom-autoloads-excluded-files
|
||||||
|
'literal)))))
|
||||||
|
|
||||||
(provide 'doom-lib '(profiles))
|
(provide 'doom-lib '(profiles))
|
||||||
;;; profiles.el ends here
|
;;; profiles.el ends here
|
||||||
|
Reference in New Issue
Block a user