[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/sqlite 0b8489d: Add command to list sticky values
From: |
Lars Ingebrigtsen |
Subject: |
scratch/sqlite 0b8489d: Add command to list sticky values |
Date: |
Tue, 7 Dec 2021 02:22:33 -0500 (EST) |
branch: scratch/sqlite
commit 0b8489db571987b6109f9b3031e4c97d7b212969
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add command to list sticky values
---
lisp/emacs-lisp/sticky.el | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/lisp/emacs-lisp/sticky.el b/lisp/emacs-lisp/sticky.el
index 1d1110b..06744e4 100644
--- a/lisp/emacs-lisp/sticky.el
+++ b/lisp/emacs-lisp/sticky.el
@@ -170,6 +170,43 @@ DOC should be a doc string, and ARGS are keywords as
applicable to
;; (sticky--set-value foo 'zot)
;; (setf (sticky-value foo) 'gazonk)
+(defvar-keymap sticky-edit-mode-map
+ "d" #'sticky-delete-value)
+
+(define-derived-mode sticky-edit-mode special-mode "Sticky"
+ "This mode lists all elements in the \"sticky\" database."
+ :interactive nil
+ (buffer-disable-undo)
+ (setq-local buffer-read-only t))
+
+;;;###autoload
+(defun list-sticky-values ()
+ "List all values in the \"sticky\" database."
+ (interactive)
+ (sticky--ensure-db)
+ (pop-to-buffer (get-buffer-create "*Sticky*"))
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (cl-loop for (package key value) in (sqlite-select
+ sticky--db
+ "select package, key, value from
sticky order by package, key")
+ do (insert (propertize (format "%s %s %s\n"
+ package key value)
+ 'sticky--id (list package key))))
+ (goto-char (point-min)))
+ (sticky-edit-mode))
+
+(defun sticky-delete-value (id)
+ "Delete the value at point."
+ (interactive (list (get-text-property (point) 'sticky--id)) sticky-edit-mode)
+ (unless id
+ (error "No value on the current line"))
+ (sqlite-execute sticky--db "delete from sticky where package = ? and key = ?"
+ id)
+ (let ((inhibit-read-only t))
+ (beginning-of-line)
+ (delete-region (point) (progn (forward-line 1) (point)))))
+
(provide 'sticky)
;;; sticky.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/sqlite 0b8489d: Add command to list sticky values,
Lars Ingebrigtsen <=