/[emacs]/emacs/lisp/progmodes/octave-mod.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/octave-mod.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by miles, Mon Sep 1 15:45:35 2003 UTC revision 1.24 by monnier, Fri Oct 24 18:58:28 2003 UTC
# Line 1  Line 1 
1  ;;; octave-mod.el --- editing Octave source files under Emacs  ;;; octave-mod.el --- editing Octave source files under Emacs
2    
3  ;; Copyright (C) 1997 Free Software Foundation, Inc.  ;; Copyright (C) 1997, 2003 Free Software Foundation, Inc.
4    
5  ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>  ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
6  ;; Author: John Eaton <jwe@bevo.che.wisc.edu>  ;; Author: John Eaton <jwe@bevo.che.wisc.edu>
# Line 94  All Octave abbrevs start with a grave ac Line 94  All Octave abbrevs start with a grave ac
94  (defvar octave-comment-char ?#  (defvar octave-comment-char ?#
95    "Character to start an Octave comment.")    "Character to start an Octave comment.")
96  (defvar octave-comment-start  (defvar octave-comment-start
97    (concat (make-string 1 octave-comment-char) " ")    (string octave-comment-char ?\ )
98    "String to insert to start a new Octave in-line comment.")    "String to insert to start a new Octave in-line comment.")
99  (defvar octave-comment-start-skip "\\s<+\\s-*"  (defvar octave-comment-start-skip "\\s<+\\s-*"
100    "Regexp to match the start of an Octave comment up to its body.")    "Regexp to match the start of an Octave comment up to its body.")
# Line 287  parenthetical grouping.") Line 287  parenthetical grouping.")
287          ["Lookup Octave Index"          octave-help t])          ["Lookup Octave Index"          octave-help t])
288    "Menu for Octave mode.")    "Menu for Octave mode.")
289    
290  (defvar octave-mode-syntax-table nil  (defvar octave-mode-syntax-table
   "Syntax table in use in octave-mode buffers.")  
 (if octave-mode-syntax-table  
     ()  
291    (let ((table (make-syntax-table)))    (let ((table (make-syntax-table)))
292      (modify-syntax-entry ?\r " "  table)      (modify-syntax-entry ?\r " "  table)
293      (modify-syntax-entry ?+ "."   table)      (modify-syntax-entry ?+ "."   table)
# Line 309  parenthetical grouping.") Line 306  parenthetical grouping.")
306      (modify-syntax-entry ?\" "\"" table)      (modify-syntax-entry ?\" "\"" table)
307      (modify-syntax-entry ?. "w"   table)      (modify-syntax-entry ?. "w"   table)
308      (modify-syntax-entry ?_ "w"   table)      (modify-syntax-entry ?_ "w"   table)
309      (modify-syntax-entry ?\% "."  table)      (modify-syntax-entry ?\% "<"  table)
310      (modify-syntax-entry ?\# "<"  table)      (modify-syntax-entry ?\# "<"  table)
311      (modify-syntax-entry ?\n ">"  table)      (modify-syntax-entry ?\n ">"  table)
312      (setq octave-mode-syntax-table table)))      table)
313      "Syntax table in use in `octave-mode' buffers.")
314    
315  (defcustom octave-auto-indent nil  (defcustom octave-auto-indent nil
316    "*Non-nil means indent line after a semicolon or space in Octave mode."    "*Non-nil means indent line after a semicolon or space in Octave mode."
# Line 565  including a reproducible test case and s Line 563  including a reproducible test case and s
563    (interactive)    (interactive)
564    (describe-function major-mode))    (describe-function major-mode))
565    
 (defun octave-point (position)  
   "Returns the value of point at certain positions."  
   (save-excursion  
     (cond  
      ((eq position 'bol)  (beginning-of-line))  
      ((eq position 'eol)  (end-of-line))  
      ((eq position 'boi)  (back-to-indentation))  
      ((eq position 'bonl) (forward-line 1))  
      ((eq position 'bopl) (forward-line -1))  
      (t (error "unknown buffer position requested: %s" position)))  
     (point)))  
   
566  (defsubst octave-in-comment-p ()  (defsubst octave-in-comment-p ()
567    "Returns t if point is inside an Octave comment, nil otherwise."    "Returns t if point is inside an Octave comment, nil otherwise."
568    (interactive)    (interactive)
569    (save-excursion    (save-excursion
570      (nth 4 (parse-partial-sexp (octave-point 'bol) (point)))))      (nth 4 (parse-partial-sexp (line-beginning-position) (point)))))
571    
572  (defsubst octave-in-string-p ()  (defsubst octave-in-string-p ()
573    "Returns t if point is inside an Octave string, nil otherwise."    "Returns t if point is inside an Octave string, nil otherwise."
574    (interactive)    (interactive)
575    (save-excursion    (save-excursion
576      (nth 3 (parse-partial-sexp (octave-point 'bol) (point)))))      (nth 3 (parse-partial-sexp (line-beginning-position) (point)))))
577    
578  (defsubst octave-not-in-string-or-comment-p ()  (defsubst octave-not-in-string-or-comment-p ()
579    "Returns t iff point is not inside an Octave string or comment."    "Returns t iff point is not inside an Octave string or comment."
580    (let ((pps (parse-partial-sexp (octave-point 'bol) (point))))    (let ((pps (parse-partial-sexp (line-beginning-position) (point))))
581      (not (or (nth 3 pps) (nth 4 pps)))))      (not (or (nth 3 pps) (nth 4 pps)))))
582    
583  (defun octave-in-block-p ()  (defun octave-in-block-p ()
# Line 682  level." Line 668  level."
668                (back-to-indentation)                (back-to-indentation)
669                (setq icol (current-column))                (setq icol (current-column))
670                (let ((bot (point))                (let ((bot (point))
671                      (eol (octave-point 'eol)))                      (eol (line-end-position)))
672                  (while (< (point) eol)                  (while (< (point) eol)
673                    (if (octave-not-in-string-or-comment-p)                    (if (octave-not-in-string-or-comment-p)
674                        (cond                        (cond
# Line 1017  Signal an error if the keywords are inco Line 1003  Signal an error if the keywords are inco
1003                  (buffer-substring-no-properties                  (buffer-substring-no-properties
1004                   (match-beginning 0) pos)                   (match-beginning 0) pos)
1005                  pos (+ pos 1)                  pos (+ pos 1)
1006                  eol (octave-point 'eol)                  eol (line-end-position)
1007                  bb-arg                  bb-arg
1008                  (save-excursion                  (save-excursion
1009                    (save-restriction                    (save-restriction
# Line 1123  otherwise." Line 1109  otherwise."
1109                    (if (save-excursion                    (if (save-excursion
1110                          (skip-syntax-backward " <")                          (skip-syntax-backward " <")
1111                          (bolp))                          (bolp))
1112                        (re-search-forward "[ \t]" (octave-point 'eol)                        (re-search-forward "[ \t]" (line-end-position)
1113                                           'move))                                           'move))
1114                    ;; If we're not in a comment line and just ahead the                    ;; If we're not in a comment line and just ahead the
1115                    ;; continuation string, don't break here.                    ;; continuation string, don't break here.

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26