This is a variation on the theme of How to <mark> code fragments in org-export.

Here the question is about making portions of src and example blocks stand out (preferably without breaking the syntax highlighting in the source blocks) in the org mode buffer itself, rather than during export.

Once again,

  • the highlighting should appear without the reader's intervention
  • fragments of lines should be highligtable.

Is there some not too painful way of doing this?

Edit to clarify:

The portions to be highlighted should be explicitly specified by the author, by some kind of markup (or perhaps by specifying the regions which should be highlighted in some annotation of the block), analogously to the way it was done in the linked question.

This markup could be the standard org =...=, /.../ and *...*, but I would be perfectly happy with other possibilities such as {{...}} or even <mark>...</mark>, appearing within the src and example blocks, but being treated as markup rather than being rendered verbatim. Just like <mark>...</mark> and {{{...}}} were used in the linked question and the accepted answer therein.

As for the appearance of the highlighting, I was thinking along the lines one of

  • a different face or overlay for the highlighted portions,
  • de-emphasize everything outside the highlighted portions à la fancy-narrow or ace-jump.


I am looking for this in the context of trying to make presentations which discuss source code and the output it generates. I want to be able to attract attention to different portions of the source code and its output at different times (on different 'slides') according to what is being discussed at any particular moment.

It would also be important to keep the absolute position of the source code and any displayed output stable on the screen as the discussion (of that particular snippet) progresses. It would be fine (perhaps even desirable) for the positions to change once the discussion moves on to a different bit of code.

It would also be interesting to take advantage of the width of the screen, by positioning at least one of the three components

  • discussion
  • source code
  • output

further to the right, next to rather than below the others.

  • @Drew Apologies, I thought that the linked question explained that adequately, but I guess that was a bit lazy. Does the edit clarify it sufficienly? – jacg Nov 3 '17 at 15:36
  • Yes, thank you. You are requesting syntax highlighting (font-lock), after someone adds additional markup. – Drew Nov 3 '17 at 18:04
  • I was reluctant to call it syntax highlighting to avoid confusion with the highlighting of the syntax of the language being discussed, which is distinct from the additional markup syntax. – jacg Nov 3 '17 at 18:20
  • You want it highlighted automatically, according to the syntax. Whether the syntax is Org syntax or something you define, it is syntax. This is not ad hoc highlighting. – Drew Nov 3 '17 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.