font-lock

Font-lock and disable js2-mode parsing node shebang line

旧巷老猫 提交于 2021-01-29 14:22:51
问题 How can I treat the a shebang line of the form #! /usr/bin/env node As a comment line, when using js2-mode ? I've tried a couple things, one as a modification of something Stefan proposed on another thread (can't find it now), eg. a modification to the syntax-propertize-rules , (defalias 'my-js2-syntax-propertize-shebang (syntax-propertize-rules ("\\`\\(#\\)!.*/[^ \t\n]+" (1 "!")))) (defun my-js2-hook () (add-function :before (local 'syntax-propertize-rules) #'my-js2-syntax-propertize-shebang

face font in c-mode when adding new keyword

笑着哭i 提交于 2020-01-11 13:05:15
问题 I am trying to customize some added words to be colored differently from the default face-font colors. This is what I am doing: (defconst lconfig-font-lock-faces (list '(font-lock-function-name-face ((((class color)) (:foreground "DarkBlue" :bold t)))) '(font-lock-constant-face ((((class color)) (:foreground "Black" :bold t)))) '(font-lock-builtin-face ((((class color)) (:foreground nil)))) '(font-lock-preprocessor-face ((((class color)) (:foreground nil)))) ) ) (autoload 'custom-set-faces

Change face of plain text between double quotation marks in Emacs

回眸只為那壹抹淺笑 提交于 2020-01-01 19:32:11
问题 I am looking for a way to highlight or use different face of quoted text in plain text. It seems that there should be a sophisticated/enhanced text mode but I cannot find it. If there isn't a easy solution, can you let me know where should I begin to write a function? Thank you very much! A noob who has been using Emacs from 19.xx 回答1: I'm not sure about a major-mode that already does this, but you can make one easily enough using define-derived-mode (define-derived-mode rich-text-mode text

How to test `font-lock-keywords` values for Emacs Lisp code

怎甘沉沦 提交于 2020-01-01 14:44:52
问题 I pose the question because I think both the question and possible answers might help Emacs users who write Lisp code that defines font-lock-keywords . I'm providing one answer that I think helps. I'm also interested in other answers. That variable's value is a list of expressions, each of which can specify one or more patterns to match or functions to perform matching, and one or more faces for highlighting the matching text. The possibilities for font-lock-keywords values are numerous and

In Emacs, how do I display a message in the minibuffer with font face properties?

寵の児 提交于 2019-12-09 08:26:53
问题 I want to display a colored string of text in the minibuffer, but when I use the 'message' function, the text-properties of are stripped. 回答1: Works for me: (message "%s" (propertize "foo" 'face '(:foreground "red"))) You probably had (message (propertize ...)) , which interprets the propertized string as a format control string, hence stripped of its properties. 来源: https://stackoverflow.com/questions/2742435/in-emacs-how-do-i-display-a-message-in-the-minibuffer-with-font-face-properties

How does a progn form in font-lock-keywords work?

怎甘沉沦 提交于 2019-12-08 13:34:36
问题 Following code will visually replace "hello world" with "HW" by passing a progn form to font lock keywords. (font-lock-add-keywords nil '(("\\(hello world\\)" (0 (progn (put-text-property (match-beginning 1) (match-end 1) 'display "HW") nil))))) I've look into C-h v font-lock-keywords to see if this is a documented feature of font lock. The hello world element seemed to be of this form: (MATCHER HIGHLIGHT ...) which would mean that (0 ...) is HIGHLIGHT and the doc says HIGHLIGHT should be

latex-mode / font-lock: any way to obtain more than three (3) levels of highlighting?

↘锁芯ラ 提交于 2019-12-08 12:05:59
问题 With latex-mode, is there any way to obtain more than three (3) levels of highlighting? I would like to control more than three levels of highlighting, however, it appears as though latex-mode may be limited to three (3) levels. I say this because Emacs complains when attempting a fourth level -- Error during redisplay: (jit-lock-function 1) signaled (wrong-type-argument listp prepend) . The following is just an example of an attempt to control four (4) levels, which gave the error message

Change face of plain text between double quotation marks in Emacs

元气小坏坏 提交于 2019-12-04 18:17:52
I am looking for a way to highlight or use different face of quoted text in plain text. It seems that there should be a sophisticated/enhanced text mode but I cannot find it. If there isn't a easy solution, can you let me know where should I begin to write a function? Thank you very much! A noob who has been using Emacs from 19.xx I'm not sure about a major-mode that already does this, but you can make one easily enough using define-derived-mode (define-derived-mode rich-text-mode text-mode "Rich Text" "text mode with string highlighting." ;;register keywords (setq rich-text-font-lock-keywords

In Emacs, how do I display a message in the minibuffer with font face properties?

亡梦爱人 提交于 2019-12-03 10:01:53
I want to display a colored string of text in the minibuffer, but when I use the 'message' function, the text-properties of are stripped. Works for me: (message "%s" (propertize "foo" 'face '(:foreground "red"))) You probably had (message (propertize ...)) , which interprets the propertized string as a format control string, hence stripped of its properties. 来源: https://stackoverflow.com/questions/2742435/in-emacs-how-do-i-display-a-message-in-the-minibuffer-with-font-face-properties

How to distinguish Python strings and docstrings in an emacs buffer?

感情迁移 提交于 2019-12-02 13:16:55
问题 If I have just (set-face-foreground 'font-lock-comment-face "red") (set-face-foreground 'font-lock-string-face "green") in my .emacs, emacs uses the same font-lock for Python strings and for Python docstrings. What should I add to my .emacs so that comments, strings, and docstrings are distinguished? This answer suggests that it is possible to do so. 回答1: Built-in python.el provides font-lock-doc-face via python-font-lock-syntactic-face-function. python-mode.el uses font-lock-doc-face , given