Thanks for the suggestion.  word-at-point works better than my hand rolled code.<br><br>Here&#39;s the updated version.  I also fixed a slight annoyance where if the help command output was short enough it would print the outout to both the help buffer and the minibuffer.<br>

<br>I&#39;m also open to additional suggestions.<br><br>James<br><br><span style="font-family: courier new,monospace;">(defcustom cmake-mode-cmake-executable &quot;cmake&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  &quot;*The name of the cmake executable.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">This can be either absolute or looked up on `exec-path&#39;.&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  ;; Don&#39;t use (file :must-match t).  It doesn&#39;t know about `exec-path&#39;.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  :type &#39;file</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  :group &#39;cmake)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(defun cmake-command-run (type &amp;optional topic)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  &quot;Runs the command cmake with the arguments specified.  The</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">optional argument topic will be appended to the argument list.&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  (interactive &quot;s&quot;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (let* ((bufname (concat &quot;*CMake&quot; type (if topic &quot;-&quot;) topic &quot;*&quot;))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">         (buffer  (get-buffer bufname))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         )</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    (if buffer</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        (display-buffer buffer &#39;not-this-window)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      ;; Buffer doesn&#39;t exist.  Create it and fill it</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      (setq buffer (generate-new-buffer bufname))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      (setq command (concat cmake-mode-cmake-executable &quot; &quot; type &quot; &quot; topic))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      (message &quot;Running %s&quot; command)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      ;; We don&#39;t want the contents of the shell-command running to the</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      ;; minibuffer, so turn it off.  A value of nil means don&#39;t automatically</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      ;; resize mini-windows.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      (setq resize-mini-windows-save resize-mini-windows)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      (setq resize-mini-windows nil)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      (shell-command command buffer)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      ;; Save the original window, so that we can come back to it later.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      ;; save-excursion doesn&#39;t seem to work for this.</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      (setq window (selected-window))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      ;; We need to select it so that we can apply special modes to it</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      (select-window (display-buffer buffer &#39;not-this-window))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      (cmake-mode)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      (toggle-read-only t)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      ;; Restore the original window</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      (select-window window)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      (setq resize-mini-windows resize-mini-windows-save)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">      )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    )</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(defun cmake-help-list-commands ()</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  &quot;Prints out a list of the cmake commands.&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (interactive)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  (cmake-command-run &quot;--help-command-list&quot;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(defvar cmake-help-command-history nil &quot;Topic read history.&quot;)</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(require &#39;thingatpt)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(defun cmake-get-topic (type)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  &quot;Gets the topic from the minibuffer input.  The default is the word the cursor is on.&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (interactive)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  (let* ((default-entry (word-at-point))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         (input (read-string</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">                 (format &quot;CMake %s (default %s): &quot; type default-entry) ; prompt</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                 nil ; initial input</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">                 &#39;cmake-help-command-history ; command history</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                 default-entry ; default-value</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">                 )))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    (if (string= input &quot;&quot;)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">        (error &quot;No argument given&quot;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      input))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(defun cmake-help-command ()</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  &quot;Prints out the help message corresponding to the command the cursor is on.&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (interactive)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  (setq command (cmake-get-topic &quot;command&quot;))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (cmake-command-run &quot;--help-command&quot; (downcase command))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;"><br><br>On Wed, Apr 29, 2009 at 2:58 AM, Martin Apel &lt;<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt; wrote:<br>

&gt; Hi James,<br>&gt;<br>&gt; your version for showing documentation is surely much nicer than mine.<br>&gt; One minor tip: Instead of your function cmake-find-word you could use<br>&gt; the function word-at-point coming from the package thingatpt, which does<br>

&gt; exactly, what you need. This package is part of the current Emacs<br>&gt; distribution.<br>&gt;<br>&gt; Best Regards,<br>&gt;<br>&gt; Martin<br>&gt;<br>&gt; James Bigler wrote:<br>&gt;&gt; On Tue, Apr 28, 2009 at 8:21 AM, Martin Apel &lt;<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a><br>

