help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

default value with interactive


From: Emanuel Berg
Subject: default value with interactive
Date: Sun, 19 Nov 2017 20:08:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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?

[1] https://github.com/melpa/melpa/blob/master/CONTRIBUTING.md

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]