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

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

DEFUN in Emacs's C-code. Can I give "prompt" an arbitrary lisp expressio


From: Alan Mackenzie
Subject: DEFUN in Emacs's C-code. Can I give "prompt" an arbitrary lisp expression?
Date: Thu, 14 Oct 2004 20:17:30 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

[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 via email to

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