保证flycheck模式出现在模式行的第一个位置

时间:2017-06-04 19:15:24

标签: elisp flycheck

在不太宽的缓冲区中进行编码时,在线模式中应该可见的缓冲区flycheck错误计数会被截断。如何保证flycheck模式在线模式中按主/次模式的顺序排在第一位?

1 个答案:

答案 0 :(得分:2)

次要模式按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)