Article View: gnu.emacs.help
Article #189589How to read a word from a buffer for use as a variable in a function.
From: southern
Date: Wed, 02 Jan 1991 18:11
Date: Wed, 02 Jan 1991 18:11
40 lines
2033 bytes
2033 bytes
When looking up documentation on words in a text file, I use the
following function which reads the word to be documented from the
minibuffer:
(defun get-man (current-word)
"Look up documentation"
(interactive "s Enter word to man: ")
(shell-command (concat "man " current-word))
)
For clarity, I've substituted "man" in place of the name of the local
help script that I use.
Typing the word into the minibuffer is proving cumbersome and I would
like to find a way to make the function look up the documentation for
the word that the cursor is currently on. I will also be checking the
case of the current-word and issue a shell-command "man" for the all
lower-case solution and "help" for the any upper-case letter solution
I imagine the definition would look something like:
(defun get-man-on-current-word (current-word)
"Look up documentation on current word"
(interactive)
(somehow-read current-word)
(if (equal current-word (downcase current-word))
(shell-command (concat "man " current-word)
(shell-command (concat "help " current-word)
)
)
The bit I don't know is how to somehow-read the current-word from the
text without hand-typing it in through the minibuffer. Can anyone
offer me some assistance with this?
Lawrence Buja
southern@ncar.ucar.edu
Technical Details
Message-ID:
<9718@ncar.ucar.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!asuvax!ncar!neit.cgd.ucar.edu!southernShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,b807e53d2a9d4174,start X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-01-02 10:52:42 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!asuvax!ncar!neit.cgd.ucar.edu!southern From: southern@neit.cgd.ucar.edu Newsgroups: gnu.emacs.help Subject: How to read a word from a buffer for use as a variable in a function. Message-ID: <9718@ncar.ucar.edu> Date: 2 Jan 91 18:11:08 GMT Sender: news@ncar.ucar.edu Reply-To: southern@neit.cgd.ucar.edu () Organization: Climate and Global Dynamics Division/NCAR, Boulder, CO Lines: 40