seagle0128 / grip-mode

Instant Github-flavored Markdown/Org preview using grip
GNU General Public License v3.0
269 stars 6 forks source link

Grip-mode opens horizontally instead of vertically by default #20

Closed shaunsingh closed 3 years ago

shaunsingh commented 3 years ago

Hi, when opening a preview using grip-mode, it always opens on the bottom instead of the right, how would I fix this?

I'm using doom emacs with emacs-plus@28 (with xwidgets), my config is here: https://github.com/shaunsingh/vimrc-dotfiles/blob/main/.doom.d/config.org

seagle0128 commented 3 years ago

It's related to your personal configuration. Please see the screenshot below. grip-mode uses built-in function pop-to-buffer.

image

oscarvarto commented 2 months ago

Several years ahead (and Doom Emacs using xwidgets to open the preview), I hit the same problem. I tried a lot of stuff. Found a solution that I will share just in case anyone else needs the preview to open in a side window (not at the bottom):

  1. Split vertically your window first (SPC w v)
  2. Call grip mode (SPC m p)
seagle0128 commented 2 months ago

Thanks! Actually it should be related to the doom's settings of display-buffer-alist.

oscarvarto commented 2 months ago

Some of my attempts (while using Doom Emacs), where:

(set-popup-rules!
  '(("^\\*^xwidget-webkit:.*(?:- Grip|\.html)\\*$"
     :actions (display-buffer-in-side-window)
     :side right
     :width 0.5
     :select t
     :quit nil
     :ttl nil)))

(add-to-list 'display-buffer-alist
            '("^\\*^xwidget-webkit:.*(?:- Grip|\.html)\\*$"
              (+popup-buffer)
              (actions)
              (side . right)
              (size . 0.5)
              (window-parameters (ttl) (quit))))

None worked for me. Am I missing something?

hlissner commented 2 months ago

"^\\*^xwidget-webkit:.*(?:- Grip|\.html)\\*$"

The single backslash behind the .html looks like a typo, and the group (the parens and pipe) needs to be escaped as well. Try this instead:

(set-popup-rule!
  "^\\*^xwidget-webkit:.*\\(?:- Grip\\|\\.html\\)\\*$"
  :side 'right
  :width 0.5
  :select t
  :quit nil
  :ttl nil)

(got rid of the unneeded :actions, and am using the simpler set-popup-rule!).

oscarvarto commented 2 months ago

@hlissner M-: (buffer-name) returns "*xwidget-webkit: README.md - Grip*" for me.

If I call M-x +popup/close-all nothing closes. So, I don't completely understand what's going on here.

EDIT: Correct regex is: "^\\*xwidget-webkit:.*(?:- Grip|\.html)\\*$" I had an additional ^ that I didn't notice 🫤