This commit is contained in:
Your Name
2026-05-10 01:05:57 +02:00
commit f3cb5a6e26
19 changed files with 2741 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
;;; ../../lyfi/configs/apps/doom/custom/avy-region.el -*- lexical-binding: t; -*-
(defun my/avy-region (jump-fn &optional inclusive)
"Select region between two points chosen with JUMP-FN.
JUMP-FN is a command like `avy-goto-char-timer' or `avy-goto-line'.
When INCLUSIVE is non-nil, include the character at the end point."
(interactive)
(let (p1 p2)
(cl-labels ((do-jump () (call-interactively jump-fn) (point)))
(setq p1 (do-jump))
(setq p2 (do-jump)))
(when (and p1 p2)
(let ((beg (min p1 p2))
(end (max p1 p2)))
(push-mark beg nil t)
(goto-char end)
(when inclusive
(unless (eobp) (forward-char 1)))))))
(defun my/avy-char-region ()
"mark region between 2 chars using avy-char"
(interactive)
(my/avy-region 'avy-goto-char-timer t))
(defun my/avy-line-region ()
"mark region between 2 lines using avy-line"
(interactive)
(my/avy-region 'avy-goto-line)
(forward-line 1))
+199
View File
@@ -0,0 +1,199 @@
;;; buffer-table.el --- Tabular view of buffers and recent files -*- lexical-binding: t; -*-
(require 'cl-lib)
(require 'recentf)
(defgroup buffer-table nil
"Tabular view of buffers and recent files."
:group 'convenience)
;; Faces for distinction
(defface buffer-table-open '((t :inherit font-lock-keyword-face :bold t)) "Face for open files.")
(defface buffer-table-recent '((t :inherit shadow)) "Face for recent closed files.")
(defface buffer-table-special '((t :inherit font-lock-comment-face)) "Face for internal buffers.")
(defface buffer-table-modified '((t :inherit error :bold t)) "Face for modified flag.")
(defface buffer-table-marked '((t :inherit warning :bold t)) "Face for marked entries.")
;; Mark tracking - set of entry IDs currently marked
(defvar buffer-table--marked nil
"Set of marked entry IDs (buffer objects or file paths).")
(defun buffer-table--get-entries ()
"Collect all items and format them for tabulated-list-entries."
(let ((file-entries nil)
(recent-entries nil)
(special-entries nil)
(processed-files (make-hash-table :test 'equal)))
;; 1. Open File-visiting Buffers
(dolist (buf (buffer-list))
(let ((file (buffer-file-name buf)))
(when (and file (not (string-prefix-p " " (buffer-name buf))))
(puthash file t processed-files)
(push (list buf
(vector
(if (buffer-modified-p buf) (propertize "*" 'face 'buffer-table-modified) " ")
(propertize "File" 'face 'buffer-table-open)
(propertize (buffer-name buf) 'face 'buffer-table-open)
(abbreviate-file-name (file-name-directory file))
(if (gethash buf buffer-table--marked)
(propertize "" 'face 'buffer-table-marked)
"")))
file-entries))))
;; 2. Recent Files (Closed)
(recentf-mode 1)
(dolist (file recentf-list)
(unless (gethash file processed-files)
(push (list file
(vector
" "
(propertize "Recent" 'face 'buffer-table-recent)
(propertize (file-name-nondirectory file) 'face 'buffer-table-recent)
(abbreviate-file-name (file-name-directory file))
(if (gethash file buffer-table--marked)
(propertize "" 'face 'buffer-table-marked)
"")))
recent-entries)))
;; 3. Special Buffers
(dolist (buf (buffer-list))
(unless (or (buffer-file-name buf) (string-prefix-p " " (buffer-name buf)))
(push (list buf
(vector
(if (buffer-modified-p buf) (propertize "*" 'face 'buffer-table-modified) " ")
(propertize "Special" 'face 'buffer-table-special)
(propertize (buffer-name buf) 'face 'buffer-table-special)
""
(if (gethash buf buffer-table--marked)
(propertize "" 'face 'buffer-table-marked)
"")))
special-entries)))
;; Return in requested order: Special, then File, then Recent
(append (nreverse special-entries)
(nreverse file-entries)
(nreverse recent-entries))))
(defun buffer-table--refresh ()
"Refresh the list."
(setq tabulated-list-entries (buffer-table--get-entries))
(tabulated-list-print t))
(defun buffer-table-mark ()
"Mark the entry at point."
(interactive)
(let ((id (tabulated-list-get-id)))
(when id
(puthash id t buffer-table--marked)
(buffer-table--refresh))))
(defun buffer-table-unmark ()
"Unmark the entry at point."
(interactive)
(let ((id (tabulated-list-get-id)))
(when id
(remhash id buffer-table--marked)
(buffer-table--refresh))))
(defun buffer-table-mark-all ()
"Mark all entries."
(interactive)
(dolist (entry tabulated-list-entries)
(puthash (car entry) t buffer-table--marked))
(buffer-table--refresh))
(defun buffer-table-unmark-all ()
"Unmark all entries."
(interactive)
(setq buffer-table--marked (make-hash-table))
(buffer-table--refresh))
(defun buffer-table-kill-marked ()
"Kill all marked buffers. For recent files, remove from recentf list."
(interactive)
(unless (hash-table-p buffer-table--marked)
(user-error "No entries marked"))
(when (or (null (buffer-table--marked-count))
(zerop (buffer-table--marked-count)))
(user-error "No entries marked"))
(let ((buffers-to-kill nil)
(recent-to-remove nil))
(maphash (lambda (id _)
(if (bufferp id)
(push id buffers-to-kill)
(push id recent-to-remove)))
buffer-table--marked)
;; Kill buffers
(when buffers-to-kill
(let ((count (length buffers-to-kill)))
(dolist (buf buffers-to-kill)
(when (buffer-live-p buf)
(kill-buffer buf)))
(message "Killed %d buffer%s" count (if (> count 1) "s" ""))))
;; Remove from recentf
(when recent-to-remove
(let ((count (length recent-to-remove)))
(dolist (file recent-to-remove)
(setq recentf-list (delq file recentf-list)))
(recentf-save-list)
(message "Removed %d file%s from recentf" count (if (> count 1) "s" ""))))
(setq buffer-table--marked (make-hash-table))
(buffer-table--refresh)))
(defun buffer-table--marked-count ()
"Return the number of marked entries."
(hash-table-count buffer-table--marked))
(defun buffer-table-visit ()
"Visit the buffer or file at point."
(interactive)
(let ((id (tabulated-list-get-id)))
(cond
((bufferp id) (switch-to-buffer id))
((stringp id) (find-file id))
(t (user-error "Nothing to visit here")))))
(defun buffer-table-revert ()
"Revert the table, clearing marks."
(interactive)
(setq buffer-table--marked (make-hash-table))
(buffer-table--refresh))
(define-derived-mode buffer-table-mode tabulated-list-mode "Buffer-Table"
"Major mode for a unified buffer and file list."
(setq buffer-table--marked (make-hash-table))
(setq tabulated-list-format
[("S" 1 t) ; Status (Modified)
("Type" 8 t) ; File, Recent, or Special
("Name" 35 t) ; File/Buffer name
("Path" 0 t) ; Directory path (flexible width)
("M" 3 t)]) ; Mark column
(setq tabulated-list-padding 2)
(setq tabulated-list-sort-key '("Type" . nil))
(add-hook 'tabulated-list-revert-hook #'buffer-table--refresh nil t)
(tabulated-list-init-header))
(define-key buffer-table-mode-map (kbd "RET") #'buffer-table-visit)
(define-key buffer-table-mode-map (kbd "g") #'buffer-table-revert)
(define-key buffer-table-mode-map (kbd "m") #'buffer-table-mark)
(define-key buffer-table-mode-map (kbd "M") #'buffer-table-mark-all)
(define-key buffer-table-mode-map (kbd "u") #'buffer-table-unmark-all)
(define-key buffer-table-mode-map (kbd "U") #'buffer-table-unmark)
(define-key buffer-table-mode-map (kbd "D") #'buffer-table-kill-marked)
;;;###autoload
(defun buffer-table ()
"Display the unified buffer and file table."
(interactive)
(let ((buf (get-buffer-create "*Buffer Table*")))
(with-current-buffer buf
(buffer-table-mode)
(buffer-table--refresh))
(switch-to-buffer buf)))
(provide 'buffer-table)
+129
View File
@@ -0,0 +1,129 @@
;;; ../../lyfi/configs/apps/doom/custom/meow.el -*- lexical-binding: t; -*-
;;Custom Meow Cheatsheet Renderer
(defvar my-meow-board-grid
'(("1" "2" "3" "4" "5" "6" "7" "8" "9" "0")
("q" "w" "e" "r" "t" "y" "u" "i" "o" "p")
("a" "s" "d" "f" "g" "h" "j" "k" "l" ";")
("z" "x" "c" "v" "b" "n" "m" "," "." "/" "'"))
"The physical layout of the board as a 2D array.")
(defun my-meow-get-cmd-name (key)
"Helper to get the short name of a command for a given key, or a placeholder."
(let ((cmd (key-binding key)))
(if cmd
(meow--short-command-name cmd)
(if (member key '("TAB" "SFT" "CTL" "CAPS" "GUI" "ALT" "MO1" "SPC" "ENT" "BKSL" "LMB" "RMB" "UP" "DN" "N2"))
key
"<not bound>"))))
(defun my-meow-render-grid ()
"Generates a clean table of Meow commands with base and shift layers."
(let ((output ""))
(dolist (row my-meow-board-grid)
(let ((row-lower "")
(row-upper ""))
(dolist (key row)
(let* ((low-name (my-meow-get-cmd-name key))
(up-key (upcase key))
(up-name (my-meow-get-cmd-name up-key)))
;; Build the lower layer string
(setq row-lower (concat row-lower
(format "[%s = %-12s] " key low-name)))
;; Build the upper layer string
(setq row-upper (concat row-upper
(format "[%s = %-12s] " up-key up-name)))))
;; Append both layers, then a newline for a gap between physical rows
(setq output (concat output row-lower "\n" row-upper "\n\n"))))
output))
(defun my-meow-cheatsheet ()
"Custom cheatsheet that uses a grid instead of fragile ASCII art."
(interactive)
(let ((buf (get-buffer-create "*Meow Cheatsheet*")))
(with-current-buffer buf
(text-mode)
(setq buffer-read-only nil)
(erase-buffer)
(insert "Meow Custom Layout Cheatsheet\n")
(insert "====================================================================================================\n\n")
(insert (my-meow-render-grid))
(insert "\n====================================================================================================\n")
(insert meow--cheatsheet-note)
(insert (meow--render-cheatsheet-thing-table))
(add-face-text-property (point-min) (point-max) 'meow-cheatsheet-command)
(setq buffer-read-only t))
(switch-to-buffer buf)))
(defun meow-setup ()
;; We no longer need the physical-layout strings because we use my-meow-board-grid
(meow-motion-overwrite-define-key
'("j" . meow-next)
'("k" . meow-prev)
'("<escape>" . mode-line-other-buffer))
(meow-leader-define-key
'("/" . meow-keypad-describe-key)
'("?" . my-meow-cheatsheet)) ;; Use our new custom renderer here
(meow-normal-define-key
'("0" . meow-expand-0)
'("9" . meow-expand-9)
'("8" . meow-expand-8)
'("7" . meow-expand-7)
'("6" . meow-expand-6)
'("5" . meow-expand-5)
'("4" . meow-expand-4)
'("3" . meow-expand-3)
'("2" . meow-expand-2)
'("1" . meow-expand-1)
'("-" . negative-argument)
'(";" . meow-reverse)
'("," . meow-inner-of-thing)
'("." . meow-bounds-of-thing)
'("[" . meow-beginning-of-thing)
'("]" . meow-end-of-thing)
'("a" . meow-append)
'("A" . meow-open-below)
'("b" . meow-back-word)
'("B" . meow-back-symbol)
'("c" . meow-change)
'("d" . meow-delete)
'("D" . meow-backward-delete)
'("e" . meow-next-word)
'("E" . meow-next-symbol)
'("f" . meow-find)
'("g" . meow-cancel-selection)
'("G" . meow-grab)
'("h" . meow-left)
'("H" . meow-left-expand)
'("i" . meow-insert)
'("I" . meow-open-above)
'("j" . meow-next)
'("J" . meow-next-expand)
'("k" . meow-prev)
'("K" . meow-prev-expand)
'("l" . meow-right)
'("L" . meow-right-expand)
'("m" . meow-join)
'("n" . meow-search)
'("o" . meow-block)
'("O" . meow-to-block)
'("p" . meow-yank)
'("q" . meow-quit)
'("Q" . meow-goto-line)
'("r" . meow-replace)
'("R" . meow-swap-grab)
'("s" . meow-kill)
'("t" . meow-till)
'("u" . meow-undo)
'("U" . meow-undo-in-selection)
'("v" . meow-visit)
'("w" . meow-mark-word)
'("W" . meow-mark-symbol)
'("x" . meow-line)
'("X" . meow-goto-line)
'("y" . meow-save)
'("Y" . meow-sync-grab)
'("z" . meow-pop-selection)
'("'" . repeat)))
+13
View File
@@ -0,0 +1,13 @@
;;; ../../lyfi/configs/apps/doom/custom/ui.el -*- lexical-binding: t; -*-
(defun my/apply-theme (frame)
"Apply a specific theme based on whether the FRAME is graphic or TUI."
(select-frame frame)
(if (display-graphic-p frame)
(progn
(mapc #'disable-theme custom-enabled-themes)
(load-theme 'cutarv32 t)) ;; Your GUI theme
(progn
(mapc #'disable-theme custom-enabled-themes)
(load-theme 'cutarv32_dark t)))) ;; Your TUI theme
+28
View File
@@ -0,0 +1,28 @@
;;; ../../lyfi/configs/apps/doom/custom/unifiedlist.el -*- lexical-binding: t; -*-
(defun my/get-unified-list ()
"Combine buffers and recentf into a list for tabulated-list-mode."
(let ((items '()))
;; Add Live Buffers
(dolist (buf (buffer-list))
(with-current-buffer buf
(push (list buf (vector (buffer-name) "Live" (format-mode-line mode-name) (or (buffer-file-name) ""))) items)))
;; Add Recent Files (if not already open)
(dolist (file recentf-list)
(unless (get-file-buffer file)
(push (list file (vector (file-name-nondirectory file) "Recent" "File" file)) items)))
(nreverse items)))
(define-derived-mode my-unified-list-mode tabulated-list-mode "Unified-List"
(setq tabulated-list-format [("Name" 30 t)
("Status" 10 t)
("Mode" 15 t)
("Path" 0 t)])
(setq tabulated-list-entries #'my/get-unified-list)
(tabulated-list-init-header))
(defun my/open-unified-list ()
(interactive)
(pop-to-buffer "*Unified Switcher*")
(my-unified-list-mode)
(tabulated-list-print))