/[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.19 by pj, Sun Dec 30 22:20:58 2001 UTC revision 1.19.4.1 by miles, Fri Apr 4 06:20:36 2003 UTC
# Line 51  Line 51 
51  (defvar inferior-octave-receive-in-progress nil)  (defvar inferior-octave-receive-in-progress nil)
52    
53  (defconst octave-maintainer-address  (defconst octave-maintainer-address
54    "Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>, bug-gnu-emacs@gnu.org"    "Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>, bug-gnu-emacs@gnu.org"
55    "Current maintainer of the Emacs Octave package.")    "Current maintainer of the Emacs Octave package.")
56    
57  (defvar octave-abbrev-table nil  (defvar octave-abbrev-table nil
# Line 207  parenthetical grouping.") Line 207  parenthetical grouping.")
207      (define-key map "\n" 'octave-reindent-then-newline-and-indent)      (define-key map "\n" 'octave-reindent-then-newline-and-indent)
208      (define-key map "\t" 'indent-according-to-mode)      (define-key map "\t" 'indent-according-to-mode)
209      (define-key map "\e;" 'octave-indent-for-comment)      (define-key map "\e;" 'octave-indent-for-comment)
210      (define-key map "\e\n" 'octave-indent-new-comment-line)        (define-key map "\e\n" 'octave-indent-new-comment-line)
211      (define-key map "\e\t" 'octave-complete-symbol)      (define-key map "\e\t" 'octave-complete-symbol)
212      (define-key map "\M-\C-a" 'octave-beginning-of-defun)      (define-key map "\M-\C-a" 'octave-beginning-of-defun)
213      (define-key map "\M-\C-e" 'octave-end-of-defun)      (define-key map "\M-\C-e" 'octave-end-of-defun)
214      (define-key map "\M-\C-h" 'octave-mark-defun)      (define-key map "\M-\C-h" 'octave-mark-defun)
215      (define-key map "\M-\C-q" 'octave-indent-defun)        (define-key map "\M-\C-q" 'octave-indent-defun)
216      (define-key map "\C-c;" 'octave-comment-region)      (define-key map "\C-c;" 'octave-comment-region)
217      (define-key map "\C-c:" 'octave-uncomment-region)        (define-key map "\C-c:" 'octave-uncomment-region)
218      (define-key map "\C-c\C-b" 'octave-submit-bug-report)      (define-key map "\C-c\C-b" 'octave-submit-bug-report)
219      (define-key map "\C-c\C-p" 'octave-previous-code-line)      (define-key map "\C-c\C-p" 'octave-previous-code-line)
220      (define-key map "\C-c\C-n" 'octave-next-code-line)      (define-key map "\C-c\C-n" 'octave-next-code-line)
221      (define-key map "\C-c\C-a" 'octave-beginning-of-line)      (define-key map "\C-c\C-a" 'octave-beginning-of-line)
222      (define-key map "\C-c\C-e" 'octave-end-of-line)        (define-key map "\C-c\C-e" 'octave-end-of-line)
223      (define-key map "\C-c\M-\C-n" 'octave-forward-block)      (define-key map "\C-c\M-\C-n" 'octave-forward-block)
224      (define-key map "\C-c\M-\C-p" 'octave-backward-block)      (define-key map "\C-c\M-\C-p" 'octave-backward-block)
225      (define-key map "\C-c\M-\C-u" 'octave-backward-up-block)      (define-key map "\C-c\M-\C-u" 'octave-backward-up-block)
226      (define-key map "\C-c\M-\C-d" 'octave-down-block)      (define-key map "\C-c\M-\C-d" 'octave-down-block)
227      (define-key map "\C-c\M-\C-h" 'octave-mark-block)      (define-key map "\C-c\M-\C-h" 'octave-mark-block)
228      (define-key map "\C-c]" 'octave-close-block)      (define-key map "\C-c]" 'octave-close-block)
229      (define-key map "\C-cf" 'octave-insert-defun)      (define-key map "\C-c\C-f" 'octave-insert-defun)
230      (define-key map "\C-c\C-h" 'octave-help)      (define-key map "\C-c\C-h" 'octave-help)
231      (define-key map "\C-cil" 'octave-send-line)      (define-key map "\C-c\C-il" 'octave-send-line)
232      (define-key map "\C-cib" 'octave-send-block)      (define-key map "\C-c\C-ib" 'octave-send-block)
233      (define-key map "\C-cif" 'octave-send-defun)      (define-key map "\C-c\C-if" 'octave-send-defun)
234      (define-key map "\C-cir" 'octave-send-region)        (define-key map "\C-c\C-ir" 'octave-send-region)
235      (define-key map "\C-cis" 'octave-show-process-buffer)      (define-key map "\C-c\C-is" 'octave-show-process-buffer)
236      (define-key map "\C-cih" 'octave-hide-process-buffer)      (define-key map "\C-c\C-ih" 'octave-hide-process-buffer)
237      (define-key map "\C-cik" 'octave-kill-process)      (define-key map "\C-c\C-ik" 'octave-kill-process)
238        (define-key map "\C-c\C-i\C-l" 'octave-send-line)
239        (define-key map "\C-c\C-i\C-b" 'octave-send-block)
240        (define-key map "\C-c\C-i\C-f" 'octave-send-defun)
241        (define-key map "\C-c\C-i\C-r" 'octave-send-region)
242        (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer)
243        (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer)
244        (define-key map "\C-c\C-i\C-k" 'octave-kill-process)
245      (setq octave-mode-map map)))      (setq octave-mode-map map)))
246    
247  (defvar octave-mode-menu  (defvar octave-mode-menu
# Line 376  end keywords as associated values.") Line 383  end keywords as associated values.")
383    "Alist of Octave symbols for completion in Octave mode.    "Alist of Octave symbols for completion in Octave mode.
384  Each element looks like (VAR . VAR), where the car and cdr are the same  Each element looks like (VAR . VAR), where the car and cdr are the same
385  symbol (an Octave command or variable name).  symbol (an Octave command or variable name).
386  Currently, only builtin variables can be completed.")  Currently, only builtin variables can be completed.")
387    
388  (defvar octave-mode-imenu-generic-expression  (defvar octave-mode-imenu-generic-expression
389    (list    (list
# Line 509  including a reproducible test case and s Line 516  including a reproducible test case and s
516    (setq mode-name "Octave")    (setq mode-name "Octave")
517    (setq local-abbrev-table octave-abbrev-table)    (setq local-abbrev-table octave-abbrev-table)
518    (set-syntax-table octave-mode-syntax-table)    (set-syntax-table octave-mode-syntax-table)
519      
520    (make-local-variable 'indent-line-function)    (make-local-variable 'indent-line-function)
521    (setq indent-line-function 'octave-indent-line)    (setq indent-line-function 'octave-indent-line)
522    
523    (make-local-variable 'comment-start)      (make-local-variable 'comment-start)
524    (setq comment-start octave-comment-start)    (setq comment-start octave-comment-start)
525    (make-local-variable 'comment-end)    (make-local-variable 'comment-end)
526    (setq comment-end "")    (setq comment-end "")
527    (make-local-variable 'comment-column)    (make-local-variable 'comment-column)
528    (setq comment-column 32)        (setq comment-column 32)
529    (make-local-variable 'comment-start-skip)    (make-local-variable 'comment-start-skip)
530    (setq comment-start-skip "\\s<+\\s-*")    (setq comment-start-skip "\\s<+\\s-*")
531    (make-local-variable 'comment-indent-function)    (make-local-variable 'comment-indent-function)
# Line 559  including a reproducible test case and s Line 566  including a reproducible test case and s
566    (describe-function major-mode))    (describe-function major-mode))
567    
568  (defun octave-point (position)  (defun octave-point (position)
569    "Returns the value of point at certain positions."    "Returns the value of point at certain positions."
570    (save-excursion    (save-excursion
571      (cond      (cond
572       ((eq position 'bol)  (beginning-of-line))       ((eq position 'bol)  (beginning-of-line))
# Line 637  See `comment-region'." Line 644  See `comment-region'."
644    (interactive "r\nP")    (interactive "r\nP")
645    (let ((comment-start (char-to-string octave-comment-char)))    (let ((comment-start (char-to-string octave-comment-char)))
646      (comment-region beg end arg)))      (comment-region beg end arg)))
647      
648  (defun octave-uncomment-region (beg end &optional arg)  (defun octave-uncomment-region (beg end &optional arg)
649    "Uncomment each line in the region as Octave code."    "Uncomment each line in the region as Octave code."
650    (interactive "r\nP")    (interactive "r\nP")
# Line 734  level." Line 741  level."
741    "Maybe insert and indent an Octave comment.    "Maybe insert and indent an Octave comment.
742  If there is no comment already on this line, create a code-level comment  If there is no comment already on this line, create a code-level comment
743  \(started by two comment characters) if the line is empty, or an in-line  \(started by two comment characters) if the line is empty, or an in-line
744  comment (started by one comment character) otherwise.  comment (started by one comment character) otherwise.
745  Point is left after the start of the comment which is properly aligned."  Point is left after the start of the comment which is properly aligned."
746    (interactive)    (interactive)
747    (indent-for-comment)    (indent-for-comment)
# Line 760  fixed goal column." Line 767  fixed goal column."
767  (defun octave-indent-new-comment-line ()  (defun octave-indent-new-comment-line ()
768    "Break Octave line at point, continuing comment if within one.    "Break Octave line at point, continuing comment if within one.
769  If within code, insert `octave-continuation-string' before breaking the  If within code, insert `octave-continuation-string' before breaking the
770  line.  If within a string, signal an error.    line.  If within a string, signal an error.
771  The new line is properly indented."  The new line is properly indented."
772    (interactive)    (interactive)
773    (delete-horizontal-space)    (delete-horizontal-space)
774    (cond    (cond
# Line 801  On success, return 0.  Otherwise, go as Line 808  On success, return 0.  Otherwise, go as
808          (setq n (forward-line inc)))          (setq n (forward-line inc)))
809        (setq arg (- arg inc)))        (setq arg (- arg inc)))
810      n))      n))
811          
812  (defun octave-previous-code-line (&optional arg)  (defun octave-previous-code-line (&optional arg)
813    "Move ARG lines of Octave code backward (forward if ARG is negative).    "Move ARG lines of Octave code backward (forward if ARG is negative).
814  Skips past all empty and comment lines.  Default for ARG is 1.  Skips past all empty and comment lines.  Default for ARG is 1.
# Line 856  does not end in `...' or `\\' or is insi Line 863  does not end in `...' or `\\' or is insi
863                            (looking-at octave-continuation-regexp)))                            (looking-at octave-continuation-regexp)))
864                      (zerop (forward-line 1)))))                      (zerop (forward-line 1)))))
865      (end-of-line)))      (end-of-line)))
866      
867  (defun octave-scan-blocks (from count depth)  (defun octave-scan-blocks (from count depth)
868    "Scan from character number FROM by COUNT Octave begin-end blocks.    "Scan from character number FROM by COUNT Octave begin-end blocks.
869  Returns the character number of the position thus found.  Returns the character number of the position thus found.
# Line 1061  An end of a function occurs right after Line 1068  An end of a function occurs right after
1068    (interactive "p")    (interactive "p")
1069    (or arg (setq arg 1))    (or arg (setq arg 1))
1070    (and (< arg 0) (skip-syntax-backward "w"))    (and (< arg 0) (skip-syntax-backward "w"))
1071    (and (> arg 0) (skip-syntax-forward "w"))      (and (> arg 0) (skip-syntax-forward "w"))
1072    (if (octave-in-defun-p)    (if (octave-in-defun-p)
1073        (setq arg (- arg 1)))        (setq arg (- arg 1)))
1074    (if (= arg 0) (setq arg -1))    (if (= arg 0) (setq arg -1))
# Line 1084  The function marked is the one containin Line 1091  The function marked is the one containin
1091            (exchange-point-and-mark))            (exchange-point-and-mark))
1092        (goto-char pos)        (goto-char pos)
1093        (message "No function to mark found"))))        (message "No function to mark found"))))
1094      
1095    
1096  ;;; Filling  ;;; Filling
1097  (defun octave-auto-fill ()  (defun octave-auto-fill ()
# Line 1094  otherwise." Line 1101  otherwise."
1101    (let (fc give-up)    (let (fc give-up)
1102      (if (or (null (setq fc (current-fill-column)))      (if (or (null (setq fc (current-fill-column)))
1103              (save-excursion              (save-excursion
1104                (beginning-of-line)                (beginning-of-line)
1105                (and auto-fill-inhibit-regexp                (and auto-fill-inhibit-regexp
1106                     (looking-at auto-fill-inhibit-regexp))))                     (looking-at auto-fill-inhibit-regexp))))
1107          nil                             ; Can't do anything          nil                             ; Can't do anything
# Line 1151  otherwise." Line 1158  otherwise."
1158  (defun octave-fill-paragraph (&optional arg)  (defun octave-fill-paragraph (&optional arg)
1159   "Fill paragraph of Octave code, handling Octave comments."   "Fill paragraph of Octave code, handling Octave comments."
1160   (interactive "P")   (interactive "P")
1161   (save-excursion   (save-excursion
1162     (let ((end (progn (forward-paragraph) (point)))     (let ((end (progn (forward-paragraph) (point)))
1163           (beg (progn           (beg (progn
1164                  (forward-paragraph -1)                  (forward-paragraph -1)
# Line 1183  otherwise." Line 1190  otherwise."
1190                           (beginning-of-line)                           (beginning-of-line)
1191                           (looking-at "^\\s-*\\s<+\\s-*$"))))                           (looking-at "^\\s-*\\s<+\\s-*$"))))
1192               ;; This is a nonempty comment line which does not extend               ;; This is a nonempty comment line which does not extend
1193               ;; past the fill column.  If it is followed by an nonempty               ;; past the fill column.  If it is followed by a nonempty
1194               ;; comment line with the same comment prefix, try to               ;; comment line with the same comment prefix, try to
1195               ;; combine them, and repeat this until either we reach the               ;; combine them, and repeat this until either we reach the
1196               ;; fill-column or there is nothing more to combine.               ;; fill-column or there is nothing more to combine.
# Line 1256  variables." Line 1263  variables."
1263             (let ((list (all-completions string octave-completion-alist))             (let ((list (all-completions string octave-completion-alist))
1264                   (conf (current-window-configuration)))                   (conf (current-window-configuration)))
1265               ;; Taken from comint.el               ;; Taken from comint.el
1266               (message "Making completion list...")                           (message "Making completion list...")
1267               (with-output-to-temp-buffer "*Completions*"               (with-output-to-temp-buffer "*Completions*"
1268                 (display-completion-list list))                 (display-completion-list list))
1269               (message "Hit space to flush")               (message "Hit space to flush")
# Line 1277  variables." Line 1284  variables."
1284                       (set-window-configuration conf)                       (set-window-configuration conf)
1285                     (setq unread-command-events                     (setq unread-command-events
1286                           (listify-key-sequence key))))))))))                           (listify-key-sequence key))))))))))
1287                  
1288    
1289  ;;; Electric characters && friends  ;;; Electric characters && friends
1290  (defun octave-reindent-then-newline-and-indent ()  (defun octave-reindent-then-newline-and-indent ()
# Line 1376  entered without parens)." Line 1383  entered without parens)."
1383      (indent-according-to-mode)      (indent-according-to-mode)
1384      (newline 2)      (newline 2)
1385      (insert prefix "usage: " string)      (insert prefix "usage: " string)
1386      (reindent-then-newline-and-indent)          (reindent-then-newline-and-indent)
1387      (insert prefix)      (insert prefix)
1388      (reindent-then-newline-and-indent)          (reindent-then-newline-and-indent)
1389      (insert prefix)      (insert prefix)
1390      (indent-according-to-mode)      (indent-according-to-mode)
1391      (save-excursion      (save-excursion
1392        (newline 2)        (newline 2)
1393        (insert "endfunction")        (insert "endfunction")
1394        (indent-according-to-mode))))        (indent-according-to-mode))))
1395                  
1396    
1397  ;;; Menu  ;;; Menu
1398  (defun octave-add-octave-menu ()  (defun octave-add-octave-menu ()
1399    "Adds the `Octave' menu to the menu bar in Octave mode."    "Adds the `Octave' menu to the menu bar in Octave mode."
1400    (require 'easymenu)      (require 'easymenu)
1401    (easy-menu-define octave-mode-menu-map octave-mode-map    (easy-menu-define octave-mode-menu-map octave-mode-map
1402                      "Menu keymap for Octave mode." octave-mode-menu)                      "Menu keymap for Octave mode." octave-mode-menu)
1403    (easy-menu-add octave-mode-menu-map octave-mode-map))    (easy-menu-add octave-mode-menu-map octave-mode-map))
# Line 1424  entered without parens)." Line 1431  entered without parens)."
1431  (defun octave-send-region (beg end)  (defun octave-send-region (beg end)
1432    "Send current region to the inferior Octave process."    "Send current region to the inferior Octave process."
1433    (interactive "r")    (interactive "r")
1434    (inferior-octave t)      (inferior-octave t)
1435    (let ((proc inferior-octave-process)    (let ((proc inferior-octave-process)
1436          (string (buffer-substring-no-properties beg end))          (string (buffer-substring-no-properties beg end))
1437          line)          line)
# Line 1452  entered without parens)." Line 1459  entered without parens)."
1459        (display-buffer inferior-octave-buffer)))        (display-buffer inferior-octave-buffer)))
1460    
1461  (defun octave-send-block ()  (defun octave-send-block ()
1462    "Send current Octave block to the inferior Octave process."      "Send current Octave block to the inferior Octave process."
1463    (interactive)    (interactive)
1464    (save-excursion    (save-excursion
1465      (octave-mark-block)      (octave-mark-block)
# Line 1491  code line." Line 1498  code line."
1498          (print-escape-newlines nil)          (print-escape-newlines nil)
1499          (opoint (point)))          (opoint (point)))
1500      (terpri)      (terpri)
1501      (prin1          (prin1
1502       (save-excursion       (save-excursion
1503         (forward-sexp -1)         (forward-sexp -1)
1504         (inferior-octave-send-list-and-digest         (inferior-octave-send-list-and-digest

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.19.4.1

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