unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alan Mackenzie <acm@muc.de>
Subject: DEFUN in Emacs's C-code. Can I give "prompt" an arbitrary lisp expression?
Date: Thu, 14 Oct 2004 20:17:30 +0000	[thread overview]
Message-ID: <qsmmkc.r6.ln@acm.acm> (raw)

[N.B. "prompt" in an Emacs C-code DEFUN is what would be created by
`(interactive ...)' in a command written in lisp.]

Right now, I'm unhappy with the command `rename-buffer', because M-x
rename-buffer prompts with an empty string.  I'd far rather it prompted
with the current name of the buffer, allowing me to edit the name, rather
than requiring me to enter the entire name from scratch.

Why do I want this?  Because I often want to change names like
"longbuffername.el<2>" to "longbuffername.el", and that much typing is
tedious ;-).  Besides, the analogous `find-alternate-file' prompts with
the name of the current file.

rename-buffer's interactive form is "sRename buffer (to new name): \nP".
I'd like to change it to this lisp form:

(let ((n (buffer-name (current-buffer))))
   (read-string "New buffer name: " n nil n  t))

[OK, I'd need to think about the P on the end, but that's inessential for
now].  Can I do this directly in emacs/src/buffer.c, somehow?  I tried
this by just inserting the lisp form (not within string quotes), but got
only compiler errors.

Also, there appears to be no command/function `set-interactive-form' to
match `interactive-form'.  Pity.  ;-)

Now presumably I could do what I want by advising the function, somehow.
But it would be nice to hack the interactive form directly in the C
source.

Thanks in advance for any help.

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

             reply	other threads:[~2004-10-14 20:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-14 20:17 Alan Mackenzie [this message]
2004-10-14 20:46 ` DEFUN in Emacs's C-code. Can I give "prompt" an arbitrary lisp expression? Stefan Monnier
2004-10-14 22:18 ` Kevin Rodgers

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=qsmmkc.r6.ln@acm.acm \
    --to=acm@muc.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).