use transpose-frame package

ご主人様
not manx 4 years ago
parent 1a3b35b39f
commit 3d03663547
Signed by: C-xC-c
GPG Key ID: F52ED472284EF2F4

@ -12,6 +12,10 @@
(setq use-package-always-ensure t
use-package-verbose t)
(use-package keychain-environment
:bind ("C-c r e" . 'keychain-refresh-environment)
:init (keychain-refresh-environment))
(use-package auto-minor-mode)
(use-package diminish)
@ -56,21 +60,18 @@
(add-hook 'lisp-mode-hook 'slime-mode)
(slime-setup '(slime-fancy slime-company)))
(use-package keychain-environment
:bind ("C-c r e" . 'keychain-refresh-environment)
:init (keychain-refresh-environment))
(use-package htmlize)
(use-package spaceline
:init
(require 'spaceline-config)
(spaceline-spacemacs-theme)
:config
(spaceline-toggle-buffer-size-off)
;;This isn't set in :custom because it breaks the arrow.
(setq powerline-default-seperator 'arrow)
(add-hook 'after-init-hook 'spaceline-compile))
(use-package yasnippet
:diminish 'yas-minor-mode
:hook ((html-mode
LaTeX-mode
emacs-lisp-mode
lisp-mode)
. yas-minor-mode)
:init ;; These are computationally expensive, so init.
(use-package yasnippet-snippets)
(yas-reload-all))
(use-package dashboard
:diminish (dashboard-mode page-break-lines-mode)
@ -85,6 +86,12 @@
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(use-package transpose-frame
:ensure t
:bind (("C-c f t" . transpose-frame)
("C-c f i" . flip-frame)
("C-c f o" . flop-frame)))
(use-package switch-window
:custom
(switch-window-input-style 'minibuffer)
@ -92,16 +99,26 @@
(switch-window-threshold 2)
:bind ([remap other-window] . switch-window))
(use-package yasnippet
:diminish 'yas-minor-mode
:hook ((html-mode
LaTeX-mode
emacs-lisp-mode
lisp-mode)
. yas-minor-mode)
:init ;; These are computationally expensive, so init.
(use-package yasnippet-snippets)
(yas-reload-all))
(setq ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-everywhere 1)
(use-package ido-vertical-mode
:bind ("C-l" . 'ido-reread-directory)
:custom (ido-vertical-define-keys 'C-n-and-C-p-only)
:config
(ido-vertical-mode 1)
(ido-mode 1))
(use-package spaceline
:init
(require 'spaceline-config)
(spaceline-spacemacs-theme)
:config
(spaceline-toggle-buffer-size-off)
;;This isn't set in :custom because it breaks the arrow.
(setq powerline-default-seperator 'arrow)
(add-hook 'after-init-hook 'spaceline-compile))
(use-package hungry-delete
:diminish 'hungry-delete-mode
@ -121,24 +138,13 @@
(use-package popup-kill-ring
:bind ("M-y" . popup-kill-ring))
(setq ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-everywhere 1)
(use-package ido-vertical-mode
:bind ("C-l" . 'ido-reread-directory)
:custom (ido-vertical-define-keys 'C-n-and-C-p-only)
:config
(ido-vertical-mode 1)
(ido-mode 1))
(definteractive manx/config-reload ()
(when (get-buffer "config.org")
(with-current-buffer "config.org" (save-buffer)))
(org-babel-load-file (concat user-emacs-directory "config.org")))
(org-babel-load-file manx/emacs-org))
(global-set-key (kbd "C-c x r") 'manx/config-reload)
(global-set-key (kbd "C-c x e") (lambdainteractive () (find-file (concat user-emacs-directory "config.org"))))
(global-set-key (kbd "C-c x e") (lambdainteractive () (find-file manx/emacs-org)))
(setq org-src-window-setup 'current-window)
@ -191,32 +197,26 @@
(global-set-key (kbd "<M-right>") 'forward-whitespace)
(definteractive manx/scratch-buffer ()
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
(global-set-key (kbd "C-c s b") 'manx/scratch-buffer)
(global-set-key (kbd "C-x k") (lambdainteractive () (kill-buffer (current-buffer))))
(global-set-key (kbd "C-M-s-k") (lambdainteractive ()
(mapc 'kill-buffer (buffer-list))
(manx/scratch-buffer)))
;; This is only used here for now but we should still more it some
;; time
(add-to-list 'load-path "~/.emacs.d/scripts/")
(require 'transpose-frame)
(global-set-key (kbd "C-c f t") 'transpose-frame)
(global-set-key (kbd "C-c f i") 'flip-frame)
(global-set-key (kbd "C-c f o") 'flop-frame)
(global-set-key (kbd "C-M-s-k")
(lambdainteractive ()
(mapc 'kill-buffer (buffer-list))
(manx/scratch-buffer)))
(defmacro manx/split-and-follow (direction)
`(progn
,direction
(balance-windows)
(other-window 1)))
`(progn
,direction
(balance-windows)
(other-window 1)))
(global-set-key (kbd "C-x 3") (lambdainteractive () (manx/split-and-follow (split-window-below))))
(global-set-key (kbd "C-x 2") (lambdainteractive () (manx/split-and-follow (split-window-horizontally))))
(global-set-key (kbd "C-x 3")
(lambdainteractive () (manx/split-and-follow (split-window-below))))
(global-set-key (kbd "C-x 2")
(lambdainteractive () (manx/split-and-follow (split-window-horizontally))))
(defun unix-line-ends ()
(when (string-match
@ -255,8 +255,10 @@
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setq visible-bell nil
ring-bell-function 'ignore)
(global-unset-key (kbd "C-z")) ;; Fuck unix
(setq-default tab-width 2
@ -272,8 +274,8 @@
(defmacro manx/prettify (lst)
`(add-hook (quote ,(car lst))
(lambda ()
(mapc (lambda (pair) (push pair prettify-symbols-alist))
(quote ,(cdr lst))))))
(dolist (pair (quote ,(cdr lst)))
(push pair prettify-symbols-alist)))))
(manx/prettify
(emacs-lisp-mode-hook

@ -28,6 +28,12 @@ Always ensure packages are installed. Log to ~*Messages*~.
(setq use-package-always-ensure t
use-package-verbose t)
#+END_SRC
** keychain-environment
#+BEGIN_SRC emacs-lisp
(use-package keychain-environment
:bind ("C-c r e" . 'keychain-refresh-environment)
:init (keychain-refresh-environment))
#+END_SRC
** auto-minor-mode
#+BEGIN_SRC emacs-lisp
(use-package auto-minor-mode)
@ -88,28 +94,23 @@ sbcl is in a werid place on Gentoo.
(add-hook 'lisp-mode-hook 'slime-mode)
(slime-setup '(slime-fancy slime-company)))
#+END_SRC
** keychain-environment
#+BEGIN_SRC emacs-lisp
(use-package keychain-environment
:bind ("C-c r e" . 'keychain-refresh-environment)
:init (keychain-refresh-environment))
#+END_SRC
** htmlize
*** htmlize
#+BEGIN_SRC emacs-lisp
(use-package htmlize)
#+END_SRC
** spaceline
#+BEGIN_SRC emacs-lisp
(use-package spaceline
:init
(require 'spaceline-config)
(spaceline-spacemacs-theme)
:config
(spaceline-toggle-buffer-size-off)
;;This isn't set in :custom because it breaks the arrow.
(setq powerline-default-seperator 'arrow)
(add-hook 'after-init-hook 'spaceline-compile))
#+END_SRC
** yasnippet
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
:diminish 'yas-minor-mode
:hook ((html-mode
LaTeX-mode
emacs-lisp-mode
lisp-mode)
. yas-minor-mode)
:init ;; These are computationally expensive, so init.
(use-package yasnippet-snippets)
(yas-reload-all))
#+END_SRC
** dashboard
#+BEGIN_SRC emacs-lisp
(use-package dashboard
@ -125,7 +126,16 @@ sbcl is in a werid place on Gentoo.
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
#+END_SRC
** switch window
** windows and frames
*** transpose-frame
#+BEGIN_SRC emacs-lisp
(use-package transpose-frame
:ensure t
:bind (("C-c f t" . transpose-frame)
("C-c f i" . flip-frame)
("C-c f o" . flop-frame)))
#+END_SRC
*** switch window
#+BEGIN_SRC emacs-lisp
(use-package switch-window
:custom
@ -134,19 +144,31 @@ sbcl is in a werid place on Gentoo.
(switch-window-threshold 2)
:bind ([remap other-window] . switch-window))
#+END_SRC
** yasnippet
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
:diminish 'yas-minor-mode
:hook ((html-mode
LaTeX-mode
emacs-lisp-mode
lisp-mode)
. yas-minor-mode)
:init ;; These are computationally expensive, so init.
(use-package yasnippet-snippets)
(yas-reload-all))
#+END_SRC
*** ido
#+BEGIN_SRC emacs-lisp
(setq ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-everywhere 1)
(use-package ido-vertical-mode
:bind ("C-l" . 'ido-reread-directory)
:custom (ido-vertical-define-keys 'C-n-and-C-p-only)
:config
(ido-vertical-mode 1)
(ido-mode 1))
#+END_SRC
*** spaceline
#+BEGIN_SRC emacs-lisp
(use-package spaceline
:init
(require 'spaceline-config)
(spaceline-spacemacs-theme)
:config
(spaceline-toggle-buffer-size-off)
;;This isn't set in :custom because it breaks the arrow.
(setq powerline-default-seperator 'arrow)
(add-hook 'after-init-hook 'spaceline-compile))
#+END_SRC
** minor modes
*** hungry-delete
#+BEGIN_SRC emacs-lisp
@ -176,30 +198,17 @@ sbcl is in a werid place on Gentoo.
(use-package popup-kill-ring
:bind ("M-y" . popup-kill-ring))
#+END_SRC
** ido
#+BEGIN_SRC emacs-lisp
(setq ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-everywhere 1)
(use-package ido-vertical-mode
:bind ("C-l" . 'ido-reread-directory)
:custom (ido-vertical-define-keys 'C-n-and-C-p-only)
:config
(ido-vertical-mode 1)
(ido-mode 1))
#+END_SRC
* org
** edit/reload config
Also saves config if open.
Also saves config if open. manx/emacs-org is defined in [[./init.el][init.el]]
#+BEGIN_SRC emacs-lisp
(definteractive manx/config-reload ()
(when (get-buffer "config.org")
(with-current-buffer "config.org" (save-buffer)))
(org-babel-load-file (concat user-emacs-directory "config.org")))
(definteractive manx/config-reload ()
(when (get-buffer "config.org")
(with-current-buffer "config.org" (save-buffer)))
(org-babel-load-file manx/emacs-org))
(global-set-key (kbd "C-c x r") 'manx/config-reload)
(global-set-key (kbd "C-c x e") (lambdainteractive () (find-file (concat user-emacs-directory "config.org"))))
(global-set-key (kbd "C-c x r") 'manx/config-reload)
(global-set-key (kbd "C-c x e") (lambdainteractive () (find-file manx/emacs-org)))
#+END_SRC
** misc
#+BEGIN_SRC emacs-lisp
@ -265,37 +274,28 @@ Also saves config if open.
** buffers
#+BEGIN_SRC emacs-lisp
(definteractive manx/scratch-buffer ()
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
(global-set-key (kbd "C-c s b") 'manx/scratch-buffer)
(global-set-key (kbd "C-x k") (lambdainteractive () (kill-buffer (current-buffer))))
(global-set-key (kbd "C-M-s-k") (lambdainteractive ()
(mapc 'kill-buffer (buffer-list))
(manx/scratch-buffer)))
(global-set-key (kbd "C-M-s-k")
(lambdainteractive ()
(mapc 'kill-buffer (buffer-list))
(manx/scratch-buffer)))
#+END_SRC
** frames
*** transpose-frame
#+BEGIN_SRC emacs-lisp
;; This is only used here for now but we should still more it some
;; time
(add-to-list 'load-path "~/.emacs.d/scripts/")
(require 'transpose-frame)
(global-set-key (kbd "C-c f t") 'transpose-frame)
(global-set-key (kbd "C-c f i") 'flip-frame)
(global-set-key (kbd "C-c f o") 'flop-frame)
#+END_SRC
*** split and follow
#+BEGIN_SRC emacs-lisp
(defmacro manx/split-and-follow (direction)
`(progn
,direction
(balance-windows)
(other-window 1)))
(global-set-key (kbd "C-x 3") (lambdainteractive () (manx/split-and-follow (split-window-below))))
(global-set-key (kbd "C-x 2") (lambdainteractive () (manx/split-and-follow (split-window-horizontally))))
(defmacro manx/split-and-follow (direction)
`(progn
,direction
(balance-windows)
(other-window 1)))
(global-set-key (kbd "C-x 3")
(lambdainteractive () (manx/split-and-follow (split-window-below))))
(global-set-key (kbd "C-x 2")
(lambdainteractive () (manx/split-and-follow (split-window-horizontally))))
#+END_SRC
* misc
** unix line endings
@ -346,8 +346,10 @@ parens.
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setq visible-bell nil
ring-bell-function 'ignore)
(global-unset-key (kbd "C-z")) ;; Fuck unix
#+END_SRC
** indentation
@ -366,10 +368,11 @@ tabs > spaces. Except in Lisp.
(global-prettify-symbols-mode t)
(defmacro manx/prettify (lst)
`(add-hook (quote ,(car lst))
(lambda ()
(mapc (lambda (pair) (push pair prettify-symbols-alist))
(quote ,(cdr lst))))))
`(add-hook
(quote ,(car lst))
(lambda ()
(dolist (pair (quote ,(cdr lst)))
(push pair prettify-symbols-alist)))))
(manx/prettify
(emacs-lisp-mode-hook

@ -22,7 +22,7 @@
'(nginx-indent-tabs-mode t)
'(package-selected-packages
(quote
(auto-minor-mode htmlize alchemist elixir-mode nginx-mode yasnippet-snippets which-key use-package switch-window spacemacs-theme spaceline slime-company popup-kill-ring omnisharp keychain-environment ido-vertical-mode hungry-delete diminish dashboard company-auctex beacon avy)))
(transpose-frame auto-minor-mode htmlize alchemist elixir-mode nginx-mode yasnippet-snippets which-key use-package switch-window spacemacs-theme spaceline slime-company popup-kill-ring omnisharp keychain-environment ido-vertical-mode hungry-delete diminish dashboard company-auctex beacon avy)))
'(slime-lisp-implementations
(quote
((sbcl

@ -1,268 +0,0 @@
;;; transpose-frame.el --- Transpose windows arrangement in a frame
;; Copyright (c) 2011 S. Irie
;; Author: S. Irie
;; Maintainer: S. Irie
;; Keywords: window
(defconst transpose-frame-version "0.1.0")
;; This program is free software.
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;; 1. Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;; 2. Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; Commentary:
;; This program provides some interactive functions which allows users
;; to transpose windows arrangement in currently selected frame:
;;
;; `transpose-frame' ... Swap x-direction and y-direction
;;
;; +------------+------------+ +----------------+--------+
;; | | B | | A | |
;; | A +------------+ | | |
;; | | C | => +--------+-------+ D |
;; +------------+------------+ | B | C | |
;; | D | | | | |
;; +-------------------------+ +--------+-------+--------+
;;
;; `flip-frame' ... Flip vertically
;;
;; +------------+------------+ +------------+------------+
;; | | B | | D |
;; | A +------------+ +------------+------------+
;; | | C | => | | C |
;; +------------+------------+ | A +------------+
;; | D | | | B |
;; +-------------------------+ +------------+------------+
;;
;; `flop-frame' ... Flop horizontally
;;
;; +------------+------------+ +------------+------------+
;; | | B | | B | |
;; | A +------------+ +------------+ A |
;; | | C | => | C | |
;; +------------+------------+ +------------+------------+
;; | D | | D |
;; +-------------------------+ +-------------------------+
;;
;; `rotate-frame' ... Rotate 180 degrees
;;
;; +------------+------------+ +-------------------------+
;; | | B | | D |
;; | A +------------+ +------------+------------+
;; | | C | => | C | |
;; +------------+------------+ +------------+ A |
;; | D | | B | |
;; +-------------------------+ +------------+------------+
;;
;; `rotate-frame-clockwise' ... Rotate 90 degrees clockwise
;;
;; +------------+------------+ +-------+-----------------+
;; | | B | | | A |
;; | A +------------+ | | |
;; | | C | => | D +--------+--------+
;; +------------+------------+ | | B | C |
;; | D | | | | |
;; +-------------------------+ +-------+--------+--------+
;;
;; `rotate-frame-anticlockwise' ... Rotate 90 degrees anti-clockwise
;;
;; +------------+------------+ +--------+--------+-------+
;; | | B | | B | C | |
;; | A +------------+ | | | |
;; | | C | => +--------+--------+ D |
;; +------------+------------+ | A | |
;; | D | | | |
;; +-------------------------+ +-----------------+-------+
;;
;; This program is tested on GNU Emacs 22, 23.
;;
;; Installation:
;;
;; First, save this file as transpose-frame.el and byte-compile in a directory
;; that is listed in load-path.
;;
;; Put the following in your .emacs file:
;;
;; (require 'transpose-frame)
;;
;; To swap x-direction and y-direction of windows arrangement, for example,
;; just type as:
;;
;; M-x transpose-frame
;;
;; Have fun!
;;
;;; ChangeLog:
;; 2011-03-01 S. Irie
;; * Version 0.1.0
;; * Save more information such as hscroll, margins, fringes, etc.
;; * Bug fix
;; 2011-02-28 S. Irie
;; * Version 0.0.1
;; * Initial version
;;; ToDo:
;;; Code:
;; Internal functions
(defun transpose-frame-get-arrangement (&optional frame subtree)
(let ((tree (or subtree
(car (window-tree frame)))))
(if (windowp tree)
(list (window-buffer tree)
(window-start tree)
(window-point tree)
(window-hscroll tree)
(window-margins tree)
(window-fringes tree)
(window-dedicated-p tree)
(window-redisplay-end-trigger tree)
tree
(eq tree (frame-selected-window frame)))
(let* ((vertical (car tree))
(edges (cadr tree))
(length (float (if vertical
(- (nth 3 edges) (cadr edges))
(- (nth 2 edges) (car edges))))))
(cons vertical
(mapcar (lambda (subtree)
(cons (transpose-frame-get-arrangement frame subtree)
(/ (let ((edges (if (windowp subtree)
(window-edges subtree)
(cadr subtree))))
(if vertical
(- (nth 3 edges) (cadr edges))
(- (nth 2 edges) (car edges))))
length)))
(cddr tree)))))))
(defun transpose-frame-set-arrangement (config &optional window-or-frame &rest how)
(let ((window (if (windowp window-or-frame)
window-or-frame
(frame-selected-window window-or-frame))))
(unless (windowp window-or-frame)
(delete-other-windows window))
(if (bufferp (car config))
(let ((buffer (pop config)))
(set-window-buffer window buffer)
(set-window-start window (pop config))
(set-window-point window (pop config))
(set-window-hscroll window (pop config))
(set-window-margins window (caar config) (cdr (pop config)))
(apply 'set-window-fringes window (pop config))
(set-window-dedicated-p window (pop config))
(set-window-redisplay-end-trigger window (pop config))
(let ((orig-window (pop config))
(ol-func (lambda (ol)
(if (eq (overlay-get ol 'window) orig-window)
(overlay-put ol 'window window))))
(ol-lists (with-current-buffer buffer
(overlay-lists))))
(mapc ol-func (car ol-lists))
(mapc ol-func (cdr ol-lists)))
(if (car config) (select-window window)))
(let* ((horizontal (if (memq 'transpose how)
(pop config)
(not (pop config))))
(edges (window-edges window))
(length (if horizontal
(- (nth 2 edges) (car edges))
(- (nth 3 edges) (cadr edges)))))
(if (memq (if horizontal 'flop 'flip) how)
(setq config (reverse config)))
(while (cdr config)
(setq window (prog1
(split-window window (round (* length (cdar config)))
horizontal)
(apply 'transpose-frame-set-arrangement
(caar config) window how))
config (cdr config)))
(apply 'transpose-frame-set-arrangement
(caar config) window how)))))
;; User commands
;;;###autoload
(defun transpose-frame (&optional frame)
"Transpose windows arrangement at FRAME.
Omitting FRAME means currently selected frame."
(interactive)
(transpose-frame-set-arrangement (transpose-frame-get-arrangement frame) frame
'transpose)
(if (interactive-p) (recenter)))
;;;###autoload
(defun flip-frame (&optional frame)
"Flip windows arrangement vertically at FRAME.
Omitting FRAME means currently selected frame."
(interactive)
(transpose-frame-set-arrangement (transpose-frame-get-arrangement frame) frame
'flip))
;;;###autoload
(defun flop-frame (&optional frame)
"Flop windows arrangement horizontally at FRAME.
Omitting FRAME means currently selected frame."
(interactive)
(transpose-frame-set-arrangement (transpose-frame-get-arrangement frame) frame
'flop))
;;;###autoload
(defun rotate-frame (&optional frame)
"Rotate windows arrangement 180 degrees at FRAME.
Omitting FRAME means currently selected frame."
(interactive)
(transpose-frame-set-arrangement (transpose-frame-get-arrangement frame) frame
'flip 'flop))
;;;###autoload
(defun rotate-frame-clockwise (&optional frame)
"Rotate windows arrangement 90 degrees clockwise at FRAME.
Omitting FRAME means currently selected frame."
(interactive)
(transpose-frame-set-arrangement (transpose-frame-get-arrangement frame) frame
'transpose 'flop)
(if (interactive-p) (recenter)))
;;;###autoload
(defun rotate-frame-anticlockwise (&optional frame)
"Rotate windows arrangement 90 degrees anti-clockwise at FRAME.
Omitting FRAME means currently selected frame."
(interactive)
(transpose-frame-set-arrangement (transpose-frame-get-arrangement frame) frame
'transpose 'flip)
(if (interactive-p) (recenter)))
(provide 'transpose-frame)
;;;
;;; transpose-frame.el ends here
Loading…
Cancel
Save