Emacs: Make elisp-index-search use Current Symbol

By Xah Lee. Date: . Last updated: .

Emacs's elisp-index-search command does not use the current symbol when called. This page shows code that fixes that, and also offer some other suggestions.

In emacs, you can press 【Ctrl+h f】 to see any emacs lisp function's doc string, and if the cursor is on a function, it defaults to lookup that function. This integrated facility is extremely convenient. However, some improvement can be made. Here are some suggestions:

Make elisp-index-search prompt Default to Current Symbol

Kevin Rodgers and others have suggested implementations. (Source groups.google.com) Here's one that works for me:

;; Kevin Rodgers 〔kevin.d.rodg…@gmail.com〕, 2008-10-09
(defadvice elisp-index-search (before interactive-default activate)
  "Provide the symbol at point as the default when reading TOPIC interactively."
   (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)))))

Link to Emacs Manual

Showing a link to elisp manual of pertinent page would be convenient. Because sometimes doc string is not detailed enough or doesn't provide context.

Link to Related Functions

Listing similar functions is a practical need. For example:

Listing related functions in a function's doc is in many programing lang manuals. e.g Mathematica, Microsoft's JScript, PHP. They are quite useful. Because, for those who are not yet expert of a language (which is majority), often they do not know similar functions or do not know if there's manual page that list such, and often are confused about the differences of many functions that seem the same. By providing a list of similar functions, a coder can easily locate the right function he need.

Note: some of the above suggestions are reported to emacs dev as bugs: bug#575, bug#1119.

Make describe-function Work for All Popular Languages

Extend describe-function to other languages than emacs lisp, would be a major improvement. For example, in Perl, to lookup a function, i have to type 【Meta+! perldoc -f function_name Enter】. To look up a function while coding in Python, i typically have to switch to shell, start Python interactive interpreter, type “help()” then the function's name. To lookup PHP keywords, i have to switch to browser then type “http://php.net/keyword”. Emacs can automate all these. When describe-function is called, it can simply check the value of “major-mode” local variable to determine the current language, then, switch to web browser with a appropriate URL for that function's doc. If the language's documentation does provide a info format, then the integration would be seamless. (for a proof of concept, see: Emacs: Lookup Google, Dictionary, Documentation.)

Emacs Modernization

  1. Simple Changes Emacs Should Adopt
  2. Why Emacs Keys are Painful
  3. Problems of the Scratch Buffer
  4. M-key Notation vs Alt+key Notation
  5. Menu Problem
  6. Mode Line Problem
  7. cua-mode Problems
  8. kill-buffer Induces Buffer Accumulation
  9. Emacs Form Feed ^L
  10. Inconsistency of Search Features
  11. Single Key to Delete Whole Line
  12. Emacs HTML Mode Sucks
  13. Emacs Does Not Support Viewing Images Files In Windows
  14. Emacs Spell Checker Problems
  15. Adopt HTML as Texinfo Replacement
  16. Support HTML Mail
  17. Problems of “man” Command
  18. Emacs Lisp Mode Syntax Coloring Problem
  19. Emacs Ahk Mode Problems
  20. Problems of Emacs's Manual
  21. Problems of Emacs's Manual; Examples
  22. Emacs: Have You Read Emacs Manual?
  23. Elisp: Ban Syntax Table
  24. Emacs: Make elisp-index-search use Current Symbol
  25. Emacs: Usability Problems of Mode Documentation
  26. Problems of Emacswiki
  27. Emacs GNU Texinfo Problems; Invalid HTML
  28. A Record of Frustration in IT Industry; Disappearing FSF URLs, 2006
  29. Emacs Manual Node Persistency Issues
  30. Emacs: dired-do-query-replace-regex Replace ALL (fixed)
  31. Problems of Emacs Supporting Obsolete Systems
  32. Elisp: Function to Copy/Delete a Dir Recursively (fixed)
  33. Thoughts on Common Lisp Scheme Lisp Based Emacs
  34. Text Editors Popularity and Market Research
  35. Text Editor's Cursor Movement Behavior (emacs, vi, Notepad++)
  36. GNU Emacs Development Inefficiency
  37. Emacs Dev Inefficiency and Emacs Web 2.0?
  38. Letter-Case Commands Usability Problems
  39. Emacs: Select Line, between Quotes, Extend Selection
  40. Emacs: isearch Current Word
  41. Suggestions on Line Wrap Commands
  42. Emacs: Single Key to Delete Whole Line
  43. Emacs Cult Problem: Emacs vs Windows Notepad
  44. Emacs Undo and Emacs Cult Problem

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp