0
我要排除不需要show-trailing-whitespace
模式:無法設置與dolist全局變量的elisp
(set-default 'show-trailing-whitespace t)
(defmacro non-trailing-whitespaces-modes (mode)
(let ((hook (intern (concat (symbol-name mode) "-mode-hook"))))
`(add-hook ',hook (lambda() (setq show-trailing-whitespace nil)))))
(defvar trailing-whitespace-exclude-modes '(eshell term help diff ztree org calendar syslog slime-repl Info ielm))
(dolist (m trailing-whitespace-exclude-modes)
(non-trailing-whitespaces-modes m))
但是,使用dolist
我無法添加掛鉤,但加入idividual呼籲各模式下工作,例如:
(non-trailing-whitespaces-modes eshell)
(non-trailing-whitespaces-modes term)
(non-trailing-whitespaces-modes ielm
怎麼了?
我明白了。宏使用參數符號,因爲它是。那麼,至少我更瞭解宏觀。另外,通過變成一個函數,你的意思是我應該創建一個鉤子列表併爲這些鉤子添加函數?如果是這種情況,那就是我使用宏的原因,所以我不必編寫'-mode-hook'。 – Amumu
如何在傳入宏之前對'm'進行評估?再讀一點,參數列表是用來製作自定義語法的,所以沒有辦法評估。 – Amumu
謝謝。功能解決方案很整潔。但是,如何用宏來解決這個問題,其中參數符號是從字面上理解的? – Amumu