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

Save/restore window configuration #3

Closed kaushalmodi closed 9 years ago

kaushalmodi commented 9 years ago

Save/restore window configuration when creating/killing poporg buffer.

This works great with this in my emacs setup:

(add-to-list 'display-buffer-alist
                 '("\\*poporg.*?\\*" . ((display-buffer-reuse-window
                                         display-buffer-pop-up-window)
                                        . ((inhibit-same-window . t)))))
stardiviner commented 9 years ago

This is great, seems it is what I want. But after test, it does not work for me.

kaushalmodi commented 9 years ago

Poporg closing all the windows was the exact reason why I made this commit. It has always worked for me. Can you load poporg from my fork in emacs -Q and check if it works then?

kaushalmodi commented 9 years ago

You also need to update the display-buffer-alist as shown above.

QBobWatson commented 9 years ago

Thank you @kaushalmodi for the pull request. It works great for me, without fiddling with display-buffer-alist -- what default behavior are you changing exactly?

kaushalmodi commented 9 years ago

Thanks for merging the PR.

Without the display-buffer-alist, the poporg buffer can open in the same window from which I launched poporg; I didn't like that. I'd like to see the original buffer and the poporg buffer side-by-side and thus the display-buffer-alist tweak.

It just feels smooth to have the original buffer always in view, but probably it's just me :)

Try this out without the display-buffer-alist tweak:

I am curious to know if you too see a similar behavior. :)

QBobWatson commented 9 years ago

Certainly the expected behavior is for the poporg buffer to always open in the other window. This isn't specific to poporg -- anything that runs pop-to-buffer should behave the same way. I couldn't reproduce the behavior you describe -- I haven't changed any of the display-buffer-* settings.

kaushalmodi commented 9 years ago

@QBobWatson Thanks for the feedback.. time to debug my init then.

kaushalmodi commented 9 years ago

@QBobWatson I believe I now know why that problem occurred to me.

Now this discussion has nothing to do with your package.. I am simply brain storming.

I have this function:

;; http://www.whattheemacsd.com/
(defun rotate-windows ()
  "Rotate your windows"
  (interactive)
  (cond ((not (> (count-windows)1))
         (message "You can't rotate a single window!"))
        (t
         (setq i 1)
         (setq numWindows (count-windows))
         (while  (< i numWindows)
           (let* (
                  (w1 (elt (window-list) i))
                  (w2 (elt (window-list) (+ (% i numWindows) 1)))

                  (b1 (window-buffer w1))
                  (b2 (window-buffer w2))

                  (s1 (window-start w1))
                  (s2 (window-start w2))
                  )
             (set-window-buffer w1 b2)
             (set-window-buffer w2 b1)
             (set-window-start w1 s2)
             (set-window-start w2 s1)
             (setq i (1+ i)))))))

Steps to repeat:

I believe that's because the above function messes up the window-buffer relationship. If I don't use rotate-windows, things work fine.

QBobWatson commented 9 years ago

@kaushalmodi I still can't reproduce the issue. I'm using Emacs 24.1.1 -- I have a more recent Emacs version at home which I can try tomorrow.