diff --git a/early-init.el b/early-init.el index 922972c02..bc6032b42 100644 --- a/early-init.el +++ b/early-init.el @@ -106,9 +106,9 @@ ;; this early -- I remove `.so' from `load-suffixes' and pass the ;; `must-suffix' arg to `load'. See the docs of `load' for details. (if (let ((load-suffixes '(".elc" ".el"))) - ;; I avoid `load's NOERROR argument because other, legitimate errors - ;; (like permission or IO errors) should not be suppressed or - ;; interpreted as "this is not a Doom config". + ;; I avoid `load's NOERROR argument because it suppresses other, + ;; legitimate errors (like permission or IO errors), which gets + ;; incorrectly interpreted as "this is not a Doom config". (condition-case _ ;; Load the heart of Doom Emacs. (load (expand-file-name "lisp/doom" user-emacs-directory) diff --git a/lisp/doom-cli.el b/lisp/doom-cli.el index 25c4e1216..7d5bff2f7 100644 --- a/lisp/doom-cli.el +++ b/lisp/doom-cli.el @@ -25,22 +25,22 @@ ;; HACK: Load `cl' and site files manually to prevent polluting logs and ;; stdout with deprecation and/or file load messages. - (let ((inhibit-message (not init-file-debug))) - (require 'cl nil t) - (unless site-run-file - (let ((site-run-file "site-start") - (tail load-path) - (lispdir (expand-file-name "../lisp" data-directory)) - dir) - (while tail - (setq dir (car tail)) - (let ((default-directory dir)) - (load (expand-file-name "subdirs.el") t inhibit-message t)) - (unless (string-prefix-p lispdir dir) - (let ((default-directory dir)) - (load (expand-file-name "leim-list.el") t inhibit-message t))) - (setq tail (cdr tail))) - (load site-run-file t inhibit-message)))) + (quiet! + (require 'cl nil t) + (unless site-run-file + (let ((site-run-file "site-start") + (tail load-path) + (lispdir (expand-file-name "../lisp" data-directory)) + dir) + (while tail + (setq dir (car tail)) + (let ((default-directory dir)) + (load (expand-file-name "subdirs.el") t inhibit-message t)) + (unless (string-prefix-p lispdir dir) + (let ((default-directory dir)) + (load (expand-file-name "leim-list.el") t inhibit-message t))) + (setq tail (cdr tail))) + (load site-run-file t inhibit-message)))) (setq-default ;; PERF: Don't generate superfluous files when writing temp buffers. diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index ce9f18256..a448e89c8 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -51,12 +51,12 @@ and Emacs states, and for non-evil users.") ;; HACK: Emacs cannot distinguish between C-i from TAB. This is largely a ;; byproduct of its history in the terminal, which can't distinguish them -;; either, however, when GUIs came about Emacs greated separate input events +;; either, however, when GUIs came about Emacs created separate input events ;; for more contentious keys like TAB and RET. Therefore [return] != RET, ;; [tab] != TAB, and [backspace] != DEL. ;; -;; In the same vein, this keybind adds a [C-i] event, so users can bind to it. -;; Otherwise, it falls back to regular C-i keybinds. +;; In the same vein, this keybind adds a [C-i] event, so users can bind to it +;; independently of TAB. Otherwise, it falls back to keys bound to C-i. (define-key key-translation-map [?\C-i] (cmd! (if (let ((keys (this-single-command-raw-keys))) (and keys diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index c33edede1..9f996d3e7 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -303,9 +303,9 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions." (error "file!: cannot deduce the current file path"))) (defmacro dir! () - "Return the directory of the file this macro was called." - (let (file-name-handler-alist) - (file-name-directory (macroexpand '(file!))))) + "Return the directory of the file in which this macro was called." + (let (file-name-handler-alist) + (file-name-directory (macroexpand '(file!))))) ;; REVIEW Should I deprecate this? The macro's name is so long... (defalias 'letenv! 'with-environment-variables) @@ -883,16 +883,16 @@ testing advice (when combined with `rotate-text'). (dolist (target (cdr targets)) (advice-remove target #',symbol))))) + +;; +;;; Backports + (defmacro defbackport! (type symbol &rest body) "Backport a function/macro/alias from later versions of Emacs." (declare (indent defun) (doc-string 4)) (unless (fboundp (doom-unquote symbol)) `(,type ,symbol ,@body))) - -;; -;;; Backports - ;; `format-spec' wasn't autoloaded until 28.1 (defbackport! autoload 'format-spec "format-spec") diff --git a/lisp/doom-start.el b/lisp/doom-start.el index 5a68dd036..c5b1d46b2 100644 --- a/lisp/doom-start.el +++ b/lisp/doom-start.el @@ -100,13 +100,15 @@ ;;; Disable UI elements early ;; PERF,UI: Doom strives to be keyboard-centric, so I consider these UI elements -;; clutter. Initializing them also costs a morsel of startup time. Whats more, -;; the menu bar exposes functionality that Doom doesn't endorse. Perhaps one -;; day Doom will support these, but today is not that day. -;; +;; clutter. Initializing them also costs a morsel of startup time. What's +;; more, the menu bar exposes functionality that Doom doesn't endorse. Perhaps +;; one day Doom will support these, but today is not that day. By disabling +;; them early, we save Emacs some time. + ;; HACK: I intentionally avoid calling `menu-bar-mode', `tool-bar-mode', and -;; `scroll-bar-mode' because they do extra work to manipulate frame variables -;; that isn't necessary this early in the startup process. +;; `scroll-bar-mode' because their manipulation of frame parameters can +;; trigger/queue a superfluous (and expensive, depending on the window system) +;; frame redraw at startup. (push '(menu-bar-lines . 0) default-frame-alist) (push '(tool-bar-lines . 0) default-frame-alist) (push '(vertical-scroll-bars) default-frame-alist) @@ -119,7 +121,7 @@ ;; non-application window -- which means it doesn't automatically capture ;; focus when it is started, among other things, so enable the menu-bar for ;; GUI frames, but keep it disabled in terminal frames because there it -;; activates an ugly, in-frame menu bar. +;; unavoidably activates an ugly, in-frame menu bar. (eval-when! doom--system-macos-p (add-hook! '(window-setup-hook after-make-frame-functions) (defun doom-restore-menu-bar-in-gui-frames-h (&optional frame) @@ -136,7 +138,7 @@ ;; a step too opinionated. (setq default-input-method nil) ;; ...And the clipboard on Windows could be in a wider encoding (UTF-16), so -;; leave Emacs to its own devices. +;; leave Emacs to its own devices there. (eval-when! (not doom--system-windows-p) (setq selection-coding-system 'utf-8)) @@ -180,7 +182,7 @@ (defvar doom-incremental-packages '(t) "A list of packages to load incrementally after startup. Any large packages here may cause noticeable pauses, so it's recommended you break them up into -sub-packages. For example, `org' is comprised of many packages, and can be +sub-packages. For example, `org' is comprised of many packages, and might be broken up into: (doom-load-packages-incrementally @@ -192,16 +194,16 @@ broken up into: This is already done by the lang/org module, however. If you want to disable incremental loading altogether, either remove -`doom-load-packages-incrementally-h' from `emacs-startup-hook' or set +`doom-load-packages-incrementally-h' from `doom-after-init-hook' or set `doom-incremental-first-idle-timer' to nil. Incremental loading does not occur in daemon sessions (they are loaded immediately at startup).") (defvar doom-incremental-first-idle-timer (if (daemonp) 0 2.0) "How long (in idle seconds) until incremental loading starts. -Set this to nil to disable incremental loading. +Set this to nil to disable incremental loading at startup. Set this to 0 to load all incrementally deferred packages immediately at -`emacs-startup-hook'.") +`doom-after-init-hook'.") (defvar doom-incremental-idle-timer 0.75 "How long (in idle seconds) in between incrementally loading packages.") @@ -209,9 +211,13 @@ Set this to 0 to load all incrementally deferred packages immediately at (defun doom-load-packages-incrementally (packages &optional now) "Registers PACKAGES to be loaded incrementally. -If NOW is non-nil, load PACKAGES incrementally, in `doom-incremental-idle-timer' -intervals." - (let ((gc-cons-threshold most-positive-fixnum)) +If NOW is non-nil, PACKAGES will be marked for incremental loading next time +Emacs is idle for `doom-incremental-first-idle-timer' seconds (falls back to +`doom-incremental-idle-timer'), then in `doom-incremental-idle-timer' intervals +afterwards." + (let* ((gc-cons-threshold most-positive-fixnum) + (first-idle-timer (or doom-incremental-first-idle-timer + doom-incremental-idle-timer))) (if (not now) (cl-callf append doom-incremental-packages packages) (while packages @@ -222,7 +228,7 @@ intervals." (condition-case-unless-debug e (and (or (null (setq idle-time (current-idle-time))) - (< (float-time idle-time) doom-incremental-first-idle-timer) + (< (float-time idle-time) first-idle-timer) (not (while-no-input (doom-log "start:iloader: Loading %s (%d left)" req (length packages)) @@ -242,7 +248,7 @@ intervals." (doom-log "start:iloader: Finished!") (run-at-time (if idle-time doom-incremental-idle-timer - doom-incremental-first-idle-timer) + first-idle-timer) nil #'doom-load-packages-incrementally packages t) (setq packages nil)))))))) diff --git a/lisp/doom.el b/lisp/doom.el index 5f9835224..885e31f29 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -59,9 +59,13 @@ ;; - On first switched-to buffer: `doom-first-buffer-hook' ;; - On first opened file: `doom-first-file-hook' ;; -;; This is Doom's heart, where I define all its major constants and variables, -;; set only its sanest global defaults, employ its hackiest (and least -;; offensive) optimizations, and load the minimum for all Doom sessions. +;; This file is Doom's heart, where I define all its major constants and +;; variables, set only its sanest global defaults, employ its hackiest (and +;; least offensive) optimizations, and load the minimum needed for all Doom +;; sessions, interactive or otherwise. +;; +;; See doom-start.el for initialization intended solely for interactive +;; sessions, and doom-cli.el for non-interactive sessions. ;; ;;; Code: @@ -110,7 +114,8 @@ ;;; Custom features & global constants ;; Doom has its own features that its modules, CLI, and user extensions can ;; announce, and don't belong in `features', so they are stored here, which can -;; include information about the external system environment. +;; include information about the external system environment. Module-specific +;; features are kept elsewhere, however. (defconst doom-features (pcase system-type ('darwin '(macos bsd)) @@ -196,7 +201,7 @@ "Current version of Doom Emacs core.") ;; DEPRECATED: Remove these when the modules are moved out of core. -(defconst doom-modules-version "24.02.0-pre" +(defconst doom-modules-version "24.03.0-pre" "Current version of Doom Emacs.") (defvar doom-init-time nil @@ -410,8 +415,9 @@ users).") ;; PERF: Shave seconds off startup time by starting the scratch buffer in ;; `fundamental-mode', rather than, say, `org-mode' or `text-mode', which - ;; pull in a ton of packages. `doom/open-scratch-buffer' provides a better - ;; scratch buffer anyway. + ;; pull in a ton of packages. This buffer is created whether or not we're + ;; in an interactive session. Plus, `doom/open-scratch-buffer' provides a + ;; better scratch buffer, so keep the initial one blank. (setq initial-major-mode 'fundamental-mode initial-scratch-message nil) diff --git a/lisp/lib/debug.el b/lisp/lib/debug.el index 741e59ff3..792acb758 100644 --- a/lisp/lib/debug.el +++ b/lisp/lib/debug.el @@ -59,9 +59,6 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.") (let ((enabled doom-debug-mode)) (doom-log "debug: enabled!") (mapc #'doom-debug--set-var doom-debug-variables) - (when (called-interactively-p 'any) - (when (fboundp 'explain-pause-mode) - (explain-pause-mode (if enabled +1 -1)))) ;; Watch for changes in `doom-debug-variables', or when packages load (and ;; potentially define one of `doom-debug-variables'), in case some of them ;; aren't defined when `doom-debug-mode' is first loaded. diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 2ffcc8c1e..088463293 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -527,5 +527,77 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation." (recentf-save-list) (message "Removed %S from `recentf-list'" (abbreviate-file-name file))) + +;; +;;; Backports + +;; Introduced in Emacs 29. +;;;###autoload +(eval-when! (not (fboundp 'find-sibling-file)) + (defvar find-sibling-rules nil) + + (defun find-sibling-file (file) + "Visit a \"sibling\" file of FILE. +When called interactively, FILE is the currently visited file. + +The \"sibling\" file is defined by the `find-sibling-rules' variable." + (interactive (progn + (unless buffer-file-name + (user-error "Not visiting a file")) + (list buffer-file-name))) + (unless find-sibling-rules + (user-error "The `find-sibling-rules' variable has not been configured")) + (let ((siblings (find-sibling-file-search (expand-file-name file) + find-sibling-rules))) + (cond + ((null siblings) + (user-error "Couldn't find any sibling files")) + ((length= siblings 1) + (find-file (car siblings))) + (t + (let ((relatives (mapcar (lambda (sibling) + (file-relative-name + sibling (file-name-directory file))) + siblings))) + (find-file + (completing-read (format-prompt "Find file" (car relatives)) + relatives nil t nil nil (car relatives)))))))) + + (defun find-sibling-file-search (file &optional rules) + "Return a list of FILE's \"siblings\". +RULES should be a list on the form defined by `find-sibling-rules' (which +see), and if nil, defaults to `find-sibling-rules'." + (let ((results nil)) + (pcase-dolist (`(,match . ,expansions) (or rules find-sibling-rules)) + ;; Go through the list and find matches. + (when (string-match match file) + (let ((match-data (match-data))) + (dolist (expansion expansions) + (let ((start 0)) + ;; Expand \\1 forms in the expansions. + (while (string-match "\\\\\\([&0-9]+\\)" expansion start) + (let ((index (string-to-number (match-string 1 expansion)))) + (setq start (match-end 0) + expansion + (replace-match + (substring file + (elt match-data (* index 2)) + (elt match-data (1+ (* index 2)))) + t t expansion))))) + ;; Then see which files we have that are matching. (And + ;; expand from the end of the file's match, since we might + ;; be doing a relative match.) + (let ((default-directory (substring file 0 (car match-data)))) + ;; Keep the first matches first. + (setq results + (nconc + results + (mapcar #'expand-file-name + (file-expand-wildcards expansion nil t))))))))) + ;; Delete the file itself (in case it matched), and remove + ;; duplicates, in case we have several expansions and some match + ;; the same subsets of files. + (delete file (delete-dups results))))) + (provide 'doom-lib '(files)) ;;; files.el ends here diff --git a/lisp/lib/text.el b/lisp/lib/text.el index 60a56b47e..cef1a098b 100644 --- a/lisp/lib/text.el +++ b/lisp/lib/text.el @@ -88,10 +88,11 @@ Uses `evil-visual-beginning' if available." "Return end position of selection. Uses `evil-visual-end' if available." (declare (side-effect-free t)) - (if (and (bound-and-true-p evil-local-mode) - (evil-visual-state-p)) - evil-visual-end - (region-end))) + (or (and (bound-and-true-p evil-local-mode) + (evil-visual-state-p) + (markerp evil-visual-end) + (marker-position evil-visual-end)) + (region-end))) ;;;###autoload (defun doom-thing-at-point-or-region (&optional thing prompt) diff --git a/lisp/lib/ui.el b/lisp/lib/ui.el index ea553c1d1..f564248e4 100644 --- a/lisp/lib/ui.el +++ b/lisp/lib/ui.el @@ -175,15 +175,18 @@ Use `winner-undo' to undo this. Alternatively, use "Interactively change the current frame's opacity. OPACITY is an integer between 0 to 100, inclusive." - (interactive - (list (read-number "Opacity (0-100): " - (or (frame-parameter - nil (if (> emacs-major-version 28) - 'alpha-background 'alpha)) - 100)))) - (set-frame-parameter nil (if (> emacs-major-version 28) - 'alpha-background 'alpha) - opacity)) + (interactive '(interactive)) + (let* ((parameter + (if (eq window-system 'pgtk) + 'alpha-background + 'alpha)) + (opacity + (if (eq opacity 'interactive) + (read-number "Opacity (0-100): " + (or (frame-parameter nil parameter) + 100)) + opacity))) + (set-frame-parameter nil parameter opacity))) (defvar doom--narrowed-base-buffer nil) ;;;###autoload @@ -195,12 +198,9 @@ narrowing doesn't affect other windows displaying the same buffer. Call `doom/widen-indirectly-narrowed-buffer' to undo it (incrementally). Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/" - (interactive - (list (or (bound-and-true-p evil-visual-beginning) (region-beginning)) - (or (bound-and-true-p evil-visual-end) (region-end)))) - (unless (region-active-p) - (setq beg (line-beginning-position) - end (line-end-position))) + (interactive (if (region-active-p) + (list (doom-region-beginning) (doom-region-end)) + (list (bol) (eol)))) (deactivate-mark) (let ((orig-buffer (current-buffer))) (with-current-buffer (switch-to-buffer (clone-indirect-buffer nil nil)) @@ -239,12 +239,9 @@ If the current buffer is not an indirect buffer, it is `widen'ed." ;;;###autoload (defun doom/toggle-narrow-buffer (beg end) "Narrow the buffer to BEG END. If narrowed, widen it." - (interactive - (list (or (bound-and-true-p evil-visual-beginning) (region-beginning)) - (or (bound-and-true-p evil-visual-end) (region-end)))) + (interactive (if (region-active-p) + (list (doom-region-beginning) (doom-region-end)) + (list (bol) (eol)))) (if (buffer-narrowed-p) (widen) - (unless (region-active-p) - (setq beg (line-beginning-position) - end (line-end-position))) (narrow-to-region beg end))) diff --git a/lisp/packages.el b/lisp/packages.el index 11bd02520..dd908a10d 100644 --- a/lisp/packages.el +++ b/lisp/packages.el @@ -4,10 +4,6 @@ ;; doom.el (package! auto-minor-mode :pin "17cfa1b54800fdef2975c0c0531dad34846a5065") (package! gcmh :pin "0089f9c3a6d4e9a310d0791cf6fa8f35642ecfd9") -(package! explain-pause-mode - :recipe (:host github - :repo "lastquestion/explain-pause-mode") - :pin "2356c8c3639cbeeb9751744dbe737267849b4b51") ;; doom-packages.el (package! straight diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index d410d8093..96651c6b1 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -58,7 +58,7 @@ Possible values are: corfu-preselect 'prompt corfu-count 16 corfu-max-width 120 - corfu-preview-current (if (modulep! +on-type) 'insert t) + corfu-preview-current 'insert corfu-on-exact-match nil corfu-quit-at-boundary (if (modulep! +orderless) 'separator t) corfu-quit-no-match (if (modulep! +orderless) 'separator t) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index c603b01ca..cca3c88ca 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -372,7 +372,8 @@ orderless." (if (or (eq sym major-mode) (and (memq sym minor-mode-list) - (boundp sym))) + (boundp sym) + (symbol-value sym))) (add-face-text-property 0 (length cmd) 'font-lock-constant-face 'append cmd))) cmd)) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 40979e429..1cab4a3c9 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -168,13 +168,13 @@ :v "C-SPC" (cmd! (call-interactively #'evil-change) (call-interactively #'completion-at-point))) (:map corfu-map - "C-SPC" #'corfu-insert-separator - "C-k" #'corfu-previous - "C-j" #'corfu-next - "C-u" (cmd! (let (corfu-cycle) - (funcall-interactively #'corfu-next (- corfu-count)))) - "C-d" (cmd! (let (corfu-cycle) - (funcall-interactively #'corfu-next corfu-count))))) + :i "C-SPC" #'corfu-insert-separator + "C-k" #'corfu-previous + "C-j" #'corfu-next + "C-u" (cmd! (let (corfu-cycle) + (funcall-interactively #'corfu-next (- corfu-count)))) + "C-d" (cmd! (let (corfu-cycle) + (funcall-interactively #'corfu-next corfu-count))))) (:after corfu-popupinfo :map corfu-popupinfo-map "C-h" #'corfu-popupinfo-toggle @@ -712,7 +712,7 @@ :desc "Configure project" "g" #'projectile-configure-project :desc "Invalidate project cache" "i" #'projectile-invalidate-cache :desc "Kill project buffers" "k" #'projectile-kill-buffers - :desc "Find other file" "o" #'projectile-find-other-file + :desc "Find sibling file" "o" #'find-sibling-file :desc "Switch project" "p" #'projectile-switch-project :desc "Find recent project files" "r" #'projectile-recentf :desc "Run project" "R" #'projectile-run-project diff --git a/modules/editor/evil/+commands.el b/modules/editor/evil/+commands.el index 7c05694bc..05bb798c2 100644 --- a/modules/editor/evil/+commands.el +++ b/modules/editor/evil/+commands.el @@ -52,7 +52,7 @@ (evil-ex-define-cmd "pop[up]" #'+popup/buffer) ;;; Project navigation -(evil-ex-define-cmd "a" #'projectile-find-other-file) +(evil-ex-define-cmd "a" #'find-sibling-file) (evil-ex-define-cmd "cd" #'+evil:cd) (evil-ex-define-cmd "pwd" #'+evil:pwd) diff --git a/modules/email/mu4e/autoload/mu-lock.el b/modules/email/mu4e/autoload/mu-lock.el index 14cf1b01d..6f1a111cd 100644 --- a/modules/email/mu4e/autoload/mu-lock.el +++ b/modules/email/mu4e/autoload/mu-lock.el @@ -35,9 +35,9 @@ If STRICT only accept an unset lock file." (when (or strict (/= (emacs-pid) pid)) t)))) ;;;###autoload -(defun +mu4e-lock-file-delete-maybe () +(defun +mu4e-lock-file-delete-maybe (&optional bury) "Check `+mu4e-lock-file', and delete it if this process is responsible for it." - (when (+mu4e-lock-available) + (when (and (+mu4e-lock-available) (not bury)) (delete-file +mu4e-lock-file) (file-notify-rm-watch +mu4e-lock--request-watcher))) diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index 81514b2a9..9b1c2acc3 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -78,6 +78,8 @@ This is ignored by ccls.") :return "return" :yield "#require") + (add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.c\\(c\\|pp\\)\\'" "\\1.\\(h\\|hh\\|hpp\\)")) + (when (modulep! +tree-sitter) (add-hook! '(c-mode-local-vars-hook c++-mode-local-vars-hook) diff --git a/modules/lang/java/autoload/java.el b/modules/lang/java/autoload/java.el index ed0ebddcd..82fc4a7f1 100644 --- a/modules/lang/java/autoload/java.el +++ b/modules/lang/java/autoload/java.el @@ -44,8 +44,9 @@ It does this by ignoring everything before the nearest package root (see root)." (cond ((doom-special-buffer-p (current-buffer)) "{PackageName}") - ((not (eq major-mode 'java-mode)) - (user-error "Not in java-mode")) + ((and (not (eq major-mode 'java-mode)) + (not (eq major-mode 'java-ts-mode)) + (user-error "Not in java-mode or java-ts-mode"))) ((when-let (project-root (doom-project-root)) (let* ((project-root (file-truename project-root)) (file-path @@ -73,8 +74,9 @@ root)." "Get the class name for the current file." (cond ((doom-special-buffer-p (current-buffer)) "{ClassName}") - ((not (eq major-mode 'java-mode)) - (user-error "Not in java-mode")) + ((and (not (eq major-mode 'java-mode)) + (not (eq major-mode 'java-ts-mode)) + (user-error "Not in java-mode or java-ts-mode"))) (buffer-file-name (file-name-sans-extension (file-name-base (buffer-file-name)))) ((user-error "Can't deduce the class name")))) diff --git a/modules/lang/markdown/config.el b/modules/lang/markdown/config.el index 9461635c9..cad315f38 100644 --- a/modules/lang/markdown/config.el +++ b/modules/lang/markdown/config.el @@ -18,9 +18,7 @@ capture, the end position, and the output buffer.") (use-package! markdown-mode :mode ("/README\\(?:\\.md\\)?\\'" . gfm-mode) :init - (setq markdown-enable-math t ; syntax highlighting for latex fragments - markdown-enable-wiki-links t - markdown-italic-underscore t + (setq markdown-italic-underscore t markdown-asymmetric-header t markdown-gfm-additional-languages '("sh") markdown-make-gfm-checkboxes-buttons t diff --git a/modules/lang/nim/README.org b/modules/lang/nim/README.org index 166e0f6da..774d38a60 100644 --- a/modules/lang/nim/README.org +++ b/modules/lang/nim/README.org @@ -52,8 +52,8 @@ Alternatively, nim is usually available through your OS's package manager: - openSUSE: ~$ zypper install nim~ ** Formatter - -Formatting is handled using the [[doom-module::editor format]] module via [[https://github.com/FedericoCeratto/nimfmt#installation][nimfmt]]. +Formatting is handled using the [[doom-module::editor format]] module via nimpretty +(included with Nim). * TODO Usage #+begin_quote diff --git a/modules/lang/nim/config.el b/modules/lang/nim/config.el index ddaf986f3..231f29262 100644 --- a/modules/lang/nim/config.el +++ b/modules/lang/nim/config.el @@ -12,7 +12,7 @@ nimsuggest isn't installed." (when (and nimsuggest-path (file-executable-p nimsuggest-path)) (nimsuggest-mode)))) - (set-formatter! 'nmfmt '("nimfmt" filepath) :modes '(nim-mode)) + (set-formatter! 'nmfmt '("nimpretty" filepath) :modes '(nim-mode)) (when (featurep :system 'windows) ;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode) diff --git a/modules/lang/nim/doctor.el b/modules/lang/nim/doctor.el index 32980d7ed..f9927b6b6 100644 --- a/modules/lang/nim/doctor.el +++ b/modules/lang/nim/doctor.el @@ -1,4 +1,3 @@ - ;;; lang/nim/doctor.el (unless (executable-find "nimsuggest") @@ -8,5 +7,5 @@ (warn! "Could not find nim executable; build commands will be disabled.")) (when (modulep! :editor format) - (unless (executable-find "nimfmt") - (warn! "Could not find nimfmt. Formatting will be disabled."))) + (unless (executable-find "nimpretty") + (warn! "Could not find nimpretty. Formatting will be disabled."))) diff --git a/modules/lang/nim/packages.el b/modules/lang/nim/packages.el index 30993cbcc..0f4d4c71f 100644 --- a/modules/lang/nim/packages.el +++ b/modules/lang/nim/packages.el @@ -3,7 +3,7 @@ ;;; requires nim nimsuggest nimble -(package! nim-mode :pin "1338e5b0d5e111ad932efb77d3cad680cc3b86c9") +(package! nim-mode :pin "625cc023bd75a741b7d4e629e5bec3a52f45b4be") (when (and (modulep! :checkers syntax) (not (modulep! :checkers syntax +flymake))) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index f88057bf3..549f38c10 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -1438,7 +1438,12 @@ between the two." ;; HACK: Somehow, users/packages still find a way to modify tab-width in ;; org-mode. Since org-mode treats a non-standerd tab-width as an error ;; state, I use this hook to makes it much harder to change by accident. - (add-hook! 'org-mode-hook :depth 110 (setq-local tab-width 8)) + (add-hook! 'org-mode-hook + (add-hook! 'after-change-major-mode-hook :local + ;; The second check is necessary, in case of `org-edit-src-code' which + ;; clones a buffer and changes its major-mode. + (when (derived-mode-p 'org-mode) + (setq tab-width 8)))) ;; Save target buffer after archiving a node. (setq org-archive-subtree-save-file-p t) diff --git a/modules/lang/ruby/autoload.el b/modules/lang/ruby/autoload.el index 70f3e68ff..47e5b1f73 100644 --- a/modules/lang/ruby/autoload.el +++ b/modules/lang/ruby/autoload.el @@ -13,3 +13,9 @@ open." (when (processp process) (kill-process (get-buffer-process inf-buffer)) (kill-buffer inf-buffer))))))) + +;;;###autoload +(defun +ruby-robe-repl-handler () + "Start Robe and open a REPL (for `set-repl-handler!')." + (robe-start) + (robe-inf-buffer)) diff --git a/modules/lang/ruby/config.el b/modules/lang/ruby/config.el index 61f2d46d1..31cc15c4b 100644 --- a/modules/lang/ruby/config.el +++ b/modules/lang/ruby/config.el @@ -48,7 +48,7 @@ (bound-and-true-p lsp--buffer-deferred) (robe-mode +1)))) :config - (set-repl-handler! 'ruby-mode #'robe-start) + (set-repl-handler! 'ruby-mode #'+ruby-robe-repl-handler) (set-company-backend! 'ruby-mode 'company-robe 'company-dabbrev-code) (set-lookup-handlers! 'ruby-mode :definition #'robe-jump diff --git a/modules/lang/web/+css.el b/modules/lang/web/+css.el index fdcc4c744..144670d42 100644 --- a/modules/lang/web/+css.el +++ b/modules/lang/web/+css.el @@ -8,13 +8,7 @@ be aligned. If set to `nil', disable all the above behaviors.") -(after! projectile - (pushnew! projectile-other-file-alist - '("css" "scss" "sass" "less" "styl") - '("scss" "css") - '("sass" "css") - '("less" "css") - '("styl" "css"))) +(add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.\\(\\(s[ac]\\|le\\)ss\\|styl\\)\\'" "\\1\\.css")) ;; diff --git a/modules/lang/web/README.org b/modules/lang/web/README.org index 4418f522b..53ff8e32c 100644 --- a/modules/lang/web/README.org +++ b/modules/lang/web/README.org @@ -6,7 +6,7 @@ * Description :unfold: This module adds support for various web languages, including HTML5, CSS, SASS/SCSS, Pug/Jade/Slim, and HAML, as well as various web frameworks, like -ReactJS, Wordpress, Jekyll, Phaser, AngularJS, Djano, and more. +ReactJS, Wordpress, Jekyll, Phaser, AngularJS, Django, and more. ** Maintainers - @hlissner @@ -41,6 +41,9 @@ ReactJS, Wordpress, Jekyll, Phaser, AngularJS, Djano, and more. 󱌣 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] #+end_quote +- Fixes ~//~ line commenting in JSX and Javascript files (if you aren't using + :lang javascript for some reason) + ** TODO Changelog # This section will be machine generated. Don't edit it by hand. /This module does not have a changelog yet./ @@ -49,13 +52,8 @@ ReactJS, Wordpress, Jekyll, Phaser, AngularJS, Djano, and more. [[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] ** Formatter - Formatting is handled using the [[doom-module::editor format]] module via [[https://prettier.io/docs/en/install.html][prettier]]. -#+begin_quote - 󱌣 /No installation steps have been documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - * TODO Usage #+begin_quote 󱌣 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] diff --git a/modules/tools/biblio/config.el b/modules/tools/biblio/config.el index 61caf6677..970990d27 100644 --- a/modules/tools/biblio/config.el +++ b/modules/tools/biblio/config.el @@ -29,12 +29,6 @@ org-cite-activate-processor 'citar) :config - (after! embark - (citar-embark-mode)) - - (after! org-roam - (citar-org-roam-mode)) - (when (modulep! :completion vertico +icons) (defvar citar-indicator-files-icons (citar-indicator-create @@ -81,6 +75,20 @@ ;; ;;; Third-party +(use-package! citar-embark + :defer t + :init + (after! (citar embark) + (citar-embark-mode))) + + +(use-package! citar-org-roam + :defer t + :init + (after! (citar org-roam) + (citar-org-roam-mode))) + + (use-package! bibtex-completion :when (or (modulep! :completion ivy) (modulep! :completion helm)) diff --git a/modules/tools/editorconfig/config.el b/modules/tools/editorconfig/config.el index e6d52b3c5..f98078c97 100644 --- a/modules/tools/editorconfig/config.el +++ b/modules/tools/editorconfig/config.el @@ -1,21 +1,5 @@ ;;; tools/editorconfig/config.el -*- lexical-binding: t; -*- -;; editorconfig cannot procure the correct settings for extension-less files. -;; Executable scripts with a shebang line, for example. So why not use Emacs' -;; major mode to drop editorconfig a hint? This is accomplished by temporarily -;; appending an extension to `buffer-file-name' when we talk to editorconfig. -(defvar +editorconfig-mode-alist - '((emacs-lisp-mode . "el") - (js2-mode . "js") - (perl-mode . "pl") - (php-mode . "php") - (python-mode . "py") - (ruby-mode . "rb") - (sh-mode . "sh")) - "An alist mapping major modes to extensions. Used by -`doom--editorconfig-smart-detection-a' to give editorconfig filetype hints.") - - ;; Handles whitespace (tabs/spaces) settings externally. This way projects can ;; specify their own formatting rules. (use-package! editorconfig @@ -30,24 +14,20 @@ (add-to-list 'editorconfig-exclude-regexps "\\.\\(zip\\|\\(doc\\|xls\\|ppt\\)x\\)\\'") - (defadvice! +editorconfig--smart-detection-a (fn) - "Retrieve the properties for the current file. If it doesn't have an -extension, try to guess one." - :around #'editorconfig-call-editorconfig-exec - (let ((buffer-file-name - (if (and (not (bound-and-true-p org-src-mode)) - (file-name-extension buffer-file-name)) - buffer-file-name - (format "%s%s" (buffer-file-name (buffer-base-buffer)) - (if-let (ext (alist-get major-mode +editorconfig-mode-alist)) - (concat "." ext) - ""))))) - (funcall fn))) - (add-hook! 'editorconfig-after-apply-functions (defun +editorconfig-disable-indent-detection-h (props) "Inhibit `dtrt-indent' if an explicit indent_style and indent_size is specified by editorconfig." - (when (or (gethash 'indent_style props) - (gethash 'indent_size props)) - (setq doom-inhibit-indent-detection 'editorconfig))))) + (when (and (not doom-inhibit-indent-detection) + (or (gethash 'indent_style props) + (gethash 'indent_size props))) + (setq doom-inhibit-indent-detection 'editorconfig))) + ;; I use a hook over `editorconfig-exclude-modes' because the option + ;; inhibits all settings, and I only want to inhibit indent_size. Plus modes + ;; in that option won't apply to derived modes, so we'd have to add *all* + ;; possible org-mode derivatives to it. + (defun +editorconfig-unset-tab-width-in-org-mode-h (props) + "A tab-width != 8 is an error state in org-mode, so prevent changing it." + (when (and (gethash 'indent_size props) + (derived-mode-p 'org-mode)) + (setq tab-width 8))))) diff --git a/modules/tools/editorconfig/packages.el b/modules/tools/editorconfig/packages.el index 022f9f75f..db1f0ecf0 100644 --- a/modules/tools/editorconfig/packages.el +++ b/modules/tools/editorconfig/packages.el @@ -3,4 +3,4 @@ (package! editorconfig :recipe (:nonrecursive t) - :pin "4b81a5992858cbf03bcd7ed6ef31e4be0b55a7c1") + :pin "c3666c093f3a2a80fb42e513bf0a10d597497c18") diff --git a/modules/ui/treemacs/config.el b/modules/ui/treemacs/config.el index 43e1bd875..211e1f3bc 100644 --- a/modules/ui/treemacs/config.el +++ b/modules/ui/treemacs/config.el @@ -44,7 +44,12 @@ This must be set before `treemacs' has loaded.") (use-package! treemacs-nerd-icons - :after ( treemacs lsp-treemacs nerd-icons) + :defer t + ;; HACK: Because `lsp-treemacs' mutates Treemacs' default theme, and + ;; `treemacs-nerd-icons' reads from it to populate its nerd-icons theme, + ;; load order is important to ensure they don't step on each other's toes. + :init (with-eval-after-load (if (modulep! +lsp) 'lsp-treemacs 'treemacs) + (require 'treemacs-nerd-icons)) :config (treemacs-load-theme "nerd-icons"))