GNU bug report logs - #27405
25.2; Make eshell-next-prompt more reliable

Previous Next

Package: emacs;

Reported by: Pierre Neidhardt <ambrevar <at> gmail.com>

Date: Sat, 17 Jun 2017 09:09:01 UTC

Severity: minor

Tags: confirmed, fixed, patch

Found in version 25.2

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pierre Neidhardt <ambrevar <at> gmail.com>
To: 27405 <at> debbugs.gnu.org
Subject: bug#27405: 25.2; Make eshell-next-prompt more reliable
Date: Sat, 17 Jun 2017 10:08:13 +0100
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




This bug report was last modified 8 years and 35 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.