unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts
@ 2023-05-27  8:38 Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-05-30  5:02 ` Jim Porter
  0 siblings, 1 reply; 6+ messages in thread
From: Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-27  8:38 UTC (permalink / raw)
  To: 63748

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/





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

end of thread, other threads:[~2023-06-15 16:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-27  8:38 bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-30  5:02 ` Jim Porter
2023-06-03 13:27   ` bug#63748: [PATCH] " Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-03 19:35     ` Jim Porter
2023-06-08 15:11       ` Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-15 16:46         ` Jim Porter

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).