Emacs factor-mode: correct indentation for field setters after constructors.
parent
27bcb413a5
commit
dad3a5ead1
|
@ -281,10 +281,27 @@ value from the existing code in the buffer."
|
||||||
(defsubst factor--at-begin-of-def ()
|
(defsubst factor--at-begin-of-def ()
|
||||||
(looking-at "\\([^ ]\\|^\\)+:"))
|
(looking-at "\\([^ ]\\|^\\)+:"))
|
||||||
|
|
||||||
|
(defsubst factor--looking-at-emptiness ()
|
||||||
|
(looking-at "^[ \t]*$"))
|
||||||
|
|
||||||
(defun factor--at-end-of-def ()
|
(defun factor--at-end-of-def ()
|
||||||
(or (looking-at ".*;[ \t]*$")
|
(or (looking-at ".*;[ \t]*$")
|
||||||
(looking-at factor--regex-single-liner)))
|
(looking-at factor--regex-single-liner)))
|
||||||
|
|
||||||
|
(defun factor--at-setter-line ()
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(if (not (factor--looking-at-emptiness))
|
||||||
|
(re-search-forward factor--regex-setter (line-end-position) t)
|
||||||
|
(forward-line -1)
|
||||||
|
(or (factor--at-constructor-line)
|
||||||
|
(factor--at-setter-line)))))
|
||||||
|
|
||||||
|
(defun factor--at-constructor-line ()
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(re-search-forward factor--regex-constructor (line-end-position) t)))
|
||||||
|
|
||||||
(defun factor--indent-in-brackets ()
|
(defun factor--indent-in-brackets ()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
|
@ -303,14 +320,28 @@ value from the existing code in the buffer."
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(when (factor--at-begin-of-def) 0)))
|
(when (factor--at-begin-of-def) 0)))
|
||||||
|
|
||||||
|
(defun factor--indent-setter-line ()
|
||||||
|
(when (factor--at-setter-line)
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(let ((indent (when (factor--at-constructor-line) (current-indentation))))
|
||||||
|
(while (not (or indent
|
||||||
|
(bobp)
|
||||||
|
(factor--at-begin-of-def)
|
||||||
|
(factor--at-end-of-def)))
|
||||||
|
(if (factor--at-constructor-line)
|
||||||
|
(setq indent (+ (current-indentation) factor-indent-width))
|
||||||
|
(forward-line -1)))
|
||||||
|
indent))))
|
||||||
|
|
||||||
(defun factor--indent-continuation ()
|
(defun factor--indent-continuation ()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(forward-line -1)
|
(forward-line -1)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(if (bobp) 0
|
(if (bobp) 0
|
||||||
(if (looking-at "^[ \t]*$")
|
(if (factor--looking-at-emptiness)
|
||||||
(factor--indent-continuation)
|
(factor--indent-continuation)
|
||||||
(if (factor--at-end-of-def)
|
(if (or (factor--at-end-of-def) (factor--at-setter-line))
|
||||||
(- (current-indentation) factor-indent-width)
|
(- (current-indentation) factor-indent-width)
|
||||||
(if (factor--at-begin-of-def)
|
(if (factor--at-begin-of-def)
|
||||||
(+ (current-indentation) factor-indent-width)
|
(+ (current-indentation) factor-indent-width)
|
||||||
|
@ -321,6 +352,7 @@ value from the existing code in the buffer."
|
||||||
(or (and (bobp) 0)
|
(or (and (bobp) 0)
|
||||||
(factor--indent-definition)
|
(factor--indent-definition)
|
||||||
(factor--indent-in-brackets)
|
(factor--indent-in-brackets)
|
||||||
|
(factor--indent-setter-line)
|
||||||
(factor--indent-continuation)
|
(factor--indent-continuation)
|
||||||
0))
|
0))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue