Hi James, your version for showing documentation is surely much nicer than mine. One minor tip: Instead of your function cmake-find-word you could use the function word-at-point coming from the package thingatpt, which does exactly, what you need. This package is part of the current Emacs distribution.
Best Regards, Martin James Bigler wrote: > On Tue, Apr 28, 2009 at 8:21 AM, Martin Apel <martin.a...@simpack.de > <mailto:martin.a...@simpack.de>> wrote: > > Bill Hoffman wrote: > >> Martin Apel wrote: > >> > >>> Hi all, > >>> > >>> Inspired by the Emacs command cperl-perldoc-at-point I wrote a little > >>> command to show the CMake documentation of the command on which the > >>> cursor is currently positioned. It will open another buffer and > show the > >>> documentation generated from "cmake --help-command <command>" in that > >>> buffer. I found it very useful during creating CMakeLists.txt files. > >>> > >>> Bill, maybe it makes sense to integrate this into cmake-mode.el? > >>> > >>> > >> > >> Looks neat. Is there a better way in emacs to set the path to CMake? > >> On many systems I do not put cmake into the PATH. > >> > >> -Bill > >> > >> > > You could probably make it a variable, which would be settable through > > the customize interface of Emacs. I will look into it > > and repost it, when it's done. > > > > Martin > > > > This is pretty lean. I wrote something similar that I was testing. > > Some features: > > 1. Provides a default argument, but allows you type in something > different. > 2. Maintains a history of the arguments you have given. > 3. Allows you to run an arbitrary cmake command and put the output > into a named buffer. > 4. Runs the cmake command in the back. > 5. cmake executable is a customized variable. > > James > > (defun cmake-find-word () > "Finds the word on your cursor." > (interactive) > (let (word) > (save-excursion > ;; Find the end of the word > (forward-word) > (let ((end (point))) > ;; Find the beginning > (backward-word) > ;; Set the word > (setq word (buffer-substring-no-properties (point) end)) > ) > ) > ) > ) > > (defcustom cmake-mode-cmake-executable "cmake" > "*The name of the cmake executable. > This can be either absolute or looked up on `exec-path'." > ;; Don't use (file :must-match t). It doesn't know about `exec-path'. > :type 'file > :group 'cmake) > > (defun cmake-command-run (type &optional topic) > "Runs the command cmake with the arguments specified. The > optional argument topic will be appended to the argument list." > (interactive "s") > (let* ((bufname (concat "*CMake" type (if topic "-") topic "*")) > (buffer (get-buffer bufname)) > ) > (if buffer > (display-buffer buffer 'not-this-window) > ;; Buffer doesn't exist. Create it and fill it > (setq buffer (generate-new-buffer bufname)) > (setq command (concat cmake-mode-cmake-executable " " type " " > topic)) > (message "Running %s" command) > (shell-command command buffer) > ;; Save the original window, so that we can come back to it later. > ;; save-excursion doesn't seem to work for this. > (setq window (selected-window)) > ;; We need to select it so that we can apply special modes to it > (select-window (display-buffer buffer 'not-this-window)) > (cmake-mode) > (toggle-read-only t) > ;; Restore the original window > (select-window window) > ) > ) > ) > > (defun cmake-help-list-commands () > "Prints out a list of the cmake commands." > (interactive) > (cmake-command-run "--help-command-list") > ) > > (defvar cmake-help-command-history nil "Topic read history.") > > (defun cmake-get-topic (type) > "Gets the topic from the minibuffer input. The default is the word > the cursor is on." > (interactive) > (let* ((default-entry (cmake-find-word)) > (input (read-string > (format "CMake %s (default %s): " type default-entry) > ; prompt > nil ; initial input > 'cmake-help-command-history ; command history > default-entry ; default-value > ))) > (if (string= input "") > (error "No argument given") > input)) > ) > > > (defun cmake-help-command () > "Prints out the help message corresponding to the command the cursor > is on." > (interactive) > (setq command (cmake-get-topic "command")) > (cmake-command-run "--help-command" (downcase command)) > ) -- Martin Apel Tel: 0049 8153 9288-47 Software Architect E-Mail: martin.a...@simpack.de INTEC GmbH Tel: 0049 8153 9288-0 Argelsrieder Feld 13 Fax: 0049 8153 9288-11 82234 Wessling E-Mail: in...@simpack.de Germany URL: http://www.simpack.com ____________ Virus checked by G DATA AntiVirus Version: AVB 19.313 from 28.04.2009 _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake