Got Emacs' factor-mode indentation working with non-closed brackets

db4
Alexander Solovyov 2008-04-28 23:36:54 +03:00
parent 6032bdf8e6
commit 22c10e8f4f
1 changed files with 28 additions and 12 deletions

View File

@ -241,19 +241,35 @@
(setq cur-indent 0)
(save-excursion
(while not-indented
(forward-line -1)
;; Check that we are after the end of previous word
(if (looking-at ".*;[ \t]*$")
;; Check that we are inside open brackets
(if (> (factor-brackets-depth) 0)
(progn
(setq cur-indent (- (current-indentation) default-tab-width))
(setq not-indented nil))
(if (looking-at "^\\(\\|:\\): ")
(let ((cur-depth (factor-brackets-depth)))
(forward-line -1)
(setq cur-indent (+ (current-indentation)
(* default-tab-width
(- cur-depth (factor-brackets-depth)))))
(setq not-indented nil)))
(forward-line -1)
;; Check that we are after the end of previous word
(if (looking-at ".*;[ \t]*$")
(progn
(setq cur-indent (+ (current-indentation) default-tab-width))
(setq cur-indent (- (current-indentation) default-tab-width))
(setq not-indented nil))
(if (bobp)
(setq not-indented nil))))))))
cur-indent))
;; Check that we are after the start of word
(if (looking-at "^\\(\\|:\\): ")
(progn
(setq cur-indent (+ (current-indentation) default-tab-width))
(setq not-indented nil))
(if (bobp)
(setq not-indented nil)))))))))
cur-indent))
(defun factor-brackets-depth ()
"Returns number of brackets, not closed on previous lines."
(syntax-ppss-depth
(save-excursion
(syntax-ppss (line-beginning-position)))))
(defun factor-indent-line ()
"Indent current line as Factor code"