ibufferネタ
なんとなく。
拡張子でソート
以下の優先順位でソートする
- 拡張子
- ファイル名
- バッファ名
(define-ibuffer-sorter ext "Sort the buffers by file name extension. Ordering is lexicographic." (:description "ext") (let* ((a (car a)) (b (car b)) (fa (buffer-file-name a)) (fb (buffer-file-name b)) (ea (and fa (file-name-extension fa))) (eb (and fb (file-name-extension fb))) (na (buffer-name a)) (nb (buffer-name b)) (list (list (cons ea eb) (cons fa fb) (cons na nb))) (cmp 0)) (while (and list (= cmp 0)) (let ((a (caar list)) (b (cdar list))) (setq cmp (cond ((and a b) (cond ((string= (downcase a) (downcase b)) 0) ((string-lessp (downcase a) (downcase b)) -1) (t 1))) (a -1) (b 1) (t 0)) list (cdr list)))) (< cmp 0)))
ソート方法、フィルタを completion を使って選ぶ
キーバインドを覚えられない人向け。html-helperとかもそうだけど、俺には覚えるの無理。
"s RET"でソート、"/ RET"でフィルタを選ぶ。
(defun ibuffer-select-sorting-mode () "Select sorting mode with completion." (interactive) (setq ibuffer-sorting-mode (intern (completing-read "mode: " (cons (list 'recency) ibuffer-sorting-functions-alist) nil t))) (message "Sorting by %s" ibuffer-sorting-mode) (ibuffer-redisplay t)) (defun ibuffer-select-filter () "Select filter with completion." (interactive) (let ((filter (completing-read "filter: " ibuffer-filtering-alist nil t))) (message "Filtering by %s" filter) (call-interactively (intern (concat "ibuffer-filter-by-" filter))))) (define-key ibuffer-mode-map (kbd "s RET") 'ibuffer-select-sorting-mode) (define-key ibuffer-mode-map (kbd "/ RET") 'ibuffer-select-filter)