From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pierre Neidhardt Newsgroups: gmane.emacs.bugs Subject: bug#27405: 25.2; Make eshell-next-prompt more reliable Date: Sat, 17 Jun 2017 10:08:13 +0100 Message-ID: <20170617090813.GA889@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1497690552 7856 195.159.176.226 (17 Jun 2017 09:09:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Jun 2017 09:09:12 +0000 (UTC) User-Agent: Mutt/1.8.3 (2017-05-23) To: 27405@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 17 11:09:08 2017 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 1dM9j7-0001iC-WC for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Jun 2017 11:09:06 +0200 Original-Received: from localhost ([::1]:33884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dM9jC-0002O0-SF for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Jun 2017 05:09:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dM9j7-0002Nv-Gq for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:09:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dM9j4-0004E5-BK for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:09:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dM9j4-0004DW-7K for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dM9j3-0003By-Sd for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pierre Neidhardt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2017 09:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27405 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: GNU Emacs bug Tracking System Original-Received: via spool by submit@debbugs.gnu.org id=B.149769050912231 (code B ref -1); Sat, 17 Jun 2017 09:09:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Jun 2017 09:08:29 +0000 Original-Received: from localhost ([127.0.0.1]:52093 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dM9iX-0003BD-Do for submit@debbugs.gnu.org; Sat, 17 Jun 2017 05:08:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dM9iV-0003B0-OD for submit@debbugs.gnu.org; Sat, 17 Jun 2017 05:08:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dM9iP-0003dC-Iy for submit@debbugs.gnu.org; Sat, 17 Jun 2017 05:08:22 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:51710) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dM9iP-0003d1-FU for submit@debbugs.gnu.org; Sat, 17 Jun 2017 05:08:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dM9iO-0002MI-Be for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:08:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dM9iL-0003XB-5M for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:08:20 -0400 Original-Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:35633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dM9iK-0003VX-VA for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2017 05:08:17 -0400 Original-Received: by mail-wm0-x22d.google.com with SMTP id x70so42472604wme.0 for ; Sat, 17 Jun 2017 02:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=i64VxzVXevV86Np01DZUlGaqM4Nl10/gi8nlhD45YBo=; b=fome/QVgHAiG7lGztaD8nevNtOXnrEIHEJOSDBnYs/Hs0POTknNlyxMOLMFUUA3RwQ pfu93njCj9Cul4Xv6kCVWqiT1+tn2C1DWqejYfFIboMHCzgSZmNIH3iJTmgqnJDDktqN OsY+DCweAQx0MuF2c+zhSwlRboz7H6cE3you8s3d60muhWPD+UKnXv72pb8hHsiHH1aH NNs1aaUm9jIsrxvPpVnNt0vPNJ+hdh5Mxlspy7zhpiXbIQN45xZJ6LrLBe2irjA+wpcG PwUmyzitA60ObG0/870jG6zkoDE9qg0anFv7iYp4hZ4Q3W+nEsUxETRX0DTmyOIQKhGv ckTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=i64VxzVXevV86Np01DZUlGaqM4Nl10/gi8nlhD45YBo=; b=ACezRgkgNI4h5/31qwyxPFK4n4HOx8FcEoaysC9yLYF3v0G1xScvFmSnZkIFuUc5gG mn1i0J2GpDDcKUhnVYe7kluWlo90dhQ3b/9RLMu0aNBywzuJPiMu+aAyXEVdAAkhVNSG d8/hToshdvT3Pu+LiVfUweAheu3JGWxOY6bV2LzN4EqYYkbnWTHQnCp75DflvAiZq8in WQ6QWfS6B6BbTUIc+7LgcYSKF1bEOPMfBjshnI4R+AkaTc6mTxmPu5GhL+ih4a0A+qCx gDfx8fIoBuJLIAX69LjD4NxcCiTXkcgw4YuY/Fgm7OSVey4Gh9McXBnK+FRmuVePHimR phrQ== X-Gm-Message-State: AKS2vOzfdHnIE5rI5SThsiDltJhC9yo2l37/vcPJuscefQY9egxIYL/Q Daya01AxWd/NBkz/ X-Received: by 10.28.143.16 with SMTP id r16mr10097731wmd.50.1497690495383; Sat, 17 Jun 2017 02:08:15 -0700 (PDT) Original-Received: from gmail.com ([196.203.31.130]) by smtp.gmail.com with ESMTPSA id 18sm1596506wmt.6.2017.06.17.02.08.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Jun 2017 02:08:14 -0700 (PDT) Content-Disposition: inline X-Info: Simplicity is the ultimate sophistication. X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:133688 Archived-At: Current definition of `eshell-next-prompt' merely skips a paragraph. This won't produce the right result as soon the output contains a paragraph separator (typically an empty line). I have been using the following redefinition for a while and it works much better for me: (defun eshell-next-prompt (n) "Move to end of Nth next prompt in the buffer. See `eshell-prompt-regexp'." (interactive "p") (re-search-forward eshell-prompt-regexp nil t n) (when eshell-highlight-prompt (while (not (get-text-property (line-beginning-position) 'read-only) ) (re-search-forward eshell-prompt-regexp nil t n))) (eshell-skip-prompt)) (defun eshell-previous-prompt (n) "Move to end of Nth previous prompt in the buffer. See `eshell-prompt-regexp'." (interactive "p") (backward-char) (eshell-next-prompt (- n)))) Quite naturally, I search for the `eshell-prompt-regexp'. If that prompt is too simple (say "^\$ "), some output could easily match the regexp and the function would move the point there instead of its right location. To work around that case, I check if the text is read-only, which is a property of the prompt (if `eshell-highlight-prompt' is `t') but not of the output. What do you think? Would you accept a patch? In GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.10) of 2017-04-22 built on juergen Windowing system distributor 'The X.Org Foundation', version 11.0.11903000 System Description: Arch Linux