unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: tomas@tuxteam.de
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to automatically escape regex characters for regex search?
Date: Sun, 6 Nov 2022 12:24:05 +0300	[thread overview]
Message-ID: <Y2d9NfOr77eyR1si@protected.localdomain> (raw)
In-Reply-To: <Y2d8BlnpEymKyP68@tuxteam.de>

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	other threads:[~2022-11-06  9:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06  9:10 How to automatically escape regex characters for regex search? Jean Louis
2022-11-06  9:17 ` Yuri Khan
2022-11-06 17:40   ` Marcin Borkowski
2022-11-07  5:58     ` Jean Louis
2022-11-06  9:19 ` tomas
2022-11-06  9:24   ` Jean Louis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y2d9NfOr77eyR1si@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tomas@tuxteam.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).