Upgraded version of emacs indentation
parent
22c10e8f4f
commit
83ef3149fe
|
@ -228,9 +228,17 @@
|
||||||
(define-key factor-mode-map [tab] 'indent-for-tab-command)
|
(define-key factor-mode-map [tab] 'indent-for-tab-command)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; factor-indent-line
|
;; indentation
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defconst factor-word-starting-keywords
|
||||||
|
'("" ":" "TUPLE" "MACRO" "MACRO:" "M"))
|
||||||
|
|
||||||
|
(defmacro factor-word-start-re (keywords)
|
||||||
|
`(format
|
||||||
|
"^\\(%s\\): "
|
||||||
|
(mapconcat 'identity ,keywords "\\|")))
|
||||||
|
|
||||||
(defun factor-calculate-indentation ()
|
(defun factor-calculate-indentation ()
|
||||||
"Calculate Factor indentation for line at point."
|
"Calculate Factor indentation for line at point."
|
||||||
(let ((not-indented t)
|
(let ((not-indented t)
|
||||||
|
@ -242,27 +250,28 @@
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(while not-indented
|
(while not-indented
|
||||||
;; Check that we are inside open brackets
|
;; Check that we are inside open brackets
|
||||||
(if (> (factor-brackets-depth) 0)
|
(save-excursion
|
||||||
(progn
|
(let ((cur-depth (factor-brackets-depth)))
|
||||||
(let ((cur-depth (factor-brackets-depth)))
|
(forward-line -1)
|
||||||
(forward-line -1)
|
(setq cur-indent (+ (current-indentation)
|
||||||
(setq cur-indent (+ (current-indentation)
|
(* default-tab-width
|
||||||
(* default-tab-width
|
(- cur-depth (factor-brackets-depth)))))
|
||||||
(- cur-depth (factor-brackets-depth)))))
|
(setq not-indented nil)))
|
||||||
(setq not-indented nil)))
|
(forward-line -1)
|
||||||
(forward-line -1)
|
|
||||||
;; Check that we are after the end of previous word
|
;; Check that we are after the end of previous word
|
||||||
(if (looking-at ".*;[ \t]*$")
|
(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))
|
||||||
;; Check that we are after the start of word
|
;; Check that we are after the start of word
|
||||||
(if (looking-at "^\\(\\|:\\): ")
|
(if (looking-at (factor-word-start-re factor-word-starting-keywords))
|
||||||
|
; (if (looking-at "^[A-Z:]*: ")
|
||||||
(progn
|
(progn
|
||||||
|
(message "inword")
|
||||||
(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)
|
(if (bobp)
|
||||||
(setq not-indented nil)))))))))
|
(setq not-indented nil))))))))
|
||||||
cur-indent))
|
cur-indent))
|
||||||
|
|
||||||
(defun factor-brackets-depth ()
|
(defun factor-brackets-depth ()
|
||||||
|
|
Loading…
Reference in New Issue