From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#30187: master a710f8a: * lisp/comint.el (comint-history-isearch-setup): Check if process is live. Date: Thu, 08 Feb 2018 23:29:03 +0200 Organization: LINKOV.NET Message-ID: <87vaf7tbkw.fsf@mail.linkov.net> References: <20180206213907.23079.76097@vcs0.savannah.gnu.org> <20180206213908.03CCC208E4@vcs0.savannah.gnu.org> <87tvush4zh.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1518125844 22436 195.159.176.226 (8 Feb 2018 21:37:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 8 Feb 2018 21:37:24 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 30187@debbugs.gnu.org To: Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 08 22:37:20 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejtsX-0005DK-Mc for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Feb 2018 22:37:13 +0100 Original-Received: from localhost ([::1]:53870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejtuZ-0006on-8O for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Feb 2018 16:39:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejtuL-0006kf-K8 for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2018 16:39:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejtuJ-0000nP-Fi for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2018 16:39:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejtuJ-0000mx-Ax for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2018 16:39:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ejtuJ-0006yK-52 for bug-gnu-emacs@gnu.org; Thu, 08 Feb 2018 16:39:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Feb 2018 21:39:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30187 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30187-submit@debbugs.gnu.org id=B30187.151812589926714 (code B ref 30187); Thu, 08 Feb 2018 21:39:03 +0000 Original-Received: (at 30187) by debbugs.gnu.org; 8 Feb 2018 21:38:19 +0000 Original-Received: from localhost ([127.0.0.1]:34356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejttb-0006wo-84 for submit@debbugs.gnu.org; Thu, 08 Feb 2018 16:38:19 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:45723 helo=homiemail-a23.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejttZ-0006wf-Nj for 30187@debbugs.gnu.org; Thu, 08 Feb 2018 16:38:18 -0500 Original-Received: from homiemail-a23.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a23.g.dreamhost.com (Postfix) with ESMTP id 3480D4B0089; Thu, 8 Feb 2018 13:38:17 -0800 (PST) Original-Received: from localhost.linkov.net (m91-129-111-42.cust.tele2.ee [91.129.111.42]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a23.g.dreamhost.com (Postfix) with ESMTPSA id 10A8D4B007C; Thu, 8 Feb 2018 13:38:15 -0800 (PST) In-Reply-To: (Leo Liu's message of "Thu, 08 Feb 2018 11:13:46 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143030 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> For example, try to set comint-history-isearch to =E2=80=98dwim=E2=80=99 >> and type =E2=80=98C-r=E2=80=99 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 =E2=80= =98M-x shell=E2=80=99, >> then exit it, and after =E2=80=9CProcess shell finished=E2=80=9D type = =E2=80=98M-r=E2=80=99 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 activ= e 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 =E2=80=98comint-goto-inpu= t=E2=80=99 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=comint-after-pmark-p.patch 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. --=-=-=--