Created
April 7, 2016 13:07
-
-
Save tek-nishi/10637d669309cd152a9a54231c039178 to your computer and use it in GitHub Desktop.
bs-showで「モード名、拡張子、ファイル名(拡張子除く)」要素でソートする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-buffer-mode (buffer-or-string) | |
"Returns the major mode associated with a buffer. | |
to see http://stackoverflow.com/questions/2238418/emacs-lisp-how-to-get-buffer-major-mode" | |
(with-current-buffer buffer-or-string | |
major-mode)) | |
(defun my-dired-directory (buffer-or-string) | |
"Dired-modeのpathを取得" | |
(with-current-buffer buffer-or-string | |
dired-directory)) | |
(defun my-buffer-name (b) | |
"拡張子、拡張子を除いたパス、モード名からソート用の文字列を生成" | |
(if (buffer-file-name b) | |
(let ((path (buffer-file-name b))) | |
(concat | |
" " (symbol-name (my-buffer-mode b)) | |
" " (file-name-extension path) | |
" " (file-name-sans-extension path) | |
)) | |
(concat (symbol-name (my-buffer-mode b)) | |
" " (buffer-name b) | |
) | |
)) | |
(defun my-bs-sort-by-filename2 (b1 b2) | |
"Compare buffers B1 and B2 by file name and mode-name." | |
(string< (upcase (my-buffer-name b1)) | |
(upcase (my-buffer-name b2)) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bs-sort-functionsにmy-bs-sort-by-filename2を適時追加すれば、使えるようになる。