![]() 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. Having said that, I often found myself doing some lightweight preprocessing prior to invoking org-insert-link.( defun font-lock-fontify-keywords-region (start end &optional loudly ) "Fontify according to `font-lock-keywords' between START and END. I used it so frequently that I quickly internalized its key binding. Take for example, org-insert-link, bound to C-c C-l by default. Examples being upcase-dwim, downcase-dwim, or mc/mark-all-dwim.īut what if the DWIM command doesn't exist or the author has written a command for what they mean? This is your editor, so you can make it do what you mean. I typically gravitate towards these commands and bind them in my Emacs config. Third-party packages often include them too. It's really great to find built-in DWIM-powered Emacs commands. The word “dwim” is an acronym for “Do What I Mean” it indicates that this command can be used for many different jobs relating to comments, depending on the situation where you use it. The Emacs manual does a great job describing DWIM for the comment-dwim command: They enable commands to be smarter and thus pack more functionality, without incurring the typical cognitive overhead associated with remembering multiple commands (or key bindings). Don't think I remember what the command itself was, but what's important here is that DWIM stands for do what I mean. I was a rather puzzled the first time I spotted DWIM in an Emacs interactive command name.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |