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

poporg minor mode is not enabled in opened buffer. #2

Closed stardiviner closed 9 years ago

stardiviner commented 9 years ago

poporg minor mode is not enabled in opened buffer, so the keybinding [C-x C-s] does not work. and here is my config:

(require 'poporg)
(autoload 'poporg-dwim "poporg" nil t)

(setq poporg-adjust-fill-column t
      poporg-delete-trailing-whitespace t)

;; Org-mode Babel like keybindings.
(if (featurep 'poporg)
    (progn
      (global-set-key (kbd "C-c '") 'poporg-dwim)
      (define-key poporg-mode-map [remap save-buffer] 'poporg-edit-exit)
      ))
QBobWatson commented 9 years ago

Are you sure the minor mode is not enabled? (poporg-mode +1) runs unconditionally in (poporg-edit-thing). Also, isn't your define-key redundant given the definition of (poporg-mode-map)?

stardiviner commented 9 years ago

Yes, I'm sure the minor mode is not enabled, and I checked out the definition of poporg-dwim -> poporg-edit-thing -> (poporg-mode +1). I know my define-key to poporg-edit-exit is redundant. it's the way I try to fix this issue, but it does not work.

QBobWatson commented 9 years ago

In that case I'm stumped. Can you turn the mode on manually using M-x poporg-mode from the poporg buffer? What version of Emacs are you using?

stardiviner commented 9 years ago

@QBobWatson yes, I can enable poporg minor mode manually. Emacs version: "25.0.50.1"

QBobWatson commented 9 years ago

I haven't tried it with Emacs 25+ yet, so that may be the problem. Have you tried putting (poporg-mode +1) in poporg-edit-hook? If your buffer ends up in org mode then presumably that's getting run.

stardiviner commented 9 years ago

@QBobWatson I tried to add (poporg-mode +1) into poporg-edit-hook. not work. I will try to debug my emacs with emacs -Q, must be something wrong in my Emacs configs. let you know update as soon I get the bisect result.

stardiviner commented 9 years ago

UPDATE: after test with emacs -Q, and load poporg-mode only, it works.

stardiviner commented 9 years ago

After bisect test my Emacs configs, I found why:

I have enable this:

(setq org-startup-with-latex-preview t)

And this caused poporg-mode does not loaded in popup buffer correctly.

QBobWatson commented 9 years ago

I see -- org latex preview won't work on non-file buffers, so it throws an error, which poporg is not catching. I just committed a revision which should hopefully fix your problem -- please let me know if it works.

Thanks for the debugging!

stardiviner commented 9 years ago

@QBobWatson it works now, but still have a small question, it will auto close the opened buffer window, instead of switch back to previous buffer.

QBobWatson commented 9 years ago

You mean when you type C-x C-s?

stardiviner commented 9 years ago

Yes

QBobWatson commented 9 years ago

That's the intended behavior. If you want to switch back to the previous buffer with the poporg buffer open, use C-x o. The part of the text that you're editing in poporg is marked immutable.

stardiviner commented 9 years ago

Not that, I mean, keep the window open, just close poporg popup buffer. For example: I have two windows which opened two buffers : buffer1 buffer2, and the two windows corresponding two buffers are: window1, window2. Then I open poporg in window1, the poporg will popup buffer in window2. After [C-x C-s], poporg closed the window2. I hope the window2 can be keep, just close the poporg buffer, the final result is the buffer in window2 is still buffer2.

(This is a little kind of complicated way to describe my situation. but it is accurate)

stardiviner commented 9 years ago

seems this https://github.com/QBobWatson/poporg/pull/3 can solve my problem.