Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save buzztaiki/ad4f351b638c262c01e731723b115d26 to your computer and use it in GitHub Desktop.
Save buzztaiki/ad4f351b638c262c01e731723b115d26 to your computer and use it in GitHub Desktop.

package-install で入れたパッケージの require が flymake で赤くならないようにする

elisp-flymake-byte-compile でチェックしてくれるが、batch-byte-compile するため、package-install 入れたものが見つからずに赤くなる。 flycheck の場合は flycheck-emacs-lisp-initialize-packages を設定してあげればよいのだけど、flymake には存在しない。

elisp-flymake-byte-compile にいい感じでひっかける場所が存在しなかったから、以下のように make-process に無理矢理ひっかける事にした。

(defun advices/elisp-flymake-package-initialize (fn &rest args)
    (when (string= (plist-get args :name) "elisp-flymake-byte-compile")
      (let ((command (plist-get args :command)))
        (setq args (plist-put args :command
                              `(,(car command)
                                "--eval" "(package-initialize)"
                                ,@(cdr command))))))
    (apply fn args))
  (advice-add 'make-process :around #'advices/elisp-flymake-package-initialize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment