簡體   English   中英

Emacs:我想突出顯示變量包含的數字,沒有變量本身的名稱

[英]Emacs: I want to highlight the numbers that my variables contain, no the name of the variables by itself

因此,我將其添加到主題中:

(font-lock-add-keywords 'c-mode
        '(("\\([0-9]+\\)" . font-lock-warning-face)))

到目前為止很好...它改變了變量包含的顏色。 例如:

int a = 5

其中'5'用預定義的顏色着色。 問題出在我有一個變量名稱與“ variable_1”相對應的變量時,它在“ variable_1”中的顏色為“ 1” ...是否可以解決此問題?

該解決方案在以下三(3)個示例中進行了測試:

  • 整數a = 5

  • 功能(1、2)

  • variable_1

(defun my-c-mode-keywords ()
  (font-lock-add-keywords nil (list
    (list "[^_]\\([0-9]+\\)" '(1 'font-lock-warning-face))) 'prepend))

(add-hook 'c-mode-hook 'my-c-mode-keywords)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM