From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Re: Can we add a delete-match function to subr(-x).el? Date: Sat, 25 Jan 2020 06:23:32 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="26059"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs Devel To: "Paul W. Rankin" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 25 06:24:16 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ivDvc-0006kQ-Dm for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Jan 2020 06:24:16 +0100 Original-Received: from localhost ([::1]:50894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ivDvb-0000nC-HC for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Jan 2020 00:24:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54883) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ivDv7-0000LE-W0 for emacs-devel@gnu.org; Sat, 25 Jan 2020 00:23:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ivDv6-0003t1-Vg for emacs-devel@gnu.org; Sat, 25 Jan 2020 00:23:45 -0500 Original-Received: from mail-pl1-f177.google.com ([209.85.214.177]:46267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ivDv6-0003sO-QE for emacs-devel@gnu.org; Sat, 25 Jan 2020 00:23:44 -0500 Original-Received: by mail-pl1-f177.google.com with SMTP id y8so1623514pll.13 for ; Fri, 24 Jan 2020 21:23:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yaG9g5QbxQVwqkaeIA93mH/VmXpRfNsMgN5SDkONjao=; b=jPpxyR0v3Oi0T/qErPB8NOr8iVPVwOlF6bABCETVfc2WJqOjcASpNhNCqvBWwHjOJm wnZsHhboo6dfH93MH9d9XZ7owy9nKaLcjp+72EnVEgRlDWwDVwFawVeccjXZfjooqlQF 9OXCz5uwtGw7HX1OrRES2fjVP8UJUD5DQ0jqYSrs6W6Z32ttXTMX4wWBlfz8RhKWsO64 o1EfEji+68Ya3ZF8bxQyM8F7jeHo1QHY/ihA0bxvMlFuxHfqRUHRv0c2CFfUplCy8r0H tMRWMoAEqiEp6bz3ARkc+axV1t/23hO0OH35djnA2ttzXLQG6MAf1XzLS03UWoKbgB+e JLUA== X-Gm-Message-State: APjAAAUfvBnVk2+33+SayMQI2Swvhg3vI9hpx8ZL+jla2V6NQQ9Wql9h 1ZHiHQ4VYL3kpXp9PHn3E7brTeeM7ui1ykdi97BwlThT X-Google-Smtp-Source: APXvYqwZuBKSPTY8TiGOAoOnZ121BTU/Y6fWaXQVepzqa+YPWFQCUA+3Rdzi0eXcLkLCUiiDSD4mliy9egRYoRTEyvU= X-Received: by 2002:a17:90a:a409:: with SMTP id y9mr3107435pjp.119.1579929823674; Fri, 24 Jan 2020 21:23:43 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.214.177 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244594 Archived-At: Paul W. Rankin 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