BUG: Fix cmake-mode.el indentation cursor motion
This makes cursor motion in the indent function consistent with emacs conventions. Patch from Mike Wittman. See issue #8625.
This commit is contained in:
parent
3829be4ca6
commit
8597f01acd
|
@ -102,15 +102,18 @@
|
|||
(defun cmake-indent ()
|
||||
"Indent current line as CMAKE code."
|
||||
(interactive)
|
||||
(beginning-of-line)
|
||||
(if (cmake-line-starts-inside-string)
|
||||
()
|
||||
(if (bobp)
|
||||
(indent-line-to 0)
|
||||
(let ((point-start (point))
|
||||
token cur-indent)
|
||||
(cmake-indent-line-to 0)
|
||||
(let (cur-indent)
|
||||
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
|
||||
(let ((point-start (point))
|
||||
token)
|
||||
|
||||
; Search back for the last indented line.
|
||||
(cmake-find-last-indented-line)
|
||||
|
||||
|
@ -133,23 +136,36 @@
|
|||
(setq cur-indent (+ cur-indent cmake-tab-width))
|
||||
)
|
||||
)
|
||||
)
|
||||
(goto-char point-start)
|
||||
|
||||
; If this is the end of a block, decrease indentation.
|
||||
(if (looking-at cmake-regex-block-close)
|
||||
(setq cur-indent (- cur-indent cmake-tab-width))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Indent this line by the amount selected.
|
||||
(if (< cur-indent 0)
|
||||
(indent-line-to 0)
|
||||
(indent-line-to cur-indent)
|
||||
(cmake-indent-line-to 0)
|
||||
(cmake-indent-line-to cur-indent)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(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))))
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue