:group 'octave
:version "24.4")
-(defcustom inferior-octave-startup-file nil
+(defcustom inferior-octave-startup-file
+ (convert-standard-filename
+ (concat "~/.emacs-" (file-name-nondirectory inferior-octave-program)))
"Name of the inferior Octave startup file.
The contents of this file are sent to the inferior Octave process on
startup."
- :type '(choice (const :tag "None" nil)
- file)
- :group 'octave)
+ :type '(choice (const :tag "None" nil) file)
+ :group 'octave
+ :version "24.4")
(defcustom inferior-octave-startup-args nil
"List of command line arguments for the inferior Octave process.
the file specified by `inferior-octave-startup-file' or by the default
startup file, `~/.emacs-octave'."
(interactive "P")
- (let ((buffer inferior-octave-buffer))
- (get-buffer-create buffer)
- (if (comint-check-proc buffer)
- ()
+ (let ((buffer (get-buffer-create inferior-octave-buffer)))
+ (unless (comint-check-proc buffer)
(with-current-buffer buffer
- (comint-mode)
- (inferior-octave-startup)
- (inferior-octave-mode)))
- (if (not arg)
- (pop-to-buffer buffer))))
+ (inferior-octave-startup)
+ (inferior-octave-mode)))
+ (unless arg
+ (pop-to-buffer buffer))
+ buffer))
;;;###autoload
(defalias 'run-octave 'inferior-octave)
(defun inferior-octave-startup ()
"Start an inferior Octave process."
(let ((proc (comint-exec-1
- (substring inferior-octave-buffer 1 -1)
- inferior-octave-buffer
- inferior-octave-program
- (append (list "-i" "--no-line-editing")
- inferior-octave-startup-args))))
+ (substring inferior-octave-buffer 1 -1)
+ inferior-octave-buffer
+ inferior-octave-program
+ (append (list "-i" "--no-line-editing")
+ inferior-octave-startup-args))))
(set-process-filter proc 'inferior-octave-output-digest)
- (setq comint-ptyp process-connection-type
- inferior-octave-process proc
- inferior-octave-output-list nil
- inferior-octave-output-string nil
- inferior-octave-receive-in-progress t)
+ (setq inferior-octave-process proc
+ inferior-octave-output-list nil
+ inferior-octave-output-string nil
+ inferior-octave-receive-in-progress t)
;; This may look complicated ... However, we need to make sure that
;; we additional startup code only AFTER Octave is ready (otherwise,
(concat
(if (not (bobp)) "\f\n")
(if inferior-octave-output-list
- (concat (mapconcat
- 'identity inferior-octave-output-list "\n")
- "\n"))))
+ (concat (mapconcat
+ 'identity inferior-octave-output-list "\n")
+ "\n"))))
;; An empty secondary prompt, as e.g. obtained by '--braindead',
;; means trouble.
(inferior-octave-send-list-and-digest (list "PS2\n"))
- (if (string-match "\\(PS2\\|ans\\) = *$" (car inferior-octave-output-list))
- (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n")))
-
- ;; O.k., now we are ready for the Inferior Octave startup commands.
- (let* (commands
- (program (file-name-nondirectory inferior-octave-program))
- (file (or inferior-octave-startup-file
- (concat "~/.emacs-" program))))
- (setq commands
- (list "more off;\n"
- (if (not (string-equal
- inferior-octave-output-string ">> "))
- "PS1 (\"\\\\s> \");\n")
- (if (file-exists-p file)
- (format "source (\"%s\");\n" file))))
- (inferior-octave-send-list-and-digest commands))
+ (when (string-match "\\(PS2\\|ans\\) = *$"
+ (car inferior-octave-output-list))
+ (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n")))
+
+ ;; O.K., now we are ready for the Inferior Octave startup commands.
+ (inferior-octave-send-list-and-digest
+ (list "more off;\n"
+ (unless (equal inferior-octave-output-string ">> ")
+ "PS1 (\"\\\\s> \");\n")
+ (when (and inferior-octave-startup-file
+ (file-exists-p inferior-octave-startup-file))
+ (format "source (\"%s\");\n" inferior-octave-startup-file))))
+ ;; XXX: the first prompt is incorrectly highlighted
(insert-before-markers
(concat
(if inferior-octave-output-list
- (concat (mapconcat
- 'identity inferior-octave-output-list "\n")
- "\n"))
+ (concat (mapconcat
+ 'identity inferior-octave-output-list "\n")
+ "\n"))
inferior-octave-output-string))
;; And finally, everything is back to normal.