help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to automatically escape regex characters for regex search?


From: Jean Louis
Subject: Re: How to automatically escape regex characters for regex search?
Date: Sun, 6 Nov 2022 12:24:05 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

Thank you much.

Though I found in mean time `rx-to-string' and it works well. Maybe I
am using it wrong. Do I?

(defun rcd-check-start (&optional rcd-check-in rcd-check-out)
  "Insert variable `rcd-check-in' at the beginning of line."
  (interactive)
  (let* ((start (line-beginning-position))
         (end (line-end-position))
         (line (buffer-substring start end))
         (rcd-check-in (or rcd-check-in "❰    ❱"))
         (rcd-check-out (or rcd-check-out "❰DONE❱")))
    (when (and (not (string-match (rx-to-string rcd-check-in) line))
               (not (string-match (rx-to-string rcd-check-out) line)))
      (save-excursion
        (goto-char start)
        (insert rcd-check-in " "))
      (when (= start end)
        (goto-char (line-end-position))))))


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]