Mercurial > emacs
comparison lisp/progmodes/octave-inf.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; octave-inf.el --- running Octave as an inferior Emacs process | 1 ;;; octave-inf.el --- running Octave as an inferior Emacs process |
2 | 2 |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005 |
4 | 4 ;; Free Software Foundation, Inc. |
5 ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> | 5 |
6 ;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> | |
6 ;; Author: John Eaton <jwe@bevo.che.wisc.edu> | 7 ;; Author: John Eaton <jwe@bevo.che.wisc.edu> |
7 ;; Maintainer: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> | 8 ;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
8 ;; Keywords: languages | 9 ;; Keywords: languages |
9 | 10 |
10 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
11 | 12 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 ;; GNU General Public License for more details. | 21 ;; GNU General Public License for more details. |
21 | 22 |
22 ;; You should have received a copy of the GNU General Public License | 23 ;; 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 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02111-1307, USA. | 26 ;; Boston, MA 02110-1301, USA. |
26 | 27 |
27 ;;; Commentary: | 28 ;;; Commentary: |
28 | 29 |
29 ;;; Code: | 30 ;;; Code: |
30 | 31 |
39 "*Program invoked by `inferior-octave'." | 40 "*Program invoked by `inferior-octave'." |
40 :type 'string | 41 :type 'string |
41 :group 'octave-inferior) | 42 :group 'octave-inferior) |
42 | 43 |
43 (defcustom inferior-octave-prompt | 44 (defcustom inferior-octave-prompt |
44 "\\(^octave\\(\\|.bin\\)\\(:[0-9]+\\)?\\|^debug\\|^\\)>+ " | 45 "\\(^octave\\(\\|.bin\\)\\(-[.0-9]+\\)?\\(:[0-9]+\\)?\\|^debug\\|^\\)>+ " |
45 "*Regexp to match prompts for the inferior Octave process." | 46 "*Regexp to match prompts for the inferior Octave process." |
46 :type 'regexp | 47 :type 'regexp |
47 :group 'octave-inferior) | 48 :group 'octave-inferior) |
48 | 49 |
49 (defcustom inferior-octave-startup-file nil | 50 (defcustom inferior-octave-startup-file nil |
127 buffer. | 128 buffer. |
128 | 129 |
129 Entry to this mode successively runs the hooks `comint-mode-hook' and | 130 Entry to this mode successively runs the hooks `comint-mode-hook' and |
130 `inferior-octave-mode-hook'." | 131 `inferior-octave-mode-hook'." |
131 (interactive) | 132 (interactive) |
132 (comint-mode) | 133 (delay-mode-hooks (comint-mode)) |
133 (setq comint-prompt-regexp inferior-octave-prompt | 134 (setq comint-prompt-regexp inferior-octave-prompt |
134 major-mode 'inferior-octave-mode | 135 major-mode 'inferior-octave-mode |
135 mode-name "Inferior Octave" | 136 mode-name "Inferior Octave" |
136 mode-line-process '(":%s") | 137 mode-line-process '(":%s") |
137 local-abbrev-table octave-abbrev-table) | 138 local-abbrev-table octave-abbrev-table) |
156 comint-input-filter-functions '(inferior-octave-directory-tracker) | 157 comint-input-filter-functions '(inferior-octave-directory-tracker) |
157 comint-dynamic-complete-functions | 158 comint-dynamic-complete-functions |
158 inferior-octave-dynamic-complete-functions) | 159 inferior-octave-dynamic-complete-functions) |
159 (comint-read-input-ring t) | 160 (comint-read-input-ring t) |
160 | 161 |
161 (run-hooks 'inferior-octave-mode-hook)) | 162 (run-mode-hooks 'inferior-octave-mode-hook)) |
162 | 163 |
163 ;;;###autoload | 164 ;;;###autoload |
164 (defun inferior-octave (&optional arg) | 165 (defun inferior-octave (&optional arg) |
165 "Run an inferior Octave process, I/O via `inferior-octave-buffer'. | 166 "Run an inferior Octave process, I/O via `inferior-octave-buffer'. |
166 This buffer is put in Inferior Octave mode. See `inferior-octave-mode'. | 167 This buffer is put in Inferior Octave mode. See `inferior-octave-mode'. |
217 (if (not (bobp)) "\n") | 218 (if (not (bobp)) "\n") |
218 (if inferior-octave-output-list | 219 (if inferior-octave-output-list |
219 (concat (mapconcat | 220 (concat (mapconcat |
220 'identity inferior-octave-output-list "\n") | 221 'identity inferior-octave-output-list "\n") |
221 "\n")))) | 222 "\n")))) |
223 | |
224 ;; An empty secondary prompt, as e.g. obtained by '--braindead', | |
225 ;; means trouble. | |
226 (inferior-octave-send-list-and-digest (list "PS2\n")) | |
227 (if (string-match "^PS2 = *$" (car inferior-octave-output-list)) | |
228 (inferior-octave-send-list-and-digest (list "PS2 = \"> \"\n"))) | |
229 | |
222 ;; O.k., now we are ready for the Inferior Octave startup commands. | 230 ;; O.k., now we are ready for the Inferior Octave startup commands. |
223 (let* (commands | 231 (let* (commands |
224 (program (file-name-nondirectory inferior-octave-program)) | 232 (program (file-name-nondirectory inferior-octave-program)) |
225 (file (or inferior-octave-startup-file | 233 (file (or inferior-octave-startup-file |
226 (concat "~/.emacs-" program)))) | 234 (concat "~/.emacs-" program)))) |
245 (setq inferior-octave-complete-impossible | 253 (setq inferior-octave-complete-impossible |
246 (not (string-match "5$" (car inferior-octave-output-list)))) | 254 (not (string-match "5$" (car inferior-octave-output-list)))) |
247 | 255 |
248 ;; And finally, everything is back to normal. | 256 ;; And finally, everything is back to normal. |
249 (set-process-filter proc 'inferior-octave-output-filter) | 257 (set-process-filter proc 'inferior-octave-output-filter) |
250 (run-hooks 'inferior-octave-startup-hook))) | 258 (run-hooks 'inferior-octave-startup-hook) |
259 (run-hooks 'inferior-octave-startup-hook) | |
260 ;; Just in case, to be sure a cd in the startup file | |
261 ;; won't have detrimental effects. | |
262 (inferior-octave-resync-dirs))) | |
251 | 263 |
252 | 264 |
253 (defun inferior-octave-complete () | 265 (defun inferior-octave-complete () |
254 "Perform completion on the Octave symbol preceding point. | 266 "Perform completion on the Octave symbol preceding point. |
255 This is implemented using the Octave command `completion_matches' which | 267 This is implemented using the Octave command `completion_matches' which |
380 | 392 |
381 ;;; provide ourself | 393 ;;; provide ourself |
382 | 394 |
383 (provide 'octave-inf) | 395 (provide 'octave-inf) |
384 | 396 |
397 ;;; arch-tag: bdce0395-24d1-4bb4-bfba-6fb1eeb1a660 | |
385 ;;; octave-inf.el ends here | 398 ;;; octave-inf.el ends here |