dev: merge from master

This commit is contained in:
Matt Nish-Lapidus 2024-08-30 10:10:13 -04:00
commit 10c703a182
16 changed files with 172 additions and 143 deletions

View file

@ -79,7 +79,7 @@ OPTIONS:
(when (and old-version (not (equal old-version emacs-version)))
(print! (warn "Emacs version has changed since last sync (from %s to %s)") old-version emacs-version)
(setq to-rebuild t))
(when (and (integerp hash)
(when (and (stringp hash)
(not (equal hash (doom-sync--system-hash))))
(print! (warn "Your system has changed since last sync"))
(setq to-rebuild t))
@ -113,7 +113,19 @@ OPTIONS:
;;; Helpers
(defun doom-sync--system-hash ()
(sxhash (list doom-local-dir system-type system-configuration-features)))
(secure-hash
'md5 (mapconcat
#'identity
(list
;; Changes to this path could indicate a change to the username and/or
;; the location of Straight's build artifacts; both warrant a rebuild
;; of your packages.
doom-local-dir
;; Changes to this indicate the user's system/OS has changed (e.g. if
;; the user copied their config to another system, on another OS) or
;; Emacs' compiled features have (even if the major version hasn't).
system-configuration)
"")))
(defun doom-sync--abort-warning-h ()
(print! (warn "Script was abruptly aborted, leaving Doom in an incomplete state!"))

View file

@ -545,61 +545,6 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(message ""))))) ; warn silently
(funcall fn arg)))))
(use-package! helpful
;; a better *help* buffer
:commands helpful--read-symbol
:hook (helpful-mode . visual-line-mode)
:init
;; Make `apropos' et co search more extensively. They're more useful this way.
(setq apropos-do-all t)
(global-set-key [remap describe-function] #'helpful-callable)
(global-set-key [remap describe-command] #'helpful-command)
(global-set-key [remap describe-variable] #'helpful-variable)
(global-set-key [remap describe-key] #'helpful-key)
(global-set-key [remap describe-symbol] #'helpful-symbol)
(defun doom-use-helpful-a (fn &rest args)
"Force FN to use helpful instead of the old describe-* commands."
(letf! ((#'describe-function #'helpful-function)
(#'describe-variable #'helpful-variable))
(apply fn args)))
(after! apropos
;; patch apropos buttons to call helpful instead of help
(dolist (fun-bt '(apropos-function apropos-macro apropos-command))
(button-type-put
fun-bt 'action
(lambda (button)
(helpful-callable (button-get button 'apropos-symbol)))))
(dolist (var-bt '(apropos-variable apropos-user-option))
(button-type-put
var-bt 'action
(lambda (button)
(helpful-variable (button-get button 'apropos-symbol))))))
;; DEPRECATED: Remove when support for 29 is dropped.
(when (= emacs-major-version 29)
(defadvice! doom--find-function-search-for-symbol-save-excursion-a (fn &rest args)
"Suppress cursor movement by `find-function-search-for-symbol'.
Addresses an unwanted side-effect in `find-function-search-for-symbol' on Emacs
29 where the cursor is moved to a variable's definition if it's defined in the
current buffer."
:around #'find-function-search-for-symbol
(let (buf pos)
(letf! (defun find-library-name (library)
(let ((filename (funcall find-library-name library)))
(with-current-buffer (find-file-noselect filename)
(setq buf (current-buffer)
pos (point)))
filename))
(prog1 (apply fn args)
(when (buffer-live-p buf)
(with-current-buffer buf (goto-char pos))))))))
:config
(setq helpful-set-variable-function #'setq!))
(use-package! smartparens
;; Auto-close delimiters and blocks as you type. It's more powerful than that,

View file

@ -121,9 +121,6 @@ Is nil if no executable is found in your PATH during startup.")
(put 'projectile-ripgrep 'disabled "Use +default/search-project instead")
(put 'projectile-grep 'disabled "Use +default/search-project instead")
;; Treat current directory in dired as a "file in a project" and track it
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)
;; Accidentally indexing big directories like $HOME or / will massively bloat
;; projectile's cache (into the hundreds of MBs). This purges those entries
;; when exiting Emacs to prevent slowdowns/freezing when cache files are

View file

@ -394,7 +394,15 @@ If RETURN-P, return the message as a string instead of displaying it."
;; the next file it loads into `user-init-file'.
(setq user-init-file t)
(when init-file-name
(load init-file-name 'noerror 'nomessage 'nosuffix))
(load init-file-name 'noerror 'nomessage 'nosuffix)
;; HACK: if `init-file-name' happens to be higher in
;; `load-history' than a symbol's actual definition,
;; `symbol-file' (and help/helpful buffers) will report the
;; source of a symbol as `init-file-name', rather than it's
;; true source. By removing this file from `load-history', no
;; one will make that mistake.
(setq load-history (delete (assoc init-file-name load-history)
load-history)))
;; If it's still `t', then it failed to load the profile initfile.
;; This likely means the user has forgotten to run `doom sync'!
(when (eq user-init-file t)

View file

@ -97,10 +97,10 @@ selection of all minor-modes, active or not."
(let ((symbol
(cond ((stringp mode) (intern mode))
((symbolp mode) mode)
((error "Expected a symbol/string, got a %s" (type-of mode))))))
(if (fboundp symbol)
(helpful-function symbol)
(helpful-variable symbol))))
((error "Expected a symbol/string, got a %s" (type-of mode)))))
(fn (if (fboundp symbol) #'describe-function #'describe-variable)))
(funcall (or (command-remapping fn) fn)
symbol)))
;;
@ -414,26 +414,44 @@ current file is in, or d) the module associated with the current major mode (see
(doom-project-browse (file-name-directory path)))
((user-error "Aborted module lookup")))))
(defun doom--help-variable-p (sym)
"TODO"
(or (get sym 'variable-documentation)
(and (boundp sym)
(not (keywordp sym))
(not (memq sym '(t nil))))))
;;;###autoload
(defun doom/help-custom-variable (var)
"Look up documentation for a custom variable.
Unlike `helpful-variable', which casts a wider net that includes internal
variables, this only lists variables that exist to be customized (defined with
`defcustom')."
Unlike `describe-variable' or `helpful-variable', which casts a wider net that
includes internal variables, this only lists variables that exist to be
customized (defined with `defcustom')."
(interactive
(list (helpful--read-symbol
"Custom variable: "
(helpful--variable-at-point)
(lambda (sym)
(and (helpful--variable-p sym)
(custom-variable-p sym)
;; Exclude minor mode state variables, which aren't meant to be
;; modified directly, but through their associated function.
(not (or (and (string-suffix-p "-mode" (symbol-name sym))
(fboundp sym))
(eq (get sym 'custom-set) 'custom-set-minor-mode))))))))
(helpful-variable var))
(list
(intern (completing-read
"Custom variable: " obarray
(lambda (sym)
(and (doom--help-variable-p sym)
(custom-variable-p sym)
;; Exclude minor mode state variables, which aren't meant to
;; be modified directly, but through their associated
;; function.
(not (or (and (string-suffix-p "-mode" (symbol-name sym))
(fboundp sym))
(eq (get sym 'custom-set) 'custom-set-minor-mode)))))
t nil nil (let ((var (variable-at-point)))
;; `variable-at-point' uses 0 rather than nil to
;; signify no symbol at point (presumably because 'nil
;; is a symbol).
(unless (symbolp var)
(setq var nil))
(when (doom--help-variable-p var)
var))))))
(funcall (or (command-remapping #'describe-variable)
#'describe-variable)
var))
;;

View file

@ -30,7 +30,6 @@
;; doom-editor.el
(package! better-jumper :pin "47622213783ece37d5337dc28d33b530540fc319")
(package! dtrt-indent :pin "a8aa356684804c52f26602d4e315f1306c6f3e59")
(package! helpful :pin "4ba24cac9fb14d5fdc32582cd947572040e82b2c")
(package! smartparens :pin "c7519a1b69f196050a13e2230b7532893b077086")
(package! ws-butler :pin "e3a38d93e01014cd47bf5af4924459bd145fd7c4")