diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-09-15 00:19:36 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-09-15 00:19:36 +0000 |
commit | 0c131cad2530e765bee43fa445d8f5ac991a7711 (patch) | |
tree | 885f93833834f5e00bb97215cc98604fe89e170a /elisp | |
parent | dd992aae95e7765640bed19ce95a72745cc84a53 (diff) | |
download | mailfromd-0c131cad2530e765bee43fa445d8f5ac991a7711.tar.gz mailfromd-0c131cad2530e765bee43fa445d8f5ac991a7711.tar.bz2 |
* elisp/mfl-mode.el (mfl-next-line-indentation)
(mfl-find-line-indentation): Fix computations for `alias',
`returns' and for comment lines.
(mfl-returns-offset, mfl-comment-offset): New customization
variables.
git-svn-id: file:///svnroot/mailfromd/trunk@1667 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/mfl-mode.el | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/elisp/mfl-mode.el b/elisp/mfl-mode.el index 69f92f8f..75f2f59e 100644 --- a/elisp/mfl-mode.el +++ b/elisp/mfl-mode.el @@ -110,6 +110,16 @@ :type 'integer :group 'mfl-indentation) +(defcustom mfl-returns-offset 2 + "*Indentation increment for `alias' and `returns' statements" + :type 'integer + :group 'mfl-indentation) + +(defcustom mfl-comment-offset 1 + "*Indentation increment for comment lines" + :type 'integer + :group 'mfl-indentation) + (defcustom mfl-case-line-offset 0 "*The default indentation increment for `when' and `case' lines." :type 'integer @@ -119,7 +129,12 @@ "Find the beginning of a multiline comment the point is in." (while (not (or (bobp) (looking-at ".*/\\*"))) (forward-line -1))) - + +(defun func-indentation () + (while (and (not (bobp)) (not (looking-at "^\\s *func\\s "))) + (forward-line -1)) + (current-indentation)) + (defun mfl-next-line-indentation () "Guess and return the indentation of the next line." (save-excursion @@ -130,9 +145,14 @@ (cond ((looking-at (regexp-opt '("do" "if" "else" "elif") 'words)) (+ (current-indentation) mfl-basic-offset)) + ((looking-at (regexp-opt '("alias" "returns") 'words)) + (- (func-indentation) mfl-returns-offset)) ((looking-at ".*/\\*") - (+ (current-indentation) - (- (match-end 0) (match-beginning 0)) 1)) ; FIXME: customization + (if (not (looking-at ".*\\*/\\s *$")) + (+ (current-indentation) + (- (match-end 0) (match-beginning 0)) mfl-comment-offset) + (forward-line -1) + (mfl-next-line-indentation))) ((looking-at ".*\\*/\\s *$") (mfl-find-comment-start) (forward-line -1) @@ -188,6 +208,8 @@ block constructs. Return t if the line was found, nil otherwise." (cond ((looking-at (regexp-opt '("else" "elif" "fi") 'words)) (mfl-find-line-indentation (regexp-opt '("if" "elif") 'words))) + ((looking-at (regexp-opt '("alias" "returns") 'words)) + (+ (func-indentation) mfl-returns-offset)) ((looking-at "\\<done\\>") ; FIXME: Continuation lines are not properly handled (mfl-find-line-indentation ".*\\<do\\>")) @@ -229,7 +251,8 @@ keywords: else, elif, fi, done, when, case. (beginning-of-line) (skip-chars-forward " \t") (looking-at (regexp-opt - '("else" "elif" "fi" "done" "when" "case" "default") + '("else" "elif" "fi" "done" "when" "case" "default" + "alias" "returns") 'words))) (mfl-indent-line)) (newline-and-indent)) |