From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Newsgroups: gmane.emacs.bugs Subject: bug#17871: 24.4.50; (elisp) `Core Advising Primitives': interactive spec as function? Date: Sun, 18 Aug 2019 15:32:43 +0200 Message-ID: <87ef1i38g4.fsf@gmail.com> References: <400906ac-35f1-48e4-8df9-8e65b340209b@default> <87vbrjdajs.fsf@web.de> <82178260-247b-4653-85db-d6586480419e@default> <87d2dqdsyj.fsf@web.de> <8736ihb0ds.fsf@mouse.gnus.org> <87d0hl3xqx.fsf@web.de> <878ss99jhi.fsf@mouse.gnus.org> <87o914xh50.fsf@web.de> <87ftmgdl2d.fsf@mouse.gnus.org> <8736hy1wxt.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="220914"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Lars Ingebrigtsen , Stefan Monnier , 17871@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 18 15:33:49 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hzLJd-000vNU-8h for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Aug 2019 15:33:49 +0200 Original-Received: from localhost ([::1]:41228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzLJb-0001XL-OR for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Aug 2019 09:33:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50190) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzLIt-0001VX-WE for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2019 09:33:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzLIs-0006kQ-L7 for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2019 09:33:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzLIs-0006kE-7E for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2019 09:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hzLIs-0001qh-3G for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2019 09:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Aug 2019 13:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17871 X-GNU-PR-Package: emacs Original-Received: via spool by 17871-submit@debbugs.gnu.org id=B17871.15661351737093 (code B ref 17871); Sun, 18 Aug 2019 13:33:02 +0000 Original-Received: (at 17871) by debbugs.gnu.org; 18 Aug 2019 13:32:53 +0000 Original-Received: from localhost ([127.0.0.1]:57505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hzLIj-0001qK-1k for submit@debbugs.gnu.org; Sun, 18 Aug 2019 09:32:53 -0400 Original-Received: from mail-wr1-f41.google.com ([209.85.221.41]:37399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hzLIg-0001q3-Az for 17871@debbugs.gnu.org; Sun, 18 Aug 2019 09:32:51 -0400 Original-Received: by mail-wr1-f41.google.com with SMTP id z11so5970973wrt.4 for <17871@debbugs.gnu.org>; Sun, 18 Aug 2019 06:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-transfer-encoding; bh=JXg4SACTZmWx3MLNOKfyXY10tZSUYk0j4PSnzPZZ64c=; b=l+RSmandQzaOn5QV90bPVopAidfvBdmEfJKuwKI6wcyyyBzW4J6CntekHm3fdE94zn 6gJrS6um+H4DdJOIqMvYjXQiRdGVNHeruPIdJ+qtQJukPUHjVWjRohKhJidiBIgTli0+ 69pIWO6v0p3DchAVw7WV7q1rkB1mxUMoON03QM1MUaDOqQFFSokxJC92uKQTRQaOj98o 65vMoJ5DUAzM/+VhImFG4KQNOOwHU+5HniJR2VpFfMhA83UTYviF2mTAUCUJQbW9TM5m EHh2dK1ae0u4GyJMmFp2eJfX7tPtlGa7e3VbSO2NRHJcRI1mdRvffPpsfS7JRNDhUrBJ AxKg== 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:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=JXg4SACTZmWx3MLNOKfyXY10tZSUYk0j4PSnzPZZ64c=; b=raohmGTZ+WPqLnuhZWLK1x2L3KBbCKWFb447hZzCWnhcPJ+KfjTGdkn/mEBXYlEix+ 4uTBMwrIgxZO6zr2Idn5jrcdU3ogIataXj9/0UzcJ93FaeGjwC1aoDSAlWl/NdElOKrM kJ/2J3Ha9L1z3Baq3eZEaiqXO+K1F9/dCthC+edQ8eYo84ogzZsv6OZE2wZPCwJXwQ6k LgZzoqWNpe1xzF+vJ4fPWEADNP7/l/SgWXDh7Lg0TydXt9XOwRQSIOg3tfc+Eb0GrJ9s ZicqWsj00r28yRG7Dy1b6/nIRbyOMqVe1JYrN10NyRLogisZAy0eyIgDkxMtKuD/IrCh rNOw== X-Gm-Message-State: APjAAAXB7lYnO1EvPq/oy8F5qP5Dw5fO2iQDtP3DtGJR9aECksAk8VvX QUsgqs9QJPyRu36KBLeMQsM= X-Google-Smtp-Source: APXvYqyED2JKyIjI5pidjQwJ2tN2jveEVtikbM0fzz3g+bhIynkm5ibX1opdSBD28a8ubFOj/tgkLg== X-Received: by 2002:adf:fe85:: with SMTP id l5mr20458049wrr.5.1566135164407; Sun, 18 Aug 2019 06:32:44 -0700 (PDT) Original-Received: from localhost ([185.112.167.114]) by smtp.gmail.com with ESMTPSA id c15sm29387428wrb.80.2019.08.18.06.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 06:32:43 -0700 (PDT) In-Reply-To: <8736hy1wxt.fsf@web.de> (Michael Heerdegen's message of "Sun, 18 Aug 2019 14:26:38 +0200") 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: 209.51.188.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:165321 Archived-At: On Sun, 18 Aug 2019 14:26:38 +0200 Michael Heerdegen wrote: >> > (2) Enhance a command to accept an additional argument. The interacti= ve >> > form of the :around advice will reuse the interactive form of the >> > original command to read in the arguments the original command accepts, >> > read in the additional argument, and return the combined list. >> >> I think an example along these lines would be very nice for the manual. > > =C5=A0t=C4=9Bp=C3=A1n, any nice idea which command I could use to write t= he example? Well, the closest I see in my init is this (in fact I have been doing it differently and more uglily, but now I see this is simpler): (defun my-compose-mail-advice (orig &rest args) "Read From: address interactively." (interactive (lambda (spec) (let* ((user-mail-address (completing-read "From: " '("one.address@example.n= et" "alternative.address@e= xample.net"))) (from (message-make-from user-full-name user-mail-address)) (spec (advice-eval-interactive-spec spec))) ;; notmuch doesn't understand "From", it has to be a sym= bol (push (cons 'From from) (nth 2 spec)) spec))) (apply orig args)) (advice-add 'compose-mail :around #'my-compose-mail-advice) One might argue that, given the simple nature of `compose-mail' original interactive spec (no actual user interaction), constructing a plain list disregarding the original would suffice here, but it would really be almost the same. I'm sure one could come up with better examples, but I can't think of anything off the top of my head. --=20 =C5=A0t=C4=9Bp=C3=A1n