From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: default value with interactive Date: Mon, 20 Nov 2017 03:18:14 +0100 Message-ID: <87po8dvgk9.fsf@web.de> References: <86a7zi13ze.fsf@zoho.com> <87d14e6is1.fsf@web.de> <86o9nxzxp4.fsf@zoho.com> <871sktx19j.fsf@web.de> <86fu99zre9.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511144333 19150 195.159.176.226 (20 Nov 2017 02:18:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Nov 2017 02:18:53 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 20 03:18:46 2017 Return-path: Envelope-to: geh-help-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 1eGbfX-0004K3-RV for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Nov 2017 03:18:43 +0100 Original-Received: from localhost ([::1]:55035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGbfd-0002zH-EZ for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 21:18:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGbfB-0002zC-R1 for help-gnu-emacs@gnu.org; Sun, 19 Nov 2017 21:18:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGbf7-0005id-SL for help-gnu-emacs@gnu.org; Sun, 19 Nov 2017 21:18:21 -0500 Original-Received: from mout.web.de ([212.227.15.3]:49958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGbf7-0005iH-IB for help-gnu-emacs@gnu.org; Sun, 19 Nov 2017 21:18:17 -0500 Original-Received: from drachen.dragon ([88.66.201.17]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MGARb-1eLmSG1N7n-00FAmx; Mon, 20 Nov 2017 03:18:15 +0100 In-Reply-To: <86fu99zre9.fsf@zoho.com> (Emanuel Berg's message of "Mon, 20 Nov 2017 02:10:38 +0100") X-Provags-ID: V03:K0:UOOuCPxcCzP3uf3LsjNOY5b5LOXXZMF1YsI7iA9AYwViqKzpUbz LTPpxrwzvs7um65L4ZqI2du7uu8UYIbV+mp0ubZnSJOAXVYro5fJrzAxN8cD3EhkHU0pDrR YMTe1FkodpsQPUpMjNYJXeEj3vxbvepIwd2bP3/kiX41zfi8SqgZRRq086IAcuxLUFmYStN 4ujm4tTiWzUUypNMYK6MA== X-UI-Out-Filterresults: notjunk:1;V01:K0:YwW4YBkOUS8=:XReYazQ5X0xTTkmHIHDWFe D2gui5kxBVvb8EEvlcw5AwbAhGnHRdwA3w23eEh/TwT4m3ExEk9QKLoDNDDKjprsX46pZQJSb t3KaWbNXl5EfH21hXoD05Vpuj1ogdDIG5wJ6vQKjBojRRpmKU+5BSIqD3lUBtWn31gvm9YWU8 T3uz6mAgGGZ8T0dwGQHHbe24F00daox6MDGK/N0/lB+Mvm/Rrki+25Tt2CkXS0buWbVt+Qzmj dH9NkcwRkIoGzBsiOvQOJW6M7073jvjOQJA5xViGfszoV2ToLG2Zj4Co2sfnzYBmy9zDTngEd oR+yLDfAfGx5cijc3KB9WkKFhxp2UyeLZxuiUpPgP0baSrSrs+dteeZQ2thstLv6bUT/BNRjO 49K7hJnXk0Buo665IueVnrMmUmNz1iEBeFbXQwTMkb9eQNtTQCIVuGaLQP6M/Z5ZG+vT+DNRK 9CJLj+PuSgOY5eBOTY+0uYLqx2c58Y0+UZOE0xOp6gGxdXf4qFcfsQeaSpbOEE4xwVhP7OG0k +y6k6HjtegNNG0Yv9IcAm32KAVAp2XZ/ElZrMFYZk2sbDWsQ3nt1It9H5Rq70taxSUvE9FoOv xZl8ik142/prezABQMDuhxyFtxVj6YVdtsxUdioiDYhNiVhUxy3NPTpb/2ZWbYc079J77hRkr cAIOMoK2Ma+PjzxO3uuqPK841yolkOk2UZcjBRWtSJcNkFEKk10amn9TMjbkK85PdXFHclzqF 8pZAPqK5OdGUy/JscFdh31ybOH593KBF2Z8IQTAL9hiX8R7Tz0Q8SV+nD0qqO9u5+qrooTEk X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114997 Archived-At: Emanuel Berg writes: > What I have is two functions, one that > searches, and one that "searches again" with > the previous search string as input. > > When the function that searches is invoked, it > asks for a search string, but if it isn't > provided, the default (i.e., previous) string > is used even tho the better way to do that is > to invoke the function that searches > again directly. > > I can extract into a function the code that > fetches the previous search *but* how do I use > that in the interactive form as well as outside > it without computing twice? As was instructed > here - (info "(elisp) Programming Tips") - only > even in the provided example, it really didn't > happen that way at all. You are trying to solve a problem that doesn't exist. The convention does only speak about "region or position arguments" - right? Maybe, more generally, about arguments that the user specifies implicitly, like having marked a region, having a certain position of point, positioning the cursor over a certain url, or so. Implicitly, because you don't really enter the bounds of the region etc. when using a command that operates on the region. The rule you want to fulfill exists to make `repeat-complex-command' behave convenient. When you e.g. have a command `foo' that operates on the current region (let's say, it query-replaces something in the current region), `foo' will have arguments BEG, END, and a REGEXP etc. The interactive form should return BEG and END as nil so that when I have invoked the command, but want to redo it with a different region (and just reuse the given input), I can just change the region and invoke `repeat-complex-command' - without having to paste the actual region bounds as numbers into the minibuffer. I just can confirm the default, because the command function had been invoked with BEG and END nil, and that means "use the current region". In your case, it makes no sense to use the "search again" command with `repeat-complex-command' - when I want a new search, I should `repeat-complex-command' the original search command (or just call it itself), and the other one is already a redo command. But even if you unite the two commands, it is still _useful_ to have the last search pattern in the minibuffer to be able to reuse or edit it (it's easy enough to replace it with something else) when using `repeat-complex-command'. It takes a bit of routine to learn how to design commands so that they work well with `repeat-complex-command', but it's only sanity and reason at the end. Regards, Michael.