Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work correctly with protected eshell prompts #9

Open
pchan37 opened this issue May 31, 2019 · 2 comments
Open

Doesn't work correctly with protected eshell prompts #9

pchan37 opened this issue May 31, 2019 · 2 comments

Comments

@pchan37
Copy link

pchan37 commented May 31, 2019

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!

@dieggsy
Copy link
Owner

dieggsy commented Jan 22, 2021

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?

@dieggsy
Copy link
Owner

dieggsy commented Jan 22, 2021

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants