diff options
author | Roy Crihfield <rscrihf@gmail.com> | 2015-03-06 16:36:09 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-07-27 09:40:54 -0400 |
commit | 5593f28fac6d2aeb909370c4daaa19f419e5d596 (patch) | |
tree | ad3d4641d7d41fe427ea82533b30a00b316afa6a /Auxiliary | |
parent | 41d6044bcfed908a6197502b038bea86a5ad3526 (diff) | |
download | cmake-5593f28fac6d2aeb909370c4daaa19f419e5d596.tar.gz |
cmake-mode.el: Derive cmake-mode from prog-mode
Emacs 24 and above support a generic "prog-mode" to simplify definition
of programming modes. Derive "cmake-mode" from it since we are a
programming mode.
Diffstat (limited to 'Auxiliary')
-rw-r--r-- | Auxiliary/cmake-mode.el | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 6e1a23c5c1..02f03855fd 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -207,12 +207,18 @@ the indentation. Otherwise it retains the same position on the line" ;------------------------------------------------------------------------------ -;; -;; Syntax table for this mode. Initialize to nil so that it is -;; regenerated when the cmake-mode function is called. -;; -(defvar cmake-mode-syntax-table nil "Syntax table for cmake-mode.") -(setq cmake-mode-syntax-table nil) +;; 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))) ;; ;; User hook entry point. @@ -226,41 +232,23 @@ the indentation. Otherwise it retains the same position on the line" ;------------------------------------------------------------------------------ -;; -;; CMake mode startup function. +;; For compatibility with Emacs < 24 +(defalias 'cmake--parent-mode + (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode)) + +;;------------------------------------------------------------------------------ +;; Mode definition. ;; ;;;###autoload -(defun cmake-mode () - "Major mode for editing CMake listfiles." - (interactive) - (kill-all-local-variables) - (setq major-mode 'cmake-mode) - (setq mode-name "CMAKE") - - ; Create the syntax table - (setq cmake-mode-syntax-table (make-syntax-table)) - (set-syntax-table cmake-mode-syntax-table) - (modify-syntax-entry ?\( "()" cmake-mode-syntax-table) - (modify-syntax-entry ?\) ")(" cmake-mode-syntax-table) - (modify-syntax-entry ?# "<" cmake-mode-syntax-table) - (modify-syntax-entry ?\n ">" cmake-mode-syntax-table) +(define-derived-mode cmake-mode cmake--parent-mode "CMake" + "Major mode for editing CMake source files." ; Setup font-lock mode. - (make-local-variable 'font-lock-defaults) - (setq font-lock-defaults '(cmake-font-lock-keywords)) - + (set (make-local-variable 'font-lock-defaults) '(cmake-font-lock-keywords)) ; Setup indentation function. - (make-local-variable 'indent-line-function) - (setq indent-line-function 'cmake-indent) - + (set (make-local-variable 'indent-line-function) 'cmake-indent) ; Setup comment syntax. - (make-local-variable 'comment-start) - (setq comment-start "#") - - ; Run user hooks. - (if (boundp 'prog-mode-hook) - (run-hooks 'prog-mode-hook 'cmake-mode-hook) - (run-hooks 'cmake-mode-hook))) + (set (make-local-variable 'comment-start) "#")) ; Help mode starts here |