From 0518b057fe4e50664cb84bfb6d8ef24d81c94431 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Mon, 2 Dec 2013 15:13:01 +0800 Subject: [PATCH] * subr.el (process-live-p): Return nil for non-process. * progmodes/sh-script.el (sh-shell-process): * progmodes/octave.el (inferior-octave-process-live-p): * progmodes/gdb-mi.el (gdb-delchar-or-quit) (gdb-inferior-io-sentinel): * emacs-lock.el (emacs-lock-live-process-p): All uses changed. Fixes: debbugs:16023 --- lisp/ChangeLog | 10 ++++++++++ lisp/emacs-lock.el | 3 +-- lisp/progmodes/gdb-mi.el | 8 ++++---- lisp/progmodes/octave.el | 2 +- lisp/progmodes/sh-script.el | 2 +- lisp/subr.el | 8 +++++--- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b943b3c5fa8..df576658697 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2013-12-02 Leo Liu + + * subr.el (process-live-p): Return nil for non-process. (Bug#16023) + + * progmodes/sh-script.el (sh-shell-process): + * progmodes/octave.el (inferior-octave-process-live-p): + * progmodes/gdb-mi.el (gdb-delchar-or-quit) + (gdb-inferior-io-sentinel): + * emacs-lock.el (emacs-lock-live-process-p): All uses changed. + 2013-12-02 Dmitry Gutov * vc/log-edit.el (log-edit-kill-buffer): Move the use of diff --git a/lisp/emacs-lock.el b/lisp/emacs-lock.el index ac12c149b01..f1fa9316c82 100644 --- a/lisp/emacs-lock.el +++ b/lisp/emacs-lock.el @@ -109,8 +109,7 @@ Internal use only.") (defun emacs-lock-live-process-p (buffer-or-name) "Return t if BUFFER-OR-NAME is associated with a live process." - (let ((proc (get-buffer-process buffer-or-name))) - (and proc (process-live-p proc)))) + (process-live-p (get-buffer-process buffer-or-name))) (defun emacs-lock--can-auto-unlock (action) "Return t if the current buffer can auto-unlock for ACTION. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 4b0a012e538..224def85895 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -981,7 +981,8 @@ no input, and GDB is waiting for input." (eq gud-minor-mode 'gdbmi)) (error "Not in a GDB-MI buffer")) (let ((proc (get-buffer-process gud-comint-buffer))) - (if (and (eobp) proc (process-live-p proc) + (if (and (eobp) + (process-live-p proc) (not gud-running) (= (point) (marker-position (process-mark proc)))) ;; Sending an EOF does not work with GDB-MI; submit an @@ -1584,9 +1585,8 @@ this trigger is subscribed to `gdb-buf-publisher' and called with ;; read from the pty, and stops listening to it. If the gdb ;; process is still running, remove the pty, make a new one, and ;; pass it to gdb. - (let ((gdb-proc (get-buffer-process gud-comint-buffer)) - (io-buffer (process-buffer proc))) - (when (and gdb-proc (process-live-p gdb-proc) + (let ((io-buffer (process-buffer proc))) + (when (and (process-live-p (get-buffer-process gud-comint-buffer)) (buffer-live-p io-buffer)) ;; `comint-exec' deletes the original process as a side effect. (comint-exec io-buffer "gdb-inferior" nil nil nil) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 5e79e6627d8..7b9d7c97f85 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -700,7 +700,7 @@ in the Inferior Octave buffer.") (declare-function compilation-forget-errors "compile" ()) (defun inferior-octave-process-live-p () - (and inferior-octave-process (process-live-p inferior-octave-process))) + (process-live-p inferior-octave-process)) (define-derived-mode inferior-octave-mode comint-mode "Inferior Octave" "Major mode for interacting with an inferior Octave process." diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 3ac0868414b..c270d433e76 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1478,7 +1478,7 @@ frequently editing existing scripts with different styles.") (defun sh-shell-process (force) "Get a shell process for interaction. If FORCE is non-nil and no process found, create one." - (if (and sh-shell-process (process-live-p sh-shell-process)) + (if (process-live-p sh-shell-process) sh-shell-process (setq sh-shell-process (let ((found nil) proc diff --git a/lisp/subr.el b/lisp/subr.el index b22c719f010..6b1e99f337c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1885,9 +1885,11 @@ Signal an error if the program returns with a non-zero exit status." (defun process-live-p (process) "Returns non-nil if PROCESS is alive. A process is considered alive if its status is `run', `open', -`listen', `connect' or `stop'." - (memq (process-status process) - '(run open listen connect stop))) +`listen', `connect' or `stop'. Value is nil if PROCESS is not a +process." + (and (processp process) + (memq (process-status process) + '(run open listen connect stop)))) ;; compatibility -- 2.39.2