开发者

Check if current Emacs buffer contains a string

开发者 https://www.devze.com 2023-01-03 03:27 出处:网络
I have a buffer open in emacs. I want a function that will return t if the current buffer contains the string, oth开发者_Python百科erwise it returns nil.

I have a buffer open in emacs. I want a function that will return t if the current buffer contains the string, oth开发者_Python百科erwise it returns nil.

(defun buffer-contains-substring (string)
    ...
)


This is careful to not change where you are, or damage any match data.

(defun buffer-contains-substring (string)
  (save-excursion
    (save-match-data
      (goto-char (point-min))
      (search-forward string nil t))))
0

精彩评论

暂无评论...
验证码 换一张
取 消