bbatsov / super-save

Save Emacs buffers when they lose focus
316 stars 20 forks source link

Super-save not triggered #7

Closed heikkil closed 6 years ago

heikkil commented 8 years ago

I have commands from two packages that I use regularly that do not trigger super-save. Typically my current buffer is unsaved:

  1. magit-status from magit (magit does not see latest changes)
  2. quickrun from quickrun (copies and runs the code from the current unsaved buffer so the problem is not serious)

Could you please either advise how to add code to include them or add fixes to the distribution code.

bbatsov commented 8 years ago

Fixed by #8.

heikkil commented 8 years ago

I do not see any change in the behaviour after upgrading super-save.

How to reproduce the problem:

  1. Make sure super-save mode is enabled.
  2. Open a text file that is under git in emacs.
  3. Make a small change. Do not save.
  4. Run magit-status. The text file remains unsaved.
  5. Quit the magit buffer to return to the text file. The text file remains unsaved (until idle timer triggers saving or the file is saved manually).
bbatsov commented 8 years ago

I've tested the latest version and it definitely works fine for me. Where did you install it from?

heikkil commented 8 years ago

Melpa. Now running version 20160211.256. This is under GNU Emacs 25.1.50.1 (x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F1605)) of 2016-01-28

bbatsov commented 8 years ago

Hmm, I'm running the same myself. Can you run C-h f RET switch-to-buffer and tell what advices do you see there?

heikkil commented 8 years ago

:before advice: ‘super-save-command-advice’ :around advice: ‘ad-Advice-switch-to-buffer’ Also, it tells me that: Its keys are remapped to ‘ivy-switch-buffer’.

I am using heavily abo-abo's packages that might affect things.

bbatsov commented 8 years ago

Not sure what his advice does, but it definitely seems super-save's advice is properly applied for you. //cc @abo-abo

abo-abo commented 8 years ago

Not sure what his advice does, but it definitely seems super-save's advice is properly applied for you.

ivy-mode ony does this, it doesn't introduce any advices:

(define-key map [remap switch-to-buffer] 'ivy-switch-buffer)

Perhaps super-save should un-alias to the command that switch-to-buffer binding is remapped to.

heikkil commented 8 years ago

The :around advice comes from git-gutter-fringe. I disabled it, rebooted. No change.

I also disables ivy-mode. No change there either.

bbatsov commented 8 years ago

Maybe the super-save package is corrupted or something? Remove it and install it again.

heikkil commented 8 years ago

The package has been updated a few times while I've been aware of the problem. Tried anyway to remove-reinstall, but no luck.

If it is just me, the problem is not that serious. I'll keep trying different options. Saving when buffer loses focus and on idle work reliably.

bbatsov commented 8 years ago

I'm so so sorry - I didn't read carefully the ticket description. You're right - those commands don't trigger super-save for some reason. I'll look into this.

jiegec commented 8 years ago

In magit-display-buffer, it calls select-window internally. So just adding a advice to select-window should do work. Testing.

jiegec commented 8 years ago

Yes that works for Magit. i will make a pull request some time later if you don't have time.

jiegec commented 8 years ago

Quickrun uses save-selected-window which internally uses set-frame-selected-window and select-window.

jiegec commented 8 years ago

There is no network or quickrun in my laptop. On my way home now. Sorry for the delay to test quickrun.

jiegec commented 8 years ago

other-window switch-to-buffer and windmove series all uses select-window internally. select-window is defined in c and does the actual work.

heikkil commented 7 years ago

Update: it does not look like PR was submitted to either of the github repositories.

Meanwhile quickrun has been updated to work on the buffer content and does not need saving of the buffer to work as expected.

Situation with magit remains as it is: magit-status does not trigger super-save.

azzamsa commented 6 years ago

Have the same issue today. It was confusing. I don't have any clue about the root of problem. Cause I don't change anything regarding supre-save configuration.

Come to this repo. Fortunately my problem correlate directly to this lastest commit :)

The problem is because I added this line for ace-window configuration

(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))

Using this additional config. Solve the problem :)

(add-to-list 'super-save-triggers 'ace-window)
bbatsov commented 6 years ago

Yeah, now it's simple to just add whatever commands (or hooks) you want to list of triggers. I think we can mark this one as fixed.

hyperfocus1337 commented 3 years ago

I actually have the exact same problem in 2020, super save doesn't recognize the 'magit-status' trigger in my Doom Emacs installation, all other commands work except for 'magit-status' while triggering it with the keystrokes SPC g g.

Super-save-triggers contains these commands.

Value
(evil-window-next magit-status switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right next-buffer previous-buffer evil-window-previous)

I've installed super-save using the default package manager in Doom Emacs (straight.el) in my packages.el file like so (package! super-save), I'm guessing I use the latest version? Don't know how to verify atm.

Also, wouldn't know how to debug this behaviour. Any help would be appreciated.

hyperfocus1337 commented 3 years ago

I don't know how but saving with 'magit-status' started working after I included a few new triggers to the list.

Value
(evil-window-next magit-status switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right next-buffer previous-buffer evil-window-prev +workspace/switch-left +workspace/switch-right)
dlip commented 3 years ago

@hyperfocus1337 I'm having the same problem with evil doom, did you find a fix?

hyperfocus1337 commented 3 years ago

Unfortunately I don't, the same issue started cropping up again, I'm in the same boat.

This is my configuration, for what it's worth.

(use-package! super-save
  :ensure t
  :config
  (super-save-mode +1))

(add-to-list 'super-save-triggers 'evil-window-next)
(add-to-list 'super-save-triggers 'evil-window-prev)
(add-to-list 'super-save-triggers 'next-buffer)
(add-to-list 'super-save-triggers 'previous-buffer)
(add-to-list 'super-save-triggers 'switch-to-buffer)
(add-to-list 'super-save-triggers 'other-window)
(add-to-list 'super-save-triggers 'windmove-up)
(add-to-list 'super-save-triggers 'windmove-down)
(add-to-list 'super-save-triggers 'windmove-left)
(add-to-list 'super-save-triggers 'windmove-right)
(add-to-list 'super-save-triggers '+workspace/switch-left)
(add-to-list 'super-save-triggers '+workspace/switch-right)
(add-to-list 'super-save-triggers '+workspace/switch-to-final)
(add-to-list 'super-save-triggers '+workspace/switch-to)
(add-to-list 'super-save-triggers '+ivy/projectile-find-file)
(add-to-list 'super-save-triggers 'magit-status)
hyperfocus1337 commented 3 years ago

@dlip

Awesome, I found a solution. It's described here.

Use this code:

(setq magit-save-repository-buffers 'dontask)