QBobWatson / poporg

Emacs programming tool for editing strings or comments in Org mode or any other text mode
GNU General Public License v3.0
91 stars 9 forks source link

Wish: command to save without exiting comment buffer #4

Closed ddoherty03 closed 7 years ago

ddoherty03 commented 7 years ago

I often, out of habit really, hit the "save" key sequence, C-x C-s, or SPC f s (evil-mode), after a large edit. What i really want is just to have the original buffer updated, but popwin will exit the buffer instead. It would be nice to have a popwin command just to save back to the original buffer for these key sequences, and bind something like C-c C-c to poporg-edit-exit. BTW, this is one of my favorite programming add-ons to emacs. Thanks.

QBobWatson commented 7 years ago

I like the idea -- thank you. It shouldn't be too hard to implement; the only annoying thing will probably be updating the overlay. Give me a couple days.

QBobWatson commented 7 years ago

Ok, it's done. I didn't want to change the previous keybindings, so by default you now have C-c C-c for poporg-update and C-c C-s for poporg-update-and-save. The former does what you want; the latter saves the original buffer too. Of course, you can always customize poporg-mode-map to rebind to your liking.

Please let me know if you find any bugs.

ddoherty03 commented 7 years ago

@QBobWatson, many thanks for the quick response. I'll hook it in. Sorry for the typo "popwin" in the OP instead of "poporg".

ddoherty03 commented 7 years ago

I see its not in melpa yet. Will you be pushing soon?

QBobWatson commented 7 years ago

MELPA automatically pulls from GitHub sources periodically. It looks like it's updated now.

ddoherty03 commented 7 years ago

Yea, just saw it. Thanks.

ddoherty03 commented 7 years ago

For the sake of posterity, here is how I have bound the new functions. I use spacemacs and some regular emacs bindings:

  (use-package poporg
    :ensure t
    :bind  ("C-c #" . poporg-dwim)
    :commands (poporg-dwin)
    :config (progn
              (define-key poporg-mode-map [remap save-buffer] 'poporg-update)
              (define-key poporg-mode-map [remap evil-write] 'poporg-update)
              (define-key poporg-mode-map [remap evil-save-modified-and-close] 'poporg-edit-exit)
              (bind-key "C-x C-s" 'poporg-update poporg-mode-map)
              (bind-key "C-c C-c" 'poporg-edit-exit poporg-mode-map)
              (bind-key "C-c #" 'poporg-edit-exit poporg-mode-map)))
  (spacemacs/set-leader-keys "o#" 'poporg-dwim)

Great package!