From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#30202: 27.0.50; Code refactoring on assq-delete-all assoc-delete-all Date: Wed, 24 Jan 2018 12:10:42 +0900 (JST) Message-ID: References: <87r2qilb3d.fsf@gmail.com> <83lggprj4c.fsf@gnu.org> <83r2qgzhkz.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1516763444 5697 195.159.176.226 (24 Jan 2018 03:10:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 24 Jan 2018 03:10:44 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 30202@debbugs.gnu.org, monnier@iro.umontreal.ca, Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 24 04:10:39 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeBSC-0000K5-46 for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Jan 2018 04:10:24 +0100 Original-Received: from localhost ([::1]:44958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeBUC-0003iW-7I for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Jan 2018 22:12:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeBTG-0003bu-H1 for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 22:12:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeBSo-0000qn-Jn for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 22:11:30 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eeBSo-0000pa-AU for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 22:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eeBSn-0002lv-Ts for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 22:11:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2018 03:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30202 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30202-submit@debbugs.gnu.org id=B30202.151676345710644 (code B ref 30202); Wed, 24 Jan 2018 03:11:01 +0000 Original-Received: (at 30202) by debbugs.gnu.org; 24 Jan 2018 03:10:57 +0000 Original-Received: from localhost ([127.0.0.1]:40210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeBSh-0002la-9i for submit@debbugs.gnu.org; Tue, 23 Jan 2018 22:10:55 -0500 Original-Received: from mail-pg0-f45.google.com ([74.125.83.45]:41995) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeBSf-0002lN-4E for 30202@debbugs.gnu.org; Tue, 23 Jan 2018 22:10:53 -0500 Original-Received: by mail-pg0-f45.google.com with SMTP id q67so1733329pga.9 for <30202@debbugs.gnu.org>; Tue, 23 Jan 2018 19:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=qWIN7mukB1Ny033IrW35JfFUPciDm2UBe+v48KY9X/k=; b=oJisHMKCSXXEVMVVMjZmgKrxQ3aUakkNBtEYAZDk/KopHslpS1s3YC/OXiqj0REnxT 4EcuCPgbLuMocH7LS1am8VQxvn06a/qJ8Hapt538bUonHMQR6rWhiwGYcow6GHEbVZQV 4R8aVkomVZQfegxqomd/YCvzSOFTN/2wgS9nQDDNbpLSTF29Io9CJ2mBifVq4Vc/cZs1 uR+2X0QJ1gJyKld+50TUEmf6rWFYUcxqdEgbWSpwSveWgWb2owUpqefjqqSNh2rCbWtO sZb+zNqrcVl7ax6Ifk8SQ4C2+uVDfvtHg0IJLLX+Nt2jcwKWlk6IPMIwEp0DpyBJH+ZI 2NwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=qWIN7mukB1Ny033IrW35JfFUPciDm2UBe+v48KY9X/k=; b=m013BwR8n18iW695z9w6frOIeeyQqcvPDekjEp1PD9Stx59YKzhtvgXNS/B1agVvTe bvABaVnG7MVt1nZDFmlrl3qd3yFIpG5e9h4QvHkvMoPLV+PZiTSIdlHCQ0kbxbGv2TJW Q4du7DnLUNK0e3jBktS7QquOJphEUu+nSlmCdMJapWmeZ6R07DOdbrhPPbI7d1b6W/Ky dU95yT2snT7ENDnPKTBjM0gnsPi5eu8d1R30YcBKjUq1/IRGCtA2A65jfZHrn7AbzpAK NTYRvfdmBBAxskxx7aX9Kg1u4kyYilHoB0NHKIJH4eUos19gaV8Wu1sktuT3dKN8Yeqe ip+Q== X-Gm-Message-State: AKwxytc7w0lU1k1nx/H2k0vwizqjmb8sx3SaW/h7072iomEZIZP0fe6u hEsDrWcA26qRVLi5SzI3o+E= X-Google-Smtp-Source: AH8x225uiFVj0npzLO5VCKq0tvCdO2jjx8071aXp6jzSfXA86Yrt5veRLGi84C7U/FT2v5lBrKwBGg== X-Received: by 10.98.58.5 with SMTP id h5mr11518712pfa.169.1516763447136; Tue, 23 Jan 2018 19:10:47 -0800 (PST) Original-Received: from calancha-pc (FL1-125-193-170-29.tky.mesh.ad.jp. [125.193.170.29]) by smtp.gmail.com with ESMTPSA id f80sm6421683pfa.1.2018.01.23.19.10.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 19:10:46 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83r2qgzhkz.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142460 Archived-At: On Tue, 23 Jan 2018, Eli Zaretskii wrote: > An even more minor nit: try to avoid starting a sentence with @var. > In an Info manual, @var produces UPPER CASE, which looks OK at the > beginning of a sentence; but in the printed manual, @var produces a > lower-case word in slant typeface, which makes the sentence begin with > a lower-case letter. Excellent! Thank you! Indeed I found very ugly when I wrote such sentence starting with @{var}; I couldn't find an alternative way to say what I wanted to say. You summarized the point nicely. Updated the patch (below). I will push it by Sunday (4 days from now) if there is no more activity in thi thread. --8<-----------------------------cut here---------------start------------->8--- commit 55b82da7a7d0c1e016ef73ef46a7579fd9369cbf Author: tino calancha Date: Wed Jan 24 12:03:14 2018 +0900 Code refactoring * lisp/subr.el (assoc-delete-all): Add optional arg TEST. (assq-delete-all): Use assoc-delete-all. * doc/lispref/lists.texi (Association Lists): Document assoc-delete-all in the manual. ; * etc/NEWS: Add entry for assoc-delete-all diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 3e2dd13c70..761750eb20 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi @@ -1733,6 +1733,14 @@ Association Lists @end example @end defun +@defun assoc-delete-all key alist &optional test +This function is like @code{assq-delete-all} except that it accepts +an optional argument @var{test}, a predicate function to compare the +keys in @var{alist}. If omitted or @code{nil}, @var{test} defaults to +@code{equal}. As @code{assq-delete-all}, this function often modifies +the original list structure of @var{alist}. +@end defun + @defun rassq-delete-all value alist This function deletes from @var{alist} all the elements whose @sc{cdr} is @code{eq} to @var{value}. It returns the shortened alist, and diff --git a/etc/NEWS b/etc/NEWS index d30f0b087c..c491777781 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -204,6 +204,9 @@ as new-style, bind the new variable 'force-new-style-backquotes' to t. * Lisp Changes in Emacs 27.1 ++++ +** New function assoc-delete-all. + ** 'print-quoted' now defaults to t, so if you want to see (quote x) instead of 'x you will have to bind it to nil where applicable. diff --git a/lisp/subr.el b/lisp/subr.el index 092850a44d..e7a0ffc5be 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -705,17 +705,19 @@ member-ignore-case (setq list (cdr list))) list) -(defun assoc-delete-all (key alist) - "Delete from ALIST all elements whose car is `equal' to KEY. +(defun assoc-delete-all (key alist &optional test) + "Delete from ALIST all elements whose car is KEY. +Compare keys with TEST. Defaults to `equal'. Return the modified alist. Elements of ALIST that are not conses are ignored." + (unless test (setq test #'equal)) (while (and (consp (car alist)) - (equal (car (car alist)) key)) + (funcall test (caar alist) key)) (setq alist (cdr alist))) (let ((tail alist) tail-cdr) (while (setq tail-cdr (cdr tail)) (if (and (consp (car tail-cdr)) - (equal (car (car tail-cdr)) key)) + (funcall test (caar tail-cdr) key)) (setcdr tail (cdr tail-cdr)) (setq tail tail-cdr)))) alist) @@ -724,16 +726,7 @@ assq-delete-all "Delete from ALIST all elements whose car is `eq' to KEY. Return the modified alist. Elements of ALIST that are not conses are ignored." - (while (and (consp (car alist)) - (eq (car (car alist)) key)) - (setq alist (cdr alist))) - (let ((tail alist) tail-cdr) - (while (setq tail-cdr (cdr tail)) - (if (and (consp (car tail-cdr)) - (eq (car (car tail-cdr)) key)) - (setcdr tail (cdr tail-cdr)) - (setq tail tail-cdr)))) - alist) + (assoc-delete-all key alist #'eq)) (defun rassq-delete-all (value alist) "Delete from ALIST all elements whose cdr is `eq' to VALUE. --8<-----------------------------cut here---------------end--------------->8---