确保 flycheck-mode 出现在模式行的第一个位置

Guarantee that flycheck-mode appears in first position in the mode line

当在不太宽的缓冲区中编码时,应该在行模式下可见的 flycheck 错误计数被截断。我如何保证 flycheck 模式计数在线路模式中按照 major/minor 模式的顺序排在第一位?

次要模式按minor-mode-alist的顺序显示。默认情况下,这仅反映了加载顺序(因此您注意到了一种解决方法,但请注意,一旦加载了其他次要模式,该解决方法就会失败)。

加载库后操作列表可以让您持续保持所需的显示顺序。

(defun my-promote-flycheck (&optional _file)
  "Give `flycheck-mode' priority position in `minor-mode-alist'.

Called via `after-load-functions', as well as `after-init-hook'."
  (unless (eq (caar minor-mode-alist) 'flycheck-mode)
    (let ((found (assq 'flycheck-mode minor-mode-alist)))
      (when found
        (assq-delete-all 'flycheck-mode minor-mode-alist)
        (push found minor-mode-alist)))))

(add-hook 'after-load-functions 'my-promote-flycheck)
(add-hook 'after-init-hook 'my-promote-flycheck)