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

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

Re: Splitting the input string in interactive


From: Heime
Subject: Re: Splitting the input string in interactive
Date: Thu, 05 Sep 2024 14:15:30 +0000

On Friday, September 6th, 2024 at 1:55 AM, Michael Heerdegen via Users list for 
the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Heime heimeborgia@protonmail.com writes:
> 
> > > How much of the docstring did you read ? - Michael.
> > 
> > Currently one has to input a literal string from what I understood.
> > Not variables or expressions.
> 
> 
> You can also specify an expression - an expression that returns the list
> of arguments. But not an interactive ARG-DESCRIPTOR - the arguments as
> a list, at runtime.
> 
> 
> What you can do:
> 
> (1) Rewrite your interactive form to use an expression that returns the
> argument list to use. Something like
> 
> #+begin_src emacs-lisp
> (interactive (list (read-string ...) (read-number ...))
> #+end_src
> 
> or (2)
> 
> There is a read syntax for "escaped" line breaks in strings. Not only
> for interactive arguments descriptors - for any strings. For example in
> your case this would look like:
> 
> #+begin_src emacs-lisp
> (call-interactively (lambda (s n) (interactive "\
> sEnter search text: \n\
> nEnter number of context lines: ")
> (list s n)))
> #+end_src
> 
> or (the explicit newline character and escaping the line break cancel out
> each other) simplified
> 
> #+begin_src emacs-lisp
> (call-interactively (lambda (s n) (interactive "\
> sEnter search text:
> nEnter number of context lines: ")
> (list s n)))
> #+end_src
> 
> Note that it is an error to indent the string's lines here, since the
> indentation would get part of the string's contents. Emacs's
> indentation commands know about this. Looks a bit unusual first but one
> gets used to it. - Michael.

Correct.  I do not see much code using it, interactive usage frequently 
uses the list approach.



reply via email to

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