summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2007-10-13 20:01:38 +0000
committerGlenn Morris <rgm@gnu.org>2007-10-13 20:01:38 +0000
commitf5b54e3190f7f88921ed89f072f9d0dcec4769d9 (patch)
tree8c05cf2bb4f384e41c38609836b0dafca8550770
parent4b690a83340d0cd2efb6e93aff13349ffc545580 (diff)
downloademacs-f5b54e3190f7f88921ed89f072f9d0dcec4769d9.tar.gz
John W. Eaton <jwe at octave.org>
(octave-looking-at-kw) (octave-re-search-forward-kw, octave-re-search-backward-kw): New functions. (octave-in-defun-p, calculate-octave-indent) (octave-blink-matching-block-open, octave-beginning-of-defun) (octave-auto-fill): Use octave-looking-at-kw instead of looking-at, to search for regexps that contain case-sensitive keywords. (octave-beginning-of-defun): Likewise, for octave-re-search-backward-kw. (octave-scan-blocks): Likewise, for octave-re-search-forward-kw.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/octave-mod.el38
2 files changed, 37 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7539d1c2c16..4a83eb217cf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
+2007-10-13 John W. Eaton <jwe@octave.org>
+
+ * progmodes/octave-mod.el (octave-looking-at-kw)
+ (octave-re-search-forward-kw, octave-re-search-backward-kw):
+ New functions.
+ (octave-in-defun-p, calculate-octave-indent)
+ (octave-blink-matching-block-open, octave-beginning-of-defun)
+ (octave-auto-fill): Use octave-looking-at-kw instead of looking-at,
+ to search for regexps that contain case-sensitive keywords.
+ (octave-beginning-of-defun): Likewise, for octave-re-search-backward-kw.
+ (octave-scan-blocks): Likewise, for octave-re-search-forward-kw.
+
2007-10-13 Richard Stallman <rms@gnu.org>
* files.el (directory-abbrev-alist): Doc fix.
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el
index 3da3434cda2..72b605e6d59 100644
--- a/lisp/progmodes/octave-mod.el
+++ b/lisp/progmodes/octave-mod.el
@@ -598,13 +598,25 @@ to end after the end keyword."
(error nil))
(< pos (point)))))
+(defun octave-looking-at-kw (regexp)
+ (let ((case-fold-search nil))
+ (looking-at regexp)))
+
+(defun octave-re-search-forward-kw (regexp)
+ (let ((case-fold-search nil))
+ (re-search-forward regexp nil 'move inc)))
+
+(defun octave-re-search-backward-kw (regexp)
+ (let ((case-fold-search nil))
+ (re-search-backward regexp nil 'move inc)))
+
(defun octave-in-defun-p ()
"Return t if point is inside an Octave function declaration.
The function is taken to start at the `f' of `function' and to end after
the end keyword."
(let ((pos (point)))
(save-excursion
- (or (and (looking-at "\\<function\\>")
+ (or (and (octave-looking-at-kw "\\<function\\>")
(octave-not-in-string-or-comment-p))
(and (octave-beginning-of-defun)
(condition-case nil
@@ -675,14 +687,14 @@ level."
(while (< (point) eol)
(if (octave-not-in-string-or-comment-p)
(cond
- ((looking-at "\\<switch\\>")
+ ((octave-looking-at-kw "\\<switch\\>")
(setq icol (+ icol (* 2 octave-block-offset))))
- ((looking-at octave-block-begin-regexp)
+ ((octave-looking-at-kw octave-block-begin-regexp)
(setq icol (+ icol octave-block-offset)))
- ((looking-at octave-block-else-regexp)
+ ((octave-looking-at-kw octave-block-else-regexp)
(if (= bot (point))
(setq icol (+ icol octave-block-offset))))
- ((looking-at octave-block-end-regexp)
+ ((octave-looking-at-kw octave-block-end-regexp)
(if (not (= bot (point)))
(setq icol (- icol
(octave-block-end-offset)))))))
@@ -692,10 +704,10 @@ level."
(save-excursion
(back-to-indentation)
(cond
- ((and (looking-at octave-block-else-regexp)
+ ((and (octave-looking-at-kw octave-block-else-regexp)
(octave-not-in-string-or-comment-p))
(setq icol (- icol octave-block-offset)))
- ((and (looking-at octave-block-end-regexp)
+ ((and (octave-looking-at-kw octave-block-end-regexp)
(octave-not-in-string-or-comment-p))
(setq icol (- icol (octave-block-end-offset))))
((or (looking-at "\\s<\\s<\\s<\\S<")
@@ -871,8 +883,8 @@ an error is signaled."
(save-excursion
(while (/= count 0)
(catch 'foo
- (while (or (re-search-forward
- octave-block-begin-or-end-regexp nil 'move inc)
+ (while (or (octave-re-search-forward-kw
+ octave-block-begin-or-end-regexp)
(if (/= depth 0)
(error "Unbalanced block")))
(if (octave-not-in-string-or-comment-p)
@@ -991,7 +1003,7 @@ Signal an error if the keywords are incompatible."
(looking-at "\\>")
(save-excursion
(skip-syntax-backward "w")
- (looking-at octave-block-else-or-end-regexp)))
+ (octave-looking-at-kw octave-block-else-or-end-regexp)))
(save-excursion
(cond
((match-end 1)
@@ -1038,11 +1050,11 @@ Returns t unless search stops at the beginning or end of the buffer."
(inc (if (> arg 0) 1 -1))
(found))
(and (not (eobp))
- (not (and (> arg 0) (looking-at "\\<function\\>")))
+ (not (and (> arg 0) (octave-looking-at-kw "\\<function\\>")))
(skip-syntax-forward "w"))
(while (and (/= arg 0)
(setq found
- (re-search-backward "\\<function\\>" nil 'move inc)))
+ (octave-re-search-backward-kw "\\<function\\>")))
(if (octave-not-in-string-or-comment-p)
(setq arg (- arg inc))))
(if found
@@ -1095,7 +1107,7 @@ otherwise."
(save-excursion
(beginning-of-line)
(and auto-fill-inhibit-regexp
- (looking-at auto-fill-inhibit-regexp))))
+ (octave-looking-at-kw auto-fill-inhibit-regexp))))
nil ; Can't do anything
(if (and (not (octave-in-comment-p))
(> (current-column) fc))