emacs-devel
[Top][All Lists]
Advanced

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

Re: Can we add a delete-match function to subr(-x).el?


From: Stefan Kangas
Subject: Re: Can we add a delete-match function to subr(-x).el?
Date: Sat, 25 Jan 2020 06:23:32 +0100

Paul W. Rankin <address@hidden> writes:

> I frequently forget that Emacs doesn't include a delete-match function
> to be called after (re-)search-forward or the like.
>
> Can we add something like the following to subr(-x).el?
>
>     (defun delete-match (&optional subexp)
>       "Delete text matched by last search.
>
>     Optional argument SUBEXP specifies the subexpression to delete,
>     or delete the entire match."
>       (when (consp (match-data))
>         (unless group (setq subexp 0))
>         (delete-region (match-beginning subexp) (match-end subexp))))

I think adding that would be convenient.

You have a typo in the code btw, should say:
    (unless subexp (setq subexp 0))

Best regards,
Stefan Kangas



reply via email to

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