unifiedlist.el 1.1 KB

12345678910111213141516171819202122232425262728
  1. ;;; ../../lyfi/configs/apps/doom/custom/unifiedlist.el -*- lexical-binding: t; -*-
  2. (defun my/get-unified-list ()
  3. "Combine buffers and recentf into a list for tabulated-list-mode."
  4. (let ((items '()))
  5. ;; Add Live Buffers
  6. (dolist (buf (buffer-list))
  7. (with-current-buffer buf
  8. (push (list buf (vector (buffer-name) "Live" (format-mode-line mode-name) (or (buffer-file-name) ""))) items)))
  9. ;; Add Recent Files (if not already open)
  10. (dolist (file recentf-list)
  11. (unless (get-file-buffer file)
  12. (push (list file (vector (file-name-nondirectory file) "Recent" "File" file)) items)))
  13. (nreverse items)))
  14. (define-derived-mode my-unified-list-mode tabulated-list-mode "Unified-List"
  15. (setq tabulated-list-format [("Name" 30 t)
  16. ("Status" 10 t)
  17. ("Mode" 15 t)
  18. ("Path" 0 t)])
  19. (setq tabulated-list-entries #'my/get-unified-list)
  20. (tabulated-list-init-header))
  21. (defun my/open-unified-list ()
  22. (interactive)
  23. (pop-to-buffer "*Unified Switcher*")
  24. (my-unified-list-mode)
  25. (tabulated-list-print))