dev: merge branch 'pr7002' into emenel

This commit is contained in:
Matt Nish-Lapidus 2024-02-02 17:52:59 -05:00
commit ea3bcdaa32
6 changed files with 125 additions and 32 deletions

View file

@ -168,7 +168,7 @@
"Current version of Doom Emacs core.")
;; DEPRECATED: Remove these when the modules are moved out of core.
(defconst doom-modules-version "23.12.0-pre"
(defconst doom-modules-version "24.02.0-pre"
"Current version of Doom Emacs.")
(defvar doom-init-time nil

View file

@ -176,7 +176,16 @@ A wgrep buffer can be opened from swiper with [[kbd:][C-c C-e]].
** TODO Change the position of the ivy childframe
* TODO Troubleshooting
/There are no known problems with this module./ [[doom-report:][Report one?]]
** Sorting is not applied at all sometimes
If the number of candidates is greater than ~ivy-sort-max-size~, sorting will be
disabled completely. Doom lowers the default value to prevent performance
issues, so increasing the value may fix your issue:
#+begin_src elisp
;;; add to $DOOMDIR/config.el
(after! ivy
(setq ivy-sort-max-size 30000)) ; Doom sets this to 7500, but Ivy's default is 30k
#+end_src
* Frequently asked questions
[[doom-suggest-faq:][Ask a question?]]

View file

@ -13,6 +13,10 @@
;; sane `comment-line-break-function', so...
comment-line-break-function nil)
;; HACK: See #5823: indent detection is slow and inconclusive in coq-mode files,
;; and rarely helpful anyway, so I inhibit it.
(add-to-list 'doom-detect-indentation-excluded-modes 'coq-mode)
;; We've replaced coq-mode abbrevs with yasnippet snippets (in the snippets
;; library included with Doom).
(setq coq-mode-abbrev-table '())

View file

@ -277,25 +277,81 @@ https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
file-base)))))))
(not (locate-dominating-file default-directory ".doommodule")))))
;;;###autoload
(define-minor-mode +emacs-lisp-non-package-mode
"Reduce flycheck verbosity where it is appropriate.
(defvar-local +emacs-lisp-reduced-flymake-byte-compile--process nil)
Essentially, this means in any elisp file that either:
- Is not a theme in `custom-theme-load-path',
- Lacks a `provide' statement,
- Lives in a project with a .doommodule file,
- Is a dotfile (like .dir-locals.el or .doomrc).
(defun +emacs-lisp-reduced-flymake-byte-compile (report-fn &rest _args)
"A Flymake backend for byte compilation in non-package elisp files.
This generally applies to your private config (`doom-user-dir') or Doom's source
\(`doom-emacs-dir')."
This checker reduces the amount of false positives the byte compiler throws off
compared to `elisp-flymake-byte-compile'. The linter warnings that are enabled
are set by `+emacs-lisp-linter-warnings'
This backend does not need to be added directly
as `+emacs-lisp-non-package-mode' will enable it and disable the other checkers."
;; if a process already exists. kill it.
(when (and +emacs-lisp-reduced-flymake-byte-compile--process
(process-live-p +emacs-lisp-reduced-flymake-byte-compile--process))
(kill-process +emacs-lisp-reduced-flymake-byte-compile--process))
(let ((source (current-buffer))
(tmp-file (make-temp-file "+emacs-lisp-byte-compile-src"))
(out-buf (generate-new-buffer "+emacs-lisp-byte-compile-out")))
;; write the content to a temp file
(save-restriction
(widen)
(write-region nil nil tmp-file nil 'nomessage))
;; make the process
(setq +emacs-lisp-reduced-flymake-byte-compile--process
(make-process
:name "+emacs-reduced-flymake"
:noquery t
:connection-type 'pipe
:buffer out-buf
:command `(,(expand-file-name invocation-name invocation-directory)
"-Q"
"--batch"
,@(mapcan (lambda (p) (list "-L" p)) elisp-flymake-byte-compile-load-path)
;; this is what silences the byte compiler
"--eval" ,(prin1-to-string `(setq doom-modules ',doom-modules
doom-disabled-packages ',doom-disabled-packages
byte-compile-warnings ',+emacs-lisp-linter-warnings))
"-f" "elisp-flymake--batch-compile-for-flymake"
,tmp-file)
:stderr "*stderr of +elisp-flymake-byte-compile-out*"
:sentinel
;; deal with the process when it exits
(lambda (proc _event)
(when (memq (process-status proc) '(exit signal))
(unwind-protect
(cond
;; if the buffer is dead or the process is not the same, log the process as old.
((or (not (buffer-live-p source))
(not (with-current-buffer source (eq proc +emacs-lisp-reduced-flymake-byte-compile--process))))
(flymake-log :warning "byte compile process %s is old" proc))
;; if the process exited without problem process the buffer
((zerop (process-exit-status proc))
(elisp-flymake--byte-compile-done report-fn source out-buf))
;; otherwise something else horrid has gone wrong and we panic
(t (funcall report-fn :panic
:explanation
(format "byte compile process %s died" proc))))
;; cleanup
(ignore-errors (delete-file tmp-file))
(kill-buffer out-buf))))))))
(define-minor-mode +emacs-lisp--flymake-non-package-mode
""
:since "3.0.0"
(unless (and (bound-and-true-p flycheck-mode)
(not (+emacs-lisp--in-package-buffer-p)))
(setq +emacs-lisp-non-package-mode nil))
(when (derived-mode-p 'emacs-lisp-mode)
(add-hook 'after-save-hook #'+emacs-lisp-non-package-mode nil t))
(if (not +emacs-lisp-non-package-mode)
(if +emacs-lisp--flymake-non-package-mode
(progn
(remove-hook! 'flymake-diagnostic-functions :local #'elisp-flymake-checkdoc #'elisp-flymake-byte-compile)
(add-hook 'flymake-diagnostic-functions #'+emacs-lisp-reduced-flymake-byte-compile nil t))
(add-hook! 'flymake-diagnostic-functions :local #'elisp-flymake-checkdoc #'elisp-flymake-byte-compile)
(remove-hook 'flymake-diagnostic-functions #'+emacs-lisp-reduced-flymake-byte-compile t)))
(define-minor-mode +emacs-lisp--flycheck-non-package-mode
""
:since "3.0.0"
(if (not +emacs-lisp--flycheck-non-package-mode)
(when (get 'flycheck-disabled-checkers 'initial-value)
(setq-local flycheck-disabled-checkers (get 'flycheck-disabled-checkers 'initial-value))
(kill-local-variable 'flycheck-emacs-lisp-check-form))
@ -323,6 +379,30 @@ This generally applies to your private config (`doom-user-dir') or Doom's source
,(read (default-toplevel-value 'flycheck-emacs-lisp-check-form))))
flycheck-disabled-checkers (cons 'emacs-lisp-checkdoc
flycheck-disabled-checkers))))
;;;###autoload
(define-minor-mode +emacs-lisp-non-package-mode
"Reduce flycheck/flymake verbosity where it is appropriate.
Essentially, this means in any elisp file that either:
- Is not a theme in `custom-theme-load-path',
- Lacks a `provide' statement,
- Lives in a project with a .doommodule file,
- Is a dotfile (like .dir-locals.el or .doomrc).
This generally applies to your private config (`doom-user-dir') or Doom's source
\(`doom-emacs-dir')."
:since "3.0.0"
(unless (and (or (bound-and-true-p flycheck-mode)
(bound-and-true-p flymake-mode))
(not (+emacs-lisp--in-package-buffer-p)))
(setq +emacs-lisp-non-package-mode nil))
(when (derived-mode-p 'emacs-lisp-mode)
(add-hook 'after-save-hook #'+emacs-lisp-non-package-mode nil t))
(let ((toggle (if +emacs-lisp-non-package-mode +1 -1)))
(cond ((modulep! :checkers syntax +flymake)
(+emacs-lisp--flymake-non-package-mode toggle))
((modulep! :checkers syntax)
(+emacs-lisp--flycheck-non-package-mode toggle)))))
;;

View file

@ -95,11 +95,18 @@ See `+emacs-lisp-non-package-mode' for details.")
;; Ensure straight sees modifications to installed packages
#'+emacs-lisp-init-straight-maybe-h)
;; UX: Flycheck's two emacs-lisp checkers produce a *lot* of false positives
;; in non-packages (like Emacs configs or elisp scripts), so I disable
;; `emacs-lisp-checkdoc' and set `byte-compile-warnings' to a subset of the
;; original in the flycheck instance (see `+emacs-lisp-linter-warnings').
(add-hook 'flycheck-mode-hook #'+emacs-lisp-non-package-mode)
;; UX: Both Flycheck's and Flymake's two
;; emacs-lisp checkers produce a *lot* of false positives in non-packages
;; (like Emacs configs or elisp scripts), so I disable `checkdoc' (`emacs-lisp-checkdoc', `elisp-flymake-checkdoc')
;; and set `byte-compile-warnings' to a subset that makes more sense (see `+emacs-lisp-linter-warnings')
(add-hook! '(flycheck-mode-hook flymake-mode-hook) #'+emacs-lisp-non-package-mode)
(defadvice! +syntax--fix-elisp-flymake-load-path (orig-fn &rest args)
"Set load path for elisp byte compilation Flymake backend"
:around #'elisp-flymake-byte-compile
(let ((elisp-flymake-byte-compile-load-path
(append elisp-flymake-byte-compile-load-path load-path)))
(apply orig-fn args)))
;; Enhance elisp syntax highlighting, by highlighting Doom-specific
;; constructs, defined symbols, and truncating :pin's in `package!' calls.

View file

@ -244,12 +244,5 @@ Emacs versions < 29."
(use-package! fish-completion
:unless IS-WINDOWS
:hook (eshell-mode . fish-completion-mode)
:init (setq fish-completion-fallback-on-bash-p t)
:config
;; HACK Even with `fish-completion-fallback-on-bash-p' non-nil,
;; `fish-completion--list-completions-with-desc' will throw an error if
;; fish isn't installed (and so, will fail to fall back to bash), so we
;; advise it to fail silently.
(defadvice! +eshell--fallback-to-bash-a (&rest _)
:before-until #'fish-completion--list-completions-with-desc
(unless (executable-find "fish") "")))
:init (setq fish-completion-fallback-on-bash-p t
fish-completion-inhibit-missing-fish-command-warning t))