comparison emacs/octave-inf.el @ 5204:2a44a667da02

[project @ 2005-03-15 05:07:15 by jwe]
author jwe
date Tue, 15 Mar 2005 05:07:15 +0000
parents 03c053808a7c
children 4c8a2e4e0717
comparison
equal deleted inserted replaced
5203:dbeafbc0ff64 5204:2a44a667da02
21 21
22 ;; You should have received a copy of the GNU General Public License 22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA. 25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Commentary:
26 28
27 ;;; Code: 29 ;;; Code:
28 30
29 (require 'octave-mod) 31 (require 'octave-mod)
30 (require 'comint) 32 (require 'comint)
91 (list 93 (list
92 (cons inferior-octave-prompt 'font-lock-type-face)) 94 (cons inferior-octave-prompt 'font-lock-type-face))
93 ;; Could certainly do more font locking in inferior Octave ... 95 ;; Could certainly do more font locking in inferior Octave ...
94 "Additional expressions to highlight in Inferior Octave mode.") 96 "Additional expressions to highlight in Inferior Octave mode.")
95 97
98
99 ;;; Compatibility functions
100 (if (not (fboundp 'comint-line-beginning-position))
101 ;; comint-line-beginning-position is defined in Emacs 21
102 (defun comint-line-beginning-position ()
103 "Returns the buffer position of the beginning of the line, after any prompt.
104 The prompt is assumed to be any text at the beginning of the line matching
105 the regular expression `comint-prompt-regexp', a buffer local variable."
106 (save-excursion (comint-bol nil) (point))))
107
108
96 (defvar inferior-octave-output-list nil) 109 (defvar inferior-octave-output-list nil)
97 (defvar inferior-octave-output-string nil) 110 (defvar inferior-octave-output-string nil)
98 (defvar inferior-octave-receive-in-progress nil) 111 (defvar inferior-octave-receive-in-progress nil)
99 112
100 (defvar inferior-octave-startup-hook nil) 113 (defvar inferior-octave-startup-hook nil)
101 114
102 (defvar inferior-octave-complete-impossible nil 115 (defvar inferior-octave-complete-impossible nil
103 "Non-nil means that `inferior-octave-complete' is impossible.") 116 "Non-nil means that `inferior-octave-complete' is impossible.")
104 117
105 (defvar inferior-octave-dynamic-complete-functions 118 (defvar inferior-octave-dynamic-complete-functions
106 '(inferior-octave-complete comint-dynamic-complete-filename) 119 '(inferior-octave-complete comint-dynamic-complete-filename)
107 "List of functions called to perform completion for inferior Octave. 120 "List of functions called to perform completion for inferior Octave.
108 This variable is used to initialize `comint-dynamic-complete-functions' 121 This variable is used to initialize `comint-dynamic-complete-functions'
109 in the Inferior Octave buffer.") 122 in the Inferior Octave buffer.")
110 123
111 (defun inferior-octave-mode () 124 (defun inferior-octave-mode ()
123 mode-line-process '(":%s") 136 mode-line-process '(":%s")
124 local-abbrev-table octave-abbrev-table) 137 local-abbrev-table octave-abbrev-table)
125 (use-local-map inferior-octave-mode-map) 138 (use-local-map inferior-octave-mode-map)
126 (set-syntax-table inferior-octave-mode-syntax-table) 139 (set-syntax-table inferior-octave-mode-syntax-table)
127 140
128 (make-local-variable 'comment-start) 141 (make-local-variable 'comment-start)
129 (setq comment-start octave-comment-start) 142 (setq comment-start octave-comment-start)
130 (make-local-variable 'comment-end) 143 (make-local-variable 'comment-end)
131 (setq comment-end "") 144 (setq comment-end "")
132 (make-local-variable 'comment-column) 145 (make-local-variable 'comment-column)
133 (setq comment-column 32) 146 (setq comment-column 32)
134 (make-local-variable 'comment-start-skip) 147 (make-local-variable 'comment-start-skip)
135 (setq comment-start-skip octave-comment-start-skip) 148 (setq comment-start-skip octave-comment-start-skip)
136 149
137 (make-local-variable 'font-lock-defaults) 150 (make-local-variable 'font-lock-defaults)
138 (setq font-lock-defaults '(inferior-octave-font-lock-keywords nil nil)) 151 (setq font-lock-defaults '(inferior-octave-font-lock-keywords nil nil))
212 (file (or inferior-octave-startup-file 225 (file (or inferior-octave-startup-file
213 (concat "~/.emacs-" program)))) 226 (concat "~/.emacs-" program))))
214 (setq commands 227 (setq commands
215 (list "page_screen_output = 0;\n" 228 (list "page_screen_output = 0;\n"
216 (if (not (string-equal 229 (if (not (string-equal
217 inferior-octave-output-string ">> ")) 230 inferior-octave-output-string ">> "))
218 "PS1=\"\\\\s> \";\n") 231 "PS1=\"\\\\s> \";\n")
219 (if (file-exists-p file) 232 (if (file-exists-p file)
220 (format "source (\"%s\");\n" file)))) 233 (format "source (\"%s\");\n" file))))
221 (inferior-octave-send-list-and-digest commands)) 234 (inferior-octave-send-list-and-digest commands))
222 (insert-before-markers 235 (insert-before-markers
241 "Perform completion on the Octave symbol preceding point. 254 "Perform completion on the Octave symbol preceding point.
242 This is implemented using the Octave command `completion_matches' which 255 This is implemented using the Octave command `completion_matches' which
243 is NOT available with versions of Octave prior to 2.0." 256 is NOT available with versions of Octave prior to 2.0."
244 (interactive) 257 (interactive)
245 (let* ((end (point)) 258 (let* ((end (point))
246 (command (save-excursion 259 (command
247 (skip-syntax-backward "w_") 260 (save-excursion
248 (and (looking-at comint-prompt-regexp) 261 (skip-syntax-backward "w_" (comint-line-beginning-position))
249 (goto-char (match-end 0))) 262 (buffer-substring-no-properties (point) end)))
250 (buffer-substring-no-properties (point) end)))
251 (proc (get-buffer-process inferior-octave-buffer)) 263 (proc (get-buffer-process inferior-octave-buffer))
252 (filter (process-filter proc))) 264 (filter (process-filter proc)))
253 (cond (inferior-octave-complete-impossible 265 (cond (inferior-octave-complete-impossible
254 (error (concat 266 (error (concat
255 "Your Octave does not have `completion_matches'. " 267 "Your Octave does not have `completion_matches'. "