Function: preview-error-quote
preview-error-quote is a byte-compiled function defined in preview.el.
Signature
(preview-error-quote STRING)
Documentation
Turn STRING with potential ^^ sequences into a regexp.
To preserve sanity, additional ^ prefixes are matched literally, so the character represented by ^^^ preceding extended characters will not get matched, usually.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-error-quote (string)
"Turn STRING with potential ^^ sequences into a regexp.
To preserve sanity, additional ^ prefixes are matched literally,
so the character represented by ^^^ preceding extended characters
will not get matched, usually."
(let (output case-fold-search)
;; Some coding systems (e.g. japanese-shift-jis) use regexp meta
;; characters on encoding. Such meta characters would be
;; interfered with `regexp-quote' below. Thus the idea of
;; "encoding entire string beforehand and decoding it at the last
;; stage" does not work for such coding systems.
;; Rather, we work consistently with decoded text.
;; Bytes with value from 0x80 to 0xFF represented with ^^ form are
;; converted to byte sequence, and decoded by the file coding
;; system.
(setq string
(preview--decode-^^ab string buffer-file-coding-system))
;; Then, control characters are taken into account.
(while (string-match "\\^\\{2,\\}\\([@-_?]\\)" string)
(setq output
(concat output
(regexp-quote (substring string
0
(- (match-beginning 1) 2)))
(concat
"\\(?:" (regexp-quote
(substring string
(- (match-beginning 1) 2)
(match-end 0)))
"\\|"
(char-to-string
(logxor (aref string (match-beginning 1)) 64))
"\\)"))
string (substring string (match-end 0))))
(setq output (concat output (regexp-quote string)))
output))