elisp-index-search on current word

24 views
Skip to first unread message

Xah

unread,
Oct 7, 2008, 9:31:54 PM10/7/08
to
when i do elisp-index-search, is there a way to make the default
choice the symbol the cursor is on?

Xah
http://xahlee.org/


Thierry Volpiatto

unread,
Oct 8, 2008, 2:07:21 AM10/8/08
to help-gn...@gnu.org
Xah <xah...@gmail.com> writes:

> when i do elisp-index-search, is there a way to make the default
> choice the symbol the cursor is on?

,----
| (defun tv-get-index-at-point ()
| (interactive)
| (let ((expr (thing-at-point 'sexp)))
| (elisp-index-search expr)))
`----


--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France

Kevin Rodgers

unread,
Oct 8, 2008, 3:20:59 AM10/8/08
to help-gn...@gnu.org
Xah wrote:
> when i do elisp-index-search, is there a way to make the default
> choice the symbol the cursor is on?

(defadvice elisp-index-search (before interactive-default activate)
"Provide the symbol at point as the default when reading TOPIC
interactively."
(interactive (list (read-string "Topic: " nil nil (thing-at-point
'symbol)))))

--
Kevin Rodgers
Denver, Colorado, USA

Andy Stewart

unread,
Oct 8, 2008, 10:21:26 AM10/8/08
to
Kevin Rodgers <kevin.d...@gmail.com> writes:
> Xah wrote:
>> when i do elisp-index-search, is there a way to make the default
>> choice the symbol the cursor is on?
>
> (defadvice elisp-index-search (before interactive-default activate)
> "Provide the symbol at point as the default when reading TOPIC interactively."
> (interactive (list (read-string "Topic: " nil nil (thing-at-point 'symbol)))))

(defun elisp-index-search+ ()
"Look up TOPIC in the indices of the Emacs Lisp Reference Manual."
(interactive)
(let (topic)
(setq topic (read-string (concat "Subject to look up: ") nil nil (symbol-name (symbol-at-point))))
(funcall 'switch-to-buffer-other-window nil)
(info "elisp")
(Info-index topic)))

Regards.

-- Andy.

Xah

unread,
Oct 8, 2008, 12:11:01 PM10/8/08
to
On Oct 8, 7:21 am, Andy Stewart <lazycat.mana...@gmail.com> wrote:
> Kevin Rodgers <kevin.d.rodg...@gmail.com> writes:
> >Xahwrote:

Thierry wrote:
,----
| (defun tv-get-index-at-point ()
| (interactive)
| (let ((expr (thing-at-point 'sexp)))
| (elisp-index-search expr)))
`----

among the 3 suggestions, it seems only Thierry's version works for me.

is there a reason why it shouldn't prompt for current symbol? I think
its also useful for describe-function to provide a link to the elisp
manual at bottom. I just filed a bug report btw.

Xah
http://xahlee.org/


Thierry Volpiatto

unread,
Oct 8, 2008, 1:19:51 PM10/8/08
to help-gn...@gnu.org
Xah <xah...@gmail.com> writes:

No you can have a prompt, (use <arrow down> to display thing-at-point)

,----
| (defun tv-get-index-at-point (expr)
| (interactive
| (list (read-from-minibuffer "Search: "
| nil
| nil
| nil
| nil
| (thing-at-point 'sexp))))
| (elisp-index-search expr))

Kevin Rodgers

unread,
Oct 8, 2008, 10:49:45 PM10/8/08
to help-gn...@gnu.org

What happens when you call my version or Andy's version?

Richard Riley

unread,
Oct 9, 2008, 9:54:24 AM10/9/08
to
Thierry Volpiatto <thierry....@gmail.com> writes:

Would it be possible to have the thing at point displayed like most
defaults when you call the function? e.g If you hit search in most
editors one would normally see the word at point or region preselected
in the "search" field.


--
I think I should not go far wrong if I asserted that the amount of genuine leisure available in a society is generally in inverse proportion to the amount of labor-saving machinery it employs. ~E.F. Schumacher

Xah

unread,
Oct 9, 2008, 11:00:59 AM10/9/08
to

it didn't prompt the symbol under cursor. I tried up arrow but i
didn't try down arrow; should've.

I filed a bug report on this issue. I think it should prompt the
symbol under cursor like most other lookup commands such as describe-
function, where the current symbol is shown inside the prompt text.

Xah
http://xahlee.org/


Kevin Rodgers

unread,
Oct 9, 2008, 10:07:55 PM10/9/08
to help-gn...@gnu.org

Try moving (thing-at-point 'sexp) from the DEFAULT argument to the
INITIAL-CONTENTS argument, for either read-string or
read-from-minibuffer. Note that the doc string for both functions says
the INITIAL-CONTENTS argument is deprecated.

Kevin Rodgers

unread,
Oct 9, 2008, 10:18:59 PM10/9/08
to help-gn...@gnu.org
Xah wrote:
> On Oct 8, 7:49 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
>> What happens when you call my version or Andy's version?
>
> it didn't prompt the symbol under cursor. I tried up arrow but i
> didn't try down arrow; should've.

Yes, <down> would have worked.

> I filed a bug report on this issue. I think it should prompt the
> symbol under cursor like most other lookup commands such as describe-
> function, where the current symbol is shown inside the prompt text.

Ah, to get the conventional prompt:

(defadvice elisp-index-search (before interactive-default activate)
"Provide the symbol at point as the default when reading TOPIC
interactively."

(interactive (let ((symbol-at-point (thing-at-point 'symbol)))
(list (read-string (if symbol-at-point
(format "Topic (%s): " symbol-at-point)
(format "Topic: "))
nil nil symbol-at-point)))))

Xah

unread,
Oct 9, 2008, 10:36:07 PM10/9/08
to
On Oct 9, 7:18 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:

> Ah, to get the conventional prompt:
>
> (defadvice elisp-index-search (before interactive-default activate)
>    "Provide the symbol at point as the default when reading TOPIC
> interactively."
>    (interactive (let ((symbol-at-point (thing-at-point 'symbol)))
>                  (list (read-string (if symbol-at-point
>                                         (format "Topic (%s): " symbol-at-point)
>                                       (format "Topic: "))
>                                     nil nil symbol-at-point)))))

Thanks! Super.

Xah
http://xahlee.org/

Richard Riley

unread,
Oct 10, 2008, 4:41:30 AM10/10/08
to
Kevin Rodgers <kevin.d...@gmail.com> writes:

Your reply to Xah with the default value in the "conventional prompt" did
the job too - thanks.

Reply all
Reply to author
Forward
0 new messages