&gt;&gt; &lt;mailto:<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt;&gt; wrote:<br>&gt;&gt; &gt; Bill Hoffman wrote:<br>&gt;&gt; &gt;&gt; Martin Apel wrote:<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt;&gt; Hi all,<br>

&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt; Inspired by the Emacs command cperl-perldoc-at-point I wrote a little<br>&gt;&gt; &gt;&gt;&gt; command to show the CMake documentation of the command on which the<br>&gt;&gt; &gt;&gt;&gt; cursor is currently positioned. It will open another buffer and<br>

&gt;&gt; show the<br>&gt;&gt; &gt;&gt;&gt; documentation generated from &quot;cmake --help-command &lt;command&gt;&quot; in that<br>&gt;&gt; &gt;&gt;&gt; buffer. I found it very useful during creating CMakeLists.txt files.<br>

&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt; Bill, maybe it makes sense to integrate this into cmake-mode.el?<br>&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; Looks neat.  Is there a better way in emacs to set the path to CMake?<br>

&gt;&gt; &gt;&gt; On many systems I do not put cmake into the PATH.<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; -Bill<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt; You could probably make it a variable, which would be settable through<br>

&gt;&gt; &gt; the customize interface of Emacs. I will look into it<br>&gt;&gt; &gt; and repost it, when it&#39;s done.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; Martin<br>&gt;&gt; &gt;<br>&gt;&gt;<br>&gt;&gt; This is pretty lean.  I wrote something similar that I was testing.<br>

&gt;&gt;<br>&gt;&gt; Some features:<br>&gt;&gt;<br>&gt;&gt; 1. Provides a default argument, but allows you type in something<br>&gt;&gt; different.<br>&gt;&gt; 2. Maintains a history of the arguments you have given.<br>&gt;&gt; 3. Allows you to run an arbitrary cmake command and put the output<br>

