Cartonã¨plenvã使ã£ã¦ãã¨ãã§ãflymakeã§ããããã«ããï¼
flymakeã¯Emacsä¸ã§ã·ã³ã¿ãã¯ã¹ãã§ãã¯ãããã¤ï¼
ã¾ãï¼exec-path-from-shellã§ç°å¢å¤æ°ãè¨å®ãã¦ããï¼
ããããã¨ï¼.zshenvã¨ãã«æ¸ããç°å¢å¤æ°ãEmacsã«å¼ãç¶ãããï¼(getenv "PATH")
ãã¦ã·ã§ã«ã¨åããããPATHãè¨å®ããã¦ãããã¾ããã£ã¦ãï¼MySQLã/usr/local/mysql/ã«å
¥ãã¦ãã¨ãã¯DYLD_LIBRARY_PATHãè¨å®ããï¼
(exec-path-from-shell-initialize) (exec-path-from-shell-copy-env "DYLD_LIBRARY_PATH")
flymakeã®è¨å®ãããªæãï¼
(defun flymake-perl-init () (let* ((root (expand-file-name (or (vc-git-root default-directory) default-directory)))) (list "perl" (list "-MProject::Libs lib_dirs => [qw(local/lib/perl5), glob(qw(modules/*/lib))]" "-wc" buffer-file-name) root) )) (push '(".+\\.p[ml]$" flymake-perl-init) flymake-allowed-file-name-masks) (push '(".+\\.psgi$" flymake-perl-init) flymake-allowed-file-name-masks) (push '(".+\\.t$" flymake-perl-init) flymake-allowed-file-name-masks) (add-hook 'cperl-mode-hook (lambda () (flymake-mode t)))
PATHãè¨å®ããã¦ãã°ï¼plenvã.per-versionãè¦ã¦é©åãªPerlå¼ãã§ãããï¼
Project::Libsã使ãï¼local/lib/perl5ãè¨å®ãã¦ãã®ã¯ï¼Cartonã§ã¤ã³ã¹ãã¼ã«ããã¨ããã«å
¥ãã®ã§è¿½å ããï¼Project::Libsãlocal/lib/perl5以ä¸ã«å
¥ã£ã¦ã¦ãæå³ãªãã®ã§ï¼æ®éã«cpanm Project::Libsãã¦å
¥ããï¼
globãã¦ããã®ã¯ä¼ç¤¾ã®ãªãã¸ããªã®é½åã§ï¼modules/ãªãã¨ã ã«Gitã®ãµãã¢ã¸ã¥ã¼ã«ãç½®ãã¦ãã¦ï¼Project::Libsã¯modules/ãªãã¨ãã«Gitã®ãµãã¢ã¸ã¥ã¼ã«ãããã°èªã¿è¾¼ãã§ãããã®ã ãã©ï¼Gitãªãã¸ããªãããªãã¦ï¼åãªããã£ã¬ã¯ããªã¨ããç½®ãã¦ãã¨èªãã§ãããªãã®ã§ï¼globãã¦æå®ããï¼ãã®è¨å®ãããªã人ãããã¨æãï¼
listã®æå¾ã«Gitã®ã«ã¼ããã£ã¬ã¯ããªãè¨å®ãã¦ããï¼ããããã¨ï¼ã³ãã³ãããã®ãã£ã¬ã¯ããªã§å®è¡ãããï¼flymakeã®ã½ã¼ã¹ã³ã¼ãèªãã§ããè¦ã¤ããï¼use lib;ã¨ããã¦ãã¨ãã¨ãï¼modules/*/libãglobããã¨ãã¨ãï¼ãªãã¸ããªã®ãããããå®è¡ããªãã¨ãããããªããã¨ãããï¼
Gitãããªãã¨ããããã¸ã§ã¯ãã®ãããããå®è¡ããã»ããããã ãããã©ï¼ã½ã¼ã¹ã³ã¼ã触ããã¨ãªãã®ã§ï¼ææãã§ï¼default-directoryããå®è¡ããããã«ããï¼
éè«(1)
.zshenvã«PATHã®è¨å®æ¸ãã¦ãã°ï¼M-! which perl
ã¨ãããã¨ãã«ï¼.zshenvãèªã¾ãã¦ï¼æ£ããç°å¢å¤æ°ãè¨å®ããã¦ä¾¿å©ã ã£ãï¼
ããã§ã ããããã¾ããã£ã¦ï¼EmacsããPerlã®ãã¹ãå®è¡ããã®ã¨ãï¼carton exec -- perl ãªãã¨ã.t
ã¨ãæ®éã«æ¸ãã°ãã¹ãã§ããï¼.zshenvã«PATHã®è¨å®æ¸ãã°plenv.el使ãå¿
è¦ãªãã¨ããèªèã§ããï¼
flymakeãåã調åã§ã§ãããã¨æã£ããã©ï¼M-! ã§å®è¡ããã¨ãã¯ã·ã§ã«ãå®è¡ããã¦ãã¦ï¼flymakeããå®è¡ããã¨ãã¯åãªãããã»ã¹ã¨ãã¦å®è¡ãããç¹ãã¡ããï¼ãªã®ã§ï¼flymakeããplenvã®Perlã¨ããå¼ã¶ããã«ã¯ï¼Emacså´ã®ç°å¢å¤æ°ãè¨å®ããªãã¨ãããªãï¼
PATHè¨å®ããã ãã§ã¯ã ãã§ï¼DYLD_LIBRARY_PATHã¨ãï¼ä»ã«ãè¨å®ããªãã¨ãããªãã®ãããï¼èªåã§è¨å®ãããªãããã¡ãã£ã¨ä¸ä¾¿ã ã¨æãï¼
exec-path-from-shellã使ããï¼æ¯åã·ã§ã«ãèµ·åããæ¹æ³ããã£ã¦ãã®ã»ããã¡ã³ããã³ã¹ã楽ã ã¨æã£ããã©ï¼è¦ãç®ãä¸æ°å³ã ã£ãï¼flymakeã©ããé
ããããã£ã¡ã§ãããæ°ãããï¼ããã«ããã°exec-path-from-shellè¦ããªãï¼
(defun flymake-perl-init () (let* ((perl (guess-plenv-perl-path)) (root (expand-file-name (vc-git-root default-directory)))) (list shell-file-name (list "-c" (format "perl '-MProject::Libs lib_dirs => [qw(local/lib/perl5), glob(qw(modules/*/lib))]' -wc %s" (shell-quote-argument buffer-file-name))) root) ))
éè«(2)
flymakeã¯ããã©ã«ãã§ã¯ä½ãè¨ããï¼ä¸ã§ã©ããªã£ã¦ãã®ãããåãããªãï¼
(setq flymake-log-level 3)
ã¨ããã¨ï¼Messagesã«ãã°ãåºã¦ï¼ã¡ãã£ã¨ä¾¿å©ï¼
ããã ãã§ã¯ä¸ååã ã£ãã®ã§ï¼ããã»ã¹ããè¿ã£ãå 容ãMessagesã«åºãã¦è¦³å¯ãã¦ãï¼ããã¯é¢æ°ãä¸æ¸ããã¦è¦³å¯ããæãã§ã²ã©ãï¼
(defun flymake-process-filter (process output) "Parse OUTPUT and highlight error lines. It's flymake process filter." (let ((source-buffer (process-buffer process))) (flymake-log 3 "received %d byte(s) of output from process %d" (length output) (process-id process)) (message "----------") (message output) (message "~~~~~~~~~~") (when (buffer-live-p source-buffer) (with-current-buffer source-buffer (flymake-parse-output-and-residual output)))))
ãã¨ï¼ç°å¢å¤æ°ã©ããªã£ã¦ãã調ã¹ãããã«ï¼envã¨ããå®è¡ããã¦æ§åãè¦ãããã¦ãï¼envãè¦ããPATHãå¤ã ã£ãã¨ãæ°ä»ããï¼
(defun flymake-perl-init () (let* ((root (expand-file-name (or (vc-git-root default-directory) default-directory)))) (list "env") ))
éè«(3)
flymakeåãããã«ããã®ãªããåæ¥ãããããã£ã¦ã¤ããã£ãï¼é±æ«ä¸»ã«Emacsã®è¨å®ãããçµãã£ãï¼
æ¨æ¥ã500åã®ãã¹é£²ã¿ã«è¡ã£ã¦ï¼3æ¥é£ç¶ã§ã®ãã¹é£²ãã§ãã£ãã·ã¥&ãããã¹é£ã¹ãã飽ãã¦ãã¦ãããããã£ãï¼æ¯æ¥é£ã¹ãã主é£ã¿ãããªæ±ãã«ãªãï¼ãã®å¾å¯¿å¸é£ã¹ãããã¤ã¦ãªãæãã§å¯¿å¸ããããã£ãï¼