diff options
-rw-r--r-- | elogt.el | 56 |
1 files changed, 54 insertions, 2 deletions
@@ -41,8 +41,7 @@ ;; TODO: Clean files older than X. -;; TODO: Show only Priority P or Category C. -;; `elogt-narrow-priority' and `elogt-narrow-category' +;; TODO: Time narrowing NEWER or OLDER, now uses regexp. ;; TODO: Rewrite `elogt--make-log-table-contents'? ;; Maybe Use `dolist' or `do'? @@ -63,6 +62,9 @@ (" \e[32m*\e[0m" . info) (" \e[33;01m*\e[0m" . warn))) +(defconst elogt--priority-levels + `("Error" "Info" "Warn" "None")) + (defconst elogt--priority-level-indicators `((error . ,(propertize "Error" 'font-lock-face '(:foreground "red"))) (info . ,(propertize "Info" 'font-lock-face '(:foreground "green"))) @@ -240,6 +242,52 @@ Return opened buffer (done via `find-file')." (tabulated-list-sort elogt--index-time)) +;; Result narrowing + +(defun elogt--narrow (column-index column-value) + "Narrow the ElogT table to a selected COLUMN-INDEX of COLUMN-VALUE. + +Table record values of the selected column are compared by regex, +using the `string-match', function to the wanted COLUMN-VALUE." + (setq tabulated-list-entries + (seq-filter (lambda (entry) + (string-match column-value + (substring-no-properties + (aref (cadr entry) column-index)))) + tabulated-list-entries)) + (tabulated-list-print t)) + +(defun elogt-narrow-priority (selected) + "Narrow the ElogT table to a SELECTED Priority. + +Uses the `elogt--narrow' function." + (interactive + (list + (completing-read "Priority: " elogt--priority-levels nil 'require-match))) + (elogt--narrow elogt--index-priority selected)) + +(defun elogt-narrow-category (selected) + "Narrow the ElogT table to a SELECTED Category. + +Uses the `elogt--narrow' function." + (interactive "sCategory: ") + (elogt--narrow elogt--index-category selected)) + +(defun elogt-narrow-package (selected) + "Narrow the ElogT table to a SELECTED Package. + +Uses the `elogt--narrow' function." + (interactive "sPackage: ") + (elogt--narrow elogt--index-package selected)) + +(defun elogt-narrow-time (selected) + "Narrow the ElogT table to a SELECTED Time. + +Uses the `elogt--narrow' function." + (interactive "sTime: ") + (elogt--narrow elogt--index-time selected)) + + ;; Major mode (defvar elogt-mode-hook nil @@ -256,6 +304,10 @@ Return opened buffer (done via `find-file')." (define-key elogt-mode-map (kbd "a") #'elogt-sort-category) (define-key elogt-mode-map (kbd "c") #'elogt-sort-priority) (define-key elogt-mode-map (kbd "t") #'elogt-sort-time) + (define-key elogt-mode-map (kbd "n l") #'elogt-narrow-priority) + (define-key elogt-mode-map (kbd "n c") #'elogt-narrow-category) + (define-key elogt-mode-map (kbd "n p") #'elogt-narrow-package) + (define-key elogt-mode-map (kbd "n t") #'elogt-narrow-time) ;; Miscellaneous key bindings. (define-key elogt-mode-map (kbd "/") #'isearch-forward) elogt-mode-map) |