comparison lisp/progmodes/octave-mod.el @ 85277:5a08fa250727

(octave-looking-at-kw): Add doc string. (octave-re-search-forward-kw, octave-re-search-backward-kw): Add doc string, and an explicit COUNT argument. (octave-scan-blocks, octave-beginning-of-defun): Explicitly pass INC to search functions.
author Glenn Morris <rgm@gnu.org>
date Sat, 13 Oct 2007 20:09:14 +0000
parents 3e4b36ffb1c8
children f873840f9fea a0e466c4d599
comparison
equal deleted inserted replaced
85276:326dfd4201f2 85277:5a08fa250727
580 t) 580 t)
581 (error nil)) 581 (error nil))
582 (< pos (point))))) 582 (< pos (point)))))
583 583
584 (defun octave-looking-at-kw (regexp) 584 (defun octave-looking-at-kw (regexp)
585 "Like `looking-at', but sets `case-fold-search' nil."
585 (let ((case-fold-search nil)) 586 (let ((case-fold-search nil))
586 (looking-at regexp))) 587 (looking-at regexp)))
587 588
588 (defun octave-re-search-forward-kw (regexp) 589 (defun octave-re-search-forward-kw (regexp count)
590 "Like `re-search-forward', but sets `case-fold-search' nil, and moves point."
589 (let ((case-fold-search nil)) 591 (let ((case-fold-search nil))
590 (re-search-forward regexp nil 'move inc))) 592 (re-search-forward regexp nil 'move count)))
591 593
592 (defun octave-re-search-backward-kw (regexp) 594 (defun octave-re-search-backward-kw (regexp count)
595 "Like `re-search-backward', but sets `case-fold-search' nil, and moves point."
593 (let ((case-fold-search nil)) 596 (let ((case-fold-search nil))
594 (re-search-backward regexp nil 'move inc))) 597 (re-search-backward regexp nil 'move count)))
595 598
596 (defun octave-in-defun-p () 599 (defun octave-in-defun-p ()
597 "Return t if point is inside an Octave function declaration. 600 "Return t if point is inside an Octave function declaration.
598 The function is taken to start at the `f' of `function' and to end after 601 The function is taken to start at the `f' of `function' and to end after
599 the end keyword." 602 the end keyword."
865 (inc (if (> count 0) 1 -1))) 868 (inc (if (> count 0) 1 -1)))
866 (save-excursion 869 (save-excursion
867 (while (/= count 0) 870 (while (/= count 0)
868 (catch 'foo 871 (catch 'foo
869 (while (or (octave-re-search-forward-kw 872 (while (or (octave-re-search-forward-kw
870 octave-block-begin-or-end-regexp) 873 octave-block-begin-or-end-regexp inc)
871 (if (/= depth 0) 874 (if (/= depth 0)
872 (error "Unbalanced block"))) 875 (error "Unbalanced block")))
873 (if (octave-not-in-string-or-comment-p) 876 (if (octave-not-in-string-or-comment-p)
874 (progn 877 (progn
875 (cond 878 (cond
1035 (and (not (eobp)) 1038 (and (not (eobp))
1036 (not (and (> arg 0) (octave-looking-at-kw "\\<function\\>"))) 1039 (not (and (> arg 0) (octave-looking-at-kw "\\<function\\>")))
1037 (skip-syntax-forward "w")) 1040 (skip-syntax-forward "w"))
1038 (while (and (/= arg 0) 1041 (while (and (/= arg 0)
1039 (setq found 1042 (setq found
1040 (octave-re-search-backward-kw "\\<function\\>"))) 1043 (octave-re-search-backward-kw "\\<function\\>" inc)))
1041 (if (octave-not-in-string-or-comment-p) 1044 (if (octave-not-in-string-or-comment-p)
1042 (setq arg (- arg inc)))) 1045 (setq arg (- arg inc))))
1043 (if found 1046 (if found
1044 (progn 1047 (progn
1045 (and (< inc 0) (goto-char (match-beginning 0))) 1048 (and (< inc 0) (goto-char (match-beginning 0)))