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

Eshell doesn't remember history #8538

Closed
bandali0 opened this issue Mar 16, 2017 · 12 comments
Closed

Eshell doesn't remember history #8538

bandali0 opened this issue Mar 16, 2017 · 12 comments

Comments

@bandali0
Copy link

Description :octocat:

Eshell doesn't remember history

Reproduction guide 🪲

  • Start Emacs
  • M-m a s e (start Eshell)
  • Type out a few commands (e.g. pwd, ls, uname)
  • C-d (exit the Eshell)
  • M-m a s e (start Eshell again)
  • M-p

Observed behaviour: 👀 💔

  • M-p results in displaying Empty input ring in the minibar.
  • Eshell doesn't save history (~/.emacs.d/.cache/eshell/ has no files)

Expected behaviour: ❤️ 😄

  • M-p should go back through the history.

System Info 💻

  • OS: gnu/linux
  • Emacs: 25.1.1
  • Spacemacs: 0.200.7
  • Spacemacs branch: develop (rev. e624e8f)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: emacs
  • Completion: ivy
  • Layers:
(aminb auto-completion
       (better-defaults :variables better-defaults-move-to-beginning-of-code-first t better-defaults-move-to-end-of-code-first t)
       bibtex c-c   emacs-lisp git haskell html ivy latex markdown org rust
       (shell :variables shell-default-height 30 shell-default-position 'bottom)
       shell-scripts spell-checking syntax-checking version-control yaml)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

Backtrace 🐾


@bmag
Copy link
Collaborator

bmag commented Mar 16, 2017

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
Copy link

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

@Compro-Prasad
Copy link
Contributor

I just tested it. This bug is still there.

@bandali0
Copy link
Author

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
Copy link
Contributor

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
Copy link

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 kyagi/shell-pop-el#66

@github-actions
Copy link

github-actions bot commented Jan 8, 2021

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!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Jan 8, 2021
@bcc32
Copy link
Contributor

bcc32 commented Jan 8, 2021

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

@duianto duianto removed the stale marked as a stale issue/pr (usually by a bot) label Jan 20, 2021
@github-actions
Copy link

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!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Mar 14, 2022
@evorion
Copy link

evorion commented Jul 13, 2023

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

@github-actions github-actions bot removed the stale marked as a stale issue/pr (usually by a bot) label May 1, 2024
@smile13241324
Copy link
Collaborator

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

@smile13241324 smile13241324 self-assigned this Sep 1, 2024
smile13241324 added a commit that referenced this issue Sep 3, 2024
this is a workaround as the upstream issue is not
solved yet.

See #8538
@smile13241324
Copy link
Collaborator

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.

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

No branches or pull requests

9 participants