1

I want to write a shackle rule to split the current window (top/bottom) instead of splitting the root window to display the new buffer.

Here is what I'm getting:

+-------+--------+
|       |current |
|       |        |
+-------+--------+
|      new       |
+----------------+

here is the associated code

;; shackle
(setq shackle-rules '(("*Flycheck errors*" :regexp t :align 'below :size 10)
                      ("*compilation*"     :regexp t :align 'below :size 0.4)))

this is what I want:

+-------+--------+
|       |current |
|       |        |
|       +--------+
|       |  new   |
+-------+--------+
  • 2
    :align is the wrong action for that then, you'll have to write a custom one. – wasamasa Aug 9 '17 at 19:22
2

Going off of wasamasa's suggestion, I wrote a simple shackle rule that happened to do what I wanted (extremely simple dynamic tiling). Hopefully with the example (and/or looking at shackle source) you'll be able to get what you wanted.

  (defun jay/shackle--smart-split-dir ()
    (if (>= (window-pixel-height)
            (window-pixel-width))
        'below
      'right))

  (defun jay/shackle-dynamic-tyling (buffer alist plist)
    (let
        ((frame (shackle--splittable-frame))
         (window (if (eq (jay/shackle--smart-split-dir) 'below)
                     (split-window-below)
                   (split-window-right))))
      (prog1
          (window--display-buffer buffer window 'window alist display-buffer-mark-dedicated)
        (when window
          (setq shackle-last-window window
                shackle-last-buffer buffer))
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame frame)))))

  (setq shackle-rules
        '(("\\`\\*e?shell"
           :regexp t
           :select t
           :custom jay/shackle-dynamic-tyling)))
1

The rules I tend to use for shackle follow the general form:

:regexp t :popup t :select t :align bottom

And the :select value may be nil depending on whether you want point to move to the new window. So, a couple notes on your code:

  1. I think your :align value is not correct.
  2. If you supply t for :regexp, remember that asterisks in the string are interpreted as special modifying characters, so your buffer names are not matching quite what you might expect. I would remove the :regexp unless you explicitly need it to match multiple buffer names.
  3. I have never tried specifying explicit sizes myself, so cannot advise you on how that works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.