![]() If laxmatch is non- nil, it means there should be no error If it is append, the face is added to the end of the If it is prepend, the face specified byįacespec is added to the beginning of the font-lock-face If it is keep, thenĮach character is fontified if it has not been fontified already by This element can override existing fontification made by previousĮlements of font-lock-keywords. The last two values in subexp-highlighter, override and Subelement, facespec, is an expression whose value specifies the Of the match to fontify (0 means the entire matching text). The car, subexp, is an integer specifying which subexpression Which specifies how to highlight matches found by matcher. subexp-highlighter ) In this kind of element, subexp-highlighter is a list The solution is do not derive your mode from a parent mode that will fontify the undesired part of the file and set the override option to t. The second round is so called search based fontification, as the code above shows, when override is nil, the already fontified text will not be override. Here is the thing: there are two phases of fontifications, the first round is called syntactic fontification, for example if you treat the text as HTML, it will be fontified according to HTML syntax, in my case, the text that matched with custum regular expression are fontified as string. What the code does is performing re-search-forward repeatedly and apply text property and font face to matched text.įrom the debugging output I found every matched pieces of text are found correctly, but the font face is not applied. (font-lock-fillin-text-property start end 'face val ) ) ) ) ) ) ) (font-lock-append-text-property start end 'face val ) ) ( ( eq override 'keep ) Keep existing fontification. (font-lock-prepend-text-property start end 'face val ) ) ( ( eq override ' append ) Append to existing fontification. (put-text-property start end 'face val ) ) ( ( eq override 'prepend ) Prepend to existing fontification. ( or (text-property-not-all start end 'face nil ) (put-text-property start end 'face val ) ) ) ( ( eq override t ) Override existing fontification. Stef nil ) ( ( not override ) Cannot override existing fontification. ![]() ![]() `pos' is a marker because anchored keyword may add/delete text (this happens e.g. ![]() ( if ( numberp ( car ( car highlights ) ) ) (font-lock-apply-highlight ( car highlights ) ) (set-marker pos (point ) ) (font-lock-fontify-anchored-keywords ( car highlights ) end ) Ensure forward progress. ( setq highlights ( cdr keyword ) ) (while highlights 'font-lock-multiline t ) ) Apply each highlight to this instance of `matcher', which may be specific highlights or more keywords anchored to `matcher'. (goto-char (match-beginning 0 ) ) (forward-line 1 ) (point ) ) ) ( 1- (point ) ) (match-beginning 0 ) ) (point ) ( >= (point ) (save-excursion (goto-char (match-beginning 0 ) ) (forward-line 1 ) (point ) ) ) ) this is a multiline regexp match (setq font-lock-multiline t) (put-text-property ( if ( = (point ) (save-excursion ( setq keyword ( car keywords ) matcher ( car keyword ) ) (goto-char start ) (while ( and ( (point ) (match-beginning 0 ) ) ( progn (forward-char 1 ) t ) ) ) (message (format "looping matches start %s end %s" (match-beginning 0 ) (match-end 0 ) ) ) ( when ( and font-lock-multiline ) ) ) Find an occurrence of `matcher' from `start' to `end'. (message (format "start %s end %s loop keywords %s" start end ( car keywords ) ) ) ( if loudly (message "Fontifying %s. Keyword matcher highlights ) Fontify each item in `font-lock-keywords' from `start' to `end'. (font-lock-compile-keywords font-lock-keywords ) ) ) ( let ( (case-fold-search font-lock-keywords-case-fold-search ) (keywords ( cddr font-lock-keywords ) ) (bufname (buffer- name ) ) (count 0 ) (pos (make-marker ) ) LOUDLY, if non-nil, allows progress-meter bar." (unless ( eq ( car font-lock-keywords ) t ) ( setq font-lock-keywords START should be at the beginning of a line. ( defun font-lock-fontify-keywords-region (start end &optional loudly ) "Fontify according to `font-lock-keywords' between START and END.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |