--- Begin Message ---
Subject: |
30.0.50; eshell-previous-prompt doesn't work for multiline prompts |
Date: |
Sat, 27 May 2023 10:38:11 +0200 |
Hi,
in commit c257fd3a406d6aa83be60b96217e42b49b62cf5f, the way prompt
navigation in eshell is done was changed; it now works via a text
property search instead of searching for the prompt regexp. When
backwards searching with a prompt that spans multiple lines, however,
one doesn't get off the ground because the current prompt isn't properly
skipped.
More precisely: define a custom prompt
(defun my/default-prompt-function ()
(concat "┌─"
(user-login-name) "@" (system-name)
" " (abbreviate-file-name (eshell/pwd)) " \n"
"└─"
(if (zerop (user-uid)) "#" "$")
" "))
and enable it by setting
(setq eshell-prompt-function #'my/default-prompt-function)
(setq eshell-prompt-regexp "└─[$#] ") ; For good measure.
This will result in the point not moving backwards to the last prompt on
C-c C-p (eshell-previous-prompt), but instead it gets "stuck" on the
very left of the line it is on. A solution to this (I think) is to
actually search for the beginning of the current prompt, instead of
using forward-line by itself. I.e., something like
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 9f9e58e83d..b6c873b41d 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -180,7 +180,8 @@ eshell-next-prompt
(text-property-search-forward 'field 'prompt t))
(setq n (1- n)))
(let (match this-match)
- (forward-line 0) ; Don't count prompt on current line.
+ ;; Don't count prompt on current line.
+ (text-property-search-backward 'field 'prompt t)
(while (and (< n 0)
(setq this-match (text-property-search-backward
'field 'prompt t)))
This is a tiny change, so I suppose it can be applied immediately (if I
haven't overlooked anything, of course), or I can prepare a proper patch
(that perhaps adds a test for multiline prompts to the right place).
Tony
-----------------------------------------------------------------------
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-musl, cairo version
1.16.0) of 2023-05-17 built on pbox
Repository revision: 6cb963b73c3768958e13e96b2534d1e99239a3ff
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Void Linux
Configured using:
'configure --with-x --without-x-toolkit --without-toolkit-scroll-bars
--without-dbus --without-gconf --without-gsettings --with-modules
--with-file-notification=inotify --with-jpeg --with-tiff --with-gif
--with-png --with-xpm --with-rsvg --without-imagemagick --with-cairo
--with-gnutls --with-sound --with-json --with-harfbuzz --with-gpm
--with-native-compilation --without-compress-install --with-xinput2
--with-small-ja-dic --without-tree-sitter 'CFLAGS=-O2 -pipe
-march=native -mtune=native -fomit-frame-pointer''
Configured features:
CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBOTF
LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY OLDXMENU PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF WEBP X11 XDBE XIM XINPUT2 XPM
ZLIB
Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LC_COLLATE: C
value of $LANG: en_GB
locale-coding-system: utf-8-unix
--
Tony Zorman | https://tony-zorman.com/
--- End Message ---