Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First 2 bullet points of future developments #20

Open
cyruseuros opened this issue Jun 28, 2019 · 0 comments
Open

First 2 bullet points of future developments #20

cyruseuros opened this issue Jun 28, 2019 · 0 comments

Comments

@cyruseuros
Copy link

It's been implemented in Spacemacs for a while and it really should be part of this package considering that it only makes sense as a part of it.

          (defun spacemacs/move-buffer-to-window (windownum follow-focus-p)
            "Moves a buffer to a window, using the spacemacs numbering. follow-focus-p
            controls whether focus moves to new window (with buffer), or stays on
            current"
            (interactive)
            (let ((b (current-buffer))
                  (w1 (selected-window))
                  (w2 (winum-get-window-by-number windownum)))
              (unless (eq w1 w2)
                (set-window-buffer w2 b)
                (switch-to-prev-buffer)
                (unrecord-window-buffer w1 b)))
            (when follow-focus-p (select-window (winum-get-window-by-number windownum))))
          (defun spacemacs/swap-buffers-to-window (windownum follow-focus-p)
            "Swaps visible buffers between active window and selected window.
            follow-focus-p controls whether focus moves to new window (with buffer), or
            stays on current"
            (interactive)
            (let* ((b1 (current-buffer))
                  (w1 (selected-window))
                  (w2 (winum-get-window-by-number windownum))
                  (b2 (window-buffer w2)))
              (unless (eq w1 w2)
                (set-window-buffer w1 b2)
                (set-window-buffer w2 b1)
                (unrecord-window-buffer w1 b1)
                (unrecord-window-buffer w2 b2)))
            (when follow-focus-p (winum-select-window-by-number windownum)))
          (dotimes (i 9)
            (let ((n (+ i 1)))
              (eval `(defun ,(intern (format "buffer-to-window-%s" n)) (&optional arg)
                        ,(format "Move buffer to the window with number %i." n)
                        (interactive "P")
                        (if arg
                            (spacemacs/swap-buffers-to-window ,n t)
                          (spacemacs/move-buffer-to-window ,n t))))
              (eval `(defun ,(intern (format "move-buffer-window-no-follow-%s" n)) ()
                      (interactive)
                      (spacemacs/move-buffer-to-window ,n nil)))
              (eval `(defun ,(intern (format "swap-buffer-window-no-follow-%s" n)) ()
                      (interactive)
                      (spacemacs/swap-buffers-to-window ,n nil)))
              ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant