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#27584: 26.0.50; alist-get: Add optional arg TESTFN Date: Wed, 05 Jul 2017 17:53:29 +0900 Message-ID: <87k23n8dti.fsf@calancha-pc> References: <87tw2rva7v.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1499244855 5052 195.159.176.226 (5 Jul 2017 08:54:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Jul 2017 08:54:15 +0000 (UTC) Cc: nicolas petton , stefan monnier To: 27584@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 05 10:54:11 2017 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 1dSg4W-0000sF-Cs for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 10:54:09 +0200 Original-Received: from localhost ([::1]:44883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSg4a-0002Vc-4H for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 04:54:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSg4U-0002VV-2T for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 04:54:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSg4R-0006C1-0O for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 04:54:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50260) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSg4Q-0006Bv-Su for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 04:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dSg4Q-0007Bm-Fy for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 04:54:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87tw2rva7v.fsf@calancha-pc> Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jul 2017 08:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27584 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27584-submit@debbugs.gnu.org id=B27584.149924482227602 (code B ref 27584); Wed, 05 Jul 2017 08:54:02 +0000 Original-Received: (at 27584) by debbugs.gnu.org; 5 Jul 2017 08:53:42 +0000 Original-Received: from localhost ([127.0.0.1]:52937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSg46-0007B8-6Z for submit@debbugs.gnu.org; Wed, 05 Jul 2017 04:53:42 -0400 Original-Received: from mail-pg0-f67.google.com ([74.125.83.67]:33733) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSg45-0007Au-3Y for 27584@debbugs.gnu.org; Wed, 05 Jul 2017 04:53:41 -0400 Original-Received: by mail-pg0-f67.google.com with SMTP id u62so30779879pgb.0 for <27584@debbugs.gnu.org>; Wed, 05 Jul 2017 01:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:message-id:mime-version; bh=3aRej7ilQQlU3PmgbYCo6sXrPjWosLcYlKvrizpjcyA=; b=n5SVy8zsoo3xus2OpfGgvgt4FUX1EZKCR0gLM9ti969PrdzTCSjsWOr4THgevRmRjw GMmz7FnzXILvS0RUaxUkGR0B054B0woAhGxlZoA94Jz3PYqzWEtblE9X9odF3rawyeWN 99na39sTsz7VbE2ohhTTV9fAiQieKx/31X+sksm7CqCejHcjf7/qsxY8jol619hmlYEh iUz73eCXcKRTPaDW9rAA8r/HwSzfzcgLF/PnsLnSdYrv8O2hriQTcit9Yz1c9GnvEMkm SRHSQjZI9qjI78hbfqlL7cfBhySw6unRK95PWrCUGyvLQKDlL9hGwERYj3XBUrLsRkcN ktZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:message-id :mime-version; bh=3aRej7ilQQlU3PmgbYCo6sXrPjWosLcYlKvrizpjcyA=; b=lrc5khQin+NBe65JphCHc8R8cUyGsY1kEg99AhTa0K6PDI14np8SRUYqfXQhWceQud K0bXFoNbo5TN8BFqar30rWTALiax2o2NC0mPS8+c4VPF0YhLPGYN7JzcDjjpeLp4Vizg k2fTTp46WPBASsKjye1/IbbuP621AVbpMYwPSZ3Gw2FyVnKD6DCzxklmCT1O4ub7Ifbp SZVLdJ3a6IAvIWNNTV7MwuMKV9nhnzn/9hYKMJS9cfikHvqNTb0Pq/+2L4AAExI9pZiG /y69knuMNjd20ITkkffkCVe7d2N6y3PxIRYoPpdZd5kPB+nmW8B20xcQeLhnEJF7lMRh D5WQ== X-Gm-Message-State: AIVw110cyJqBcsIhLihYbhOAS+2EptWt0MlO9ZUmkaPMY0jE8U12f0Zw /Dej+vWs/uHAAw== X-Received: by 10.84.138.131 with SMTP id 3mr11760902plp.293.1499244815185; Wed, 05 Jul 2017 01:53:35 -0700 (PDT) Original-Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222]) by smtp.gmail.com with ESMTPSA id n19sm45378876pfa.64.2017.07.05.01.53.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jul 2017 01:53:34 -0700 (PDT) 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:134201 Archived-At: > > -(defun assoc-default (key alist &optional test default) > +(defun assoc-default (key alist &optional test default full) > "Find object KEY in a pseudo-alist ALIST. > ALIST is a list of conses or objects. Each element > (or the element's car, if it is a cons) is compared with KEY by > calling TEST, with two arguments: (i) the element or its car, > and (ii) KEY. > If that is non-nil, the element matches; then `assoc-default' > - returns the element's cdr, if it is a cons, or DEFAULT if the > - element is not a cons. > + returns the element, if it is a cons and FULL is non-nil, > + or the element's cdr, if it is a cons and FULL is nil, > + or DEFAULT if the element is not a cons. > > If no element matches, the value is nil. > If TEST is omitted or nil, `equal' is used." > (let (found (tail alist) value) > (while (and tail (not found)) > (let ((elt (car tail))) > - (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) > - (setq found t value (if (consp elt) (cdr elt) default)))) > + (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) > + (setq found t > + value (cond ((consp elt) > + (if full elt (cdr elt))) > + (t default))))) > (setq tail (cdr tail))) > value)) If we go in this direction, then i think it has sense to add something with less parameters, like this: (defsubst assoc-predicate (key alist test) "Like `assoc' but compare keys with TEST." (assoc-default key alist test nil 'full))