5

Are there any better alternatives? Emacs 27 will support a fill column indicator natively by way of the buffer-local minor mode display-fill-column-indicator-mode and its global counterpart global-display-fill-column-indicator-mode. Here it is in action: Quoth (emacs) Displaying Boundaries: 14.15 Displaying Boundaries =========================== Emacs ...


3

You can use the package font-lock-profiler. For each font-lock rule, it measures execution time and the number of times the rule matched. The package supports measuring time for highlighting a buffer or a region. It also allows measuring time during an editing session. Simply run font-lock-profiler-start, edit your text, and run font-lock-profiles-stop-and-...


3

There is indeed an existing test framework: https://github.com/Lindydancer/faceup Make sure to check out the author's other packages, many of them are related to the intricacies of font-lock.


3

I don't think "inserting x and seeing the resulting font-lock highlighting" is a good approach in general. You'll likely be better off calling asking directly the code that performs this font-lock highlighting (which should be able to make this decision directly). But FWIW, here's how you could do it "by asking font-lock" like you suggest: (add-hook 'post-...


2

A way to think about figuring that out is to wonder what code in hi-lock needs to know what has been highlighted. An obvious place is in the code for unhighlighting, since it prompts for a choice of regexps that have already been highlighted. If you look at the function, you can probably chase it down from there.


2

I noticed that you have found the answer to your question already, by looking at the source code. The behaviour is in fact documented. The doc string of the variable font-lock-keywords contains the following, in the section describing MATCH-ANCHORED: The limit of the MATCHER search defaults to the end of the line after PRE-MATCH-FORM is evaluated. ...


2

M-x customize-group RET css RET would inform you about: C-hv css-fontify-colors css-fontify-colors is a variable defined in `css-mode.el'. Its value is t This variable is safe as a file local variable if its value satisfies the predicate `booleanp'. Documentation: Whether CSS colors should be fontified using the color as the background. When non-`...


2

Inside a string, you need to double the backslashes. It makes the regexps look rather ugly, but it's something we have to live with. :-)


1

The function c-literal-limits, defined in progmodes/cc-engine.el determines how strings and comments are identified in all c-mode variants. It uses these two definitions to do so: ;; String syntax chars, suitable for skip-syntax-(forward|backward). (defconst c-string-syntax (if (memq 'gen-string-delim c-emacs-features) "\"|" ...


1

Here's a code snippet that will make all occurrences of " / " appear as " ÷ " in the current buffer: (add-to-list 'font-lock-extra-managed-props 'display) (font-lock-add-keywords nil '((" \\(/\\) " 1 '(face nil display "÷")))) The first line makes font-lock manage the display property of text, so that it removes the property when a piece of text no longer ...


1

I believe what you need to do is check the inheritance of the various faces. This can be done with describe-face. The available options are given in the manual under Face Attributes, but I believe the one you want is unspecified. Here is what I use in my init.el for highlighting and how I solved the problem of the highlight clobbering other faces: (...


1

You need to set font-lock keywords, e.g., (font-lock-add-keywords 'emacs-lisp-mode '(("(\\(defun-tco\\)\\_>\\s *\\(\\(?:\\sw\\|\\s_\\)+\\)?" (1 font-lock-keyword-face nil t) (2 font-lock-function-name-face nil t)))) the above is adapted from https://github.com/emacs-mirror/emacs/blob/8fe21b03/lisp/emacs-lisp/generator.el#L796. I suggest you to ...


1

I think you're looking for C-hv hi-lock-interactive-patterns Following the question edit... The strange behaviour (for me) of this function is that the STRING 2 highlight is non turned off Ultimately hi-lock is using the font-lock machinery, and so the patterns get added to (but not removed from) font-lock-keywords with the way your code was working. ...


1

This is now fixed in 5.3.2 of ada-mode.


1

Since fill-column-indicator is quite heavy, this solution shows a character to the right of the current line. So when you're typing you can see the line limit before you exceed it. This defines the minor-mode hl-line-margin-mode: ;; Global, ensures one active margin for the active buffer. (defvar hl-line-margin--overlay nil) (defun hl-line-margin--...


1

I've found a solution using the emacs package mmm-mode. Most of the information I got was from this article. What this package does, is allow multiple major modes in the same buffer. You basically set the opening and closing clauses for whatever nested syntax you have, and that block will be highlighted in a submode. M-x package-install RET graphql-mode M-...


1

The main workhorse here is the following: (add-hook 'org-mode-hook (lambda () (font-lock-add-keywords nil tex-font-lock-keywords-3))) In addition, I had to customize the subscript, superscript, and tex-math faces to get this effect: You can customize the faces to get them to look how you like. I also found that I had to remove the org-...


Only top voted, non community-wiki answers of a minimum length are eligible