aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2013-05-03 05:34:53 +0800
committerLeo Liu2013-05-03 05:34:53 +0800
commit0d634d3a3c2ad4e0a741b3e42a1784e6f2d797dc (patch)
treebf33c37abd0aec9454061b399ac1272fa3c3ac4c
parentb4c8295e81157fa913674140dee1fc201c881642 (diff)
downloademacs-0d634d3a3c2ad4e0a741b3e42a1784e6f2d797dc.tar.gz
emacs-0d634d3a3c2ad4e0a741b3e42a1784e6f2d797dc.zip
* progmodes/octave.el (inferior-octave-startup-file): Change default.
(inferior-octave): Remove calling comint-mode and return the buffer. (inferior-octave-startup): Cosmetic changes.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/octave.el86
2 files changed, 47 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 79fd3820074..695f66c272c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,11 @@
12013-05-02 Leo Liu <sdl.web@gmail.com> 12013-05-02 Leo Liu <sdl.web@gmail.com>
2 2
3 * progmodes/octave.el (inferior-octave-startup-file): Change default.
4 (inferior-octave): Remove calling comint-mode and return the buffer.
5 (inferior-octave-startup): Cosmetic changes.
6
72013-05-02 Leo Liu <sdl.web@gmail.com>
8
3 * progmodes/octave.el (octave-syntax-propertize-function): Include 9 * progmodes/octave.el (octave-syntax-propertize-function): Include
4 the case when ' is at line beginning. (Bug#14336) 10 the case when ' is at line beginning. (Bug#14336)
5 11
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 3252b16cbad..56f2805d48e 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -553,13 +553,15 @@ See `comint-prompt-read-only' for details."
553 :group 'octave 553 :group 'octave
554 :version "24.4") 554 :version "24.4")
555 555
556(defcustom inferior-octave-startup-file nil 556(defcustom inferior-octave-startup-file
557 (convert-standard-filename
558 (concat "~/.emacs-" (file-name-nondirectory inferior-octave-program)))
557 "Name of the inferior Octave startup file. 559 "Name of the inferior Octave startup file.
558The contents of this file are sent to the inferior Octave process on 560The contents of this file are sent to the inferior Octave process on
559startup." 561startup."
560 :type '(choice (const :tag "None" nil) 562 :type '(choice (const :tag "None" nil) file)
561 file) 563 :group 'octave
562 :group 'octave) 564 :version "24.4")
563 565
564(defcustom inferior-octave-startup-args nil 566(defcustom inferior-octave-startup-args nil
565 "List of command line arguments for the inferior Octave process. 567 "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
650the file specified by `inferior-octave-startup-file' or by the default 652the file specified by `inferior-octave-startup-file' or by the default
651startup file, `~/.emacs-octave'." 653startup file, `~/.emacs-octave'."
652 (interactive "P") 654 (interactive "P")
653 (let ((buffer inferior-octave-buffer)) 655 (let ((buffer (get-buffer-create inferior-octave-buffer)))
654 (get-buffer-create buffer) 656 (unless (comint-check-proc buffer)
655 (if (comint-check-proc buffer)
656 ()
657 (with-current-buffer buffer 657 (with-current-buffer buffer
658 (comint-mode) 658 (inferior-octave-startup)
659 (inferior-octave-startup) 659 (inferior-octave-mode)))
660 (inferior-octave-mode))) 660 (unless arg
661 (if (not arg) 661 (pop-to-buffer buffer))
662 (pop-to-buffer buffer)))) 662 buffer))
663 663
664;;;###autoload 664;;;###autoload
665(defalias 'run-octave 'inferior-octave) 665(defalias 'run-octave 'inferior-octave)
@@ -667,17 +667,16 @@ startup file, `~/.emacs-octave'."
667(defun inferior-octave-startup () 667(defun inferior-octave-startup ()
668 "Start an inferior Octave process." 668 "Start an inferior Octave process."
669 (let ((proc (comint-exec-1 669 (let ((proc (comint-exec-1
670 (substring inferior-octave-buffer 1 -1) 670 (substring inferior-octave-buffer 1 -1)
671 inferior-octave-buffer 671 inferior-octave-buffer
672 inferior-octave-program 672 inferior-octave-program
673 (append (list "-i" "--no-line-editing") 673 (append (list "-i" "--no-line-editing")
674 inferior-octave-startup-args)))) 674 inferior-octave-startup-args))))
675 (set-process-filter proc 'inferior-octave-output-digest) 675 (set-process-filter proc 'inferior-octave-output-digest)
676 (setq comint-ptyp process-connection-type 676 (setq inferior-octave-process proc
677 inferior-octave-process proc 677 inferior-octave-output-list nil
678 inferior-octave-output-list nil 678 inferior-octave-output-string nil
679 inferior-octave-output-string nil 679 inferior-octave-receive-in-progress t)
680 inferior-octave-receive-in-progress t)
681 680
682 ;; This may look complicated ... However, we need to make sure that 681 ;; This may look complicated ... However, we need to make sure that
683 ;; we additional startup code only AFTER Octave is ready (otherwise, 682 ;; we additional startup code only AFTER Octave is ready (otherwise,
@@ -691,35 +690,32 @@ startup file, `~/.emacs-octave'."
691 (concat 690 (concat
692 (if (not (bobp)) " \n") 691 (if (not (bobp)) " \n")
693 (if inferior-octave-output-list 692 (if inferior-octave-output-list
694 (concat (mapconcat 693 (concat (mapconcat
695 'identity inferior-octave-output-list "\n") 694 'identity inferior-octave-output-list "\n")
696 "\n")))) 695 "\n"))))
697 696
698 ;; An empty secondary prompt, as e.g. obtained by '--braindead', 697 ;; An empty secondary prompt, as e.g. obtained by '--braindead',
699 ;; means trouble. 698 ;; means trouble.
700 (inferior-octave-send-list-and-digest (list "PS2\n")) 699 (inferior-octave-send-list-and-digest (list "PS2\n"))
701 (if (string-match "\\(PS2\\|ans\\) = *$" (car inferior-octave-output-list)) 700 (when (string-match "\\(PS2\\|ans\\) = *$"
702 (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n"))) 701 (car inferior-octave-output-list))
703 702 (inferior-octave-send-list-and-digest (list "PS2 (\"> \");\n")))
704 ;; O.k., now we are ready for the Inferior Octave startup commands. 703
705 (let* (commands 704 ;; O.K., now we are ready for the Inferior Octave startup commands.
706 (program (file-name-nondirectory inferior-octave-program)) 705 (inferior-octave-send-list-and-digest
707 (file (or inferior-octave-startup-file 706 (list "more off;\n"
708 (concat "~/.emacs-" program)))) 707 (unless (equal inferior-octave-output-string ">> ")
709 (setq commands 708 "PS1 (\"\\\\s> \");\n")
710 (list "more off;\n" 709 (when (and inferior-octave-startup-file
711 (if (not (string-equal 710 (file-exists-p inferior-octave-startup-file))
712 inferior-octave-output-string ">> ")) 711 (format "source (\"%s\");\n" inferior-octave-startup-file))))
713 "PS1 (\"\\\\s> \");\n") 712 ;; XXX: the first prompt is incorrectly highlighted
714 (if (file-exists-p file)
715 (format "source (\"%s\");\n" file))))
716 (inferior-octave-send-list-and-digest commands))
717 (insert-before-markers 713 (insert-before-markers
718 (concat 714 (concat
719 (if inferior-octave-output-list 715 (if inferior-octave-output-list
720 (concat (mapconcat 716 (concat (mapconcat
721 'identity inferior-octave-output-list "\n") 717 'identity inferior-octave-output-list "\n")
722 "\n")) 718 "\n"))
723 inferior-octave-output-string)) 719 inferior-octave-output-string))
724 720
725 ;; And finally, everything is back to normal. 721 ;; And finally, everything is back to normal.