summaryrefslogtreecommitdiff
path: root/Auxiliary
diff options
context:
space:
mode:
authorcondy <condy0919@gmail.com>2020-12-05 04:50:51 +0800
committercondy <condy0919@gmail.com>2020-12-09 01:21:38 +0800
commit54b409094ddd623afe3e24c10ba17b3f379f768c (patch)
treeda64116400a526f910b2d03c53c759270d02e8c6 /Auxiliary
parent7775cbdb821b928dbdb382c18977d78d4e8ea48d (diff)
downloadcmake-54b409094ddd623afe3e24c10ba17b3f379f768c.tar.gz
cmake-mode.el: Improve help display with reStructuredText mode
Many of the `cmake --help-*` options print `.rst` source documents with only partial evaluation. View them in the Emacs `rst-mode`.
Diffstat (limited to 'Auxiliary')
-rw-r--r--Auxiliary/cmake-mode.el41
1 files changed, 31 insertions, 10 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el
index c3733ab254..6137ea92a5 100644
--- a/Auxiliary/cmake-mode.el
+++ b/Auxiliary/cmake-mode.el
@@ -27,6 +27,8 @@
;; cmake-command-help Written by James Bigler
;;
+(require 'rst)
+
(defcustom cmake-mode-cmake-executable "cmake"
"*The name of the cmake executable.
@@ -264,10 +266,29 @@ optional argument topic will be appended to the argument list."
)
;;;###autoload
+(defun cmake-command-run-help (type &optional topic buffer)
+ "`cmake-command-run' but rendered in `rst-mode'."
+ (interactive "s")
+ (let* ((bufname (if buffer buffer (concat "*CMake" type (if topic "-") topic "*")))
+ (buffer (if (get-buffer bufname) (get-buffer bufname) (generate-new-buffer bufname)))
+ (command (concat cmake-mode-cmake-executable " " type " " topic))
+ ;; Turn of resizing of mini-windows for shell-command.
+ (resize-mini-windows nil)
+ )
+ (shell-command command buffer)
+ (save-selected-window
+ (select-window (display-buffer buffer 'not-this-window))
+ (rst-mode)
+ (read-only-mode 1)
+ (view-mode 1))
+ )
+ )
+
+;;;###autoload
(defun cmake-help-list-commands ()
"Prints out a list of the cmake commands."
(interactive)
- (cmake-command-run "--help-command-list")
+ (cmake-command-run-help "--help-command-list")
)
(defvar cmake-commands '() "List of available topics for --help-command.")
@@ -293,7 +314,7 @@ and store the result as a list in LISTVAR."
(if (not (symbol-value listvar))
(let ((temp-buffer-name "*CMake Temporary*"))
(save-window-excursion
- (cmake-command-run (concat "--help-" listname "-list") nil temp-buffer-name)
+ (cmake-command-run-help (concat "--help-" listname "-list") nil temp-buffer-name)
(with-current-buffer temp-buffer-name
; FIXME: Ignore first line if it is "cmake version ..." from CMake < 3.0.
(set listvar (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n" t)))))
@@ -327,25 +348,25 @@ and store the result as a list in LISTVAR."
(defun cmake-help-command ()
"Prints out the help message for the command the cursor is on."
(interactive)
- (cmake-command-run "--help-command" (cmake-help-type "command") "*CMake Help*"))
+ (cmake-command-run-help "--help-command" (cmake-help-type "command") "*CMake Help*"))
;;;###autoload
(defun cmake-help-module ()
"Prints out the help message for the module the cursor is on."
(interactive)
- (cmake-command-run "--help-module" (cmake-help-type "module") "*CMake Help*"))
+ (cmake-command-run-help "--help-module" (cmake-help-type "module") "*CMake Help*"))
;;;###autoload
(defun cmake-help-variable ()
"Prints out the help message for the variable the cursor is on."
(interactive)
- (cmake-command-run "--help-variable" (cmake-help-type "variable") "*CMake Help*"))
+ (cmake-command-run-help "--help-variable" (cmake-help-type "variable") "*CMake Help*"))
;;;###autoload
(defun cmake-help-property ()
"Prints out the help message for the property the cursor is on."
(interactive)
- (cmake-command-run "--help-property" (cmake-help-type "property") "*CMake Help*"))
+ (cmake-command-run-help "--help-property" (cmake-help-type "property") "*CMake Help*"))
;;;###autoload
(defun cmake-help ()
@@ -368,13 +389,13 @@ and store the result as a list in LISTVAR."
(if (string= input "")
(error "No argument given")
(if (member input command-list)
- (cmake-command-run "--help-command" input "*CMake Help*")
+ (cmake-command-run-help "--help-command" input "*CMake Help*")
(if (member input variable-list)
- (cmake-command-run "--help-variable" input "*CMake Help*")
+ (cmake-command-run-help "--help-variable" input "*CMake Help*")
(if (member input module-list)
- (cmake-command-run "--help-module" input "*CMake Help*")
+ (cmake-command-run-help "--help-module" input "*CMake Help*")
(if (member input property-list)
- (cmake-command-run "--help-property" input "*CMake Help*")
+ (cmake-command-run-help "--help-property" input "*CMake Help*")
(error "Not a know help topic.") ; this really should not happen
))))))
)