我正在尝试为基于ctags文件的C / C ++项目提供更好的突出显示。所以我创造了这个:
(defun process-file (file)
(with-temp-buffer
(insert-file-contents file)
(split-string (buffer-string) "\n" t)))
(defun ctags-highlight()
(interactive)
(setq linelist (nthcdr 6 (process-file "/home/willian/Documents/M1-Class/OS/nachos/code/tags")))
(while linelist
(setq temp (split-string (car linelist) "\t"))
(setq keyword (car temp))
(setq type (car (cdddr temp)))
(cond
((string= type "v")
(font-lock-add-keywords 'c-mode
'((,keyword 1 font-lock-variable-name-face)))
(font-lock-add-keywords 'c++-mode
'((,keyword 1 font-lock-variable-name-face))))
((string= type "f")
(font-lock-add-keywords 'c-mode
'((,keyword 1 font-lock-function-name-face)))
(font-lock-add-keywords 'c++-mode
'((,keyword 1 font-lock-function-name-face))))
((string= type "d")
(font-lock-add-keywords 'c-mode
'((,keyword 1 font-lock-constant-name-face)))
(font-lock-add-keywords 'c++-mode
'((,keyword 1 font-lock-constant-name-face))))
((string= type "e")
(font-lock-add-keywords 'c-mode
'((,keyword 1 font-lock-constant-name-face)))
(font-lock-add-keywords 'c++-mode
'((,keyword 1 font-lock-constant-name-face))))
((string= type "c")
(font-lock-add-keywords 'c-mode
'((,keyword 1 font-lock-type-name-face)))
(font-lock-add-keywords 'c++-mode
'((,keyword 1 font-lock-type-name-face))))
((string= type "t")
(font-lock-add-keywords 'c-mode
'((,keyword 1 font-lock-type-name-face)))
(font-lock-add-keywords 'c++-mode
'((,keyword 1 font-lock-type-name-face))))
)
(setq linelist (cdr linelist))))
但在执行此代码后,我根本没有突出显示。
有人知道上面代码中的错误在哪里吗?