From 83ef3149fe6739b7e623cfcf24098929110ae4ec Mon Sep 17 00:00:00 2001 From: Alexander Solovyov Date: Sun, 21 Sep 2008 18:42:48 +0300 Subject: [PATCH] Upgraded version of emacs indentation --- misc/factor.el | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/misc/factor.el b/misc/factor.el index 402dfdf484..1ae8919559 100644 --- a/misc/factor.el +++ b/misc/factor.el @@ -228,9 +228,17 @@ (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 () "Calculate Factor indentation for line at point." (let ((not-indented t) @@ -242,27 +250,28 @@ (save-excursion (while not-indented ;; Check that we are inside open brackets - (if (> (factor-brackets-depth) 0) - (progn - (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) + (save-excursion + (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 not-indented nil)) ;; 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 + (message "inword") (setq cur-indent (+ (current-indentation) default-tab-width)) (setq not-indented nil)) (if (bobp) - (setq not-indented nil))))))))) + (setq not-indented nil)))))))) cur-indent)) (defun factor-brackets-depth ()