* Re: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. [not found] ` <20180206213908.03CCC208E4@vcs0.savannah.gnu.org> @ 2018-02-07 1:19 ` Leo Liu 2018-02-07 21:20 ` bug#30187: " Juri Linkov 0 siblings, 1 reply; 6+ messages in thread From: Leo Liu @ 2018-02-07 1:19 UTC (permalink / raw) To: emacs-devel On 2018-02-06 16:39 -0500, Juri Linkov wrote: > branch: master > commit a710f8aa61ca73054109dc4f926d1ac6aabdd849 > Author: Juri Linkov <juri@linkov.net> > Commit: Juri Linkov <juri@linkov.net> > > * lisp/comint.el (comint-history-isearch-setup): Check if process is live. > > Don't activate comint-history isearch when shell prompt is empty > like in all *Async Shell Command* buffers. (Bug#30187) > --- > lisp/comint.el | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/lisp/comint.el b/lisp/comint.el > index 8dba317..b4fbfc8 100644 > --- a/lisp/comint.el > +++ b/lisp/comint.el > @@ -1448,10 +1448,17 @@ If nil, Isearch operates on the whole comint buffer." > (defun comint-history-isearch-setup () > "Set up a comint for using Isearch to search the input history. > Intended to be added to `isearch-mode-hook' in `comint-mode'." > - (when (or (eq comint-history-isearch t) > - (and (eq comint-history-isearch 'dwim) > - ;; Point is at command line. > - (comint-after-pmark-p))) > + (when (and (get-buffer-process (current-buffer)) > + (or (eq comint-history-isearch t) > + (and (eq comint-history-isearch 'dwim) > + ;; Point is at command line. > + (comint-after-pmark-p) > + ;; Prompt is not empty like in Async Shell Command buffers > + (not (eq (save-excursion > + (goto-char (comint-line-beginning-position)) > + (forward-line 0) > + (point)) > + (comint-line-beginning-position)))))) > (setq isearch-message-prefix-add "history ") > (setq-local isearch-search-fun-function > #'comint-history-isearch-search) > Changing comint-history-isearch-setup this way seems too pervasive. I have a use case where (get-buffer-process (current-buffer)) is always nil. Is there another way to work around the issue in *Async Shell Command*? Thanks. Leo ^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30187: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. 2018-02-07 1:19 ` master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live Leo Liu @ 2018-02-07 21:20 ` Juri Linkov 2018-02-08 3:13 ` Leo Liu 0 siblings, 1 reply; 6+ messages in thread From: Juri Linkov @ 2018-02-07 21:20 UTC (permalink / raw) To: Leo Liu; +Cc: 30187 > Changing comint-history-isearch-setup this way seems too pervasive. I > have a use case where (get-buffer-process (current-buffer)) is always > nil. Is there another way to work around the issue in *Async Shell > Command*? Thanks. Before this fix the search was broken in *Async Shell Command* and in inactive shells. For example, try to set comint-history-isearch to ‘dwim’ and type ‘C-r’ in a *Async Shell Command* buffer. It fails with Lisp error: (wrong-type-argument processp nil) process-mark(nil) comint-after-pmark-p() comint-history-isearch-setup() ... Or even when comint-history-isearch is nil by default, run shell ‘M-x shell’, then exit it, and after “Process shell finished” type ‘M-r’ and any letter to search for it: Lisp error: (wrong-type-argument processp nil) process-mark(nil) comint-delete-input() comint-goto-input(nil) comint-history-isearch-pop-state ... In these cases the history can't be searched because there is no active shell. I wonder what use case do you need in inactive shells without a prompt, so it's impossible to search in the history. How you used to search through the shell history without failing in ‘comint-goto-input’ like in the backtrace above? ^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30187: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. 2018-02-07 21:20 ` bug#30187: " Juri Linkov @ 2018-02-08 3:13 ` Leo Liu 2018-02-08 21:29 ` Juri Linkov 0 siblings, 1 reply; 6+ messages in thread From: Leo Liu @ 2018-02-08 3:13 UTC (permalink / raw) To: Juri Linkov; +Cc: 30187 On 2018-02-07 23:20 +0200, Juri Linkov wrote: > Before this fix the search was broken in *Async Shell Command* > and in inactive shells. Thanks. I tried the following examples and saw their failures. > > For example, try to set comint-history-isearch to ‘dwim’ > and type ‘C-r’ in a *Async Shell Command* buffer. It fails with > > Lisp error: (wrong-type-argument processp nil) > process-mark(nil) > comint-after-pmark-p() > comint-history-isearch-setup() > ... It seems to make a lot of sense to have comint-after-pmark-p return nil instead. WDYT? > Or even when comint-history-isearch is nil by default, run shell ‘M-x shell’, > then exit it, and after “Process shell finished” type ‘M-r’ and any letter > to search for it: > > Lisp error: (wrong-type-argument processp nil) > process-mark(nil) > comint-delete-input() > comint-goto-input(nil) > comint-history-isearch-pop-state > ... > > In these cases the history can't be searched because there is no active shell. > I wonder what use case do you need in inactive shells without a prompt, > so it's impossible to search in the history. How you used to search > through the shell history without failing in ‘comint-goto-input’ like > in the backtrace above? My use case is using a function (or in Erlang's lingo a light-weight process) to communicate with a remote Erlang shell. So there is no process as comint/emacs understands. Leo ^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30187: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. 2018-02-08 3:13 ` Leo Liu @ 2018-02-08 21:29 ` Juri Linkov 2018-02-09 2:45 ` Leo Liu 0 siblings, 1 reply; 6+ messages in thread From: Juri Linkov @ 2018-02-08 21:29 UTC (permalink / raw) To: Leo Liu; +Cc: 30187 [-- Attachment #1: Type: text/plain, Size: 1561 bytes --] >> For example, try to set comint-history-isearch to ‘dwim’ >> and type ‘C-r’ in a *Async Shell Command* buffer. It fails with >> >> Lisp error: (wrong-type-argument processp nil) >> process-mark(nil) >> comint-after-pmark-p() >> comint-history-isearch-setup() >> ... > > It seems to make a lot of sense to have comint-after-pmark-p return nil > instead. WDYT? Good idea. The patch at the end of this message also always checks if the prompt is empty at the end of the shell buffer to exclude Async Shell Command buffers and inactive shells. >> Or even when comint-history-isearch is nil by default, run shell ‘M-x shell’, >> then exit it, and after “Process shell finished” type ‘M-r’ and any letter >> to search for it: >> >> Lisp error: (wrong-type-argument processp nil) >> process-mark(nil) >> comint-delete-input() >> comint-goto-input(nil) >> comint-history-isearch-pop-state >> ... >> >> In these cases the history can't be searched because there is no active shell. >> I wonder what use case do you need in inactive shells without a prompt, >> so it's impossible to search in the history. How you used to search >> through the shell history without failing in ‘comint-goto-input’ like >> in the backtrace above? > > My use case is using a function (or in Erlang's lingo a light-weight > process) to communicate with a remote Erlang shell. So there is no > process as comint/emacs understands. Nice, good to know, as these days I completely switched to Elixir. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: comint-after-pmark-p.patch --] [-- Type: text/x-diff, Size: 1810 bytes --] diff --git a/lisp/comint.el b/lisp/comint.el index b4fbfc8..22fbe06 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1448,17 +1448,18 @@ comint-history-isearch-message-overlay (defun comint-history-isearch-setup () "Set up a comint for using Isearch to search the input history. Intended to be added to `isearch-mode-hook' in `comint-mode'." - (when (and (get-buffer-process (current-buffer)) + (when (and + ;; Prompt is not empty like in Async Shell Command buffers + ;; or in inactive shells + (not (eq (save-excursion + (goto-char (comint-line-beginning-position)) + (forward-line 0) + (point)) + (comint-line-beginning-position))) (or (eq comint-history-isearch t) (and (eq comint-history-isearch 'dwim) ;; Point is at command line. - (comint-after-pmark-p) - ;; Prompt is not empty like in Async Shell Command buffers - (not (eq (save-excursion - (goto-char (comint-line-beginning-position)) - (forward-line 0) - (point)) - (comint-line-beginning-position)))))) + (comint-after-pmark-p)))) (setq isearch-message-prefix-add "history ") (setq-local isearch-search-fun-function #'comint-history-isearch-search) @@ -2288,8 +2289,10 @@ comint-skip-prompt (defun comint-after-pmark-p () "Return t if point is after the process output marker." - (let ((pmark (process-mark (get-buffer-process (current-buffer))))) - (<= (marker-position pmark) (point)))) + (let ((process (get-buffer-process (current-buffer)))) + (when process + (let ((pmark (process-mark process))) + (<= (marker-position pmark) (point)))))) (defun comint-simple-send (proc string) "Default function for sending to PROC input STRING. ^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#30187: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. 2018-02-08 21:29 ` Juri Linkov @ 2018-02-09 2:45 ` Leo Liu 2018-02-11 21:44 ` Juri Linkov 0 siblings, 1 reply; 6+ messages in thread From: Leo Liu @ 2018-02-09 2:45 UTC (permalink / raw) To: Juri Linkov; +Cc: 30187 On 2018-02-08 23:29 +0200, Juri Linkov wrote: > Good idea. The patch at the end of this message also always checks > if the prompt is empty at the end of the shell buffer to exclude > Async Shell Command buffers and inactive shells. Thanks for taking this on. The patch looks good. >> My use case is using a function (or in Erlang's lingo a light-weight >> process) to communicate with a remote Erlang shell. So there is no >> process as comint/emacs understands. > > Nice, good to know, as these days I completely switched to Elixir. Good to know too. The BEAM is underappreciated. Leo ^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30187: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. 2018-02-09 2:45 ` Leo Liu @ 2018-02-11 21:44 ` Juri Linkov 0 siblings, 0 replies; 6+ messages in thread From: Juri Linkov @ 2018-02-11 21:44 UTC (permalink / raw) To: Leo Liu; +Cc: 30187 >> Good idea. The patch at the end of this message also always checks >> if the prompt is empty at the end of the shell buffer to exclude >> Async Shell Command buffers and inactive shells. > > Thanks for taking this on. The patch looks good. This is now pushed to master. Thanks for the feedback. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-11 21:44 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20180206213907.23079.76097@vcs0.savannah.gnu.org> [not found] ` <20180206213908.03CCC208E4@vcs0.savannah.gnu.org> 2018-02-07 1:19 ` master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live Leo Liu 2018-02-07 21:20 ` bug#30187: " Juri Linkov 2018-02-08 3:13 ` Leo Liu 2018-02-08 21:29 ` Juri Linkov 2018-02-09 2:45 ` Leo Liu 2018-02-11 21:44 ` Juri Linkov
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.