+
+ ;; (loop for (mode . program) in '(
+ ;; (lua-mode-hook . "lua")
+ ;; (perl-mode-hook . "perl")
+ ;; (python-mode-hook . "python")
+ ;; (shell-mode-hook . "sh"))
+ ;; do (add-hook mode `(lambda ()
+ ;; (unless (or (file-exists-p "makefile")
+ ;; (file-exists-p "Makefile"))
+ ;; (set (make-local-variable 'compile-command)
+ ;; (concat ,program
+ ;; " "
+ ;; (if buffer-file-name
+ ;; (shell-quote-argument buffer-file-name))))))))
+
+ ;; here note dynamic binding the value of vv, otherwise it will resport error when run the hook.
+ ;; https://emacs.stackexchange.com/questions/10394/scope-in-lambda
+ (dolist (vv '(
+ (cperl-mode-hook . "perl")
+ (lua-mode-hook . "lua")
+ (python-mode-hook . "python")
+ (shell-mode-hook . "sh")))
+ (add-hook (car vv) `(lambda ()
+ (unless (or (file-exists-p "makefile")
+ (file-exists-p "Makefile"))
+ (set (make-local-variable 'compile-command)
+ (concat (cdr ',vv)
+ " "
+ (if buffer-file-name
+ (shell-quote-argument buffer-file-name))))))))
+