有 M-x narrow-to-line
和之类的功能M-x narrow-to-page
。哪些例程可以帮助我实现不存在的 Mx 缩小正则表达式的功能?
谢谢。
这似乎有效。将提示用户输入开始和结束正则表达式。(没有经过非常彻底的测试!):
(defun narrow-to-regex ()
"narrow the buffer visibility to the section between two regexes the user provides"
(interactive)
(let* ((beginRegex (read-regexp "begin pattern"))
(endRegex (read-regexp "end pattern"))
(beg)
(end))
(goto-char (point-min)) ;; go to the start of the buffer
(if (re-search-forward beginRegex nil t nil)
(setq beg (- (point) (length beginRegex))))
(if (re-search-forward endRegex nil t nil)
(setq end (point)))
(if (and beg end (> end beg))
(narrow-to-region beg end)
(message "did not find both instances of the regex, %s %s, no narrow" beg end))))
您也可以通过将其放入缓冲区(暂存等)并按 CTRL+X 然后按 CTRL+E 来安装它