Skip to content

Instantly share code, notes, and snippets.

@jidaikobo-shibata
Last active April 14, 2018 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jidaikobo-shibata/54dab2fc5f2e278833f5 to your computer and use it in GitHub Desktop.
Save jidaikobo-shibata/54dab2fc5f2e278833f5 to your computer and use it in GitHub Desktop.
Emacs(Elisp): move current tab (buffer) to top at tabbar-mode. tabbarで選択中のタブ(バッファ)を左端に移動します。
;; move-current-tab-to-top
;; gist-description: Emacs(Elisp): move current tab (buffer) to top at tabbar-mode. tabbarで選択中のタブ(バッファ)を左端に移動します。
;; gist-id: 54dab2fc5f2e278833f5
;; gist-name: move-current-tab-to-top.el
;; gist-private: nil
(defun move-current-tab-to-top ()
"Move current tab to top."
(interactive)
(let* ((bufset (tabbar-current-tabset t))
(bufs (tabbar-tabs bufset))
(car-bufs (list))
(cdr-bufs (list)))
;; 現在のバッファと一致するものを探して先頭へ
(dolist (buf bufs)
(if (string= (buffer-name) (format "%s" (car buf)))
(add-to-list 'car-bufs buf)
(add-to-list 'cdr-bufs buf)))
(setq cdr-bufs (reverse cdr-bufs))
(set bufset (append car-bufs cdr-bufs))
;; タブバー書き換え
(tabbar-set-template bufset nil)
(tabbar-display-update)))
@leisti
Copy link

leisti commented Apr 14, 2018

Very nice. Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment