]> git.eshelyaron.com Git - emacs.git/commitdiff
* progmodes/octave.el (inferior-octave-startup-file): Change default.
authorLeo Liu <sdl.web@gmail.com>
Thu, 2 May 2013 21:34:53 +0000 (05:34 +0800)
committerLeo Liu <sdl.web@gmail.com>
Thu, 2 May 2013 21:34:53 +0000 (05:34 +0800)
(inferior-octave): Remove calling comint-mode and return the buffer.
(inferior-octave-startup): Cosmetic changes.

lisp/ChangeLog
lisp/progmodes/octave.el

index 79fd38200749f99088c0f16485d525564b2c02e4..695f66c272c69955be56f8205078bc692b042c91 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-02  Leo Liu  <sdl.web@gmail.com>
+
+       * progmodes/octave.el (inferior-octave-startup-file): Change default.
+       (inferior-octave): Remove calling comint-mode and return the buffer.
+       (inferior-octave-startup): Cosmetic changes.
+
 2013-05-02  Leo Liu  <sdl.web@gmail.com>
 
        * progmodes/octave.el (octave-syntax-propertize-function): Include
index 3252b16cbad076ffbc5918b4885fb9ac0103eb9b..56f2805d48eda77932b741516e6ca00b1bbe9526 100644 (file)
@@ -553,13 +553,15 @@ See `comint-prompt-read-only' for details."
   :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.
@@ -650,16 +652,14 @@ Additional commands to be executed on startup can be provided either in
 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)
@@ -667,17 +667,16 @@ startup file, `~/.emacs-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,
@@ -691,35 +690,32 @@ startup file, `~/.emacs-octave'."
      (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.