From 4e599d2c2ad677a5761cbd19e78bb1d55dc2e986 Mon Sep 17 00:00:00 2001 From: Jeff Kreeftmeijer Date: Mon, 8 Apr 2024 17:39:39 +0200 Subject: [PATCH] Use eshell-bol-ignoring-prompt on Emacs 30 Currently, the `eshell-atuin--get-input` function uses the `beginning-of-line` function to move the point to the beginning of the line (before the prompt). It then checks if the prompt is present through `looking-at-p` to ensure the current line is a command instead of output that's scrolled back to. This works on Emacs 29, but the behaviour of the `beginning-of-line` function changed in Emacs 30. There, it doesn't actually move the point before the prompt, but behaves like `eshell-bo`l function (which is also deprecated on Emacs 30, in favor of using `beginning-of-line`). To get eshell-atuin to work on Emacs 30, it therefor needs to use `eshell-bol-ignoring-prompt` instead of `beginning-of-line`. This patch adds `eshell-atuin--bol-ignoring-prompt`, which calls `eshell-bol-ignoring-prompt` if available, and falls back to `beginning-of-line` if it doesn't. This fixes compatibility with Emacs 30. --- eshell-atuin.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eshell-atuin.el b/eshell-atuin.el index 6ca109b..50f4e95 100644 --- a/eshell-atuin.el +++ b/eshell-atuin.el @@ -128,10 +128,15 @@ include here. Some examples: (defvar eshell-atuin--session-id nil "Current atuin session ID.") +(defun eshell-atuin--bol-ignoring-prompt () + (if (fboundp 'eshell-bol-ignoring-prompt) + (eshell-bol-ignoring-prompt nil) + (beginning-of-line))) + (defun eshell-atuin--get-input () "Get eshell input string on the current line." (save-excursion - (beginning-of-line) + (eshell-atuin--bol-ignoring-prompt) (when (looking-at-p eshell-prompt-regexp) (substring-no-properties (eshell-get-old-input)))))