aboutsummaryrefslogtreecommitdiffstats
path: root/elisp
diff options
context:
space:
mode:
Diffstat (limited to 'elisp')
-rw-r--r--elisp/journalctl.el37
1 files changed, 27 insertions, 10 deletions
diff --git a/elisp/journalctl.el b/elisp/journalctl.el
index 81d7e61..03f5007 100644
--- a/elisp/journalctl.el
+++ b/elisp/journalctl.el
@@ -8,7 +8,7 @@
;; Modified: September 07, 2022
;; Version: 0.0.1
;; Homepage: https://git.oscarnajera.com/dotfiles/tree/elisp/journalctl.el
-;; Package-Requires: ((emacs "27.1"))
+;; Package-Requires: ((emacs "28.1"))
;;
;; This file is not part of GNU Emacs.
;;
@@ -19,6 +19,7 @@
;;; Code:
(require 'org)
(require 'cl-extra)
+(require 'transient)
(defvar-local journalctl-current-host nil
"Keeps the optetes of the last call to journalctl.")
@@ -103,9 +104,9 @@
(4 'font-lock-comment-face))))
(defcustom journalctl-hosts
- '("/ssh:alina|sudo::"
- "/ssh:nina|sudo::"
- "/sudo::")
+ '("/sudo::"
+ "/ssh:ingrid|sudo::"
+ "/ssh:nina|sudo::")
"Valid hosts to connect for journal data."
:type (list 'string)
:group 'file)
@@ -125,6 +126,18 @@
"--priority")
"List of possible options to be given to journalctl." )
+(transient-define-prefix journalct-opts ()
+ "prefix for opts"
+ ["infixes"
+ ("f" "follow" "--follow")
+ ("h" "host" "--host=" :choices journalctl-hosts :prompt "hus: ")
+ ("u" "unit" "--unit="
+ :prompt "a unit: "
+ :reader journalctl-read-system-units
+ ;; :always-read t
+ )])
+;; (journalct-opts)
+
(defun journalctl--clean-buffer ()
"Produce a clean buffer for the log.
It seems I must kill the buffer for tramp to behave correctly on the new calls."
@@ -134,17 +147,21 @@ It seems I must kill the buffer for tramp to behave correctly on the new calls."
(kill-buffer buffer))
(get-buffer-create name-buffer)))
-(defun journalctl-system-units (host-location)
+(defun journalctl--system-units (host-location)
"Query HOST-LOCATION (a tramp path) for its systemd units."
- (interactive (list (completing-read "Tramp host: " journalctl-hosts)))
(let ((default-directory host-location))
(with-temp-buffer
(start-file-process "units" (current-buffer) "systemctl" "list-units" "--all" "--quiet" "--full")
(sit-for 0.1)
(thread-last (split-string (buffer-string) "\n")
(mapcar (lambda (line) (car (split-string line)) ))
- (delq nil)
- (completing-read "Unit: ")))))
+ (delq nil)))))
+
+(defun journalctl-read-system-units (_prompt host-location history)
+ "Query HOST-LOCATION (a tramp path) for its systemd units."
+ (completing-read "Unit: "
+ (journalctl--system-units host-location)
+ nil nil nil history))
(defun journalctl-remove-opt (opt)
"Remove an OPT flag from the journal query."
@@ -164,7 +181,7 @@ If OPT is set, remove this option."
(pcase opt
((or "--since" "--until") (org-read-date t))
((or "--follow" "--reverse" "--user" "--pager-end" "--catalog"))
- ("--unit" (journalctl-system-units host))
+ ("--unit" (journalctl-read-system-units nil host nil))
(_ (read-string (concat opt "= "))))
(list opt)
(list)
@@ -206,7 +223,7 @@ If OPT is set, remove this option."
(interactive
(let ((picked-host (completing-read "Tramp host: " journalctl-hosts)))
(list picked-host
- `(("--unit" ,(journalctl-system-units picked-host)) ("--follow")))))
+ `(("--unit" ,(journalctl-read-system-units nil picked-host nil)) ("--follow")))))
(let ((buffer (journalctl--clean-buffer))
(default-directory host))
(apply #'start-file-process "Journal" buffer "journalctl" (flatten-tree options))