我有一个字符串,我通过调用buffer-substring
. 有没有办法根据它的face
设置从这个字符串中删除文本?作为一个随机的例子:
(save-excursion
(let ((end (point)))
(ignore-errors
(while (not (looking-at "[^][ \t\r\n(){}]+:"))
(backward-sexp)))
不知道 SO 将如何突出显示这一点,但在 Emacs 中save-excursion
,let
,ignore-errors
和while
都突出显示为关键字,并且正则表达式参数 tolooking-at
突出显示为字符串。的返回值buffer-substring
看起来像
#(" (save-excursion
(let ((end (point)))
(ignore-errors
(while (not (looking-at \"[^][ \\t\\r\\n(){}]+:\"))
(backward-sexp)))" 0 5 (fontified t) 5 19 (fontified t face font-lock-keyword-face) 19 28 (fontified t) 28 31 (fontified t face font-lock-keyword-face) 31 50 (fontified t) 50 63 (fontified t face font-lock-keyword-face) 63 65 (fontified t) 65 69 (fontified t) 69 74 (fontified t face font-lock-keyword-face) 74 75 (fontified t) 75 92 (fontified t) 92 94 (fontified t face font-lock-string-face) 94 95 (fontified t face (font-lock-negation-char-face font-lock-string-face)) 95 112 (fontified t face font-lock-string-face) 112 115 (fontified t) 115 137 (fontified t))
鉴于该示例字符串,我将如何剥离所有具有face
font-lock-keyword-face
? 也就是说,我想做能够做类似的事情
(foo-bar *that-region* 'font-lock-keyword-face)
并让它返回
(
( ((end (point)))
(
( (not (looking-at "[^][ \t\r\n(){}]+:"))
(backward-sexp)))