Download
(defvar nobreak-char-display)
(defgroup Highlight-Characters nil
"Highlight specified sets of characters, possibly including whitespace."
:prefix "hc-"
:group 'convenience :group 'matching :group 'font-lock
:link `(url-link :tag "Send Bug Report"
,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
highlight-chars.el bug: \
&body=Describe bug here, starting with `emacs -q'. \
Don't forget to mention your Emacs and library versions."))
:link '(url-link :tag "Other Libraries by Drew"
"http://www.emacswiki.org/DrewsElispLibraries")
:link '(url-link :tag "Download"
"http://www.emacswiki.org/highlight-chars.el")
:link '(url-link :tag "Description"
"http://www.emacswiki.org/ShowWhiteSpace#HighlightChars")
:link '(emacs-commentary-link :tag "Commentary" "highlight-chars")
)
(defface hc-tab '((t (:background "LemonChiffon")))
"*Face for highlighting tab characters (`C-i') in Font-Lock mode."
:group 'Highlight-Characters :group 'faces)
(defface hc-trailing-whitespace '((t (:background "Gold")))
"*Face for highlighting whitespace at line ends in Font-Lock mode.
This includes tab, space, and hard (non-breaking) space characters."
:group 'Highlight-Characters :group 'faces)
(defface hc-hard-space '((t (:background "Aquamarine")))
"*Face for highlighting non-breaking spaces (`?\u00a0')in Font-Lock mode.
\(This is also ?\240.)"
:group 'Highlight-Characters :group 'faces)
(when (> emacs-major-version 22)
(defface hc-hard-hyphen '((t (:background "PaleGreen")))
"*Face for highlighting non-breaking hyphens (`?\u2011')in Font-Lock mode."
:group 'Highlight-Characters :group 'faces))
(defface hc-other-char '((t (:background "HotPink")))
"*Face for highlighting chars in `hc-other-chars' in Font-Lock mode."
:group 'Highlight-Characters :group 'faces)
(defun hc-other-chars-defcustom-spec ()
"Custom :type spec for `hc-other-chars' and `hc-other-chars-NOT'."
(if (> emacs-major-version 21)
`(repeat
(choice
(string :tag "Characters (string)")
(choice :tag "Character set" ,@(mapcar (lambda (cset) `(const ,cset))
(if (fboundp 'charset-priority-list)
(charset-priority-list)
charset-list)))
(cons :tag "Character range" (character :tag "From") (character :tag "To"))
(choice :tag "Character class"
(const :tag "ASCII char\t[:ascii:]" [:ascii:])
(const :tag "Non-ASCII char\t[:nonascii:]" [:nonascii:])
(const :tag "Word char\t[:word:]" [:word:])
(const :tag "Letter or digit\t[:alnum:]" [:alnum:])
(const :tag "Letter\t[:alpha:]" [:alpha:])
(const :tag "Lowercase letter\t[:lower:]" [:lower:])
(const :tag "Uppercase letter\t[:upper:]" [:upper:])
(const :tag "Digit\t[:digit:]" [:digit:])
(const :tag "Hex digit\t[:xdigit:]" [:xdigit:])
(const :tag "Punctuation char (non-word char)\t[:punct:]" [:punct:])
(const :tag "Space or tab char\t[:blank:]" [:blank:])
(const :tag "Whitespace char\t[:space:]" [:space:])
(const :tag "Control char\t[:cntrl:]" [:cntrl:])
(const :tag "Not control or delete char\t[:print:]" [:print:])
(const :tag "Not control, space or delete char\t[:graph:]" [:graph:])
(const :tag "Multibyte char\t[:multibyte:]" [:multibyte:])
(const :tag "Unibyte char\t[:unibyte:]" [:unibyte:]))))
'(repeat
(choice
(string :tag "Characters (string)")
(cons :tag "Character range" (character :tag "From") (character :tag "To"))))))
(defcustom hc-other-chars ()
"*Characters to highlight using face `hc-other-char'.
The characters are highlighted unless they are excluded by option
`hc-other-chars-NOT'.
A nil value means highlight *all* characters (except those excluded by
`hc-other-chars-NOT').
If non-nil, the value is a list of entries, each of which can be any
of these:
* a string of individual characters
* a character range, represented as a cons (FROM . TO),
where FROM and TO are both included
* a character class, such as [:nonascii:]
* a character set, such as `iso-8859-1' or `lao'
The last two alternatives are available only for Emacs 22 and later.
For the first alternative, remember that you can insert any character
into the string using `C-q', and (for Emacs 23 and later) you can
insert any Unicode character using `C-x 8 RET'.
For Emacs 20, the first alternative is not well supported: Do not use
chars that are special within a regexp character alternative (i.e.,
\[...]). In Emacs 20, the string you specify is simply wrapped with
\[...], which is not correct for all chars."
:set (lambda (sym defs)
(custom-set-default sym defs)
(setq hc--saved-nobreak-char-display nil))
:type (hc-other-chars-defcustom-spec) :group 'Highlight-Characters)
(defcustom hc-other-chars-NOT ()
"*Chars to exclude from highlighting with face `hc-other-char'.
The possible option values are the same as for `hc-other-char'."
:set (lambda (sym defs)
(custom-set-default sym defs)
(setq hc--saved-nobreak-char-display nil))
:type (hc-other-chars-defcustom-spec) :group 'Highlight-Characters)
(defcustom hc-other-chars-font-lock-override 'append
"*How highlighting for other chars interacts with existing highlighting.
The values correspond to the values for an OVERRIDE spec in
`font-lock-keywords'. See (elisp) `Search-based Fontification'.
This affects commands `hc-toggle-highlight-other-chars' and
`hc-highlight-chars', and functions `hc-highlight-other-chars' and
`hc-dont-highlight-other-chars'."
:type '(choice
(const :tag "Do not override existing highlighting (`keep')" keep)
(const :tag "Merge after existing highlighting (`append')" append)
(const :tag "Merge before existing highlighting (`prepend')" prepend)
(const :tag "Replace (override) existing highlighting" t))
:group 'Highlight-Characters)
(defvar hc-highlight-tabs-p nil
"Non-nil means font-lock mode highlights TAB characters (`C-i').")
(defvar hc-highlight-trailing-whitespace-p nil
"Non-nil means font-lock mode highlights whitespace at line ends.
This includes tab, space, and hard (non-breaking) space characters.")
(defvar hc-highlight-hard-spaces-p nil
"Non-nil means font-lock mode highlights non-breaking spaces (`?\u00a0').
\(This is also ?\240.)")
(defvar hc-highlight-hard-hyphens-p nil
"Non-nil means font-lock mode highlights non-breaking hyphens (`?\u2011').")
(defvar hc-highlight-other-chars-p nil
"Non-nil means font-lock mode highlights the chars in `hc-other-chars'.")
(defvar hc--other-chars-last-match-data nil
"Last successful match data for `hc-other-chars'.
Used to restore match data after matching a character to exclude.")
(defvar hc--saved-nobreak-char-display (and (boundp 'nobreak-char-display)
nobreak-char-display)
"Saved value of `nobreak-char-display', so that it can be restored.")
(defalias 'toggle-highlight-tabs 'hc-toggle-highlight-tabs)
(defun hc-toggle-highlight-tabs (&optional msgp)
"Toggle highlighting of TABs, using face `hc-tab'."
(interactive "p")
(setq hc-highlight-tabs-p (not hc-highlight-tabs-p))
(if hc-highlight-tabs-p
(add-hook 'font-lock-mode-hook 'hc-highlight-tabs)
(remove-hook 'font-lock-mode-hook 'hc-highlight-tabs)
(hc-dont-highlight-tabs))
(font-lock-mode) (font-lock-mode)
(when msgp
(message "TAB highlighting is now %s" (if hc-highlight-tabs-p "ON" "OFF"))))
(defalias 'toggle-highlight-hard-spaces 'hc-toggle-highlight-hard-spaces)
(defun hc-toggle-highlight-hard-spaces (&optional msgp)
"Toggle highlighting of non-breaking space characters (`?\u00a0').
\(This is also ?\240.)
Uses face `hc-hard-space'."
(interactive "p")
(setq hc-highlight-hard-spaces-p (not hc-highlight-hard-spaces-p))
(cond (hc-highlight-hard-spaces-p
(add-hook 'font-lock-mode-hook 'hc-highlight-hard-spaces))
(t
(remove-hook 'font-lock-mode-hook 'hc-highlight-hard-spaces)
(hc-dont-highlight-hard-spaces)))
(font-lock-mode) (font-lock-mode)
(when msgp (message "Hard (non-breaking) space highlighting is now %s"
(if hc-highlight-hard-spaces-p "ON" "OFF"))))
(when (> emacs-major-version 22)
(defalias 'toggle-highlight-hard-hyphens 'hc-toggle-highlight-hard-hyphens)
(defun hc-toggle-highlight-hard-hyphens (&optional msgp)
"Toggle highlighting of non-breaking hyphen characters (`?\u2011').
Uses face `hc-hyphen-space'."
(interactive "p")
(setq hc-highlight-hard-hyphens-p (not hc-highlight-hard-hyphens-p))
(cond (hc-highlight-hard-hyphens-p
(add-hook 'font-lock-mode-hook 'hc-highlight-hard-hyphens))
(t
(remove-hook 'font-lock-mode-hook 'hc-highlight-hard-hyphens)
(hc-dont-highlight-hard-hyphens)))
(font-lock-mode) (font-lock-mode)
(when msgp (message "Hard (non-breaking) hyphen highlighting is now %s"
(if hc-highlight-hard-hyphens-p "ON" "OFF")))))
(defun hc-highlight-chars (chars face &optional offp msgp)
"Read a string of CHARS, read a FACE name, then highlight the CHARS.
With a prefix arg, unhighlight the CHARS.
As an alternative to being a string of characters, CHARS can be any of
the following (the last two are only for Emacs 22+):
* A cons (C1 . C2), where C1 and C2 are characters, that is, integers,
which you can represent using character notation. This represents
the range of characters from C1 through C2.
For example, you would enter `(?a . ?g)' to mean the characters from
`a' through `g', inclusive. Note that you enter the parentheses and
the dot, and you can use character read syntax (e.g., `?a' for `a').
* A character class, such as `[:digit:]'. This matches all characters
in the class. You must type the brackets and colons (`:'). (This
possibility is available only for Emacs 22 and later.)
* A character set, such as `iso-8859-1' or `lao'. This matches all
characters in the set.
If you mistype CHARS in one of the above representations, then what
you type is interpreted as just a string of the characters to
highlight. For example, if you mean to type `[:digit:]' but you
instead type `[:digit]' (no second colon), then the characters
highlighted are [, :, d, g, i, t, and ]."
(interactive
(let* ((prompt (format "Chars to %shighlight: " (if current-prefix-arg "UN" "")))
(chrs (read-string prompt))
(chrs (progn (while (string= "" chrs)
(setq chrs (read-string (concat (substring prompt 0 -2)
" (not empty): "))))
chrs))
(fac (read-face-name "Face")))
(when (string= "" fac) (setq fac 'hc-other-chars))
(list (let ((cs (condition-case nil (read chrs) (error nil))))
(cond ((and (fboundp 'charsetp) (charsetp cs))
(list cs))
((and (consp cs)
(if (fboundp 'characterp) (characterp (car cs)) (integerp (car cs)))
(if (fboundp 'characterp) (characterp (cdr cs)) (integerp (cdr cs))))
(list cs))
((and (> emacs-major-version 21)
(vectorp cs) (= 1 (length cs)) (keywordp (aref cs 0))
(let ((name (symbol-name (aref cs 0))))
(eq ?: (aref name (1- (length name))))))
(list cs))
(t (list chrs))))
fac
current-prefix-arg
t)))
(if (not offp)
(add-hook 'font-lock-mode-hook
`(lambda () (hc-highlight-other-chars ',chars nil ',face))
'APPEND)
(remove-hook 'font-lock-mode-hook
`(lambda () (hc-highlight-other-chars ',chars nil ',face)))
(hc-dont-highlight-other-chars chars nil face))
(font-lock-mode) (font-lock-mode)
(when msgp
(message "Highlighting of %s with face `%s' is now %s"
(mapconcat #'hc-other-chars-description chars ", ")
(if (fboundp 'propertize)
(propertize (symbol-name face) 'face face)
face)
(if offp "OFF" "ON"))))
(defalias 'toggle-highlight-other-chars 'hc-toggle-highlight-other-chars)
(defun hc-toggle-highlight-other-chars (&optional face msgp)
"Toggle highlighting chars in `hc-other-chars'
By default, face `hc-other-char' is used.
With a prefix arg you are prompted for the face to use."
(interactive
(progn (unless hc-other-chars (error "No chars in `hc-other-chars' to highlight"))
(let ((fac (and current-prefix-arg (read-face-name "Face"))))
(when (and fac (string= "" fac)) (setq fac 'hc-other-chars))
(list fac t))))
(when (and (not hc-other-chars) msgp)
(error "No chars in `hc-other-chars' to highlight"))
(setq hc-highlight-other-chars-p (not hc-highlight-other-chars-p))
(cond (hc-highlight-other-chars-p
(add-hook
'font-lock-mode-hook
(if face
`(lambda () (hc-highlight-other-chars hc-other-chars hc-other-chars-NOT ',face))
'hc-highlight-other-chars)))
(t
(remove-hook
'font-lock-mode-hook
(if face
`(lambda () (hc-highlight-other-chars hc-other-chars hc-other-chars-NOT ',face))
'hc-highlight-other-chars))
(if face
(hc-dont-highlight-other-chars hc-other-chars hc-other-chars-NOT face)
(hc-dont-highlight-other-chars))))
(font-lock-mode) (font-lock-mode)
(when msgp
(message "Highlighting of %s%s%s is now %s"
(mapconcat #'hc-other-chars-description hc-other-chars ", ")
(if hc-other-chars-NOT
(format " (EXCEPT %s)" (mapconcat #'hc-other-chars-description
hc-other-chars-NOT
", "))
"")
(if face
(format " in face `%s'" (if (fboundp 'propertize)
(propertize (symbol-name face) 'face face)
face))
"")
(if hc-highlight-other-chars-p "ON" "OFF"))))
(defun hc-other-chars-description (chars &optional face)
"Return a desription of CHARS."
(cond ((and (fboundp 'charsetp) (charsetp chars))
(format "charset `%s'" chars))
((and (consp chars)
(if (fboundp 'characterp) (characterp (car chars)) (integerp (car chars)))
(if (fboundp 'characterp) (characterp (cdr chars)) (integerp (cdr chars))))
(if (and face (fboundp 'propertize))
(format "%s to %s"
(propertize (string (car chars)) 'face face)
(propertize (string (cdr chars)) 'face face))
(format "%c to %c" (car chars) (cdr chars))))
((vectorp chars)
(format "%s" chars))
((stringp chars)
(mapconcat (if (and face (fboundp 'propertize))
(lambda (chr) (propertize (string chr) 'face face))
#'string)
chars
", "))))
(defalias 'toggle-highlight-trailing-whitespace
'hc-toggle-highlight-trailing-whitespace)
(defun hc-toggle-highlight-trailing-whitespace (&optional msgp)
"Toggle highlighting of trailing whitespace.
This includes tab, space, and hard (non-breaking) space characters.
Uses face `hc-trailing-whitespace'."
(interactive "p")
(setq hc-highlight-trailing-whitespace-p (not hc-highlight-trailing-whitespace-p))
(if hc-highlight-trailing-whitespace-p
(add-hook 'font-lock-mode-hook 'hc-highlight-trailing-whitespace)
(remove-hook 'font-lock-mode-hook 'hc-highlight-trailing-whitespace)
(hc-dont-highlight-trailing-whitespace))
(font-lock-mode) (font-lock-mode)
(when msgp (message "Trailing whitespace highlighting is now %s"
(if hc-highlight-trailing-whitespace-p "ON" "OFF"))))
(defun hc-highlight-tabs ()
"Highlight tab characters (`C-i')."
(font-lock-add-keywords nil '(("[\t]+" (0 'hc-tab t))) 'APPEND))
(defun hc-dont-highlight-tabs ()
"Do not highlight tab characters (`C-i')."
(when (fboundp 'font-lock-remove-keywords)
(font-lock-remove-keywords nil '(("[\t]+" (0 'hc-tab t))))))
(defun hc-highlight-hard-spaces ()
"Highlight hard (non-breaking) space characters (`?\u00a0').
\(This is also ?\240.)
This also sets `nobreak-char-display' to nil, to turn off its
low-level, vanilla highlighting."
(when (boundp 'nobreak-char-display) (setq nobreak-char-display nil))
(if (> emacs-major-version 22)
(font-lock-add-keywords nil '(("[\u00a0]+" (0 'hc-hard-space t))) 'APPEND)
(font-lock-add-keywords nil '(("[\240]+" (0 'hc-hard-space t))) 'APPEND)))
(defun hc-dont-highlight-hard-spaces ()
"Do not highlight hard (non-breaking) space characters (`?\u00a0').
\(This is also ?\240.)
If no other `hc-*' highlighting of hard spaces or hard hyphens is in
effect, this also restores `nobreak-char-display' to its original
value."
(unless (or hc-highlight-trailing-whitespace-p hc-highlight-hard-hyphens-p)
(setq nobreak-char-display hc--saved-nobreak-char-display))
(when (fboundp 'font-lock-remove-keywords)
(if (> emacs-major-version 22)
(font-lock-remove-keywords nil '(("[\u00a0]+" (0 'hc-hard-space t))))
(font-lock-remove-keywords nil '(("[\240]+" (0 'hc-hard-space t)))))))
(when (> emacs-major-version 22)
(defun hc-highlight-hard-hyphens ()
"Highlight hard (non-breaking) hyphen characters (`?\u2011').
This also sets `nobreak-char-display' to nil, to turn off its
low-level, vanilla highlighting."
(when (boundp 'nobreak-char-display) (setq nobreak-char-display nil))
(font-lock-add-keywords nil '(("[\u2011]+" (0 'hc-hard-hyphen t))) 'APPEND)))
(when (> emacs-major-version 22)
(defun hc-dont-highlight-hard-hyphens ()
"Stop highlighting hard (non-breaking) hyphen characters (`?\u2011').
If no other `hc-*' highlighting of hard spaces or hard hyphens is in
effect, this also restores `nobreak-char-display' to its original
value."
(unless (or hc-highlight-trailing-whitespace-p hc-highlight-hard-spaces-p)
(setq nobreak-char-display hc--saved-nobreak-char-display))
(when (fboundp 'font-lock-remove-keywords)
(font-lock-remove-keywords nil '(("[\u2011]+" (0 'hc-hard-hyphen t)))))))
(defun hc-highlight-trailing-whitespace ()
"Highlight whitespace characters at line ends.
This includes tab, space, and hard (non-breaking) space characters.
This also sets `nobreak-char-display' to nil, to turn off the
low-level, vanilla highlighting of hard spaces."
(when (boundp 'nobreak-char-display) (setq nobreak-char-display nil))
(if (> emacs-major-version 22)
(font-lock-add-keywords
nil '(("[\u00a0\040\t]+$" (0 'hc-trailing-whitespace t))) 'APPEND)
(font-lock-add-keywords
nil '(("[\240\040\t]+$" (0 'hc-trailing-whitespace t))) 'APPEND)))
(defun hc-dont-highlight-trailing-whitespace ()
"Do not highlight whitespace characters at line ends.
See also `hc-highlight-trailing-whitespace'.
If no other `hc-*' highlighting of hard spaces or hard hyphens is in
effect, this also restores `nobreak-char-display' to its original
value."
(unless (or hc-highlight-hard-spaces-p hc-highlight-hard-hyphens-p)
(setq nobreak-char-display hc--saved-nobreak-char-display))
(when (fboundp 'font-lock-remove-keywords)
(if (> emacs-major-version 22)
(font-lock-remove-keywords
nil '(("[\u00a0\040\t]+$" (0 'hc-trailing-whitespace t))))
(font-lock-remove-keywords
nil '(("[\240\040\t]+$" (0 'hc-trailing-whitespace t)))))))
(defun hc-highlight-other-chars (&optional chars chars-NOT face)
"Highlight CHARS using FACE.
CHARS and CHARS-NOT are lists of character specifications acceptable
as a value of `hc-other-chars' or `hc-other-chars-NOT'.
CHARS defaults to the value of `hc-other-chars'.
CHARS-NOT defaults to the value of `hc-other-chars-NOT'.
FACE defaults to face `hc-other-char'."
(font-lock-add-keywords
nil (hc-other-chars-font-lock-spec chars chars-NOT face) 'APPEND))
(defun hc-dont-highlight-other-chars (&optional chars chars-NOT face)
"Do not highlight CHARS using FACE. That is, unhighlight any such.
CHARS, CHARS-NOT, and FACE are as for `hc-highlight-other-chars'."
(when (fboundp 'font-lock-remove-keywords)
(font-lock-remove-keywords
nil (hc-other-chars-font-lock-spec chars chars-NOT face))))
(defun hc-other-chars-font-lock-spec (&optional chars chars-NOT face)
"Font-lock spec used by `hc-highlight-other-chars'.
CHARS, CHARS-NOT, and FACE are as for `hc-highlight-other-chars'."
(setq face (or face 'hc-other-char)
chars (or chars hc-other-chars)
chars-NOT (or chars-NOT hc-other-chars-NOT))
(let ((regexp-in (format
"\\(%s\\)"
(mapconcat
#'identity
(mapcar (lambda (chrs)
(cond ((and (consp chrs)
(if (fboundp 'characterp)
(characterp (car chrs))
(integerp (car chrs)))
(if (fboundp 'characterp)
(characterp (cdr chrs))
(integerp (cdr chrs))))
(let ((chr (car chrs))
(last (cdr chrs)))
(if (> emacs-major-version 20)
(let ((chs ()))
(while (<= chr last)
(push chr chs)
(setq chr (1+ chr)))
(regexp-opt-charset (nreverse chs)))
(let ((class "["))
(while (<= chr last)
(setq class (concat class (string chr))
chr (1+ chr)))
(concat class "]")))))
((and (fboundp 'charsetp) (charsetp chrs))
(let ((chs ()))
(map-charset-chars
(lambda (range ARG)
(let ((chr (car range))
(last (cdr range)))
(while (<= chr last)
(push chr chs)
(setq chr (1+ chr)))))
chrs)
(regexp-opt-charset (nreverse chs))))
((vectorp chrs)
(concat "[" (format "%s" chrs) "]"))
((stringp chrs)
(if (> emacs-major-version 20)
(regexp-opt-charset (append chrs ()))
(concat "[" chrs "]")))))
chars)
"\\|")))
(regexp-out (format
"\\(%s\\)"
(mapconcat
#'identity
(mapcar (lambda (chrs)
(cond ((and (consp chrs)
(if (fboundp 'characterp)
(characterp (car chrs))
(integerp (car chrs)))
(if (fboundp 'characterp)
(characterp (cdr chrs))
(integerp (cdr chrs))))
(let ((chr (car chrs))
(last (cdr chrs)))
(if (> emacs-major-version 20)
(let ((chs ()))
(while (<= chr last)
(push chr chs)
(setq chr (1+ chr)))
(regexp-opt-charset (nreverse chs)))
(let ((class "["))
(while (<= chr last)
(setq class (concat class (string chr))
chr (1+ chr)))
(concat class "]")))))
((and (fboundp 'charsetp) (charsetp chrs))
(let ((chs ()))
(map-charset-chars
(lambda (range ARG)
(let ((chr (car range))
(last (cdr range)))
(while (<= chr last)
(push chr chs)
(setq chr (1+ chr)))))
chrs)
(regexp-opt-charset (nreverse chs))))
((vectorp chrs)
(concat "[" (format "%s" chrs) "]"))
((stringp chrs)
(if (> emacs-major-version 20)
(regexp-opt-charset (append chrs ()))
(concat "[" chrs "]")))))
chars-NOT)
"\\|"))))
`((,(hc-other-chars-matcher regexp-in regexp-out)
(0 ',face ,hc-other-chars-font-lock-override)))))
(defun hc-other-chars-matcher (regexp-in regexp-out)
"Return a font-lock matcher function for `hc-other-chars-font-lock-spec'.
REGEXP-IN is a regexp for matching the CHARS arg, that is, for chars
to be included.
REGEXP-OUT is a regexp for matching the CHARS-NOT arg, that is, for
chars to be excluded."
`(lambda (bound)
(let ((in nil)
(mdata (or hc--other-chars-last-match-data (match-data))))
(setq in (if (string= "\\(\\)" ,regexp-in)
(progn (forward-char)
(set-match-data
(list (copy-marker (1- (point))) (copy-marker (point))
(copy-marker (1- (point))) (copy-marker (point))))
(point))
(re-search-forward ,regexp-in bound t)))
(unless in (setq hc--other-chars-last-match-data nil))
(and in (progn
(if (string= "\\(\\)" ,regexp-out)
(setq hc--other-chars-last-match-data (match-data))
(if (save-excursion
(save-match-data (backward-char 1) (looking-at ,regexp-out)))
(set-match-data mdata)
(setq hc--other-chars-last-match-data (match-data))))
(goto-char in))))))
(provide 'highlight-chars)