2013-12-28 12:38:49 +04:00
|
|
|
;;; cmake-mode.el --- major-mode for editing CMake sources
|
|
|
|
|
2003-06-19 23:05:07 +04:00
|
|
|
;=============================================================================
|
2009-09-28 19:43:28 +04:00
|
|
|
; CMake - Cross Platform Makefile Generator
|
|
|
|
; Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2003-06-19 23:05:07 +04:00
|
|
|
;
|
2009-09-28 19:43:28 +04:00
|
|
|
; Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
; see accompanying file Copyright.txt for details.
|
2003-06-19 23:05:07 +04:00
|
|
|
;
|
2009-09-28 19:43:28 +04:00
|
|
|
; This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
; See the License for more information.
|
2003-06-19 23:05:07 +04:00
|
|
|
;=============================================================================
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;------------------------------------------------------------------------------
|
2003-12-05 18:45:16 +03:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Provides syntax highlighting and indentation for CMakeLists.txt and
|
|
|
|
;; *.cmake source files.
|
|
|
|
;;
|
|
|
|
;; Add this code to your .emacs file to use the mode:
|
|
|
|
;;
|
|
|
|
;; (setq load-path (cons (expand-file-name "/dir/with/cmake-mode") load-path))
|
|
|
|
;; (require 'cmake-mode)
|
2003-12-05 18:45:16 +03:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
;;; Code:
|
2009-09-30 17:49:52 +04:00
|
|
|
;;
|
|
|
|
;; cmake executable variable used to run cmake --help-command
|
|
|
|
;; on commands in cmake-mode
|
|
|
|
;;
|
2012-08-13 21:42:58 +04:00
|
|
|
;; cmake-command-help Written by James Bigler
|
2009-09-30 17:49:52 +04:00
|
|
|
;;
|
2006-04-25 19:52:48 +04:00
|
|
|
|
2009-09-30 17:49:52 +04:00
|
|
|
(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)
|
2015-07-23 21:47:29 +03:00
|
|
|
|
|
|
|
;; Keywords
|
|
|
|
(defconst cmake-keywords-block-open '("IF" "MACRO" "FOREACH" "ELSE" "ELSEIF" "WHILE" "FUNCTION"))
|
|
|
|
(defconst cmake-keywords-block-close '("ENDIF" "ENDFOREACH" "ENDMACRO" "ELSE" "ELSEIF" "ENDWHILE" "ENDFUNCTION"))
|
|
|
|
(defconst cmake-keywords
|
|
|
|
(let ((kwds (append cmake-keywords-block-open cmake-keywords-block-close nil)))
|
|
|
|
(delete-dups kwds)))
|
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;; Regular expressions used by line indentation function.
|
|
|
|
;;
|
|
|
|
(defconst cmake-regex-blank "^[ \t]*$")
|
2003-06-19 22:30:41 +04:00
|
|
|
(defconst cmake-regex-comment "#.*")
|
2003-12-05 18:45:16 +03:00
|
|
|
(defconst cmake-regex-paren-left "(")
|
|
|
|
(defconst cmake-regex-paren-right ")")
|
2006-04-25 19:52:48 +04:00
|
|
|
(defconst cmake-regex-argument-quoted
|
2015-07-23 21:47:29 +03:00
|
|
|
(rx ?\" (* (or (not (any ?\" ?\\)) (and ?\\ anything))) ?\"))
|
2006-04-25 19:52:48 +04:00
|
|
|
(defconst cmake-regex-argument-unquoted
|
2015-07-23 21:47:29 +03:00
|
|
|
(rx (or (not (any space "()#\"\\\n")) (and ?\\ nonl))
|
|
|
|
(* (or (not (any space "()#\\\n")) (and ?\\ nonl)))))
|
|
|
|
(defconst cmake-regex-token
|
|
|
|
(rx-to-string `(group (or (regexp ,cmake-regex-comment)
|
|
|
|
?( ?)
|
|
|
|
(regexp ,cmake-regex-argument-unquoted)
|
|
|
|
(regexp ,cmake-regex-argument-quoted)))))
|
|
|
|
(defconst cmake-regex-indented
|
|
|
|
(rx-to-string `(and bol (* (group (or (regexp ,cmake-regex-token) (any space ?\n)))))))
|
2006-04-25 19:52:48 +04:00
|
|
|
(defconst cmake-regex-block-open
|
2015-10-08 20:49:00 +03:00
|
|
|
(rx-to-string `(and symbol-start (or ,@(append cmake-keywords-block-open
|
|
|
|
(mapcar 'downcase cmake-keywords-block-open))) symbol-end)))
|
2006-04-25 19:52:48 +04:00
|
|
|
(defconst cmake-regex-block-close
|
2015-10-08 20:49:00 +03:00
|
|
|
(rx-to-string `(and symbol-start (or ,@(append cmake-keywords-block-close
|
|
|
|
(mapcar 'downcase cmake-keywords-block-close))) symbol-end)))
|
2015-07-23 21:47:29 +03:00
|
|
|
(defconst cmake-regex-close
|
|
|
|
(rx-to-string `(and bol (* space) (regexp ,cmake-regex-block-close)
|
|
|
|
(* space) (regexp ,cmake-regex-paren-left))))
|
2003-12-05 18:45:16 +03:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;------------------------------------------------------------------------------
|
2003-12-05 18:45:16 +03:00
|
|
|
|
2015-07-23 21:44:30 +03:00
|
|
|
;; Line indentation helper functions
|
|
|
|
|
2003-12-05 18:45:16 +03:00
|
|
|
(defun cmake-line-starts-inside-string ()
|
|
|
|
"Determine whether the beginning of the current line is in a string."
|
2015-07-23 21:44:30 +03:00
|
|
|
(save-excursion
|
|
|
|
(beginning-of-line)
|
|
|
|
(let ((parse-end (point)))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(nth 3 (parse-partial-sexp (point) parse-end))
|
|
|
|
)
|
2003-12-05 18:45:16 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun cmake-find-last-indented-line ()
|
|
|
|
"Move to the beginning of the last line that has meaningful indentation."
|
|
|
|
(let ((point-start (point))
|
|
|
|
region)
|
|
|
|
(forward-line -1)
|
|
|
|
(setq region (buffer-substring-no-properties (point) point-start))
|
|
|
|
(while (and (not (bobp))
|
|
|
|
(or (looking-at cmake-regex-blank)
|
2012-01-23 22:59:27 +04:00
|
|
|
(cmake-line-starts-inside-string)
|
2003-12-05 18:45:16 +03:00
|
|
|
(not (and (string-match cmake-regex-indented region)
|
|
|
|
(= (length region) (match-end 0))))))
|
|
|
|
(forward-line -1)
|
|
|
|
(setq region (buffer-substring-no-properties (point) point-start))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Line indentation function.
|
|
|
|
;;
|
2003-06-19 19:07:41 +04:00
|
|
|
(defun cmake-indent ()
|
2015-07-23 21:44:30 +03:00
|
|
|
"Indent current line as CMake code."
|
2003-12-04 22:34:23 +03:00
|
|
|
(interactive)
|
2015-07-23 21:44:30 +03:00
|
|
|
(unless (cmake-line-starts-inside-string)
|
2003-12-05 18:45:16 +03:00
|
|
|
(if (bobp)
|
2009-02-26 21:28:01 +03:00
|
|
|
(cmake-indent-line-to 0)
|
|
|
|
(let (cur-indent)
|
2003-12-05 18:45:16 +03:00
|
|
|
(save-excursion
|
2009-02-26 21:28:01 +03:00
|
|
|
(beginning-of-line)
|
|
|
|
(let ((point-start (point))
|
2012-09-20 06:33:35 +04:00
|
|
|
(case-fold-search t) ;; case-insensitive
|
2009-02-26 21:28:01 +03:00
|
|
|
token)
|
|
|
|
; Search back for the last indented line.
|
|
|
|
(cmake-find-last-indented-line)
|
|
|
|
; Start with the indentation on this line.
|
|
|
|
(setq cur-indent (current-indentation))
|
|
|
|
; Search forward counting tokens that adjust indentation.
|
|
|
|
(while (re-search-forward cmake-regex-token point-start t)
|
|
|
|
(setq token (match-string 0))
|
2015-07-23 21:44:30 +03:00
|
|
|
(when (or (string-match (concat "^" cmake-regex-paren-left "$") token)
|
|
|
|
(and (string-match cmake-regex-block-open token)
|
|
|
|
(looking-at (concat "[ \t]*" cmake-regex-paren-left))))
|
|
|
|
(setq cur-indent (+ cur-indent cmake-tab-width)))
|
|
|
|
(when (string-match (concat "^" cmake-regex-paren-right "$") token)
|
|
|
|
(setq cur-indent (- cur-indent cmake-tab-width)))
|
2003-12-05 18:45:16 +03:00
|
|
|
)
|
2009-02-26 21:28:01 +03:00
|
|
|
(goto-char point-start)
|
2015-07-23 21:44:30 +03:00
|
|
|
;; If next token closes the block, decrease indentation
|
2015-07-23 21:47:29 +03:00
|
|
|
(when (looking-at cmake-regex-close)
|
2015-07-23 21:44:30 +03:00
|
|
|
(setq cur-indent (- cur-indent cmake-tab-width))
|
2003-12-05 18:45:16 +03:00
|
|
|
)
|
|
|
|
)
|
2003-06-19 19:07:41 +04:00
|
|
|
)
|
2003-12-05 18:45:16 +03:00
|
|
|
; Indent this line by the amount selected.
|
2015-07-23 21:44:30 +03:00
|
|
|
(cmake-indent-line-to (max cur-indent 0))
|
2003-06-19 19:07:41 +04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2003-12-05 18:45:16 +03:00
|
|
|
|
2009-02-26 21:28:01 +03:00
|
|
|
(defun cmake-point-in-indendation ()
|
|
|
|
(string-match "^[ \\t]*$" (buffer-substring (point-at-bol) (point))))
|
|
|
|
|
|
|
|
(defun cmake-indent-line-to (column)
|
|
|
|
"Indent the current line to COLUMN.
|
|
|
|
If point is within the existing indentation it is moved to the end of
|
|
|
|
the indentation. Otherwise it retains the same position on the line"
|
|
|
|
(if (cmake-point-in-indendation)
|
|
|
|
(indent-line-to column)
|
|
|
|
(save-excursion (indent-line-to column))))
|
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;------------------------------------------------------------------------------
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2008-03-11 17:54:40 +03:00
|
|
|
;;
|
|
|
|
;; Helper functions for buffer
|
|
|
|
;;
|
2015-03-06 23:08:12 +03:00
|
|
|
(defun cmake-unscreamify-buffer ()
|
2008-03-11 17:54:40 +03:00
|
|
|
"Convert all CMake commands to lowercase in buffer."
|
|
|
|
(interactive)
|
2015-03-06 23:08:12 +03:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^\\([ \t]*\\)\\(\\w+\\)\\([ \t]*(\\)" nil t)
|
|
|
|
(replace-match
|
|
|
|
(concat
|
|
|
|
(match-string 1)
|
|
|
|
(downcase (match-string 2))
|
|
|
|
(match-string 3))
|
|
|
|
t))
|
|
|
|
)
|
2008-03-11 17:54:40 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;;
|
|
|
|
;; Keyword highlighting regex-to-face map.
|
|
|
|
;;
|
2006-04-26 21:04:31 +04:00
|
|
|
(defconst cmake-font-lock-keywords
|
2015-03-07 00:34:37 +03:00
|
|
|
`((,(rx-to-string `(and symbol-start
|
|
|
|
(or ,@cmake-keywords
|
|
|
|
,@(mapcar #'downcase cmake-keywords))
|
|
|
|
symbol-end))
|
|
|
|
. font-lock-keyword-face)
|
2015-08-13 18:23:34 +03:00
|
|
|
(,(rx symbol-start (group (+ (or word (syntax symbol)))) (* blank) ?\()
|
2015-03-07 00:34:37 +03:00
|
|
|
1 font-lock-function-name-face)
|
2015-08-13 18:54:27 +03:00
|
|
|
(,(rx "${" (group (+(any alnum "-_+/."))) "}")
|
2015-03-07 00:34:37 +03:00
|
|
|
1 font-lock-variable-name-face t)
|
|
|
|
)
|
|
|
|
"Highlighting expressions for CMake mode.")
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;------------------------------------------------------------------------------
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2015-03-07 00:36:09 +03:00
|
|
|
;; Syntax table for this mode.
|
|
|
|
(defvar cmake-mode-syntax-table nil
|
|
|
|
"Syntax table for CMake mode.")
|
|
|
|
(or cmake-mode-syntax-table
|
|
|
|
(setq cmake-mode-syntax-table
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
(modify-syntax-entry ?\( "()" table)
|
|
|
|
(modify-syntax-entry ?\) ")(" table)
|
|
|
|
(modify-syntax-entry ?# "<" table)
|
|
|
|
(modify-syntax-entry ?\n ">" table)
|
|
|
|
(modify-syntax-entry ?$ "'" table)
|
|
|
|
table)))
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;;
|
|
|
|
;; User hook entry point.
|
|
|
|
;;
|
2003-06-19 19:07:41 +04:00
|
|
|
(defvar cmake-mode-hook nil)
|
|
|
|
|
2006-04-25 19:52:48 +04:00
|
|
|
;;
|
|
|
|
;; Indentation increment.
|
|
|
|
;;
|
|
|
|
(defvar cmake-tab-width 2)
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
2015-03-07 00:36:09 +03:00
|
|
|
;; For compatibility with Emacs < 24
|
|
|
|
(defalias 'cmake--parent-mode
|
|
|
|
(if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
|
|
|
|
|
|
|
|
;;------------------------------------------------------------------------------
|
|
|
|
;; Mode definition.
|
2006-04-25 19:52:48 +04:00
|
|
|
;;
|
2013-12-28 12:51:32 +04:00
|
|
|
;;;###autoload
|
2015-03-07 00:36:09 +03:00
|
|
|
(define-derived-mode cmake-mode cmake--parent-mode "CMake"
|
|
|
|
"Major mode for editing CMake source files."
|
2003-12-04 22:34:23 +03:00
|
|
|
|
2003-06-19 19:07:41 +04:00
|
|
|
; Setup font-lock mode.
|
2015-03-07 00:36:09 +03:00
|
|
|
(set (make-local-variable 'font-lock-defaults) '(cmake-font-lock-keywords))
|
2003-06-19 19:07:41 +04:00
|
|
|
; Setup indentation function.
|
2015-03-07 00:36:09 +03:00
|
|
|
(set (make-local-variable 'indent-line-function) 'cmake-indent)
|
2003-06-30 04:20:14 +04:00
|
|
|
; Setup comment syntax.
|
2015-03-07 00:36:09 +03:00
|
|
|
(set (make-local-variable 'comment-start) "#"))
|
2003-06-19 19:07:41 +04:00
|
|
|
|
2009-09-30 17:49:52 +04:00
|
|
|
; Help mode starts here
|
|
|
|
|
|
|
|
|
2013-12-28 12:51:32 +04:00
|
|
|
;;;###autoload
|
2014-01-29 01:57:49 +04:00
|
|
|
(defun cmake-command-run (type &optional topic buffer)
|
2009-09-30 17:49:52 +04:00
|
|
|
"Runs the command cmake with the arguments specified. The
|
|
|
|
optional argument topic will be appended to the argument list."
|
|
|
|
(interactive "s")
|
2014-01-29 01:57:49 +04:00
|
|
|
(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)
|
2009-09-30 17:49:52 +04:00
|
|
|
)
|
2014-01-29 01:57:49 +04:00
|
|
|
(shell-command command buffer)
|
|
|
|
(save-selected-window
|
|
|
|
(select-window (display-buffer buffer 'not-this-window))
|
|
|
|
(cmake-mode)
|
|
|
|
(toggle-read-only t))
|
2009-09-30 17:49:52 +04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2013-12-28 12:51:32 +04:00
|
|
|
;;;###autoload
|
2009-09-30 17:49:52 +04:00
|
|
|
(defun cmake-help-list-commands ()
|
|
|
|
"Prints out a list of the cmake commands."
|
|
|
|
(interactive)
|
|
|
|
(cmake-command-run "--help-command-list")
|
|
|
|
)
|
|
|
|
|
2014-01-29 20:48:21 +04:00
|
|
|
(defvar cmake-commands '() "List of available topics for --help-command.")
|
|
|
|
(defvar cmake-help-command-history nil "Command read history.")
|
|
|
|
(defvar cmake-modules '() "List of available topics for --help-module.")
|
|
|
|
(defvar cmake-help-module-history nil "Module read history.")
|
|
|
|
(defvar cmake-variables '() "List of available topics for --help-variable.")
|
|
|
|
(defvar cmake-help-variable-history nil "Variable read history.")
|
|
|
|
(defvar cmake-properties '() "List of available topics for --help-property.")
|
|
|
|
(defvar cmake-help-property-history nil "Property read history.")
|
|
|
|
(defvar cmake-help-complete-history nil "Complete help read history.")
|
|
|
|
(defvar cmake-string-to-list-symbol
|
|
|
|
'(("command" cmake-commands cmake-help-command-history)
|
|
|
|
("module" cmake-modules cmake-help-module-history)
|
|
|
|
("variable" cmake-variables cmake-help-variable-history)
|
|
|
|
("property" cmake-properties cmake-help-property-history)
|
|
|
|
))
|
|
|
|
|
|
|
|
(defun cmake-get-list (listname)
|
|
|
|
"If the value of LISTVAR is nil, run cmake --help-LISTNAME-list
|
|
|
|
and store the result as a list in LISTVAR."
|
|
|
|
(let ((listvar (car (cdr (assoc listname cmake-string-to-list-symbol)))))
|
|
|
|
(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)
|
|
|
|
(with-current-buffer temp-buffer-name
|
|
|
|
(set listvar (cdr (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n" t))))))
|
|
|
|
(symbol-value listvar)
|
|
|
|
))
|
2014-01-29 18:19:06 +04:00
|
|
|
)
|
2009-09-30 17:49:52 +04:00
|
|
|
|
2015-01-19 21:49:07 +03:00
|
|
|
(require 'thingatpt)
|
2015-01-18 03:27:28 +03:00
|
|
|
(defun cmake-symbol-at-point ()
|
|
|
|
(let ((symbol (symbol-at-point)))
|
|
|
|
(and (not (null symbol))
|
|
|
|
(symbol-name symbol))))
|
|
|
|
|
2014-01-29 20:48:21 +04:00
|
|
|
(defun cmake-help-type (type)
|
2015-01-18 03:27:28 +03:00
|
|
|
(let* ((default-entry (cmake-symbol-at-point))
|
2014-01-29 20:48:21 +04:00
|
|
|
(history (car (cdr (cdr (assoc type cmake-string-to-list-symbol)))))
|
2014-01-29 18:19:06 +04:00
|
|
|
(input (completing-read
|
2014-01-29 20:48:21 +04:00
|
|
|
(format "CMake %s: " type) ; prompt
|
|
|
|
(cmake-get-list type) ; completions
|
2014-01-29 18:19:06 +04:00
|
|
|
nil ; predicate
|
|
|
|
t ; require-match
|
|
|
|
default-entry ; initial-input
|
2014-01-29 20:48:21 +04:00
|
|
|
history
|
2009-09-30 17:49:52 +04:00
|
|
|
)))
|
|
|
|
(if (string= input "")
|
|
|
|
(error "No argument given")
|
|
|
|
input))
|
|
|
|
)
|
|
|
|
|
2013-12-28 12:51:32 +04:00
|
|
|
;;;###autoload
|
2009-09-30 17:49:52 +04:00
|
|
|
(defun cmake-help-command ()
|
2014-01-29 20:48:21 +04:00
|
|
|
"Prints out the help message for the command the cursor is on."
|
2009-09-30 17:49:52 +04:00
|
|
|
(interactive)
|
2014-01-29 20:48:21 +04:00
|
|
|
(cmake-command-run "--help-command" (cmake-help-type "command") "*CMake Help*"))
|
2014-01-28 21:05:21 +04:00
|
|
|
|
2014-01-29 20:48:21 +04:00
|
|
|
;;;###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*"))
|
2014-01-29 19:25:01 +04:00
|
|
|
|
2014-01-29 20:48:21 +04:00
|
|
|
;;;###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*"))
|
2014-01-29 19:25:01 +04:00
|
|
|
|
2014-01-29 20:48:21 +04:00
|
|
|
;;;###autoload
|
|
|
|
(defun cmake-help-property ()
|
|
|
|
"Prints out the help message for the property the cursor is on."
|
2014-01-29 19:25:01 +04:00
|
|
|
(interactive)
|
2014-01-29 20:48:21 +04:00
|
|
|
(cmake-command-run "--help-property" (cmake-help-type "property") "*CMake Help*"))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun cmake-help ()
|
|
|
|
"Queries for any of the four available help topics and prints out the approriate page."
|
|
|
|
(interactive)
|
2015-01-18 03:27:28 +03:00
|
|
|
(let* ((default-entry (cmake-symbol-at-point))
|
2014-01-29 20:48:21 +04:00
|
|
|
(command-list (cmake-get-list "command"))
|
|
|
|
(variable-list (cmake-get-list "variable"))
|
|
|
|
(module-list (cmake-get-list "module"))
|
|
|
|
(property-list (cmake-get-list "property"))
|
|
|
|
(all-words (append command-list variable-list module-list property-list))
|
|
|
|
(input (completing-read
|
|
|
|
"CMake command/module/variable/property: " ; prompt
|
|
|
|
all-words ; completions
|
|
|
|
nil ; predicate
|
|
|
|
t ; require-match
|
|
|
|
default-entry ; initial-input
|
|
|
|
'cmake-help-complete-history
|
|
|
|
)))
|
|
|
|
(if (string= input "")
|
|
|
|
(error "No argument given")
|
|
|
|
(if (member input command-list)
|
|
|
|
(cmake-command-run "--help-command" input "*CMake Help*")
|
|
|
|
(if (member input variable-list)
|
|
|
|
(cmake-command-run "--help-variable" input "*CMake Help*")
|
|
|
|
(if (member input module-list)
|
|
|
|
(cmake-command-run "--help-module" input "*CMake Help*")
|
|
|
|
(if (member input property-list)
|
|
|
|
(cmake-command-run "--help-property" input "*CMake Help*")
|
|
|
|
(error "Not a know help topic.") ; this really should not happen
|
|
|
|
))))))
|
|
|
|
)
|
2009-09-30 17:49:52 +04:00
|
|
|
|
2013-12-28 12:51:32 +04:00
|
|
|
;;;###autoload
|
|
|
|
(progn
|
|
|
|
(add-to-list 'auto-mode-alist '("CMakeLists\\.txt\\'" . cmake-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.cmake\\'" . cmake-mode)))
|
2009-09-30 17:49:52 +04:00
|
|
|
|
2003-06-19 19:07:41 +04:00
|
|
|
; This file provides cmake-mode.
|
|
|
|
(provide 'cmake-mode)
|
2006-04-25 19:52:48 +04:00
|
|
|
|
|
|
|
;;; cmake-mode.el ends here
|