Reduce so-long false positives

This commit is contained in:
Henrik Lissner 2020-02-26 18:05:58 -05:00
parent 9f8cede4cd
commit 089e653637
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -488,6 +488,7 @@ files, so we replace calls to `pp' with the much faster `prin1'."
:config :config
(when doom-interactive-mode (when doom-interactive-mode
(global-so-long-mode +1)) (global-so-long-mode +1))
(setq so-long-threshold 400) ; reduce false positives w/ larger threshold
;; Don't disable syntax highlighting and line numbers, or make the buffer ;; Don't disable syntax highlighting and line numbers, or make the buffer
;; read-only, in `so-long-minor-mode', so we can have a basic editing ;; read-only, in `so-long-minor-mode', so we can have a basic editing
;; experience in them, at least. It will remain off in `so-long-mode', ;; experience in them, at least. It will remain off in `so-long-mode',
@ -517,13 +518,20 @@ files, so we replace calls to `pp' with the much faster `prin1'."
hl-fill-column-mode)) hl-fill-column-mode))
(defun doom-buffer-has-long-lines-p () (defun doom-buffer-has-long-lines-p ()
;; HACK Fix #2183: `so-long-detected-long-line-p' tries to parse comment ;; HACK Fix #2183: `so-long-detected-long-line-p' tries to parse comment
;; syntax, but in some buffers comment state isn't initialized, leading ;; syntax, but in some buffers comment state isn't initialized,
;; to a wrong-type-argument: stringp error. ;; leading to a wrong-type-argument: stringp error.
(let ((so-long-skip-leading-comments (bound-and-true-p comment-use-syntax))) (let ((so-long-skip-leading-comments (bound-and-true-p comment-use-syntax))
;; HACK If visual-line-mode is on in a text-mode, then long lines are ;; HACK If visual-line-mode is on, then false positives are more
;; normal and can be ignored. ;; likely, so up the threshold. More so in text-mode, since long
(unless (and visual-line-mode (derived-mode-p 'text-mode)) ;; paragraphs are the norm.
(so-long-detected-long-line-p)))) (so-long-threshold
(if visual-line-mode
(* so-long-threshold
(if (derived-mode-p 'text-mode)
3
2))
so-long-threshold)))
(so-long-detected-long-line-p)))
(setq so-long-predicate #'doom-buffer-has-long-lines-p)) (setq so-long-predicate #'doom-buffer-has-long-lines-p))