diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2024-01-25 16:28:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-01-25 16:51:17 (GMT) |
commit | 91336c74698b09afe272f8dc044b84ecf71d0904 (patch) | |
tree | 4fa32fb49b610a3e0e02fd13417cdfd717c49d28 /Auxiliary | |
parent | 8533a8505c315f7104a6e0f65eb6c51f07f154d0 (diff) | |
download | CMake-91336c74698b09afe272f8dc044b84ecf71d0904.zip CMake-91336c74698b09afe272f8dc044b84ecf71d0904.tar.gz CMake-91336c74698b09afe272f8dc044b84ecf71d0904.tar.bz2 |
cmake-mode.el: Simplify jumping to begin/end of functions/macros
This change was spawned by the desire to use `narrow-to-defun` in CMake
files. However, there was no "CMake version" of that function, and it
turns out that we don't need one if we make `beginning-of-defun` and
`end-of-defun` work in `cmake-mode`.
In the setup code of `cmake-mode` we now set the local variables
`beginning-of-defun-function` and `end-of-defun-function`. This makes
`beginning-of-defun` and `end-of-defun` work as expected.
Functions that use this facility also work now: `mark-defun` and
`narrow-to-defun` and possibly others.
We remove `cmake-mark-defun` since it's superfluous now.
We remove the defun-related key bindings since the standard functions
that are bound globally work fine with this patch.
Diffstat (limited to 'Auxiliary')
-rw-r--r-- | Auxiliary/cmake-mode.el | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 6bd23bf..b5e5ff4 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -258,15 +258,6 @@ Return t unless search stops due to end of buffer." (forward-line) t))) -(defun cmake-mark-defun () - "Mark the current CMake function or macro. - -This puts the mark at the end, and point at the beginning." - (interactive) - (cmake-end-of-defun) - (push-mark nil :nomsg :activate) - (cmake-beginning-of-defun)) - ;------------------------------------------------------------------------------ @@ -346,6 +337,10 @@ This puts the mark at the end, and point at the beginning." (define-derived-mode cmake-mode prog-mode "CMake" "Major mode for editing CMake source files." + ;; Setup jumping to beginning/end of a CMake function/macro. + (set (make-local-variable 'beginning-of-defun-function) #'cmake-beginning-of-defun) + (set (make-local-variable 'end-of-defun-function) #'cmake-end-of-defun) + ; Setup font-lock mode. (set (make-local-variable 'font-lock-defaults) '(cmake-font-lock-keywords)) ; Setup indentation function. @@ -356,11 +351,6 @@ This puts the mark at the end, and point at the beginning." (set (make-local-variable 'syntax-propertize-function) cmake--syntax-propertize-function) (add-hook 'syntax-propertize-extend-region-functions #'syntax-propertize-multiline nil t)) -;; Default cmake-mode key bindings -(define-key cmake-mode-map "\e\C-a" #'cmake-beginning-of-defun) -(define-key cmake-mode-map "\e\C-e" #'cmake-end-of-defun) -(define-key cmake-mode-map "\e\C-h" #'cmake-mark-defun) - ; Help mode starts here |