如何为指定的关键字设置面,但只有第一行的关键字?例如有这个文件
--- cut here ---
hello world <-- this "hello" should have face set
hello world <-- while this "hello" should not
--- cut here ---
只有第一个你好应该有面部设置
我试过这个
(defun first-line-hello(limit)
(and (save-excursion (beginning-of-line)
(bobp))
(re-search-forward "hello" limit)))
(font-lock-add-keywords 'emacs-lisp-mode
'((first-line-hello . font-lock-warning-face)))
但似乎由于某种原因(bobp)在字体锁定关键字中使用时总是返回真。我也尝试使用 line-number-at-pos 得到相同的结果。