Mercurial > emacs
annotate lisp/progmodes/octave-inf.el @ 71621:7250b94586cb
Add a paragraph for non-ASCII examples at the head. Add
Bulgarian and Hungarian. Add more "hello"s to Danish and Swedish.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 05 Jul 2006 01:28:13 +0000 |
parents | dc49655f57ae |
children | 611496c32b32 4b3d39451150 |
rev | line source |
---|---|
17517 | 1 ;;; octave-inf.el --- running Octave as an inferior Emacs process |
16903 | 2 |
68773
dc49655f57ae
Update copyright for 2006.
Nick Roberts <nickrob@snap.net.nz>
parents:
67129
diff
changeset
|
3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006 |
64699
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
16903 | 5 |
65152
7a3342784b7e
Change Author and Maintainer address.
Eli Zaretskii <eliz@gnu.org>
parents:
64699
diff
changeset
|
6 ;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
16903 | 7 ;; Author: John Eaton <jwe@bevo.che.wisc.edu> |
65152
7a3342784b7e
Change Author and Maintainer address.
Eli Zaretskii <eliz@gnu.org>
parents:
64699
diff
changeset
|
8 ;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
16903 | 9 ;; Keywords: languages |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
16903 | 27 |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30902
diff
changeset
|
28 ;;; Commentary: |
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30902
diff
changeset
|
29 |
16903 | 30 ;;; Code: |
31 | |
16904
2bc5f76917e0
Require octave-mod, not octave.
Richard M. Stallman <rms@gnu.org>
parents:
16903
diff
changeset
|
32 (require 'octave-mod) |
16903 | 33 (require 'comint) |
34 | |
20781 | 35 (defgroup octave-inferior nil |
36 "Running Octave as an inferior Emacs process." | |
37 :group 'octave) | |
16903 | 38 |
20781 | 39 (defcustom inferior-octave-program "octave" |
40 "*Program invoked by `inferior-octave'." | |
41 :type 'string | |
42 :group 'octave-inferior) | |
43 | |
44 (defcustom inferior-octave-prompt | |
52952
03afc05bc725
(inferior-octave-prompt): Recognize version number in prompt.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
45 "\\(^octave\\(\\|.bin\\)\\(-[.0-9]+\\)?\\(:[0-9]+\\)?\\|^debug\\|^\\)>+ " |
20781 | 46 "*Regexp to match prompts for the inferior Octave process." |
47 :type 'regexp | |
48 :group 'octave-inferior) | |
16903 | 49 |
20781 | 50 (defcustom inferior-octave-startup-file nil |
16903 | 51 "*Name of the inferior Octave startup file. |
52 The contents of this file are sent to the inferior Octave process on | |
20781 | 53 startup." |
54 :type '(choice (const :tag "None" nil) | |
55 file) | |
56 :group 'octave-inferior) | |
16903 | 57 |
25719
f440228994ba
(inferior-octave-startup): Ensure -i and --no-line-editing are passed
Stephen Eglen <stephen@gnu.org>
parents:
25568
diff
changeset
|
58 (defcustom inferior-octave-startup-args nil |
16903 | 59 "*List of command line arguments for the inferior Octave process. |
60 For example, for suppressing the startup message and using `traditional' | |
20781 | 61 mode, set this to (\"-q\" \"--traditional\")." |
62 :type '(repeat string) | |
63 :group 'octave-inferior) | |
16903 | 64 |
65 (defvar inferior-octave-mode-map nil | |
66 "Keymap used in Inferior Octave mode.") | |
67 (if inferior-octave-mode-map | |
68 () | |
69 (let ((map (copy-keymap comint-mode-map))) | |
70 (define-key map "\t" 'comint-dynamic-complete) | |
71 (define-key map "\M-?" 'comint-dynamic-list-filename-completions) | |
72 (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) | |
73 (define-key map [menu-bar inout list-history] | |
74 '("List Input History" . inferior-octave-dynamic-list-input-ring)) | |
75 (define-key map "\C-c\C-h" 'octave-help) | |
76 (setq inferior-octave-mode-map map))) | |
77 | |
78 (defvar inferior-octave-mode-syntax-table nil | |
79 "Syntax table in use in inferior-octave-mode buffers.") | |
80 (if inferior-octave-mode-syntax-table | |
81 () | |
82 (let ((table (make-syntax-table))) | |
83 (modify-syntax-entry ?\` "w" table) | |
84 (modify-syntax-entry ?\# "<" table) | |
85 (modify-syntax-entry ?\n ">" table) | |
86 (setq inferior-octave-mode-syntax-table table))) | |
87 | |
20781 | 88 (defcustom inferior-octave-mode-hook nil |
89 "*Hook to be run when Inferior Octave mode is started." | |
90 :type 'hook | |
91 :group 'octave-inferior) | |
16903 | 92 |
93 (defvar inferior-octave-font-lock-keywords | |
94 (list | |
95 (cons inferior-octave-prompt 'font-lock-type-face)) | |
96 ;; Could certainly do more font locking in inferior Octave ... | |
97 "Additional expressions to highlight in Inferior Octave mode.") | |
98 | |
30902
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
99 |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
100 ;;; Compatibility functions |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
101 (if (not (fboundp 'comint-line-beginning-position)) |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
102 ;; comint-line-beginning-position is defined in Emacs 21 |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
103 (defun comint-line-beginning-position () |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
104 "Returns the buffer position of the beginning of the line, after any prompt. |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
105 The prompt is assumed to be any text at the beginning of the line matching |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
106 the regular expression `comint-prompt-regexp', a buffer local variable." |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
107 (save-excursion (comint-bol nil) (point)))) |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
108 |
ffe3b5100238
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30646
diff
changeset
|
109 |
16903 | 110 (defvar inferior-octave-output-list nil) |
111 (defvar inferior-octave-output-string nil) | |
112 (defvar inferior-octave-receive-in-progress nil) | |
113 | |
114 (defvar inferior-octave-startup-hook nil) | |
115 | |
116 (defvar inferior-octave-complete-impossible nil | |
117 "Non-nil means that `inferior-octave-complete' is impossible.") | |
118 | |
119 (defvar inferior-octave-dynamic-complete-functions | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38436
diff
changeset
|
120 '(inferior-octave-complete comint-dynamic-complete-filename) |
16903 | 121 "List of functions called to perform completion for inferior Octave. |
122 This variable is used to initialize `comint-dynamic-complete-functions' | |
123 in the Inferior Octave buffer.") | |
124 | |
125 (defun inferior-octave-mode () | |
126 "Major mode for interacting with an inferior Octave process. | |
127 Runs Octave as a subprocess of Emacs, with Octave I/O through an Emacs | |
128 buffer. | |
129 | |
130 Entry to this mode successively runs the hooks `comint-mode-hook' and | |
131 `inferior-octave-mode-hook'." | |
132 (interactive) | |
63411
1244410f3457
(inferior-octave-mode): Use delay-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
62772
diff
changeset
|
133 (delay-mode-hooks (comint-mode)) |
16903 | 134 (setq comint-prompt-regexp inferior-octave-prompt |
135 major-mode 'inferior-octave-mode | |
136 mode-name "Inferior Octave" | |
137 mode-line-process '(":%s") | |
138 local-abbrev-table octave-abbrev-table) | |
139 (use-local-map inferior-octave-mode-map) | |
140 (set-syntax-table inferior-octave-mode-syntax-table) | |
141 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38436
diff
changeset
|
142 (make-local-variable 'comment-start) |
16903 | 143 (setq comment-start octave-comment-start) |
144 (make-local-variable 'comment-end) | |
145 (setq comment-end "") | |
146 (make-local-variable 'comment-column) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38436
diff
changeset
|
147 (setq comment-column 32) |
16903 | 148 (make-local-variable 'comment-start-skip) |
149 (setq comment-start-skip octave-comment-start-skip) | |
150 | |
151 (make-local-variable 'font-lock-defaults) | |
152 (setq font-lock-defaults '(inferior-octave-font-lock-keywords nil nil)) | |
153 | |
154 (setq comint-input-ring-file-name | |
155 (or (getenv "OCTAVE_HISTFILE") "~/.octave_hist") | |
156 comint-input-ring-size (or (getenv "OCTAVE_HISTSIZE") 1024) | |
157 comint-input-filter-functions '(inferior-octave-directory-tracker) | |
158 comint-dynamic-complete-functions | |
159 inferior-octave-dynamic-complete-functions) | |
160 (comint-read-input-ring t) | |
161 | |
62772
f2892faa87d4
* progmodes/ada-mode.el (ada-mode):
Lute Kamstra <lute@gnu.org>
parents:
52952
diff
changeset
|
162 (run-mode-hooks 'inferior-octave-mode-hook)) |
16903 | 163 |
164 ;;;###autoload | |
165 (defun inferior-octave (&optional arg) | |
166 "Run an inferior Octave process, I/O via `inferior-octave-buffer'. | |
167 This buffer is put in Inferior Octave mode. See `inferior-octave-mode'. | |
168 | |
169 Unless ARG is non-nil, switches to this buffer. | |
170 | |
171 The elements of the list `inferior-octave-startup-args' are sent as | |
172 command line arguments to the inferior Octave process on startup. | |
173 | |
174 Additional commands to be executed on startup can be provided either in | |
175 the file specified by `inferior-octave-startup-file' or by the default | |
176 startup file, `~/.emacs-octave'." | |
177 (interactive "P") | |
178 (let ((buffer inferior-octave-buffer)) | |
179 (get-buffer-create buffer) | |
180 (if (comint-check-proc buffer) | |
181 () | |
182 (save-excursion | |
183 (set-buffer buffer) | |
184 (comint-mode) | |
185 (inferior-octave-startup) | |
186 (inferior-octave-mode))) | |
187 (if (not arg) | |
188 (pop-to-buffer buffer)))) | |
189 | |
190 ;;;###autoload | |
191 (defalias 'run-octave 'inferior-octave) | |
192 | |
193 (defun inferior-octave-startup () | |
194 "Start an inferior Octave process." | |
195 (let ((proc (comint-exec-1 | |
196 (substring inferior-octave-buffer 1 -1) | |
197 inferior-octave-buffer | |
198 inferior-octave-program | |
25719
f440228994ba
(inferior-octave-startup): Ensure -i and --no-line-editing are passed
Stephen Eglen <stephen@gnu.org>
parents:
25568
diff
changeset
|
199 (append (list "-i" "--no-line-editing") |
f440228994ba
(inferior-octave-startup): Ensure -i and --no-line-editing are passed
Stephen Eglen <stephen@gnu.org>
parents:
25568
diff
changeset
|
200 inferior-octave-startup-args)))) |
16903 | 201 (set-process-filter proc 'inferior-octave-output-digest) |
202 (setq comint-ptyp process-connection-type | |
203 inferior-octave-process proc | |
204 inferior-octave-output-list nil | |
205 inferior-octave-output-string nil | |
206 inferior-octave-receive-in-progress t) | |
207 | |
208 ;; This may look complicated ... However, we need to make sure that | |
209 ;; we additional startup code only AFTER Octave is ready (otherwise, | |
210 ;; output may be mixed up). Hence, we need to digest the Octave | |
211 ;; output to see when it issues a prompt. | |
212 (while inferior-octave-receive-in-progress | |
213 (accept-process-output inferior-octave-process)) | |
214 (goto-char (point-max)) | |
215 (set-marker (process-mark proc) (point)) | |
216 (insert-before-markers | |
217 (concat | |
218 (if (not (bobp)) "\n") | |
219 (if inferior-octave-output-list | |
220 (concat (mapconcat | |
221 'identity inferior-octave-output-list "\n") | |
222 "\n")))) | |
67129
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
223 |
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
224 ;; An empty secondary prompt, as e.g. obtained by '--braindead', |
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
225 ;; means trouble. |
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
226 (inferior-octave-send-list-and-digest (list "PS2\n")) |
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
227 (if (string-match "^PS2 = *$" (car inferior-octave-output-list)) |
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
228 (inferior-octave-send-list-and-digest (list "PS2 = \"> \"\n"))) |
e0b37eeb2f0b
(inferior-octave-startup): Force a non-empty string for secondary prompt PS2.
Eli Zaretskii <eliz@gnu.org>
parents:
65431
diff
changeset
|
229 |
16903 | 230 ;; O.k., now we are ready for the Inferior Octave startup commands. |
231 (let* (commands | |
232 (program (file-name-nondirectory inferior-octave-program)) | |
233 (file (or inferior-octave-startup-file | |
234 (concat "~/.emacs-" program)))) | |
235 (setq commands | |
236 (list "page_screen_output = 0;\n" | |
237 (if (not (string-equal | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38436
diff
changeset
|
238 inferior-octave-output-string ">> ")) |
16903 | 239 "PS1=\"\\\\s> \";\n") |
240 (if (file-exists-p file) | |
241 (format "source (\"%s\");\n" file)))) | |
242 (inferior-octave-send-list-and-digest commands)) | |
243 (insert-before-markers | |
244 (concat | |
245 (if inferior-octave-output-list | |
246 (concat (mapconcat | |
247 'identity inferior-octave-output-list "\n") | |
248 "\n")) | |
249 inferior-octave-output-string)) | |
250 ;; Next, we check whether Octave supports `completion_matches' ... | |
251 (inferior-octave-send-list-and-digest | |
252 (list "exist \"completion_matches\"\n")) | |
253 (setq inferior-octave-complete-impossible | |
254 (not (string-match "5$" (car inferior-octave-output-list)))) | |
255 | |
256 ;; And finally, everything is back to normal. | |
257 (set-process-filter proc 'inferior-octave-output-filter) | |
65431
effbe6e5cd50
(inferior-octave-startup): Resync current dir at the end.
Eli Zaretskii <eliz@gnu.org>
parents:
65152
diff
changeset
|
258 (run-hooks 'inferior-octave-startup-hook) |
effbe6e5cd50
(inferior-octave-startup): Resync current dir at the end.
Eli Zaretskii <eliz@gnu.org>
parents:
65152
diff
changeset
|
259 (run-hooks 'inferior-octave-startup-hook) |
effbe6e5cd50
(inferior-octave-startup): Resync current dir at the end.
Eli Zaretskii <eliz@gnu.org>
parents:
65152
diff
changeset
|
260 ;; Just in case, to be sure a cd in the startup file |
effbe6e5cd50
(inferior-octave-startup): Resync current dir at the end.
Eli Zaretskii <eliz@gnu.org>
parents:
65152
diff
changeset
|
261 ;; won't have detrimental effects. |
effbe6e5cd50
(inferior-octave-startup): Resync current dir at the end.
Eli Zaretskii <eliz@gnu.org>
parents:
65152
diff
changeset
|
262 (inferior-octave-resync-dirs))) |
16903 | 263 |
264 | |
265 (defun inferior-octave-complete () | |
266 "Perform completion on the Octave symbol preceding point. | |
267 This is implemented using the Octave command `completion_matches' which | |
268 is NOT available with versions of Octave prior to 2.0." | |
269 (interactive) | |
270 (let* ((end (point)) | |
30646
bb2ebaf63949
(inferior-octave-complete): Use comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
25719
diff
changeset
|
271 (command |
bb2ebaf63949
(inferior-octave-complete): Use comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
25719
diff
changeset
|
272 (save-excursion |
bb2ebaf63949
(inferior-octave-complete): Use comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
25719
diff
changeset
|
273 (skip-syntax-backward "w_" (comint-line-beginning-position)) |
bb2ebaf63949
(inferior-octave-complete): Use comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
25719
diff
changeset
|
274 (buffer-substring-no-properties (point) end))) |
16903 | 275 (proc (get-buffer-process inferior-octave-buffer)) |
276 (filter (process-filter proc))) | |
277 (cond (inferior-octave-complete-impossible | |
278 (error (concat | |
279 "Your Octave does not have `completion_matches'. " | |
280 "Please upgrade to version 2.X."))) | |
281 ((string-equal command "") | |
282 (message "Cannot complete an empty string")) | |
283 (t | |
284 (inferior-octave-send-list-and-digest | |
285 (list (concat "completion_matches (\"" command "\");\n"))) | |
286 ;; Sort the list | |
287 (setq inferior-octave-output-list | |
288 (sort inferior-octave-output-list 'string-lessp)) | |
289 ;; Remove duplicates | |
290 (let* ((x inferior-octave-output-list) | |
291 (y (cdr x))) | |
292 (while y | |
293 (if (string-equal (car x) (car y)) | |
294 (setcdr x (setq y (cdr y))) | |
295 (setq x y | |
296 y (cdr y))))) | |
297 ;; And let comint handle the rest | |
298 (comint-dynamic-simple-complete | |
299 command inferior-octave-output-list))))) | |
300 | |
301 (defun inferior-octave-dynamic-list-input-ring () | |
302 "List the buffer's input history in a help buffer" | |
303 ;; We cannot use `comint-dynamic-list-input-ring', because it replaces | |
304 ;; "completion" by "history reference" ... | |
305 (interactive) | |
306 (if (or (not (ring-p comint-input-ring)) | |
307 (ring-empty-p comint-input-ring)) | |
308 (message "No history") | |
309 (let ((history nil) | |
310 (history-buffer " *Input History*") | |
311 (index (1- (ring-length comint-input-ring))) | |
312 (conf (current-window-configuration))) | |
313 ;; We have to build up a list ourselves from the ring vector. | |
314 (while (>= index 0) | |
315 (setq history (cons (ring-ref comint-input-ring index) history) | |
316 index (1- index))) | |
317 ;; Change "completion" to "history reference" | |
318 ;; to make the display accurate. | |
319 (with-output-to-temp-buffer history-buffer | |
320 (display-completion-list history) | |
321 (set-buffer history-buffer)) | |
322 (message "Hit space to flush") | |
323 (let ((ch (read-event))) | |
324 (if (eq ch ?\ ) | |
325 (set-window-configuration conf) | |
326 (setq unread-command-events (list ch))))))) | |
327 | |
328 (defun inferior-octave-strip-ctrl-g (string) | |
329 "Strip leading `^G' character. | |
330 If STRING starts with a `^G', ring the bell and strip it." | |
331 (if (string-match "^\a" string) | |
332 (progn | |
333 (ding) | |
334 (setq string (substring string 1)))) | |
335 string) | |
336 | |
337 (defun inferior-octave-output-filter (proc string) | |
338 "Standard output filter for the inferior Octave process. | |
339 Ring Emacs bell if process output starts with an ASCII bell, and pass | |
340 the rest to `comint-output-filter'." | |
341 (comint-output-filter proc (inferior-octave-strip-ctrl-g string))) | |
342 | |
343 (defun inferior-octave-output-digest (proc string) | |
344 "Special output filter for the inferior Octave process. | |
345 Save all output between newlines into `inferior-octave-output-list', and | |
346 the rest to `inferior-octave-output-string'." | |
347 (setq string (concat inferior-octave-output-string string)) | |
348 (while (string-match "\n" string) | |
349 (setq inferior-octave-output-list | |
350 (append inferior-octave-output-list | |
351 (list (substring string 0 (match-beginning 0)))) | |
352 string (substring string (match-end 0)))) | |
353 (if (string-match inferior-octave-prompt string) | |
354 (setq inferior-octave-receive-in-progress nil)) | |
355 (setq inferior-octave-output-string string)) | |
356 | |
357 (defun inferior-octave-send-list-and-digest (list) | |
358 "Send LIST to the inferior Octave process and digest the output. | |
359 The elements of LIST have to be strings and are sent one by one. All | |
360 output is passed to the filter `inferior-octave-output-digest'." | |
361 (let* ((proc inferior-octave-process) | |
362 (filter (process-filter proc)) | |
363 string) | |
364 (set-process-filter proc 'inferior-octave-output-digest) | |
365 (setq inferior-octave-output-list nil) | |
366 (unwind-protect | |
367 (while (setq string (car list)) | |
368 (setq inferior-octave-output-string nil | |
369 inferior-octave-receive-in-progress t) | |
370 (comint-send-string proc string) | |
371 (while inferior-octave-receive-in-progress | |
372 (accept-process-output proc)) | |
373 (setq list (cdr list))) | |
374 (set-process-filter proc filter)))) | |
375 | |
376 (defun inferior-octave-directory-tracker (string) | |
377 "Tracks `cd' commands issued to the inferior Octave process. | |
378 Use \\[inferior-octave-resync-dirs] to resync if Emacs gets confused." | |
24930
ea5923fcc5b2
inferior-octave-directory-tracker: Change regexp so that it doesn't
Stephen Eglen <stephen@gnu.org>
parents:
23343
diff
changeset
|
379 (cond |
ea5923fcc5b2
inferior-octave-directory-tracker: Change regexp so that it doesn't
Stephen Eglen <stephen@gnu.org>
parents:
23343
diff
changeset
|
380 ((string-match "^[ \t]*cd[ \t;]*$" string) |
ea5923fcc5b2
inferior-octave-directory-tracker: Change regexp so that it doesn't
Stephen Eglen <stephen@gnu.org>
parents:
23343
diff
changeset
|
381 (cd "~")) |
ea5923fcc5b2
inferior-octave-directory-tracker: Change regexp so that it doesn't
Stephen Eglen <stephen@gnu.org>
parents:
23343
diff
changeset
|
382 ((string-match "^[ \t]*cd[ \t]+\\([^ \t\n;]*\\)[ \t\n;]*" string) |
ea5923fcc5b2
inferior-octave-directory-tracker: Change regexp so that it doesn't
Stephen Eglen <stephen@gnu.org>
parents:
23343
diff
changeset
|
383 (cd (substring string (match-beginning 1) (match-end 1)))))) |
16903 | 384 |
385 (defun inferior-octave-resync-dirs () | |
386 "Resync the buffer's idea of the current directory. | |
387 This command queries the inferior Octave process about its current | |
388 directory and makes this the current buffer's default directory." | |
389 (interactive) | |
390 (inferior-octave-send-list-and-digest '("pwd\n")) | |
391 (cd (car inferior-octave-output-list))) | |
392 | |
17150 | 393 ;;; provide ourself |
394 | |
395 (provide 'octave-inf) | |
396 | |
52401 | 397 ;;; arch-tag: bdce0395-24d1-4bb4-bfba-6fb1eeb1a660 |
16906 | 398 ;;; octave-inf.el ends here |