diff options
| author | Stefan Monnier | 2003-10-24 18:58:28 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-10-24 18:58:28 +0000 |
| commit | cb3d3ec192d67e0799919123da6eb0cd46e09776 (patch) | |
| tree | 2169947bd3843396b3afa4d47897aa41d5b20515 | |
| parent | 418b094bd56cc761a13954d5f0d583fdf8f4bc5e (diff) | |
| download | emacs-cb3d3ec192d67e0799919123da6eb0cd46e09776.tar.gz emacs-cb3d3ec192d67e0799919123da6eb0cd46e09776.zip | |
(octave-comment-start): Simplify.
(octave-mode-syntax-table): Add % as a comment starter.
(octave-point): Remove.
(octave-in-comment-p, octave-in-string-p)
(octave-not-in-string-or-comment-p, calculate-octave-indent)
(octave-blink-matching-block-open, octave-auto-fill):
Use line-(beginning|end)-position instead.
| -rw-r--r-- | lisp/progmodes/octave-mod.el | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el index 6cd6b03bc01..281edfd693e 100644 --- a/lisp/progmodes/octave-mod.el +++ b/lisp/progmodes/octave-mod.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; octave-mod.el --- editing Octave source files under Emacs | 1 | ;;; octave-mod.el --- editing Octave source files under Emacs |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1997, 2003 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> | 5 | ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> |
| 6 | ;; Author: John Eaton <jwe@bevo.che.wisc.edu> | 6 | ;; Author: John Eaton <jwe@bevo.che.wisc.edu> |
| @@ -94,7 +94,7 @@ All Octave abbrevs start with a grave accent (`).") | |||
| 94 | (defvar octave-comment-char ?# | 94 | (defvar octave-comment-char ?# |
| 95 | "Character to start an Octave comment.") | 95 | "Character to start an Octave comment.") |
| 96 | (defvar octave-comment-start | 96 | (defvar octave-comment-start |
| 97 | (concat (make-string 1 octave-comment-char) " ") | 97 | (string octave-comment-char ?\ ) |
| 98 | "String to insert to start a new Octave in-line comment.") | 98 | "String to insert to start a new Octave in-line comment.") |
| 99 | (defvar octave-comment-start-skip "\\s<+\\s-*" | 99 | (defvar octave-comment-start-skip "\\s<+\\s-*" |
| 100 | "Regexp to match the start of an Octave comment up to its body.") | 100 | "Regexp to match the start of an Octave comment up to its body.") |
| @@ -287,10 +287,7 @@ parenthetical grouping.") | |||
| 287 | ["Lookup Octave Index" octave-help t]) | 287 | ["Lookup Octave Index" octave-help t]) |
| 288 | "Menu for Octave mode.") | 288 | "Menu for Octave mode.") |
| 289 | 289 | ||
| 290 | (defvar octave-mode-syntax-table nil | 290 | (defvar octave-mode-syntax-table |
| 291 | "Syntax table in use in octave-mode buffers.") | ||
| 292 | (if octave-mode-syntax-table | ||
| 293 | () | ||
| 294 | (let ((table (make-syntax-table))) | 291 | (let ((table (make-syntax-table))) |
| 295 | (modify-syntax-entry ?\r " " table) | 292 | (modify-syntax-entry ?\r " " table) |
| 296 | (modify-syntax-entry ?+ "." table) | 293 | (modify-syntax-entry ?+ "." table) |
| @@ -309,10 +306,11 @@ parenthetical grouping.") | |||
| 309 | (modify-syntax-entry ?\" "\"" table) | 306 | (modify-syntax-entry ?\" "\"" table) |
| 310 | (modify-syntax-entry ?. "w" table) | 307 | (modify-syntax-entry ?. "w" table) |
| 311 | (modify-syntax-entry ?_ "w" table) | 308 | (modify-syntax-entry ?_ "w" table) |
| 312 | (modify-syntax-entry ?\% "." table) | 309 | (modify-syntax-entry ?\% "<" table) |
| 313 | (modify-syntax-entry ?\# "<" table) | 310 | (modify-syntax-entry ?\# "<" table) |
| 314 | (modify-syntax-entry ?\n ">" table) | 311 | (modify-syntax-entry ?\n ">" table) |
| 315 | (setq octave-mode-syntax-table table))) | 312 | table) |
| 313 | "Syntax table in use in `octave-mode' buffers.") | ||
| 316 | 314 | ||
| 317 | (defcustom octave-auto-indent nil | 315 | (defcustom octave-auto-indent nil |
| 318 | "*Non-nil means indent line after a semicolon or space in Octave mode." | 316 | "*Non-nil means indent line after a semicolon or space in Octave mode." |
| @@ -565,33 +563,21 @@ including a reproducible test case and send the message." | |||
| 565 | (interactive) | 563 | (interactive) |
| 566 | (describe-function major-mode)) | 564 | (describe-function major-mode)) |
| 567 | 565 | ||
| 568 | (defun octave-point (position) | ||
| 569 | "Returns the value of point at certain positions." | ||
| 570 | (save-excursion | ||
| 571 | (cond | ||
| 572 | ((eq position 'bol) (beginning-of-line)) | ||
| 573 | ((eq position 'eol) (end-of-line)) | ||
| 574 | ((eq position 'boi) (back-to-indentation)) | ||
| 575 | ((eq position 'bonl) (forward-line 1)) | ||
| 576 | ((eq position 'bopl) (forward-line -1)) | ||
| 577 | (t (error "unknown buffer position requested: %s" position))) | ||
| 578 | (point))) | ||
| 579 | |||
| 580 | (defsubst octave-in-comment-p () | 566 | (defsubst octave-in-comment-p () |
| 581 | "Returns t if point is inside an Octave comment, nil otherwise." | 567 | "Returns t if point is inside an Octave comment, nil otherwise." |
| 582 | (interactive) | 568 | (interactive) |
| 583 | (save-excursion | 569 | (save-excursion |
| 584 | (nth 4 (parse-partial-sexp (octave-point 'bol) (point))))) | 570 | (nth 4 (parse-partial-sexp (line-beginning-position) (point))))) |
| 585 | 571 | ||
| 586 | (defsubst octave-in-string-p () | 572 | (defsubst octave-in-string-p () |
| 587 | "Returns t if point is inside an Octave string, nil otherwise." | 573 | "Returns t if point is inside an Octave string, nil otherwise." |
| 588 | (interactive) | 574 | (interactive) |
| 589 | (save-excursion | 575 | (save-excursion |
| 590 | (nth 3 (parse-partial-sexp (octave-point 'bol) (point))))) | 576 | (nth 3 (parse-partial-sexp (line-beginning-position) (point))))) |
| 591 | 577 | ||
| 592 | (defsubst octave-not-in-string-or-comment-p () | 578 | (defsubst octave-not-in-string-or-comment-p () |
| 593 | "Returns t iff point is not inside an Octave string or comment." | 579 | "Returns t iff point is not inside an Octave string or comment." |
| 594 | (let ((pps (parse-partial-sexp (octave-point 'bol) (point)))) | 580 | (let ((pps (parse-partial-sexp (line-beginning-position) (point)))) |
| 595 | (not (or (nth 3 pps) (nth 4 pps))))) | 581 | (not (or (nth 3 pps) (nth 4 pps))))) |
| 596 | 582 | ||
| 597 | (defun octave-in-block-p () | 583 | (defun octave-in-block-p () |
| @@ -682,7 +668,7 @@ level." | |||
| 682 | (back-to-indentation) | 668 | (back-to-indentation) |
| 683 | (setq icol (current-column)) | 669 | (setq icol (current-column)) |
| 684 | (let ((bot (point)) | 670 | (let ((bot (point)) |
| 685 | (eol (octave-point 'eol))) | 671 | (eol (line-end-position))) |
| 686 | (while (< (point) eol) | 672 | (while (< (point) eol) |
| 687 | (if (octave-not-in-string-or-comment-p) | 673 | (if (octave-not-in-string-or-comment-p) |
| 688 | (cond | 674 | (cond |
| @@ -1017,7 +1003,7 @@ Signal an error if the keywords are incompatible." | |||
| 1017 | (buffer-substring-no-properties | 1003 | (buffer-substring-no-properties |
| 1018 | (match-beginning 0) pos) | 1004 | (match-beginning 0) pos) |
| 1019 | pos (+ pos 1) | 1005 | pos (+ pos 1) |
| 1020 | eol (octave-point 'eol) | 1006 | eol (line-end-position) |
| 1021 | bb-arg | 1007 | bb-arg |
| 1022 | (save-excursion | 1008 | (save-excursion |
| 1023 | (save-restriction | 1009 | (save-restriction |
| @@ -1123,7 +1109,7 @@ otherwise." | |||
| 1123 | (if (save-excursion | 1109 | (if (save-excursion |
| 1124 | (skip-syntax-backward " <") | 1110 | (skip-syntax-backward " <") |
| 1125 | (bolp)) | 1111 | (bolp)) |
| 1126 | (re-search-forward "[ \t]" (octave-point 'eol) | 1112 | (re-search-forward "[ \t]" (line-end-position) |
| 1127 | 'move)) | 1113 | 'move)) |
| 1128 | ;; If we're not in a comment line and just ahead the | 1114 | ;; If we're not in a comment line and just ahead the |
| 1129 | ;; continuation string, don't break here. | 1115 | ;; continuation string, don't break here. |