emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 7a0ca22: Make eshell-next-prompt more reliable (Bug


From: Noam Postavsky
Subject: [Emacs-diffs] master 7a0ca22: Make eshell-next-prompt more reliable (Bug#27405)
Date: Thu, 20 Jul 2017 22:42:29 -0400 (EDT)

branch: master
commit 7a0ca227af1081ca7ada2e82a87b1a575ef04759
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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 8c81b43..2fd1db2 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -161,14 +161,25 @@ If N is negative, find the previous or Nth previous 
match."
   "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'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]