&gt;&gt; into a named buffer.<br>&gt;&gt; 4. Runs the cmake command in the back.<br>&gt;&gt; 5. cmake executable is a customized variable.<br>&gt;&gt;<br>&gt;&gt; James<br>&gt;&gt;<br>&gt;&gt; (defun cmake-find-word ()<br>

&gt;&gt;  &quot;Finds the word on your cursor.&quot;<br>&gt;&gt;  (interactive)<br>&gt;&gt;  (let (word)<br>&gt;&gt;    (save-excursion<br>&gt;&gt;      ;; Find the end of the word<br>&gt;&gt;      (forward-word)<br>&gt;&gt;      (let ((end (point)))<br>

&gt;&gt;        ;; Find the beginning<br>&gt;&gt;        (backward-word)<br>&gt;&gt;        ;; Set the word<br>&gt;&gt;        (setq word (buffer-substring-no-properties (point) end))<br>&gt;&gt;        )<br>&gt;&gt;      )<br>

&gt;&gt;    )<br>&gt;&gt;  )<br>&gt;&gt;<br>&gt;&gt; (defcustom cmake-mode-cmake-executable &quot;cmake&quot;<br>&gt;&gt;   &quot;*The name of the cmake executable.<br>&gt;&gt; This can be either absolute or looked up on `exec-path&#39;.&quot;<br>

&gt;&gt;   ;; Don&#39;t use (file :must-match t).  It doesn&#39;t know about `exec-path&#39;.<br>&gt;&gt;   :type &#39;file<br>&gt;&gt;   :group &#39;cmake)<br>&gt;&gt;<br>&gt;&gt; (defun cmake-command-run (type &amp;optional topic)<br>

&gt;&gt;  &quot;Runs the command cmake with the arguments specified.  The<br>&gt;&gt; optional argument topic will be appended to the argument list.&quot;<br>&gt;&gt;  (interactive &quot;s&quot;)<br>&gt;&gt;  (let* ((bufname (concat &quot;*CMake&quot; type (if topic &quot;-&quot;) topic &quot;*&quot;))<br>

&gt;&gt;         (buffer  (get-buffer bufname))<br>&gt;&gt;         )<br>&gt;&gt;    (if buffer<br>&gt;&gt;        (display-buffer buffer &#39;not-this-window)<br>&gt;&gt;      ;; Buffer doesn&#39;t exist.  Create it and fill it<br>

&gt;&gt;      (setq buffer (generate-new-buffer bufname))<br>&gt;&gt;      (setq command (concat cmake-mode-cmake-executable &quot; &quot; type &quot; &quot;<br>&gt;&gt; topic))<br>&gt;&gt;      (message &quot;Running %s&quot; command)<br>

&gt;&gt;      (shell-command command buffer)<br>&gt;&gt;      ;; Save the original window, so that we can come back to it later.<br>&gt;&gt;      ;; save-excursion doesn&#39;t seem to work for this.<br>&gt;&gt;      (setq window (selected-window))<br>

&gt;&gt;      ;; We need to select it so that we can apply special modes to it<br>&gt;&gt;      (select-window (display-buffer buffer &#39;not-this-window))<br>&gt;&gt;      (cmake-mode)<br>&gt;&gt;      (toggle-read-only t)<br>

&gt;&gt;      ;; Restore the original window<br>&gt;&gt;      (select-window window)<br>&gt;&gt;      )<br>&gt;&gt;    )<br>&gt;&gt;  )<br>&gt;&gt;<br>&gt;&gt; (defun cmake-help-list-commands ()<br>&gt;&gt;  &quot;Prints out a list of the cmake commands.&quot;<br>

&gt;&gt;  (interactive)<br>&gt;&gt;  (cmake-command-run &quot;--help-command-list&quot;)<br>&gt;&gt;  )<br>&gt;&gt;<br>&gt;&gt; (defvar cmake-help-command-history nil &quot;Topic read history.&quot;)<br>&gt;&gt;<br>&gt;&gt; (defun cmake-get-topic (type)<br>

&gt;&gt;  &quot;Gets the topic from the minibuffer input.  The default is the word<br>&gt;&gt; the cursor is on.&quot;<br>&gt;&gt;  (interactive)<br>&gt;&gt;  (let* ((default-entry (cmake-find-word))<br>&gt;&gt;         (input (read-string<br>

&gt;&gt;                 (format &quot;CMake %s (default %s): &quot; type default-entry)<br>&gt;&gt; ; prompt<br>&gt;&gt;                 nil ; initial input<br>&gt;&gt;                 &#39;cmake-help-command-history ; command history<br>

&gt;&gt;                 default-entry ; default-value<br>&gt;&gt;                 )))<br>&gt;&gt;    (if (string= input &quot;&quot;)<br>&gt;&gt;        (error &quot;No argument given&quot;)<br>&gt;&gt;      input))<br>
&gt;&gt;  )<br>
&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; (defun cmake-help-command ()<br>&gt;&gt;  &quot;Prints out the help message corresponding to the command the cursor<br>&gt;&gt; is on.&quot;<br>&gt;&gt;  (interactive)<br>&gt;&gt;  (setq command (cmake-get-topic &quot;command&quot;))<br>

&gt;&gt;  (cmake-command-run &quot;--help-command&quot; (downcase command))<br>&gt;&gt;  )<br>&gt;<br>&gt;<br>&gt; --<br>&gt;<br>&gt; Martin Apel                                     Tel:     0049 8153 9288-47<br>&gt; Software Architect                              E-Mail:  <a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a><br>

&gt;<br>&gt; INTEC GmbH                                      Tel:     0049 8153 9288-0<br>&gt; Argelsrieder Feld 13                            Fax:     0049 8153 9288-11<br>&gt; 82234 Wessling                                  E-Mail:  <a href="mailto:intec@simpack.de">intec@simpack.de</a><br>

&gt; Germany                                         URL:     <a href="http://www.simpack.com">http://www.simpack.com</a><br>&gt;<br>&gt; ____________<br>&gt; Virus checked by G DATA AntiVirus<br>&gt; Version: AVB 19.313 from 28.04.2009<br>

&gt;<br>&gt;<br>&gt;<br><br>