29

I have done something similar. It's in French, but the code should speak for itself. I use ‰ for the marker (I use a bepo layout), and when I do, the marked text as a pressed-button style. I am not fluent in lisp, so there may be room for improvement. What I have done is that, when using ‰ for marker, the marked text has a pressed-button style, and when ...


22

You will need to tell Org to Use minted for listings Include minted in the default package list Change the compilation switches to accommodate for minted: (setq org-latex-listings 'minted org-latex-packages-alist '(("" "minted")) org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "...


16

Org-mode fontifies these blocks if you enable the corresponding setting. Try: (setq org-src-fontify-natively t)


15

Native syntax highlighting of code blocks is now part of the current development version of Markdown mode. Specifically, it works for those GFM or tilde-fenced code blocks for which the language name has been specified, like the JavaScript code block in your question. You can toggle this mode with C-c C-x C-f (markdown-toggle-fontify-code-blocks-natively). ...


13

With show-paren-mode you can highlight the whole expression. You need to have the following code in your init file. You can try different style and choose what you like to highlight. (show-paren-mode t) ;; enable show paren mode (setq show-paren-style 'expression) ;; highlight whole expression Refer : http://emacs-fu.blogspot.in/2009/01/balancing-your-...


12

The problem is that it is not more robust. Firstly, the major modes are precisely the ones responsible for deciding what's a comment or a string. If they were able to successfully define them for the purpose of font-locking, they should be able to do the same for other purposes. Secondly, reading the syntax to determine the context that point is inside is ...


11

The solution for this spans elisp, org-mode and css customization. elisp By default, the fontification information is embedded in the exported html file. We need to disable that and tell org-mode that we are planning to specify the font formatting information using an external css file. I have chosen to prefix the html class names with org- string. ;; (...


11

js2-mode supports all of this. It is available on GNU ELPA and MELPA for easy access.


11

The following elisp snippet should do. The important details are: Strings are handled by syntax highlighting and not by pattern matching (i.e., keyword highlighting). This has very high priority. So one needs to override it explicitly by the value t for the MATCHER flag OVERRIDE (see doc of font-lock-keywords). One cannot use a regexp as keyword MATCHER ...


11

I think this will do it for Emacs versions < 27.1 (require 'python) (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group 1 is the quote type and a closing quote is matched ;; group 2 is the string part ("f\\(['\"]\\{1,3\\}\\)\\(.+?\\)\\1" ;;...


10

You can use font-lock-add-keywords to add custom highlights. In the below example, I am highlighting any string that begins with _ preceded by a white-space character or beginning of the line followed by a single alpha-numeric character followed by anything else ending with : The highlight color chosen is font-lock-warning-face; you can choose any other ...


10

AFAIK the example you give are actually 2-char comment delimiters, except that depending on the 3rd character, these comments are treated in different ways (but always as comments in the sense that the semantics of the code is unaffected). So, the support offered by Emacs's syntax tables should be sufficient in most cirsumstances. If you want to highlight ...


10

The Emacs one is actually better. Here's why, The purpose of syntax highlighting in text editors is not being pretty, but to make important code structures stand out. If you look at the Emacs sample, you'll see 'MyClass' being colored in the 'type name' color and 'obj' in 'variable' color, which makes the important information that you have one variable '...


10

Hey this answer solved my similar problem. A bit late but I had the same issue today. As mentioned, I add the following code snipped to my .spacemacs/.emacs config: (require 'org) (require 'ox-latex) (add-to-list 'org-latex-packages-alist '("" "minted")) (setq org-latex-listings 'minted) (setq org-latex-pdf-process '("pdflatex -shell-escape -...


9

Take a look at the C-hv value of font-lock-type-face the value is just the symbol font-lock-type-face. Now look at the C-hv value of my-mode-foo-face. Oh no! you can't! It's not a variable! You need a variable to access your face. Declaring the foo-face face does not declare the foo-face variable. Add (defvar my-mode-foo-face 'my-mode-foo-face) after the ...


8

It is correct, but it is not being refontified just because you change major modes. Enable your major mode and put your cursor in the comment then run M-x eval-expression (syntax-ppss-context (syntax-ppss (point))), it should yield 'comment and you'll see that the syntax table is setup correctly. A simple fix would be to call (font-lock-fontify-buffer) ...


8

To disable the behavior.. Programmatically: (setq web-mode-enable-current-element-highlight nil) web-mode-enable-current-element-highlight is a variable defined in ‘web-mode.el’. Its value is nil Documentation: Disable element highlight. Interactively: M-x web-mode-toggle-current-element-highlight return web-mode-toggle-current-element-...


8

They are documented in the manual, but it doesn't use the word “fence”. The characters ! and | are listed as “generic comment delimiters” and “generic string delimiters” in the syntax class reference. These characters were introduced in Emacs 20.1. Quoting the NEWS file: There are two new syntax-codes, ! and | (numeric values 14 and 15). A character ...


8

This is what I ended up going with: (defface special-comment '((t (:foreground "#2aa198"))) "Cyan") (font-lock-add-keywords 'clojure-mode '((";-;.*" 0 'special-comment t))) ";-;.*" is regex. 0 matches the entire expression. t overrides existing highlights. More info on font-lock-add-keywords can be found here: https://www.gnu.org/software/emacs/manual/...


8

With ox-html? See the docstring of org-html-htmlize-output-type. Output type to be used by htmlize when formatting code snippets. Choices are css to export the CSS selectors only,inline-css to export the CSS attribute values inline in the HTML or nil to export plain text. We use as default inline-css, in order to make the resulting HTML self-...


8

In org-9 it might be as simple as this for file links: (org-link-set-parameters "file" :face (lambda (path) (if (file-exists-p path) 'org-link 'org-warning))) For internal links I don't know an easy way to do it.


8

conf-mode.el says: This mode is designed to edit many similar varieties of Conf/Ini files and Java properties. It started out from Aurélien Tisné's ini-mode. conf-space-keywords were inspired by Robert Fitzgerald's any-ini-mode. So conf-mode seems to be what you're looking for (and comes with Emacs).


7

Using a keyboard macro is a valid option, as is defining a custom command. The main advantage of using a keyboard macro is that you don't have to know any Elisp to create it. On the other hand, custom commands are easier to modify later on. I'm going to outline both solutions; feel free to pick the one you're most comfortable with. Solution 1: Keyboard ...


7

Ok, let's get some basics straight. Nesting syntax tables is possible Syntax tables don't have to be global to the entire buffer. You can apply them as text properties to specific regions. This means you can indeed apply the elisp syntax table only to regions surrounded by backticks. How do you do that? Here's one way you can do that. This method does it ...


6

You don't want to nest one syntax table (which is a vector structure) inside another, you want to set up a buffer where, depending on the position, one syntax table would be used instead of the other. The other answer describes how to do this using the syntax-table text property. Here's how to do it using one of the "multiple major mode" packages, mmm-mode. ...


6

When you modify the buffer, only the lines you modified get re-highlighted right away. If the modification affects highlighting of lines futher down, these get re-highlighted later via an idle timer (i.e. it happens after you stop typing). This delay is controlled by jit-lock-context-time and defaults to 0.5s. Note that it really means "Emacs has been ...


6

@lawlist is correct: This question is a (not-so-obvious) duplicate of How to change word wrap highlighting in Emacs on StackOverflow. Since we can't close questions against posts on other StackExchange sites, I'm going to repeat the answer that I gave over there: Highlighting of content that exceeds word wrap bounds is provided by whitespace-mode (which is ...


6

I end with a partial solution - highlight only from the end of line: (defun my-hl-line-range-function () (cons (line-end-position) (line-beginning-position 2))) (setq hl-line-range-function #'my-hl-line-range-function) (when window-system (require 'hl-line) (set-face-attribute 'hl-line nil :inherit nil :background "light yellow") (setq ...


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