GNU bug report logs - #63748
30.0.50; eshell-previous-prompt doesn't work for multiline prompts

Previous Next

Package: emacs;

Reported by: Tony Zorman <soliditsallgood <at> mailbox.org>

Date: Sat, 27 May 2023 08:39:02 UTC

Severity: normal

Found in version 30.0.50

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Tony Zorman <soliditsallgood <at> mailbox.org>
Subject: bug#63748: closed (Re: bug#63748: [PATCH] bug#63748: 30.0.50;
 eshell-previous-prompt doesn't work for multiline prompts)
Date: Thu, 15 Jun 2023 16:47:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 63748 <at> debbugs.gnu.org.

-- 
63748: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63748
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: Tony Zorman <soliditsallgood <at> mailbox.org>, 63748-done <at> debbugs.gnu.org
Subject: Re: bug#63748: [PATCH] bug#63748: 30.0.50; eshell-previous-prompt
 doesn't work for multiline prompts
Date: Thu, 15 Jun 2023 09:46:41 -0700
On 6/8/2023 8:11 AM, Tony Zorman via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> oh, this is pretty neat, thanks!
> 
> Sorry for the slow response; I have attached the (hopefully properly)
> corrected patch now.

Thanks (and sorry for the slow response on my end too). This all looks 
good, so I've now merged it to master as f2aae8b879b. Closing this now.

[Message part 3 (message/rfc822, inline)]
From: Tony Zorman <soliditsallgood <at> mailbox.org>
To: bug-gnu-emacs <at> gnu.org
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/



This bug report was last modified 1 year and 342 days ago.

Previous Next


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