2011-08-25 190 views

回答

2

cpp-highlight-mode可製成無需用戶交互工作。這是我有我的設置:

(defun cpp-highlight-if-0/1() 
    "Modify the face of text in between #if 0 ... #endif." 
    (interactive) 
    (setq cpp-known-face '(background-color . "dim gray")) 
    (setq cpp-unknown-face 'default) 
    (setq cpp-face-type 'dark) 
    (setq cpp-known-writable 't) 
    (setq cpp-unknown-writable 't) 
    (setq cpp-edit-list 
     '((#("1" 0 1 
      (fontified nil)) 
      nil 
      (background-color . "dim gray") 
      both nil) 
      (#("0" 0 1 
      (fontified nil)) 
      (background-color . "dim gray") 
      nil 
      both nil))) 
    (cpp-highlight-buffer t)) 

(defun jpk/c-mode-hook() 
    (cpp-highlight-if-0/1) 
    (add-hook 'after-save-hook 'cpp-highlight-if-0/1 'append 'local) 
) 

(add-hook 'c-mode-common-hook 'jpk/c-mode-hook) 

的關鍵是搞清楚是cpp-highlight-modecpp-edit-list。我按照我想要的交互方式進行設置,然後查看,結果爲C-h v