Doesn't work correctly with protected eshell prompts
pchan37 opened this issue · 2 comments
I'm using the following snippet from Spacemacs to prevent modification of the eshell prompt:
(defun spacemacs//protect-eshell-prompt ()
"Protect Eshell's prompt like Comint's prompts.
E.g. `evil-change-whole-line' won't wipe the prompt. This
is achieved by adding the relevant text properties."
(let ((inhibit-field-text-motion t))
(add-text-properties
(point-at-bol)
(point)
'(rear-nonsticky t
inhibit-line-move-field-capture t
field output
read-only t
front-sticky (field inhibit-line-move-field-capture)))))
However, as a result of the additional text properties, (beginning-of-line)
in esh-autosuggest--prefix stops right after the prompt instead of at the beginning of the prompt. This causes the while loop to fail. Perhaps we can use something like (re-search-backward "^" nil 'noerror)
instead?
As a side question, can we check if (eshell-bol)
returns nil and then use the result of re-search-forward
? Not really sure why we need (eshell-bol)
here.
Thanks!
Sorry for the years late reply - re: your aside, we might not need (eshell-boll)
at all, it seems the call to re-seach-forward
puts us in the right place anyway. The logic in this bit of the code feels a bit hacked together and could probably be cleaned up some.
Re: the main issue: does replacing (beginning-of-line)
with (forward-line 0)
solve your issue?
I may just replace the entire save-excursion
block with:
(save-excursion
(re-search-backward eshell-prompt-regexp nil 'noerror)
(re-search-forward eshell-prompt-regexp nil 'noerror))