aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2013-11-22 10:02:42 +0800
committerLeo Liu2013-11-22 10:02:42 +0800
commit724bc2658767f0e2c11b3fbe9ec72490ef30cbb2 (patch)
tree60037bc1893e333ee2cd0210790b85c2f8276340
parent680f4ae6ba858da2e078a7f9c2f2d3eb4b6f325d (diff)
downloademacs-724bc2658767f0e2c11b3fbe9ec72490ef30cbb2.tar.gz
emacs-724bc2658767f0e2c11b3fbe9ec72490ef30cbb2.zip
* progmodes/octave.el (inferior-octave-process-live-p): New helper.
(inferior-octave-startup, inferior-octave-check-process) (inferior-octave-track-window-width-change) (octave-completion-at-point, octave-eldoc-function): Use it. (octave-kill-process): Provide confirmation. Fixes: debbugs:10564
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/octave.el30
2 files changed, 23 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 12085f38e5f..01cc8e48847 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-11-22 Leo Liu <sdl.web@gmail.com>
2
3 * progmodes/octave.el (inferior-octave-process-live-p): New helper.
4 (inferior-octave-startup, inferior-octave-check-process)
5 (inferior-octave-track-window-width-change)
6 (octave-completion-at-point, octave-eldoc-function): Use it.
7 (octave-kill-process): Provide confirmation. (Bug#10564)
8
12013-11-21 Leo Liu <sdl.web@gmail.com> 92013-11-21 Leo Liu <sdl.web@gmail.com>
2 10
3 * progmodes/octave.el (octave-mode, inferior-octave-mode): Fix 11 * progmodes/octave.el (octave-mode, inferior-octave-mode): Fix
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 540bd93517d..6187e5f098f 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -698,6 +698,9 @@ in the Inferior Octave buffer.")
698 698
699(declare-function compilation-forget-errors "compile" ()) 699(declare-function compilation-forget-errors "compile" ())
700 700
701(defun inferior-octave-process-live-p ()
702 (and inferior-octave-process (process-live-p inferior-octave-process)))
703
701(define-derived-mode inferior-octave-mode comint-mode "Inferior Octave" 704(define-derived-mode inferior-octave-mode comint-mode "Inferior Octave"
702 "Major mode for interacting with an inferior Octave process." 705 "Major mode for interacting with an inferior Octave process."
703 :abbrev-table octave-abbrev-table 706 :abbrev-table octave-abbrev-table
@@ -782,7 +785,7 @@ startup file, `~/.emacs-octave'."
782 ;; output may be mixed up). Hence, we need to digest the Octave 785 ;; output may be mixed up). Hence, we need to digest the Octave
783 ;; output to see when it issues a prompt. 786 ;; output to see when it issues a prompt.
784 (while inferior-octave-receive-in-progress 787 (while inferior-octave-receive-in-progress
785 (or (process-live-p inferior-octave-process) 788 (or (inferior-octave-process-live-p)
786 (error "Process `%s' died" inferior-octave-process)) 789 (error "Process `%s' died" inferior-octave-process))
787 (accept-process-output inferior-octave-process)) 790 (accept-process-output inferior-octave-process))
788 (goto-char (point-max)) 791 (goto-char (point-max))
@@ -903,8 +906,7 @@ the rest to `inferior-octave-output-string'."
903 (setq inferior-octave-output-string string)) 906 (setq inferior-octave-output-string string))
904 907
905(defun inferior-octave-check-process () 908(defun inferior-octave-check-process ()
906 (or (and inferior-octave-process 909 (or (inferior-octave-process-live-p)
907 (process-live-p inferior-octave-process))
908 (error (substitute-command-keys 910 (error (substitute-command-keys
909 "No inferior octave process running. Type \\[run-octave]")))) 911 "No inferior octave process running. Type \\[run-octave]"))))
910 912
@@ -973,8 +975,7 @@ directory and makes this the current buffer's default directory."
973 (let ((width (max inferior-octave-minimal-columns (window-width)))) 975 (let ((width (max inferior-octave-minimal-columns (window-width))))
974 (unless (eq inferior-octave-last-column-width width) 976 (unless (eq inferior-octave-last-column-width width)
975 (setq-local inferior-octave-last-column-width width) 977 (setq-local inferior-octave-last-column-width width)
976 (when (and inferior-octave-process 978 (when (inferior-octave-process-live-p)
977 (process-live-p inferior-octave-process))
978 (inferior-octave-send-list-and-digest 979 (inferior-octave-send-list-and-digest
979 (list (format "putenv ('COLUMNS', '%s');\n" width))))))) 980 (list (format "putenv ('COLUMNS', '%s');\n" width)))))))
980 981
@@ -1398,8 +1399,7 @@ The block marked is the one that contains point or follows point."
1398 (save-excursion (skip-syntax-forward "w_") 1399 (save-excursion (skip-syntax-forward "w_")
1399 (setq end (point)))) 1400 (setq end (point))))
1400 (when (> end beg) 1401 (when (> end beg)
1401 (list beg end (or (and inferior-octave-process 1402 (list beg end (or (and (inferior-octave-process-live-p)
1402 (process-live-p inferior-octave-process)
1403 inferior-octave-completion-table) 1403 inferior-octave-completion-table)
1404 octave-reserved-words))))) 1404 octave-reserved-words)))))
1405 1405
@@ -1444,12 +1444,13 @@ entered without parens)."
1444(defun octave-kill-process () 1444(defun octave-kill-process ()
1445 "Kill inferior Octave process and its buffer." 1445 "Kill inferior Octave process and its buffer."
1446 (interactive) 1446 (interactive)
1447 (if inferior-octave-process 1447 (or (yes-or-no-p "Kill the inferior Octave process and its buffer? ")
1448 (progn 1448 (user-error "Aborted"))
1449 (process-send-string inferior-octave-process "quit;\n") 1449 (when (inferior-octave-process-live-p)
1450 (accept-process-output inferior-octave-process))) 1450 (process-send-string inferior-octave-process "quit;\n")
1451 (if inferior-octave-buffer 1451 (accept-process-output inferior-octave-process))
1452 (kill-buffer inferior-octave-buffer))) 1452 (when inferior-octave-buffer
1453 (kill-buffer inferior-octave-buffer)))
1453 1454
1454(defun octave-show-process-buffer () 1455(defun octave-show-process-buffer ()
1455 "Make sure that `inferior-octave-buffer' is displayed." 1456 "Make sure that `inferior-octave-buffer' is displayed."
@@ -1592,8 +1593,7 @@ code line."
1592 1593
1593(defun octave-eldoc-function () 1594(defun octave-eldoc-function ()
1594 "A function for `eldoc-documentation-function' (which see)." 1595 "A function for `eldoc-documentation-function' (which see)."
1595 (when (and inferior-octave-process 1596 (when (inferior-octave-process-live-p)
1596 (process-live-p inferior-octave-process))
1597 (let* ((ppss (syntax-ppss)) 1597 (let* ((ppss (syntax-ppss))
1598 (paren-pos (cadr ppss)) 1598 (paren-pos (cadr ppss))
1599 (fn (save-excursion 1599 (fn (save-excursion