If you want to get a well formatted text document, you can use emacs and others packages like LaTeX, ConTeXt, org-mode, or markdown (and pandoc) to get a beautiful and well structured pdf/html/ePub document. Emacs is very efficient for coding any markup language. On the other hand, if you want organizing your notes with syntax highlighting, you can use org-...
First of all note that the behavior of highlight-symbol in your first example is actually right. The *scratch* buffer is in lisp-interaction-mode. The contents of the buffer is supposed to be Elisp and test=this is a symbol in Elisp. For an instance the following is a legal Elisp form and you can eval it in the *scratch*-buffer:
(setq test=this t)
You can use the hl-anything package (also available on Melpa) to get persistent highlights.
From its github page,
Once hl-highlight-mode is on, it will save highlights automatically before Emacs exits. It will also try to restore highlights when Emacs opens.
M-x hl-save-highlights to save highlights; M-x hl-restore-highlights to restore highlights.
@Malabarba's comment provides the answer. Try it interactively: M-x hc-highlight-chars.
It works for me. I use C-x 8 RET LEFT-TO-RIGHT EMBEDDING RET to insert character LRE (U+202A) in a buffer.
Then I use M-x hc-highlight-chars, and at the prompt I enter the same character (the same way: C-x 8 RET LEFT-TO-RIGHT EMBEDDING RET).
Then I hit RET again to ...
The following will highlight the fields of the log file. The first three fields are highlighted using plain highlight rules, the fourth use an anchored rule to highlight multiple lines.
To use this, add fl-sql-activate to a suitable major mode hook.
See comments in the code below for implementation details.
(defface fl-sql-yellow-background '((t :...
First, define a mode for this log file. Put the following somewhere in emacs and eval it:
(define-derived-mode sql-log-mode text-mode "sql-log"
(setq font-lock-multiline t)
'(("\\[DbConnectionImpl\\] - \\[\\([^\]]*\\)\\]" 1 'font-lock-warning-face))))
This creates a new mode for the sql log file. In this mode, ...
First, just what do you mean by "permanently"? There are two approaches to making highlighting permanent (persistent), depending on what you mean/need.
Whenever the given file is opened, even in a new session, make Emacs rehighlight as it did before. For this, you need to apply the same settings (e.g. use the same commands) whenever that file is opened. ...
During Isearch, including regexp searches, you can use C-x 8 RET to input any Unicode character. Completion is available against the character names, and you can alternatively enter the code point.
So you can search directly for the pattern [^ -~éèëê] instead of [^\x20-\x7eéèëê].
You can also use character composition and input methods during Isearch, as ...
If you use library highlight-chars.el you can highlight any characters any way you like.
Out of the box, you have command toggle-highlight-hard-hyphens, as well as functions hc-highlight-hard-hyphens and hc-dont-highlight-hard-hyphens, all of which control just hard-hyphen (U+2011) highlighting.
Other than that, you have general commands and functions to ...
You might need to look at the Magit code to see what it is doing. You don't say what highlighting Magit does normally, and just what changes when highlight-chars.el (Highlight Library) is added to the mix. I don't use Magit -- maybe someone else can speak to this.
But highlight-chars.el does add to font-lock-keywords for things like highlighting tabs and ...