From 3294ba546e1db8615af0ec3f4434ea7c07a50fc6 Mon Sep 17 00:00:00 2001 From: Miranda Marquez Date: Sun, 7 Apr 2024 15:41:14 -0800 Subject: [PATCH] don't modify prompt if it isn't there --- p11k.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/p11k.el b/p11k.el index f1e345c..80e2506 100644 --- a/p11k.el +++ b/p11k.el @@ -303,15 +303,16 @@ Use 'window-width' to calculate the total final width." "Toggle the direction that the prompt points according to `p11k/get-modal-status'." (save-match-data (save-mark-and-excursion - (let ((inhibit-read-only t) - (new-caret - (p11k/caret-color-status - eshell-last-command-status))) - (goto-char (point-max)) - (re-search-backward eshell-prompt-regexp) - (goto-char (point-at-bol)) - (delete-forward-char 1) - (insert new-caret)) + (if (re-search-backward eshell-prompt-regexp nil 'no-error) + (let ((inhibit-read-only t) + (new-caret + (p11k/caret-color-status + eshell-last-command-status))) + (goto-char (point-max)) + (re-search-backward eshell-prompt-regexp) + (goto-char (point-at-bol)) + (delete-forward-char 1) + (insert new-caret))) ))) (defun p11k/esh-transient-prompt ()