Got Emacs' factor-mode indentation working with non-closed brackets
parent
6032bdf8e6
commit
22c10e8f4f
|
@ -76,7 +76,7 @@
|
||||||
(modify-syntax-entry ?\" "\" " factor-mode-syntax-table)))
|
(modify-syntax-entry ?\" "\" " factor-mode-syntax-table)))
|
||||||
|
|
||||||
(defvar factor-mode-map (make-sparse-keymap))
|
(defvar factor-mode-map (make-sparse-keymap))
|
||||||
|
|
||||||
(defcustom factor-mode-hook nil
|
(defcustom factor-mode-hook nil
|
||||||
"Hook run when entering Factor mode."
|
"Hook run when entering Factor mode."
|
||||||
:type 'hook
|
:type 'hook
|
||||||
|
@ -211,7 +211,7 @@
|
||||||
(defun factor-clear ()
|
(defun factor-clear ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(factor-send-string "clear"))
|
(factor-send-string "clear"))
|
||||||
|
|
||||||
(defun factor-comment-line ()
|
(defun factor-comment-line ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
|
@ -241,19 +241,35 @@
|
||||||
(setq cur-indent 0)
|
(setq cur-indent 0)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(while not-indented
|
(while not-indented
|
||||||
(forward-line -1)
|
;; Check that we are inside open brackets
|
||||||
;; Check that we are after the end of previous word
|
(if (> (factor-brackets-depth) 0)
|
||||||
(if (looking-at ".*;[ \t]*$")
|
|
||||||
(progn
|
(progn
|
||||||
(setq cur-indent (- (current-indentation) default-tab-width))
|
(let ((cur-depth (factor-brackets-depth)))
|
||||||
(setq not-indented nil))
|
(forward-line -1)
|
||||||
(if (looking-at "^\\(\\|:\\): ")
|
(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
|
(progn
|
||||||
(setq cur-indent (+ (current-indentation) default-tab-width))
|
(setq cur-indent (- (current-indentation) default-tab-width))
|
||||||
(setq not-indented nil))
|
(setq not-indented nil))
|
||||||
(if (bobp)
|
;; Check that we are after the start of word
|
||||||
(setq not-indented nil))))))))
|
(if (looking-at "^\\(\\|:\\): ")
|
||||||
cur-indent))
|
(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 ()
|
(defun factor-indent-line ()
|
||||||
"Indent current line as Factor code"
|
"Indent current line as Factor code"
|
||||||
|
|
Loading…
Reference in New Issue