I am wondering how is that some interactive commands in emacs present default value while others don't. For instance when I am in C file and cursor stands on printf
, running manual-entry
will suggest showing manual page for printf
by default. I would like to make my own interactive commands with default value. How?
It seems like thing-at-point is a good direction, but how do I blend thing-at-point and interactive together?
Asked
Active
Viewed 5,537 times
29

N.N.
- 8,336
- 12
- 54
- 94

Alexander Sandler
- 2,078
- 2
- 19
- 21
1 Answers
33
You already have good starting points to research your own solution.
thing-at-point
is probably useful in this context. I recently answered
a question where I explained how to solve this type of problem by exploring the
Emacs code base.
Here is a rough toy function I came up with.
(defun say-word (word)
(interactive (list
(read-string (format "word (%s): " (thing-at-point 'word))
nil nil (thing-at-point 'word))))
(message "The word is %s" word))
One key thing here is to understand how the interactive
form works. I would
read the relevant manual section carefully.
-
This seems like exactly what I was looking for. Thanks a lot! – Alexander Sandler Mar 10 '12 at 12:23