Subject: M-b not navigating to the previous word in the prompt string inside Eshell on emacs 30.1
From: Hrishikesh S <[email-masked]>
To: [email-masked]
Date: Fri, 7 Mar 2025 13:58:35 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

In GNU Emacs 30.1, System Description:  macOS 15.2

which I installed by simply running "brew install emacs" on my work machine,
when I'm inside the eshell buffer, typing `M-b` does not take me back by a
word like how it used to be.

Apologies if the bug doesn't have enough information, but I was able to
verify this behavior on a fresh, clean install, without any of my
configuration or installed packages by running

"emacs -Q" and observing the same behavior.

I searched through existing bug reports and this seems like a new issue.

My relevant emacs config:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; eshell
;;
(require 'em-smart)
(setq eshell-history-size 10000)
(setq eshell-prompt-regexp "^[^#$]*[#$] ")

(defun curr-dir-git-branch-string (pwd)
  "Returns current git branch as a string, or the empty string if
PWD is not in a git repo (or the git command is not found)."
  (interactive)
  (when (and (eshell-search-path "git")
             (locate-dominating-file pwd ".git"))
    (let ((git-output (shell-command-to-string (concat "cd " pwd " && git
branch | grep '\\*' | sed -e 's/^\\* //'"))))
      (propertize (concat " ["
              (if (> (length git-output) 0)
                  (substring git-output 0 -1)
                "(no branch)")
              "]") 'face `(:foreground "green"))
      )))

(setq eshell-prompt-function
      (lambda ()
        (concat
         (propertize ((lambda (p-lst)
            (if (> (length p-lst) 3)
                (concat
                 (mapconcat (lambda (elm) (if (zerop (length elm)) ""
                                            (substring elm 0 1)))
                            (butlast p-lst 3)
                            "/")
                 "/"
                 (mapconcat (lambda (elm) elm)
                            (last p-lst 3)
                            "/"))
              (mapconcat (lambda (elm) elm)
                         p-lst
                         "/")))
          (split-string (pwd-repl-home (eshell/pwd)) "/")) 'face
`(:foreground "yellow"))
         (or (curr-dir-git-branch-string (eshell/pwd)))
         (propertize " # " 'face 'default))))

(setq eshell-highlight-prompt nil)

Thank you for all the work on emacs!

Regards,
Hrishi