unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Splitting the input string in interactive
Date: Thu, 05 Sep 2024 14:15:30 +0000	[thread overview]
Message-ID: <JoBOVsiwYTi-CJyAfk4efonqugQ8NWGqaw4wwpiWi6tkS5zsvetuQ9Yy00I-jvjDeGqf35FsuquODzSOHyGsWpm2n5hKibZiLXnPGL5og0I=@protonmail.com> (raw)
In-Reply-To: <875xra2oim.fsf@web.de>


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	other threads:[~2024-09-05 14:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05 12:04 Splitting the input string in interactive Heime
2024-09-05 12:21 ` tomas
2024-09-05 12:31   ` Heime
2024-09-05 12:36     ` tomas
2024-09-05 12:54       ` Heime
2024-09-05 13:04         ` Michael Heerdegen via Users list for the GNU Emacs text editor
2024-09-05 13:11           ` Heime
2024-09-05 13:55             ` Michael Heerdegen via Users list for the GNU Emacs text editor
2024-09-05 14:15               ` Heime [this message]
2024-09-05 14:30                 ` Heime
2024-09-05 15:23                   ` Michael Heerdegen via Users list for the GNU Emacs text editor
2024-09-05 13:19         ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='JoBOVsiwYTi-CJyAfk4efonqugQ8NWGqaw4wwpiWi6tkS5zsvetuQ9Yy00I-jvjDeGqf35FsuquODzSOHyGsWpm2n5hKibZiLXnPGL5og0I=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).