From d735c9be3d92da2754336c37ff593a321fe50ae5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 06:33:09 -0400 Subject: [PATCH 01/17] fix(graphviz): don't eagerly load flycheck at startup Due to eager expansion of the flycheck-define-checker macro. Causes a hefty delay in startup times. --- modules/lang/graphviz/config.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/lang/graphviz/config.el b/modules/lang/graphviz/config.el index 38e7c6fcc..f7710bc93 100644 --- a/modules/lang/graphviz/config.el +++ b/modules/lang/graphviz/config.el @@ -19,14 +19,14 @@ (when (and (modulep! :checker syntax) (not (modulep! :checker syntax +flymake))) (after! flycheck - (flycheck-define-checker graphviz-dot - "A checker using graphviz dot." - :command ("dot") - :standard-input t - :error-patterns ((error line-start "Error: : " (message "syntax error in line " line (* nonl))) - ;; I have no idea if this can actually be printed - (error line-start "Error: : " (message))) - :modes graphviz-dot-mode) + (eval '(flycheck-define-checker graphviz-dot + "A checker using graphviz dot." + :command ("dot") + :standard-input t + :error-patterns ((error line-start "Error: : " (message "syntax error in line " line (* nonl))) + ;; I have no idea if this can actually be printed + (error line-start "Error: : " (message))) + :modes graphviz-dot-mode)) (add-to-list 'flycheck-checkers 'graphviz-dot))) (map! :map graphviz-dot-mode-map From 14189be77c18bb079f2f37da4147fba192f3efe1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 15:11:08 -0400 Subject: [PATCH 02/17] fix: out-of-bounds error if this-single-command-raw-keys is empty It seems there's an edge case in EXWM where input events may occur without keys to cause them (#8064), so these two keybind fixes need to be ready to receive an empty vector from `this-single-command-raw-keys`. Fix: #8064 --- lisp/doom-keybinds.el | 51 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index 2ff1bcfe0..73bee7835 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -50,34 +50,29 @@ and Emacs states, and for non-evil users.") (setq w32-lwindow-modifier 'super w32-rwindow-modifier 'super))) -;; HACK: Emacs can't distinguish C-i from TAB in either GUI or TTY frames. This -;; is a byproduct of its history with the terminal, which can't distinguish -;; them either, however, Emacs has separate input events for many contentious -;; keys like TAB and RET (like [tab] and [return], aka "" and -;; ""), which are only triggered in GUI frames, so here, I create one -;; for C-i. Won't work in TTY frames, though. Doom's :os tty module has a -;; workaround for that though. -(define-key input-decode-map - [?\C-i] (cmd! (if (when-let ((keys (this-single-command-raw-keys))) - (and (display-graphic-p) - (not (cl-position 'tab keys)) - (not (cl-position 'kp-tab keys)) - ;; Fall back if no keybind can be found, - ;; otherwise we've broken all pre-existing C-i - ;; keybinds. - (key-binding (vconcat (cl-subseq keys 0 -1) [C-i]) nil t))) - [C-i] [?\C-i]))) - -;; HACK: Same as C-i, but C-m is a little harder. There is no workaround for -;; this for the terminal. -(define-key input-decode-map - [?\C-m] (cmd! (if (when-let ((keys (this-single-command-raw-keys))) - (and (display-graphic-p) - (not (cl-position 'return keys)) - (not (cl-position 'kp-return keys)) - ;; Fall back if no keybind can be found. - (key-binding (vconcat (cl-subseq keys 0 -1) [C-m]) nil t))) - [C-m] [?\C-m]))) +;; HACK: Emacs can't distinguish C-i from TAB, or C-m from RET, in either GUI or +;; TTY frames. This is a byproduct of its history with the terminal, which +;; can't distinguish them either, however, Emacs has separate input events for +;; many contentious keys like TAB and RET (like [tab] and [return], aka +;; "" and ""), which are only triggered in GUI frames, so here, I +;; create one for C-i. Won't work in TTY frames, though. Doom's :os tty module +;; has a workaround for that though. +(pcase-dolist (`(,key ,fallback . ,events) + '(([C-i] [?\C-i] tab kp-tab) + ([C-m] [?\C-m] return kp-return))) + (define-key + input-decode-map fallback + (cmd! (if (when-let ((keys (this-single-command-raw-keys))) + (and (display-graphic-p) + (not (cl-loop for event in events + if (cl-position event keys) + return t)) + ;; Use FALLBACK if nothing is bound to KEY, otherwise we've + ;; broken all pre-existing FALLBACK keybinds. + (key-binding + (vconcat (if (= 0 (length keys)) [] (cl-subseq keys 0 -1)) + key) nil t))) + key fallback)))) ;; From 0e5935f0f701803bf9b9647d72c687ea2de1a954 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 16:10:14 -0400 Subject: [PATCH 03/17] fix(cli): "Argument list too long" error from after-scripts Because a persisted envvar was larger than MAX_ARG_STRLEN (which is typically ~2kb). --- lisp/doom-cli-lib.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/doom-cli-lib.el b/lisp/doom-cli-lib.el index d8ec8cff7..81c065d69 100644 --- a/lisp/doom-cli-lib.el +++ b/lisp/doom-cli-lib.el @@ -1179,7 +1179,9 @@ Emacs' batch library lacks an implementation of the exec system call." "_doomcleanup() {\n rm -f " ,persistent-files "\n}\n" "_doomrun() {\n " ,command "\n}\n" ,(cl-loop for (var . val) in persisted-env - concat (format "%s=%s \\\n" var (shell-quote-argument val))) + if (<= (length val) 2048) ; Prevent "Argument list too long" errors + concat (format "%s=%s \\\n" var (shell-quote-argument val)) + else do (doom-log 1 "restart: wiscarding envvar %S for being too long (%d)" var (length val))) ,(format "PATH=\"%s%s$PATH\" \\\n" (doom-path doom-emacs-dir "bin") path-separator) From 41987bb00fc58626b5147ab36487e8eb882f9648 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 16:11:03 -0400 Subject: [PATCH 04/17] fix(cli): persist correct doom-log-level to after-scripts --- lisp/doom-cli-lib.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/doom-cli-lib.el b/lisp/doom-cli-lib.el index 81c065d69..335039939 100644 --- a/lisp/doom-cli-lib.el +++ b/lisp/doom-cli-lib.el @@ -1141,7 +1141,7 @@ Emacs' batch library lacks an implementation of the exec system call." `(("DOOMPROFILE" . ,(ignore-errors (doom-profile->id doom-profile))) ("EMACSDIR" . ,doom-emacs-dir) ("DOOMDIR" . ,doom-user-dir) - ("DEBUG" . ,(if init-file-debug "1")) + ("DEBUG" . ,(if init-file-debug (number-to-string doom-log-level))) ("__DOOMPID" . ,(number-to-string (doom-cli-context-pid context))) ("__DOOMSTEP" . ,(number-to-string (doom-cli-context-step context))) ("__DOOMCONTEXT" . ,context-file)) From b9eb6623347a0cbbb721bd1175fc2d5479d01657 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 20:52:21 -0400 Subject: [PATCH 05/17] feat(vertico): allow affixes to be escaped So we can search for "modulep\!" without it triggering the ! dispatcher. --- .../completion/vertico/autoload/vertico.el | 24 +++++++++++++++++++ modules/completion/vertico/config.el | 13 ++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/modules/completion/vertico/autoload/vertico.el b/modules/completion/vertico/autoload/vertico.el index 7689a18bb..2ed8a7d97 100644 --- a/modules/completion/vertico/autoload/vertico.el +++ b/modules/completion/vertico/autoload/vertico.el @@ -237,3 +237,27 @@ See minad/consult#770." (defun +vertico-basic-remote-all-completions (string table pred point) (and (vertico--remote-p string) (completion-basic-all-completions string table pred point))) + +;;;###autoload +(defun +vertico-orderless-dispatch (pattern _index _total) + "Like `orderless-affix-dispatch', but allows affixes to be escaped." + (let ((len (length pattern)) + (alist orderless-affix-dispatch-alist)) + (when (> len 0) + (cond + ;; Ignore single dispatcher character + ((and (= len 1) (alist-get (aref pattern 0) alist)) #'ignore) + ;; Prefix + ((when-let ((style (alist-get (aref pattern 0) alist)) + ((not (char-equal (aref pattern (max (1- len) 1)) ?\\)))) + (cons style (substring pattern 1)))) + ;; Suffix + ((when-let ((style (alist-get (aref pattern (1- len)) alist)) + ((not (char-equal (aref pattern (max 0 (- len 2))) ?\\)))) + (cons style (substring pattern 0 -1)))))))) + +;;;###autoload +(defun +vertico-orderless-disambiguation-dispatch (pattern _index _total) + "Ensure $ works with Consult commands, which add disambiguation suffixes." + (when (char-equal (aref pattern (1- (length pattern))) ?$) + `(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x200000-\x300000]*$")))) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index b0a5e7a16..94e8581d5 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -81,15 +81,10 @@ orderless." (?` . orderless-initialism) (?= . orderless-literal) (?^ . orderless-literal-prefix) - (?~ . orderless-flex))) - - (defun +vertico-orderless-dispatch (pattern _index _total) - (cond - ;; Ensure $ works with Consult commands, which add disambiguation suffixes - ((string-suffix-p "$" pattern) - `(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x200000-\x300000]*$"))))) - - (add-to-list 'orderless-style-dispatchers '+vertico-orderless-dispatch) + (?~ . orderless-flex)) + orderless-style-dispatchers + '(+vertico-orderless-dispatch + +vertico-orderless-disambiguation-dispatch)) (add-to-list 'completion-styles-alist From fa6893eeea7bb91b567522dffe445b8769044330 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 21:48:51 -0400 Subject: [PATCH 06/17] tweak(lib): doom-debug-variables: add doom-log-level --- lisp/lib/debug.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/lib/debug.el b/lisp/lib/debug.el index 3022f7a32..26005573a 100644 --- a/lisp/lib/debug.el +++ b/lisp/lib/debug.el @@ -10,6 +10,7 @@ `(;; Doom variables (doom-print-minimum-level . debug) (doom-inhibit-log . nil) + (doom-log-level . 2) ;; Emacs variables async-debug From 59de0ec15e14b16fbb14b3019cc2d85b17e64008 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 22:07:05 -0400 Subject: [PATCH 07/17] perf(default): eagerly loading yasnippet at startup --- modules/config/default/+evil-bindings.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 55e94f3ce..d7511760d 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -49,7 +49,8 @@ '(((memq (bound-and-true-p yas--active-field-overlay) (overlays-in (1- (point)) (1+ (point)))) #'yas-next-field-or-maybe-expand) - ((yas-maybe-expand-abbrev-key-filter 'yas-expand) + ((and (bound-and-true-p yas-minor-mode) + (yas-maybe-expand-abbrev-key-filter 'yas-expand)) #'yas-expand))) ,@(when (modulep! :completion company +tng) '(((bound-and-true-p company-mode) From c07f359d648a447ebeaaa3a89a69a3a25c3d0366 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 23:18:08 -0400 Subject: [PATCH 08/17] fix(ligatures): activate prettify-symbols-mode conditionally With +extra enabled, this module would activate `prettify-symbols-mode` in any buffer where `prettify-symbols-alist` is non-nil, whether or not `+ligatures-extra-alist` has an entry for the current major mode (or a parent thereof). This behavior is poor UX, since the user may be expecting that a empty entry for some `X-mode` in `+ligatures-extra-alist` should mean *no` prettify-symbols-mode` at all in `X-mode`. With this, `+ligatures-extra-alist` is now the authority. An empty entry for `X-mode` will result in `prettify-symbols-mode` *not* being activated there. If that entry *isn't* empty, it will be combined only with the global default value of `prettify-symbols-alist`, not any pre-existing buffer-local value, to make the end result deterministic, because some modes have their own defaults for it (like `lisp-prettify-symbols-alist`, `js--prettify-symbols-alist`, and `rust-prettify-symbols-alist`). Fix: #7440 --- modules/lang/rust/config.el | 3 --- modules/ui/ligatures/config.el | 36 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/modules/lang/rust/config.el b/modules/lang/rust/config.el index 5d07f11a8..89b4f1cd7 100644 --- a/modules/lang/rust/config.el +++ b/modules/lang/rust/config.el @@ -42,9 +42,6 @@ (setq rustic-indent-method-chain t) - ;; Conflicts with (and is redundant with) :ui ligatures - (setq rust-prettify-symbols-alist nil) - ;; Leave automatic reformatting to the :editor format module. (setq rustic-babel-format-src-block nil rustic-format-trigger nil) diff --git a/modules/ui/ligatures/config.el b/modules/ui/ligatures/config.el index e3236227b..1de06f345 100644 --- a/modules/ui/ligatures/config.el +++ b/modules/ui/ligatures/config.el @@ -99,19 +99,24 @@ efficient to remove the `+extra' flag from the :ui ligatures module instead).") (defun +ligatures-init-extra-symbols-h () "Set up `prettify-symbols-mode' for the current buffer. -Extra ligatures are mode-specific substituions, defined in -`+ligatures-extra-symbols', assigned with `set-ligatures!', and made possible -with `prettify-symbols-mode'. This variable controls where these are enabled. -See `+ligatures-extras-in-modes' to control what major modes this function can -and cannot run in." - (when (and after-init-time (+ligatures--enable-p +ligatures-extras-in-modes)) - (prependq! prettify-symbols-alist - (or (alist-get major-mode +ligatures-extra-alist) - (cl-loop for (mode . symbols) in +ligatures-extra-alist - if (derived-mode-p mode) - return symbols))) - (when prettify-symbols-alist - (when prettify-symbols-mode +Overwrites `prettify-symbols-alist' and activates `prettify-symbols-mode' if +(and only if) there is an associated entry for the current major mode (or a +parent mode) in `+ligatures-extra-alist' AND the current mode (or a parent mode) +isn't disabled in `+ligatures-extras-in-modes'." + (when after-init-time + (when-let* + (((+ligatures--enable-p +ligatures-extras-in-modes)) + (symbols + (if-let ((symbols (assq major-mode +ligatures-extra-alist))) + symbols + (cl-loop for (mode . symbols) in +ligatures-extra-alist + if (derived-mode-p mode) + return symbols)))) + (setq prettify-symbols-alist + (append symbols + ;; Don't overwrite global defaults + (default-value 'prettify-symbols-alist))) + (when (bound-and-true-p prettify-symbols-mode) (prettify-symbols-mode -1)) (prettify-symbols-mode +1)))) @@ -124,11 +129,6 @@ and cannot run in." (setq prettify-symbols-unprettify-at-point 'right-edge) (when (modulep! +extra) - ;; Lisp modes offer their own defaults for `prettify-symbols-mode' (just a - ;; lambda symbol substitution), but this might be unexpected if the user - ;; enables +extra but has unset `+ligatures-extra-symbols'. - (setq lisp-prettify-symbols-alist nil) - (add-hook 'after-change-major-mode-hook #'+ligatures-init-extra-symbols-h)) (cond From f452677c555693e354f69ebd4b8b3f074f0e616e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 12 Sep 2024 23:18:30 -0400 Subject: [PATCH 09/17] docs(ligatures): revise docstrings --- modules/ui/ligatures/autoload/ligatures.el | 10 ++++++---- modules/ui/ligatures/config.el | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/ui/ligatures/autoload/ligatures.el b/modules/ui/ligatures/autoload/ligatures.el index f23317a95..eb3bb263d 100644 --- a/modules/ui/ligatures/autoload/ligatures.el +++ b/modules/ui/ligatures/autoload/ligatures.el @@ -18,15 +18,17 @@ pretty symbols and ligatures previously defined for MODES. For example, the rule for emacs-lisp-mode is very simple: - (set-ligatures! \\='emacs-lisp-mode - :lambda \"lambda\") + (after! elisp-mode + (set-ligatures! \\='emacs-lisp-mode + :lambda \"lambda\")) This will replace any instances of \"lambda\" in emacs-lisp-mode with the symbol associated with :lambda in `+ligatures-extra-symbols'. -Pretty symbols can be unset for emacs-lisp-mode with: +Pretty symbols can be unset by passing `nil': - (set-ligatures! \\='emacs-lisp-mode nil) + (after! rustic + (set-ligatures! \\='rustic-mode nil)) Note that this will keep all ligatures in `+ligatures-prog-mode-list' active, as `emacs-lisp-mode' is derived from `prog-mode'." diff --git a/modules/ui/ligatures/config.el b/modules/ui/ligatures/config.el index 1de06f345..57dc8d7c1 100644 --- a/modules/ui/ligatures/config.el +++ b/modules/ui/ligatures/config.el @@ -59,7 +59,9 @@ font.") "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)" "\\\\" "://") (t)) - "A alist of ligatures to enable in specific modes.") + "A alist of ligatures to enable in specific modes. + +To configure this variable, use `set-ligatures!'.") (defvar +ligatures-in-modes nil "List of major modes where ligatures should be enabled.") @@ -74,7 +76,9 @@ font.") (make-obsolete-variable '+ligatures-all-modes-list "Use `+ligatures-alist' instead" "24.09.0") (defvar +ligatures-extra-alist '((t)) - "A map of major modes to symbol lists (for `prettify-symbols-alist').") + "A map of major modes to symbol lists (for `prettify-symbols-alist'). + +To configure this variable, use `set-ligatures!'.") (defvar +ligatures-extras-in-modes t "List of major modes where extra ligatures should be enabled. From 07afef645a24a663a822fe398d1bdab26f54d63e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 13 Sep 2024 08:00:14 -0400 Subject: [PATCH 10/17] tweak(company): company-idle-delay = 0.26 Bumped up from it's default of 0.2. --- modules/completion/company/config.el | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 6a1f05ea9..3de13e69a 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -11,6 +11,7 @@ company-tooltip-limit 14 company-tooltip-align-annotations t company-require-match 'never + company-idle-delay 0.26 company-global-modes '(not erc-mode circe-mode From faeab956e5bfc1dfba87f8e788eb5175b083ea47 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 13 Sep 2024 17:44:05 -0400 Subject: [PATCH 11/17] fix(vertico): consult-register: make evil-aware Since the module remaps evil-show-registers to consult-register, the latter should be made aware of evil registers. Fix: #6355 --- modules/completion/vertico/config.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index 94e8581d5..0a325ef2a 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -129,6 +129,15 @@ orderless." :before (list #'consult-recent-file #'consult-buffer) (recentf-mode +1)) + (defadvice! +vertico--use-evil-registers-a (fn &rest args) + "Use `evil-register-list' if `evil-mode' is active." + :around #'consult-register--alist + (let ((register-alist + (if (bound-and-true-p evil-local-mode) + (evil-register-list) + register-alist))) + (apply fn args))) + (setq consult-project-function #'doom-project-root consult-narrow-key "<" consult-line-numbers-widen t From b6815045828e80e1e301b11b900673593d61e419 Mon Sep 17 00:00:00 2001 From: 45mg <45mg@no.mail> Date: Fri, 13 Sep 2024 10:43:26 +0000 Subject: [PATCH 12/17] fix(fold): avoid Hideshow-not-supported error Some modes are not supported by `hs-minor-mode`, but can still support some of the `+fold/` commands. For example, `pdf-outline-minor-mode` recognizes the same commands as `outline-minor-mode`, but `hs-minor-mode` is not applicable. In cases like these, we shouldn't try to enable `hs-minor-mode`, as this will produce an error that will terminate the command. --- modules/editor/fold/autoload/fold.el | 58 ++++++++++++++++------------ modules/editor/fold/config.el | 3 +- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/modules/editor/fold/autoload/fold.el b/modules/editor/fold/autoload/fold.el index ff668d9f9..46d01338d 100644 --- a/modules/editor/fold/autoload/fold.el +++ b/modules/editor/fold/autoload/fold.el @@ -9,8 +9,16 @@ ;;; Helpers (defun +fold--ensure-hideshow-mode () - (unless (bound-and-true-p hs-minor-mode) - (hs-minor-mode +1))) + "Enable `hs-minor-mode' if not already enabled. + +Return non-nil if successful in doing so." + (if (not (bound-and-true-p hs-minor-mode)) + ;; `hs-grok-mode-type' applies this test; if it fails, it produces an + ;; error indicating that `hs-minor-mode' is not supported here. + (when (and (bound-and-true-p comment-start) + (bound-and-true-p comment-end)) + (hs-minor-mode +1)) + t)) (defun +fold--vimish-fold-p () (and (featurep 'vimish-fold) @@ -23,14 +31,14 @@ (outline-on-heading-p))) (defun +fold--hideshow-fold-p () - (+fold--ensure-hideshow-mode) - (save-excursion - (ignore-errors - (or (hs-looking-at-block-start-p) - (hs-find-block-beginning) - (unless (eolp) - (end-of-line) - (+fold--hideshow-fold-p)))))) + (when (+fold--ensure-hideshow-mode) + (save-excursion + (ignore-errors + (or (hs-looking-at-block-start-p) + (hs-find-block-beginning) + (unless (eolp) + (end-of-line) + (+fold--hideshow-fold-p))))))) ;; NOTE: does this need more? (defun +fold--ts-fold-p () @@ -186,13 +194,13 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." ((and (featurep 'vimish-fold) (+fold--vimish-fold-p)) (vimish-fold-unfold-all)) ((save-excursion - (+fold--ensure-hideshow-mode) + (when (+fold--ensure-hideshow-mode) + (hs-life-goes-on + (if (integerp level) + (hs-hide-level-recursive level (point-min) (point-max)) + (hs-show-all)))) (if (integerp level) - (progn - (outline-hide-sublevels (max 1 level)) - (hs-life-goes-on - (hs-hide-level-recursive level (point-min) (point-max)))) - (hs-show-all) + (outline-hide-sublevels (max 1 level)) (when (fboundp 'outline-show-all) (outline-show-all))))))) @@ -207,15 +215,15 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." (progn (when (featurep 'vimish-fold) (vimish-fold-refold-all)) - (+fold--ensure-hideshow-mode) - (hs-life-goes-on - (if (integerp level) - (progn - (outline--show-headings-up-to-level level) - (hs-hide-level-recursive level (point-min) (point-max))) - (hs-hide-all) - (when (fboundp 'outline-hide-sublevels) - (outline-show-only-headings)))))))) + (when (+fold--ensure-hideshow-mode) + (hs-life-goes-on + (if (integerp level) + (hs-hide-level-recursive level (point-min) (point-max)) + (hs-hide-all)))) + (if (integerp level) + (outline--show-headings-up-to-level level) + (when (fboundp 'outline-hide-sublevels) + (outline-show-only-headings))))))) ;;;###autoload (defun +fold/next (count) diff --git a/modules/editor/fold/config.el b/modules/editor/fold/config.el index 1248f4725..c063ecef7 100644 --- a/modules/editor/fold/config.el +++ b/modules/editor/fold/config.el @@ -56,8 +56,7 @@ this." (defadvice! +fold--hideshow-ensure-mode-a (&rest _) "Ensure `hs-minor-mode' is enabled when we need it, no sooner or later." :before '(hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all) - (unless (bound-and-true-p hs-minor-mode) - (hs-minor-mode +1))) + (+fold--ensure-hideshow-mode)) ;; extra folding support for more languages (unless (assq 't hs-special-modes-alist) From d34770407ce092501aeca0aee879d0f6ee6f2029 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 14 Sep 2024 02:01:50 -0400 Subject: [PATCH 13/17] fix(emacs-lisp): unremap describe-symbol to helpful-symbol The latter can't look up cl types. Rather than remap it globally, allow folks to bind them separately. --- modules/lang/emacs-lisp/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index 565296720..eeebdc5ce 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -273,7 +273,7 @@ See `+emacs-lisp-non-package-mode' for details.") (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) + ;; (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." From 66a2972ebf5fd18cd8adb6eb71a48ec08ce418b8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 14 Sep 2024 04:18:15 -0400 Subject: [PATCH 14/17] fix(lib): doom/set-indent-width on Emacs >=30 A built-in `editorconfig` package was added in Emacs 30, with a somewhat different API from the other package of the same name. Fix: #8072 --- lisp/lib/text.el | 12 ++++++++++-- modules/tools/editorconfig/config.el | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/lib/text.el b/lisp/lib/text.el index e44e127c4..0bd7a3e7a 100644 --- a/lisp/lib/text.el +++ b/lisp/lib/text.el @@ -368,7 +368,15 @@ editorconfig or dtrt-indent installed." (setq-local standard-indent width) (when (boundp 'evil-shift-width) (setq evil-shift-width width)) - (cond ((require 'editorconfig nil t) + ;; REVIEW: Only use `editorconfig' once we drop 29.x support. + (cond ((let ((load-path (get 'load-path 'initial-value))) + ;; A built-in `editorconfig' package was added in Emacs 30.x, but + ;; with a different API. Since it's built in, prefer it over the + ;; upstream one, but we still need to adapt: + (require 'editorconfig nil t)) + (pcase-dolist (`(,var . ,val) (editorconfig--default-indent-size-function width)) + (set (make-local-variable var) val))) + ((require 'editorconfig nil t) (let (editorconfig-lisp-use-default-indent) (editorconfig-set-indentation nil width))) ((require 'dtrt-indent nil t) @@ -376,7 +384,7 @@ editorconfig or dtrt-indent installed." (dolist (var (ensure-list vars)) (doom-log "Updated %s = %d" var width) (set var width))))) - (message "Changed indentation to %d" width)) + (message "Changed buffer's indent-size to %d" width)) ;; diff --git a/modules/tools/editorconfig/config.el b/modules/tools/editorconfig/config.el index f98078c97..1d2d65817 100644 --- a/modules/tools/editorconfig/config.el +++ b/modules/tools/editorconfig/config.el @@ -1,5 +1,6 @@ ;;; tools/editorconfig/config.el -*- lexical-binding: t; -*- +;; TODO: Adapt to built-in `editorconfig' in Emacs 30+ ;; Handles whitespace (tabs/spaces) settings externally. This way projects can ;; specify their own formatting rules. (use-package! editorconfig From a78237cc01adeabe0fd4a83ff8b8aca7cb269482 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 14 Sep 2024 13:24:43 -0400 Subject: [PATCH 15/17] fix(mu4e): org-msg: type error w/ prefix arg Fix: #8073 --- modules/email/mu4e/autoload/email.el | 2 -- modules/email/mu4e/config.el | 17 +++++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/email/mu4e/autoload/email.el b/modules/email/mu4e/autoload/email.el index e3f001854..50fc24376 100644 --- a/modules/email/mu4e/autoload/email.el +++ b/modules/email/mu4e/autoload/email.el @@ -281,8 +281,6 @@ attach a file, or select a folder to open dired in and select file attachments When otherwise called, open a dired buffer and enable `dired-mu4e-attach-ctrl-c-ctrl-c'." ;; TODO add ability to attach files (+dirs) as a single (named) archive (interactive "p") - (when (fboundp '+mu4e-compose-org-msg-handle-toggle) - (+mu4e-compose-org-msg-handle-toggle (/= 1 files-to-attach))) (pcase major-mode ((or 'mu4e-compose-mode 'org-msg-edit-mode) (let ((mail-buffer (current-buffer)) diff --git a/modules/email/mu4e/config.el b/modules/email/mu4e/config.el index 7e07a1714..f02b7a923 100644 --- a/modules/email/mu4e/config.el +++ b/modules/email/mu4e/config.el @@ -441,21 +441,18 @@ This should already be the case yet it does not always seem to be." (let ((files (org-msg-get-prop "attachment"))) (org-msg-set-prop "attachment" (nconc files (list file))))) - (defvar +mu4e-compose-org-msg-toggle-next t ; t to initialise org-msg - "Whether to toggle `org-msg-toggle' on ") - (defun +mu4e-compose-org-msg-handle-toggle (toggle-p) - (when (xor toggle-p +mu4e-compose-org-msg-toggle-next) - (org-msg-mode (if org-msg-mode -1 1)) - (setq +mu4e-compose-org-msg-toggle-next - (not +mu4e-compose-org-msg-toggle-next)))) - - ;; HACK: ... + ;; HACK: Toggle `org-msg' where sensible. + (defvar +mu4e--compose-org-msg-toggle-next t) (defadvice! +mu4e-maybe-toggle-org-msg-a (&rest _) + :before #'+mu4e/attach-files :before #'mu4e-compose-new :before #'mu4e-compose-reply :before #'mu4e-compose-forward :before #'mu4e-compose-resend - (+mu4e-compose-org-msg-handle-toggle (/= 1 (or current-prefix-arg 0)))) + (when (xor (/= 1 (if (integerp current-prefix-arg) current-prefix-arg 0)) + +mu4e-compose-org-msg-toggle-next) + (org-msg-mode (if org-msg-mode -1 1)) + (cl-callf not +mu4e-compose-org-msg-toggle-next))) ;; HACK: ... (defadvice! +mu4e-draft-open-signature-a (fn &rest args) From c82e7d9ea27ff1994a1891a7d162a9943ad7c897 Mon Sep 17 00:00:00 2001 From: Ajai Nelson <22969541+AjaiKN@users.noreply.github.com> Date: Sat, 14 Sep 2024 01:46:52 -0400 Subject: [PATCH 16/17] fix(ligatures): avoid invalid `prettify-symbols-alist` Otherwise, `prettify-symbols-alist` will be set to a list whose first element is the mode name, a symbol. That makes `prettify-symbols-alist` an invalid alist, so when `prettify-symbols-mode` is enabled, there's a type error in `prettify-symbols--make-keywords`. Amend: c07f359d648a --- modules/ui/ligatures/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/ligatures/config.el b/modules/ui/ligatures/config.el index 57dc8d7c1..00169e1fd 100644 --- a/modules/ui/ligatures/config.el +++ b/modules/ui/ligatures/config.el @@ -112,7 +112,7 @@ isn't disabled in `+ligatures-extras-in-modes'." (((+ligatures--enable-p +ligatures-extras-in-modes)) (symbols (if-let ((symbols (assq major-mode +ligatures-extra-alist))) - symbols + (cdr symbols) (cl-loop for (mode . symbols) in +ligatures-extra-alist if (derived-mode-p mode) return symbols)))) From 2e5307e4259281d1a233fb1bc99975d528650d53 Mon Sep 17 00:00:00 2001 From: 45mg <45mg@no.mail> Date: Sat, 14 Sep 2024 05:52:08 +0000 Subject: [PATCH 17/17] fix(emacs-lisp): always try Helpful for doc lookup As per the description in 6671adc68, this module should always use Helpful's functions as long as Helpful is available (ie. not explicitly disabled by the user in packages.el). The remapping of `describe-symbol` is irrelevant here - the user might prefer to rebind `C-h C-o` to `describe-symbol` (as `helpful-symbol` cannot look up types), but that doesn't necessarily mean they want this module not to use it. --- modules/lang/emacs-lisp/autoload.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/lang/emacs-lisp/autoload.el b/modules/lang/emacs-lisp/autoload.el index e003de2e2..fd8e0b343 100644 --- a/modules/lang/emacs-lisp/autoload.el +++ b/modules/lang/emacs-lisp/autoload.el @@ -117,8 +117,9 @@ if it's callable, `apropos' otherwise." (org-show-hidden-entry)))) 'deferred)) (thing - (funcall (or (command-remapping #'describe-symbol) - #'describe-symbol) + (funcall (if (fboundp #'helpful-symbol) + #'helpful-symbol + #'describe-symbol) (intern thing))) ((call-interactively (if (fboundp #'helpful-at-point)