unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Pierre Neidhardt <ambrevar@gmail.com>
Cc: 27405@debbugs.gnu.org
Subject: bug#27405: 25.2; Make eshell-next-prompt more reliable
Date: Tue, 11 Jul 2017 22:16:38 -0400	[thread overview]
Message-ID: <87zicae6wp.fsf@users.sourceforge.net> (raw)
In-Reply-To: <20170618141959.GB2617@gmail.com> (Pierre Neidhardt's message of "Sun, 18 Jun 2017 15:19:59 +0100")

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

tags 27405 + patch
quit

Pierre Neidhardt <ambrevar@gmail.com> writes:

>>
>> Hmm, maybe beginning-of-line would make more sense?  If I have point on
>> the same line of the prompt I can get to the beginning of the prompted
>> line with C-a, so C-c C-p probably means I want to go farther back.
>
> Agreed. Please make the change and add a comment.

I think also that doing the text property check following the regexp
search doesn't really make sense, one or the other should be used, not
both:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1848 bytes --]

From 1dd9644f1322d3b40ba98482d4aca0105db56d81 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Tue, 11 Jul 2017 22:11:19 -0400
Subject: [PATCH v2] Make eshell-next-prompt more reliable (Bug#27405)

* lisp/eshell/em-prompt.el (eshell-next-prompt): Search for
`eshell-prompt-regexp' (and `read-only' text-property if
`eshell-highlight-prompt' is set) rather than trying to use
`forward-paragraph'.
(eshell-previous-prompt): Don't count prompt on current line.
---
 lisp/eshell/em-prompt.el | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 8c81b43b1f..2fd1db2113 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -161,14 +161,25 @@ (defun eshell-next-prompt (n)
   "Move to end of Nth next prompt in the buffer.
 See `eshell-prompt-regexp'."
   (interactive "p")
-  (forward-paragraph n)
+  (if eshell-highlight-prompt
+      (progn
+        (while (< n 0)
+          (while (and (re-search-backward eshell-prompt-regexp nil t)
+                      (not (get-text-property (match-beginning 0) 'read-only))))
+          (setq n (1+ n)))
+        (while (> n 0)
+          (while (and (re-search-forward eshell-prompt-regexp nil t)
+                      (not (get-text-property (match-beginning 0) 'read-only))))
+          (setq n (1- n))))
+    (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")
-  (eshell-next-prompt (- (1+ n))))
+  (beginning-of-line)            ; Don't count prompt on current line.
+  (eshell-next-prompt (- n)))
 
 (defun eshell-skip-prompt ()
   "Skip past the text matching regexp `eshell-prompt-regexp'.
-- 
2.11.1


  reply	other threads:[~2017-07-12  2:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-17  9:08 bug#27405: 25.2; Make eshell-next-prompt more reliable Pierre Neidhardt
2017-06-17 22:13 ` npostavs
2017-06-18 13:29   ` Pierre Neidhardt
2017-06-18 13:52     ` npostavs
2017-06-18 14:19       ` Pierre Neidhardt
2017-07-12  2:16         ` npostavs [this message]
2017-07-12 13:06           ` Pierre Neidhardt
2017-07-12 19:26             ` Noam Postavsky
2017-07-21  2:44               ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zicae6wp.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=27405@debbugs.gnu.org \
    --cc=ambrevar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).