all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Cc: egarrulo <egarrulo@gmail.com>
Subject: Re: Running an extended command with default input?
Date: Mon, 7 Mar 2016 10:38:39 -0800	[thread overview]
Message-ID: <CAOj2CQTjBFoiY8KcJOewUa3oYwnbEEg282Yf3QMY4gAiCofvdQ@mail.gmail.com> (raw)
In-Reply-To: <dk5jtpFc9feU1@mid.individual.net>

egarrulo <egarrulo@gmail.com> wrote:
> How can you run an extended command with a default input? For example:
> `eval-expression` with `(+ 1 1)` as default input (in other words:
> what you would accomplish by typing `M-: (+ 1 1)` without RET). This
> code works, but it seems to add an implicit RET:
>
> (execute-kbd-macro (vconcat (kbd (substitute-command-keys "\\[eval-expression] "))
>                             "(+ 1 1)"))

One option is to define your own command, which reads the input itself
(providing the default) and then invokes the underlying command. For
instance, for ‘eval-expression’ you could do something like:

    (defun my-eval-expression (exp &optional insert-value)
      (interactive (list (read--expression "Eval: " "(+ 1 1)")
                         current-prefix-arg))
      (eval-expression exp insert-value))

-- 
john



      reply	other threads:[~2016-03-07 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 15:09 Running an extended command with default input? egarrulo
2016-03-07 18:38 ` John Mastro [this message]

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

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

  git send-email \
    --in-reply-to=CAOj2CQTjBFoiY8KcJOewUa3oYwnbEEg282Yf3QMY4gAiCofvdQ@mail.gmail.com \
    --to=john.b.mastro@gmail.com \
    --cc=egarrulo@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.