Mercurial > hg > octave-nkf
changeset 5204:2a44a667da02
[project @ 2005-03-15 05:07:15 by jwe]
author | jwe |
---|---|
date | Tue, 15 Mar 2005 05:07:15 +0000 |
parents | dbeafbc0ff64 |
children | 59592dcbb5d8 |
files | ChangeLog emacs/octave-hlp.el emacs/octave-inf.el emacs/octave-mod.el |
diffstat | 4 files changed, 115 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-03-15 John W. Eaton <jwe@octave.org> + + * emacs/octave-inf.el, emacs/octave-mod.el, emacs/octave-hlp.el: + Import changes from Emacs. + +2005-03-14 Rafael Laboissiere <rafael@debian.org> + + * emacs/octave-mod.el (octave-end-keywords): Omit "end" from the list. + (octave-reserved-words): Include "end" here. + (octve-block-match-alist): Don't include "end" here. + 2005-03-14 John W. Eaton <jwe@octave.org> * configure.in: Check for umfpack/umfpack.h instead of just umfpack.h.
--- a/emacs/octave-hlp.el +++ b/emacs/octave-hlp.el @@ -80,7 +80,7 @@ The files specified by `octave-help-files' are searched." (if octave-help-lookup-alist () - (message "Building help lookup alist...") + (message "Building help lookup alist...") (let ((files octave-help-files) file key node) (save-window-excursion (while files @@ -127,7 +127,7 @@ (add-to-list 'octave-help-completion-alist (cons (car entry) (car entry))) (setq alist (cdr alist)))) - (message "Building help completion alist...done")) + (message "Building help completion alist...done")) octave-help-completion-alist) ;;; provide ourself
--- a/emacs/octave-inf.el +++ b/emacs/octave-inf.el @@ -24,6 +24,8 @@ ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. +;;; Commentary: + ;;; Code: (require 'octave-mod) @@ -93,6 +95,17 @@ ;; Could certainly do more font locking in inferior Octave ... "Additional expressions to highlight in Inferior Octave mode.") + +;;; Compatibility functions +(if (not (fboundp 'comint-line-beginning-position)) + ;; comint-line-beginning-position is defined in Emacs 21 + (defun comint-line-beginning-position () + "Returns the buffer position of the beginning of the line, after any prompt. +The prompt is assumed to be any text at the beginning of the line matching +the regular expression `comint-prompt-regexp', a buffer local variable." + (save-excursion (comint-bol nil) (point)))) + + (defvar inferior-octave-output-list nil) (defvar inferior-octave-output-string nil) (defvar inferior-octave-receive-in-progress nil) @@ -103,7 +116,7 @@ "Non-nil means that `inferior-octave-complete' is impossible.") (defvar inferior-octave-dynamic-complete-functions - '(inferior-octave-complete comint-dynamic-complete-filename) + '(inferior-octave-complete comint-dynamic-complete-filename) "List of functions called to perform completion for inferior Octave. This variable is used to initialize `comint-dynamic-complete-functions' in the Inferior Octave buffer.") @@ -125,12 +138,12 @@ (use-local-map inferior-octave-mode-map) (set-syntax-table inferior-octave-mode-syntax-table) - (make-local-variable 'comment-start) + (make-local-variable 'comment-start) (setq comment-start octave-comment-start) (make-local-variable 'comment-end) (setq comment-end "") (make-local-variable 'comment-column) - (setq comment-column 32) + (setq comment-column 32) (make-local-variable 'comment-start-skip) (setq comment-start-skip octave-comment-start-skip) @@ -214,7 +227,7 @@ (setq commands (list "page_screen_output = 0;\n" (if (not (string-equal - inferior-octave-output-string ">> ")) + inferior-octave-output-string ">> ")) "PS1=\"\\\\s> \";\n") (if (file-exists-p file) (format "source (\"%s\");\n" file)))) @@ -243,11 +256,10 @@ is NOT available with versions of Octave prior to 2.0." (interactive) (let* ((end (point)) - (command (save-excursion - (skip-syntax-backward "w_") - (and (looking-at comint-prompt-regexp) - (goto-char (match-end 0))) - (buffer-substring-no-properties (point) end))) + (command + (save-excursion + (skip-syntax-backward "w_" (comint-line-beginning-position)) + (buffer-substring-no-properties (point) end))) (proc (get-buffer-process inferior-octave-buffer)) (filter (process-filter proc))) (cond (inferior-octave-complete-impossible
--- a/emacs/octave-mod.el +++ b/emacs/octave-mod.el @@ -1,6 +1,6 @@ ;;; octave-mod.el --- editing Octave source files under Emacs -;; Copyright (C) 1997 Free Software Foundation, Inc. +;; Copyright (C) 1997, 2003 Free Software Foundation, Inc. ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> ;; Author: John Eaton <jwe@bevo.che.wisc.edu> @@ -51,46 +51,45 @@ (defvar inferior-octave-receive-in-progress nil) (defconst octave-maintainer-address - "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" "Current maintainer of the Emacs Octave package.") (defvar octave-abbrev-table nil "Abbrev table for Octave's reserved words. -Used in octave-mode and inferior-octave-mode buffers. +Used in `octave-mode' and inferior-octave-mode buffers. All Octave abbrevs start with a grave accent (`).") -(if octave-abbrev-table - () +(unless octave-abbrev-table (let ((ac abbrevs-changed)) (define-abbrev-table 'octave-abbrev-table ()) - (define-abbrev octave-abbrev-table "`a" "all_va_args" nil) - (define-abbrev octave-abbrev-table "`b" "break" nil) - (define-abbrev octave-abbrev-table "`cs" "case" nil) - (define-abbrev octave-abbrev-table "`ca" "catch" nil) - (define-abbrev octave-abbrev-table "`c" "continue" nil) - (define-abbrev octave-abbrev-table "`el" "else" nil) - (define-abbrev octave-abbrev-table "`eli" "elseif" nil) - (define-abbrev octave-abbrev-table "`et" "end_try_catch" nil) - (define-abbrev octave-abbrev-table "`eu" "end_unwind_protect" nil) - (define-abbrev octave-abbrev-table "`ef" "endfor" nil) - (define-abbrev octave-abbrev-table "`efu" "endfunction" nil) - (define-abbrev octave-abbrev-table "`ei" "endif" nil) - (define-abbrev octave-abbrev-table "`es" "endswitch" nil) - (define-abbrev octave-abbrev-table "`ew" "endwhile" nil) - (define-abbrev octave-abbrev-table "`f" "for" nil) - (define-abbrev octave-abbrev-table "`fu" "function" nil) - (define-abbrev octave-abbrev-table "`gl" "global" nil) - (define-abbrev octave-abbrev-table "`gp" "gplot" nil) - (define-abbrev octave-abbrev-table "`gs" "gsplot" nil) - (define-abbrev octave-abbrev-table "`if" "if ()" nil) - (define-abbrev octave-abbrev-table "`o" "otherwise" nil) - (define-abbrev octave-abbrev-table "`rp" "replot" nil) - (define-abbrev octave-abbrev-table "`r" "return" nil) - (define-abbrev octave-abbrev-table "`s" "switch" nil) - (define-abbrev octave-abbrev-table "`t" "try" nil) - (define-abbrev octave-abbrev-table "`u" "until ()" nil) - (define-abbrev octave-abbrev-table "`up" "unwind_protect" nil) - (define-abbrev octave-abbrev-table "`upc" "unwind_protect_cleanup" nil) - (define-abbrev octave-abbrev-table "`w" "while ()" nil) + (define-abbrev octave-abbrev-table "`a" "all_va_args" nil 0 t) + (define-abbrev octave-abbrev-table "`b" "break" nil 0 t) + (define-abbrev octave-abbrev-table "`cs" "case" nil 0 t) + (define-abbrev octave-abbrev-table "`ca" "catch" nil 0 t) + (define-abbrev octave-abbrev-table "`c" "continue" nil 0 t) + (define-abbrev octave-abbrev-table "`el" "else" nil 0 t) + (define-abbrev octave-abbrev-table "`eli" "elseif" nil 0 t) + (define-abbrev octave-abbrev-table "`et" "end_try_catch" nil 0 t) + (define-abbrev octave-abbrev-table "`eu" "end_unwind_protect" nil 0 t) + (define-abbrev octave-abbrev-table "`ef" "endfor" nil 0 t) + (define-abbrev octave-abbrev-table "`efu" "endfunction" nil 0 t) + (define-abbrev octave-abbrev-table "`ei" "endif" nil 0 t) + (define-abbrev octave-abbrev-table "`es" "endswitch" nil 0 t) + (define-abbrev octave-abbrev-table "`ew" "endwhile" nil 0 t) + (define-abbrev octave-abbrev-table "`f" "for" nil 0 t) + (define-abbrev octave-abbrev-table "`fu" "function" nil 0 t) + (define-abbrev octave-abbrev-table "`gl" "global" nil 0 t) + (define-abbrev octave-abbrev-table "`gp" "gplot" nil 0 t) + (define-abbrev octave-abbrev-table "`gs" "gsplot" nil 0 t) + (define-abbrev octave-abbrev-table "`if" "if ()" nil 0 t) + (define-abbrev octave-abbrev-table "`o" "otherwise" nil 0 t) + (define-abbrev octave-abbrev-table "`rp" "replot" nil 0 t) + (define-abbrev octave-abbrev-table "`r" "return" nil 0 t) + (define-abbrev octave-abbrev-table "`s" "switch" nil 0 t) + (define-abbrev octave-abbrev-table "`t" "try" nil 0 t) + (define-abbrev octave-abbrev-table "`u" "until ()" nil 0 t) + (define-abbrev octave-abbrev-table "`up" "unwind_protect" nil 0 t) + (define-abbrev octave-abbrev-table "`upc" "unwind_protect_cleanup" nil 0 t) + (define-abbrev octave-abbrev-table "`w" "while ()" nil 0 t) (setq abbrevs-changed ac))) (defvar octave-comment-char ?# @@ -105,15 +104,18 @@ '("do" "for" "function" "if" "switch" "try" "unwind_protect" "while")) (defvar octave-else-keywords '("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup")) +;; Only use specific "end" tokens here to avoid confusion when "end" +;; is used in indexing (the real fix is much more complex, and is +;; probably not worth the effort). (defvar octave-end-keywords - '("end" "endfor" "endfunction" "endif" "endswitch" "end_try_catch" + '("endfor" "endfunction" "endif" "endswitch" "end_try_catch" "end_unwind_protect" "endwhile" "until")) (defvar octave-reserved-words (append octave-begin-keywords octave-else-keywords octave-end-keywords - '("all_va_args" "break" "continue" "global" "gplot" "gsplot" + '("all_va_args" "break" "continue" "end" "global" "gplot" "gsplot" "replot" "return")) "Reserved words in Octave.") @@ -212,19 +214,19 @@ (define-key map "\n" 'octave-reindent-then-newline-and-indent) (define-key map "\t" 'indent-according-to-mode) (define-key map "\e;" 'octave-indent-for-comment) - (define-key map "\e\n" 'octave-indent-new-comment-line) + (define-key map "\e\n" 'octave-indent-new-comment-line) (define-key map "\e\t" 'octave-complete-symbol) (define-key map "\M-\C-a" 'octave-beginning-of-defun) (define-key map "\M-\C-e" 'octave-end-of-defun) (define-key map "\M-\C-h" 'octave-mark-defun) - (define-key map "\M-\C-q" 'octave-indent-defun) + (define-key map "\M-\C-q" 'octave-indent-defun) (define-key map "\C-c;" 'octave-comment-region) - (define-key map "\C-c:" 'octave-uncomment-region) + (define-key map "\C-c:" 'octave-uncomment-region) (define-key map "\C-c\C-b" 'octave-submit-bug-report) (define-key map "\C-c\C-p" 'octave-previous-code-line) (define-key map "\C-c\C-n" 'octave-next-code-line) (define-key map "\C-c\C-a" 'octave-beginning-of-line) - (define-key map "\C-c\C-e" 'octave-end-of-line) + (define-key map "\C-c\C-e" 'octave-end-of-line) (define-key map "\C-c\M-\C-n" 'octave-forward-block) (define-key map "\C-c\M-\C-p" 'octave-backward-block) (define-key map "\C-c\M-\C-u" 'octave-backward-up-block) @@ -236,14 +238,14 @@ (define-key map "\C-c\C-il" 'octave-send-line) (define-key map "\C-c\C-ib" 'octave-send-block) (define-key map "\C-c\C-if" 'octave-send-defun) - (define-key map "\C-c\C-ir" 'octave-send-region) + (define-key map "\C-c\C-ir" 'octave-send-region) (define-key map "\C-c\C-is" 'octave-show-process-buffer) (define-key map "\C-c\C-ih" 'octave-hide-process-buffer) (define-key map "\C-c\C-ik" 'octave-kill-process) (define-key map "\C-c\C-i\C-l" 'octave-send-line) (define-key map "\C-c\C-i\C-b" 'octave-send-block) (define-key map "\C-c\C-i\C-f" 'octave-send-defun) - (define-key map "\C-c\C-i\C-r" 'octave-send-region) + (define-key map "\C-c\C-i\C-r" 'octave-send-region) (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer) (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer) (define-key map "\C-c\C-i\C-k" 'octave-kill-process) @@ -354,16 +356,19 @@ (concat octave-block-begin-regexp "\\|" octave-block-end-regexp)) (defvar octave-block-else-or-end-regexp (concat octave-block-else-regexp "\\|" octave-block-end-regexp)) +;; Only use specific "end" tokens here to avoid confusion when "end" +;; is used in indexing (the real fix is much more complex, and is +;; probably not worth the effort). (defvar octave-block-match-alist '(("do" . ("until")) - ("for" . ("end" "endfor")) - ("function" . ("end" "endfunction")) - ("if" . ("else" "elseif" "end" "endif")) - ("switch" . ("case" "otherwise" "end" "endswitch")) - ("try" . ("catch" "end" "end_try_catch")) - ("unwind_protect" . ("unwind_protect_cleanup" "end" + ("for" . ("endfor")) + ("function" . ("endfunction")) + ("if" . ("else" "elseif" "endif")) + ("switch" . ("case" "otherwise" "endswitch")) + ("try" . ("catch" "end_try_catch")) + ("unwind_protect" . ("unwind_protect_cleanup" "end_unwind_protect")) - ("while" . ("end" "endwhile"))) + ("while" . ("endwhile"))) "Alist with Octave's matching block keywords. Has Octave's begin keywords as keys and a list of the matching else or end keywords as associated values.") @@ -387,7 +392,7 @@ "Alist of Octave symbols for completion in Octave mode. Each element looks like (VAR . VAR), where the car and cdr are the same symbol (an Octave command or variable name). -Currently, only builtin variables can be completed.") +Currently, only builtin variables can be completed.") (defvar octave-mode-imenu-generic-expression (list @@ -396,7 +401,7 @@ "Imenu expression for Octave mode. See `imenu-generic-expression'.") (defcustom octave-mode-startup-message t - "*Nil means do not display the Octave mode startup message." + "*nil means do not display the Octave mode startup message." :type 'boolean :group 'octave) @@ -474,7 +479,7 @@ Default is a backslash. octave-mode-startup-message - Nil means do not display the Octave mode startup message. + nil means do not display the Octave mode startup message. Default is t. octave-send-echo-input @@ -520,16 +525,16 @@ (setq mode-name "Octave") (setq local-abbrev-table octave-abbrev-table) (set-syntax-table octave-mode-syntax-table) - + (make-local-variable 'indent-line-function) (setq indent-line-function 'octave-indent-line) - (make-local-variable 'comment-start) + (make-local-variable 'comment-start) (setq comment-start octave-comment-start) (make-local-variable 'comment-end) (setq comment-end "") (make-local-variable 'comment-column) - (setq comment-column 32) + (setq comment-column 32) (make-local-variable 'comment-start-skip) (setq comment-start-skip "\\s<+\\s-*") (make-local-variable 'comment-indent-function) @@ -643,7 +648,7 @@ (interactive "r\nP") (let ((comment-start (char-to-string octave-comment-char))) (comment-region beg end arg))) - + (defun octave-uncomment-region (beg end &optional arg) "Uncomment each line in the region as Octave code." (interactive "r\nP") @@ -739,8 +744,8 @@ (defun octave-indent-for-comment () "Maybe insert and indent an Octave comment. If there is no comment already on this line, create a code-level comment -(started by two comment characters) if the line is empty, or an in-line -comment (started by one comment character) otherwise. +\(started by two comment characters) if the line is empty, or an in-line +comment (started by one comment character) otherwise. Point is left after the start of the comment which is properly aligned." (interactive) (indent-for-comment) @@ -766,8 +771,8 @@ (defun octave-indent-new-comment-line () "Break Octave line at point, continuing comment if within one. If within code, insert `octave-continuation-string' before breaking the -line. If within a string, signal an error. -The new line is properly indented." +line. If within a string, signal an error. +The new line is properly indented." (interactive) (delete-horizontal-space) (cond @@ -807,7 +812,7 @@ (setq n (forward-line inc))) (setq arg (- arg inc))) n)) - + (defun octave-previous-code-line (&optional arg) "Move ARG lines of Octave code backward (forward if ARG is negative). Skips past all empty and comment lines. Default for ARG is 1. @@ -862,7 +867,7 @@ (looking-at octave-continuation-regexp))) (zerop (forward-line 1))))) (end-of-line))) - + (defun octave-scan-blocks (from count depth) "Scan from character number FROM by COUNT Octave begin-end blocks. Returns the character number of the position thus found. @@ -1067,7 +1072,7 @@ (interactive "p") (or arg (setq arg 1)) (and (< arg 0) (skip-syntax-backward "w")) - (and (> arg 0) (skip-syntax-forward "w")) + (and (> arg 0) (skip-syntax-forward "w")) (if (octave-in-defun-p) (setq arg (- arg 1))) (if (= arg 0) (setq arg -1)) @@ -1090,7 +1095,7 @@ (exchange-point-and-mark)) (goto-char pos) (message "No function to mark found")))) - + ;;; Filling (defun octave-auto-fill () @@ -1100,7 +1105,7 @@ (let (fc give-up) (if (or (null (setq fc (current-fill-column))) (save-excursion - (beginning-of-line) + (beginning-of-line) (and auto-fill-inhibit-regexp (looking-at auto-fill-inhibit-regexp)))) nil ; Can't do anything @@ -1157,7 +1162,7 @@ (defun octave-fill-paragraph (&optional arg) "Fill paragraph of Octave code, handling Octave comments." (interactive "P") - (save-excursion + (save-excursion (let ((end (progn (forward-paragraph) (point))) (beg (progn (forward-paragraph -1) @@ -1189,7 +1194,7 @@ (beginning-of-line) (looking-at "^\\s-*\\s<+\\s-*$")))) ;; This is a nonempty comment line which does not extend - ;; past the fill column. If it is followed by an nonempty + ;; past the fill column. If it is followed by a nonempty ;; comment line with the same comment prefix, try to ;; combine them, and repeat this until either we reach the ;; fill-column or there is nothing more to combine. @@ -1262,7 +1267,7 @@ (let ((list (all-completions string octave-completion-alist)) (conf (current-window-configuration))) ;; Taken from comint.el - (message "Making completion list...") + (message "Making completion list...") (with-output-to-temp-buffer "*Completions*" (display-completion-list list)) (message "Hit space to flush") @@ -1283,7 +1288,7 @@ (set-window-configuration conf) (setq unread-command-events (listify-key-sequence key)))))))))) - + ;;; Electric characters && friends (defun octave-reindent-then-newline-and-indent () @@ -1382,21 +1387,21 @@ (indent-according-to-mode) (newline 2) (insert prefix "usage: " string) - (reindent-then-newline-and-indent) + (reindent-then-newline-and-indent) (insert prefix) - (reindent-then-newline-and-indent) + (reindent-then-newline-and-indent) (insert prefix) (indent-according-to-mode) (save-excursion (newline 2) (insert "endfunction") (indent-according-to-mode)))) - + ;;; Menu (defun octave-add-octave-menu () "Adds the `Octave' menu to the menu bar in Octave mode." - (require 'easymenu) + (require 'easymenu) (easy-menu-define octave-mode-menu-map octave-mode-map "Menu keymap for Octave mode." octave-mode-menu) (easy-menu-add octave-mode-menu-map octave-mode-map)) @@ -1430,7 +1435,7 @@ (defun octave-send-region (beg end) "Send current region to the inferior Octave process." (interactive "r") - (inferior-octave t) + (inferior-octave t) (let ((proc inferior-octave-process) (string (buffer-substring-no-properties beg end)) line) @@ -1458,7 +1463,7 @@ (display-buffer inferior-octave-buffer))) (defun octave-send-block () - "Send current Octave block to the inferior Octave process." + "Send current Octave block to the inferior Octave process." (interactive) (save-excursion (octave-mark-block) @@ -1497,7 +1502,7 @@ (print-escape-newlines nil) (opoint (point))) (terpri) - (prin1 + (prin1 (save-excursion (forward-sexp -1) (inferior-octave-send-list-and-digest