all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27405: 25.2; Make eshell-next-prompt more reliable
@ 2017-06-17  9:08 Pierre Neidhardt
  2017-06-17 22:13 ` npostavs
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre Neidhardt @ 2017-06-17  9:08 UTC (permalink / raw)
  To: 27405

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-07-21  2:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-07-12 13:06           ` Pierre Neidhardt
2017-07-12 19:26             ` Noam Postavsky
2017-07-21  2:44               ` npostavs

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.