summaryrefslogtreecommitdiffstats
path: root/Docs
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-09-30 13:49:52 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-09-30 13:49:52 (GMT)
commit3b34523bc052e6bd98c35ea1e26cd622e578dd69 (patch)
tree934ee2abb5a7a1f08f6e3c932fc88ed22a8f79b9 /Docs
parente1729238c902c757a7812a6f6d6128118ae34fbf (diff)
downloadCMake-3b34523bc052e6bd98c35ea1e26cd622e578dd69.zip
CMake-3b34523bc052e6bd98c35ea1e26cd622e578dd69.tar.gz
CMake-3b34523bc052e6bd98c35ea1e26cd622e578dd69.tar.bz2
Add cmake-help-command function.
Diffstat (limited to 'Docs')
-rw-r--r--Docs/cmake-mode.el84
1 files changed, 84 insertions, 0 deletions
diff --git a/Docs/cmake-mode.el b/Docs/cmake-mode.el
index 3391c10..2f51f83 100644
--- a/Docs/cmake-mode.el
+++ b/Docs/cmake-mode.el
@@ -30,7 +30,22 @@
;------------------------------------------------------------------------------
;;; Code:
+;;
+;; cmake executable variable used to run cmake --help-command
+;; on commands in cmake-mode
+;;
+;; cmake-command-help Written by James Bigler
+;;
+(defcustom cmake-mode-cmake-executable "cmake"
+ "*The name of the cmake executable.
+
+This can be either absolute or looked up in $PATH. You can also
+set the path with these commands:
+ (setenv \"PATH\" (concat (getenv \"PATH\") \";C:\\\\Program Files\\\\CMake 2.8\\\\bin\"))
+ (setenv \"PATH\" (concat (getenv \"PATH\") \":/usr/local/cmake/bin\"))"
+ :type 'file
+ :group 'cmake)
;;
;; Regular expressions used by line indentation function.
;;
@@ -249,6 +264,75 @@ the indentation. Otherwise it retains the same position on the line"
; Run user hooks.
(run-hooks 'cmake-mode-hook))
+; Help mode starts here
+
+
+(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)
+ ;; We don't want the contents of the shell-command running to the
+ ;; minibuffer, so turn it off. A value of nil means don't automatically
+ ;; resize mini-windows.
+ (setq resize-mini-windows-save resize-mini-windows)
+ (setq resize-mini-windows nil)
+ (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)
+ (setq resize-mini-windows resize-mini-windows-save)
+ )
+ )
+ )
+
+(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.")
+
+(require 'thingatpt)
+(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 (word-at-point))
+ (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))
+ )
+
+
; This file provides cmake-mode.
(provide 'cmake-mode)