Emacs: Make elisp-index-search use Current Symbol
Emacs 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:
- (1) Make
elisp-index-search
's default prompt to be the word under cursor. This seems useful and consistent with other emacs lookup commands. - (2) Make
describe-function
's result display a link to the elisp manual's node on that function. - (3) Make
describe-function
's result display related functions as in “See also: …” - (4) Extend
describe-function
so that it is not just for emacs lisp, but for any language as determined by the current mode.
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." (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)))))
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:
search-forward
-
See also:
search-forward-regexp
,skip-chars-forward
,looking-at
. find-file
-
See also:
with-temp-buffer
,with-temp-file
. mapcar
-
See also:
mapc
. beginning-of-line
-
See also:
line-beginning-position
,move-beginning-of-line
,previous-line
.
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:
Elisp: Command to Lookup Doc.)
Emacs Modernization
- Emacs Modernization: Simple Changes Emacs Should Adopt
- Why Emacs Keys are Painful
- Emacs: Problems of the Scratch Buffer
- Emacs Modernization: Meta Key Notation
- Emacs Menu Usability Problem
- Emacs Mode Line Problem
- Emacs cua-mode Problems
- Emacs: Inconsistency of Search Features
- Problems of grep in Emacs
- Emacs: Usability Problems of Mode Documentation
- Problems of Emacs Manual
- Emacs Manual Sucks by Examples
- Emacs: kill-buffer Induces Buffer Accumulation
- Emacs Spell Checker Problems
- Emacs: Form Feed ^L Problem
- Emacs: Single Key to Delete Whole Line
- Emacs HTML Mode Sucks
- Emacs Does Not Support Viewing Images Files In Windows
- Emacs Should Adopt HTML as Texinfo Replacement
- Emacs Should Support HTML Mail
- Problems of Emacs's “man” Command
- Emacs Lisp Mode Syntax Coloring Problem
- Emacs AutoHotkey Mode Problems
- Elisp: Ban Syntax Table
- Emacs: Make elisp-index-search use Current Symbol
- Emacs GNU Texinfo Problems; Invalid HTML
- A Record of Frustration in IT Industry; Disappearing FSF URLs, 2006
- Emacs Manual Node Persistency Issues
- Emacs: dired-do-query-replace-regex Replace ALL (fixed)
- Problems of Emacs Supporting Obsolete Systems
- Elisp: Function to Copy/Delete a Dir Recursively (fixed)
- Thoughts on Common Lisp Scheme Lisp Based Emacs
- Text Editors Popularity and Market Research
- Text Editor's Cursor Movement Behavior (emacs, vi, Notepad++)
- Emacs: Usability Problems of Letter-Case Changing Commands
- Emacs Select Word Command Problem
- Emacs: Search Current Word 🚀
- Emacs fill-paragraph Problem