syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.68k stars 4.89k forks source link

Eshell doesn't remember history #8538

Closed bandali0 closed 1 month ago

bandali0 commented 7 years ago

Description :octocat:

Eshell doesn't remember history

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart:

Expected behaviour: :heart: :smile:

System Info :computer:

Backtrace :paw_prints:

bmag commented 7 years ago

I can confirm that if I open Eshell via SPC a s e (spacemacs/shell-pop-eshell) then the history isn't saved when exiting the shell. However, if I open the shell via M-x eshell, then it does save the history when exiting the shell.

After running SPC a s e and closing the Eshell buffer with C-d, I invoked M-x shell-pop directly to get an Eshell buffer, and its history as well wasn't saved after I exited with C-d. (I checked if history was saved by opening a new M-x eshell and pressing M-p.)

Perhaps a problem with shell-pop or with our configuration of shell-pop, or perhaps Eshell doesn't work well with the buffer name given by shell-pop (a somewhat wild guess). If anyone wants to investigate this, sounds like an interesting bug.

thornjad commented 5 years ago

@aminb are you still experiencing this on the latest develop branch?

Compro-Prasad commented 5 years ago

I just tested it. This bug is still there.

bandali0 commented 5 years ago

Sorry @thornjad I've long since stopped using spacemacs, and now use my own emacs configuration. For what it's worth, eshell history works fine with vanilla emacs + my configs.

Compro-Prasad commented 5 years ago

I found the reason. Its the value of eshell-exit-hook that is the problem. In the popup buffer its value is:

(shell-pop--kill-and-delete-window eshell-write-history eshell-write-last-dir-ring t)

While in normal M-x eshell its:

(eshell-write-history eshell-write-last-dir-ring t)
natemoseman commented 4 years ago

I think I found the problem. However I am not a elisp programmer, so I am not sure if my solution is the correct one.

Spacemacs shell layer uses 'shell-pop' extension.

In this file: https://github.com/kyagi/shell-pop-el/blob/master/shell-pop.el

in the 'shell-pop--set-exit-action' function on line 262... changing: (add-hook 'eshell-exit-hook 'shell-pop--kill-and-delete-window nil t)

to (add-hook 'eshell-exit-hook 'shell-pop--kill-and-delete-window t t)

This changed it so that add-hook appends the function to the hook list. So now 'eshell-exit-hook' gets set to:

(eshell-write-history eshell-write-last-dir-ring t shell-pop--kill-and-delete-window)

So I think that what was happening is that the eshell was exiting before it had a chance to write the history. Changing the order of the hooks now allows eshell to save it's history before the frame is deleted.

filed https://github.com/kyagi/shell-pop-el/issues/66

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

bcc32 commented 3 years ago

I am still experiencing this issue but it appears there have been no responses on the issue in the upstream repo.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

evorion commented 1 year ago

I am experiencing this issue today. It's still not resolved.

smile13241324 commented 1 month ago

Still there and not fixed upstream maybe we can find a workaround

smile13241324 commented 1 month ago

I have added a workaround to Spacemacs circumventing the bug in the ticket. The issue is indeed that the window is set before the store history calls in the shutdown hook.