Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
Forked from fujimisakari/file0.txt
Last active December 12, 2016 09:23
Show Gist options
  • Save tsu-nera/44763febe82874785bf7 to your computer and use it in GitHub Desktop.
Save tsu-nera/44763febe82874785bf7 to your computer and use it in GitHub Desktop.
;; forked from https://gist.github.com/fujimisakari/11518720
;; special thanks @fujimisakari
;; ref: http://qiita.com/fujimisakari/items/d7f1b904de11dcb018c3
(defun elscreen-swap-previous()
"Interchange screens selected currently and previous."
(interactive)
(cond
((elscreen-one-screen-p)
(elscreen-message "There is only one screen, cannot swap"))
(t
(let* ((screen-list (sort (elscreen-get-screen-list) '>))
(previous-screen
(or (nth 1 (memq (elscreen-get-current-screen) screen-list))
(car screen-list)))
(current-screen (elscreen-get-current-screen))
(current-screen-property
(elscreen-get-screen-property current-screen))
(previous-screen-property
(elscreen-get-screen-property previous-screen)))
(elscreen-set-screen-property current-screen previous-screen-property)
(elscreen-set-screen-property previous-screen current-screen-property)
(elscreen-goto-internal (elscreen-get-current-screen)))))
(elscreen-previous))
(defun elscreen-swap-next()
"Interchange screens selected currently and next."
(interactive)
(cond
((elscreen-one-screen-p)
(elscreen-message "There is only one screen, cannot swap"))
(t
(let* ((screen-list (sort (elscreen-get-screen-list) '<))
(next-screen
(or (nth 1 (memq (elscreen-get-current-screen) screen-list))
(car screen-list)))
(current-screen (elscreen-get-current-screen))
(current-screen-property
(elscreen-get-screen-property current-screen))
(next-screen-property
(elscreen-get-screen-property next-screen)))
(elscreen-set-screen-property current-screen next-screen-property)
(elscreen-set-screen-property next-screen current-screen-property)
(elscreen-goto-internal (elscreen-get-current-screen)))))
(elscreen-next))
(provide 'elscreen-interchange)
;; 直近バッファ選定時の無視リスト
(defvar elscreen-ignore-buffer-list
'("*scratch*" "*Backtrace*" "*Colors*" "*Faces*" "*Compile-Log*" "*Packages*" "*vc-" "*Minibuf-" "*Messages" "*WL:Message"))
;; elscreen用バッファ削除
(defun kill-buffer-for-elscreen ()
(interactive)
(kill-buffer)
(let* ((next-buffer nil)
(re (regexp-opt elscreen-ignore-buffer-list))
(next-buffer-list (mapcar (lambda (buf)
(let ((name (buffer-name buf)))
(when (not (string-match re name))
name)))
(buffer-list))))
(dolist (buf next-buffer-list)
(if (equal next-buffer nil)
(setq next-buffer buf)))
(switch-to-buffer next-buffer)))
(global-set-key (kbd "M-k") 'kill-buffer-for-elscreen) ; カレントバッファを閉じる
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment