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: Sun, 19 Nov 2017 22:49:34 +0100 Message-ID: <87d14e6is1.fsf@web.de> References: <86a7zi13ze.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511128229 30936 195.159.176.226 (19 Nov 2017 21:50:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 19 Nov 2017 21:50:29 +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 Sun Nov 19 22:50:25 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 1eGXTq-0007gT-Oe for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 22:50:22 +0100 Original-Received: from localhost ([::1]:54481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGXTx-0006RM-Pz for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 16:50:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGXTR-0006R5-Jy for help-gnu-emacs@gnu.org; Sun, 19 Nov 2017 16:49:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGXTM-0001OY-O4 for help-gnu-emacs@gnu.org; Sun, 19 Nov 2017 16:49:57 -0500 Original-Received: from mout.web.de ([212.227.17.11]:61784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGXTM-0001OJ-ED for help-gnu-emacs@gnu.org; Sun, 19 Nov 2017 16:49:52 -0500 Original-Received: from drachen.dragon ([88.66.201.17]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Ljrdd-1erW7A2pBZ-00bsW6; Sun, 19 Nov 2017 22:49:49 +0100 In-Reply-To: <86a7zi13ze.fsf@zoho.com> (Emanuel Berg's message of "Sun, 19 Nov 2017 20:08:05 +0100") X-Provags-ID: V03:K0:af46GgkGb/1wsOzZgkF7kNei9L0nY7/LxZHUJzLuDgHUHLQ/dHG ZM9L7m/Crt8upMF0v/vXsaNezhPYITDAqSZqO38nv3jvdr2xl/2FgR71/QbLobJPXTerHLg OWJGIqIsSCqayh56L6/DP+yN/sqsQuFfOkLZwdsLwR2HzP5c1mmWi6y1vNmEUcrMDiFJgpD XaJlInlrz606vOlvPvuEA== X-UI-Out-Filterresults: notjunk:1;V01:K0:ZLgX9tjju2E=:zeEL0xEVtBrXErz6ah1yGt GhIJEw7lBDF33afL2aELl41Ibz9gu3QeHTTjmYTMsaDQ7lyVyuOtuBZLLabbn1Ub/IWjxa8/k 0IAaU7oey6iNVLvT85AWTj9BiQeZbsSmqMaUPAstkzZ17Z3c+KT6wwNjPbPbatwH5gFW0EDmO 6QVEGwVdV5a1uQ8UUh4H6YeFp6KmwmUzOIst6lEJyfCdWHmhttQqKEK9RGIjPtDQySIOPHfDf fh8zzh8NDgkq0bmR0rQ7JutJyHrYD5qzCk+U/N5T6fOS8oI53GaT3guEr3vwdyqUplVe9jC7J jT6Hmt9iMyHgKgqIocNjGY999DXwNj5oOhrsceD6qUMg+AzOZ2XfUaFu+BoJZel/UK3t6FXCW Gm3XpVRU8KNvcUqIYtN45bNfWCGSnBJbvD+HNhaGz4V2Weae2QuES41/vYKmG9K54cgnLcbn/ fkt2WYkkKc/N51R+NPUeUf94pKb8v2PyogaO0h+pPrmGPj9HB5QtLEsaQYiI3DqYq+NieS5rH GZ47Fsrv5boOgH2cvYlJd1pCMA4NKXzT4zTkatI5dNP0Hozp+dTxIBAnRpZgqxFEcZZ1pJdXu ExtTIPTHNcWTkxAT2mylfLCO8SUhNGjlErmBuk/4PDp4UDSsm+yamIw0cBU8KIlFZ44Ricsr7 kWZFNpfvcRlSaaWQvxxLSw6iWUuasO0DPy/HTQXBFBg7Kgokx5+yDCm9ecFtRFThJqhdnSg/0 8MQPah6Ky6OoteKyZqzYluWIORaueQCrK5oErcKXufprhGwuKWZeRl3o1d+EKX9XqSZOZPcC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.11 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:114989 Archived-At: Emanuel Berg writes: > I'm preparing one of my packs for MELPA so I go > thru the list of formal style > suggestions [1] ... > > One I don't know how to do is when there is > a default value. The info node that is > referenced in the suggestion list, namely > > (info "(elisp) Programming Tips") > > says the prompt string should look like this > > Enter the answer (default 42): > > However then it says it should be implemented > like this > > (defun foo (pos) > (interactive > (list (if SPECIFIED SPECIFIED-POS))) > (unless pos (setq pos DEFAULT-POS)) > ...) > > Note that DEFAULT-POS in this example does not > appear in the `interactive' form! So how does > it appear in the prompt string at all? > > And even if it did, how do you then get around > it without having to compute/fetch DEFAULT-POS > two times? One time for the prompt string, and > then again to set pos (in the abstract example > above)? > > Is there a real-code example somewhere when > this is done the right way? It depends on you case. How does it look like? I think there is no general answer. In most situations, the prompt will rather look like "Position (default: point)" instead of "Position (default 15327)". In other situations, it is not really a problem to let `interactive' return the default value, because when you repeat the command, you want to specify the argument anyway, and a reasonable "default" is not well-defined when repeating. In some cases, maybe your case is such a case, it is better to read the arguments in the body of the function and test with `called-interactively-p' whether that is necessary. Michael.