diff options
Diffstat (limited to 'tools/emacs-pkgs/notable/notable.el')
-rw-r--r-- | tools/emacs-pkgs/notable/notable.el | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/emacs-pkgs/notable/notable.el b/tools/emacs-pkgs/notable/notable.el index b0cedb3de23d..d6d2dbe34817 100644 --- a/tools/emacs-pkgs/notable/notable.el +++ b/tools/emacs-pkgs/notable/notable.el @@ -98,6 +98,10 @@ (check-type id integer) (f-join notable-note-dir (format "note-%d.json" id))) +(defun notable--archive-path (id) + (check-type id integer) + (f-join notable-note-dir (format "archive-%d.json" id))) + (defun notable--add-note (content) "Add a note with CONTENT to the note store." (let* ((id (notable--next-id)) @@ -108,6 +112,19 @@ (f-write-text (notable--serialize-note note) 'utf-8 path) (message "Saved note %d" id))) +(defun notable--archive-note (id) + "Archive the note with ID." + (check-type id integer) + + (unless (f-exists? (notable--note-path id)) + (error "There is no note with ID %d." id)) + + (when (f-exists? (notable--archive-path id)) + (error "Oh no, a note with ID %d has already been archived!" id)) + + (f-move (notable--note-path id) (notable--archive-path id)) + (message "Archived note with ID %d." id)) + (defun notable--list-note-ids () "List all note IDs (not contents) from `notable-note-dir'" (cl-loop for file in (f-entries notable-note-dir) @@ -161,6 +178,10 @@ (interactive) (notable--show-note (get-text-property (point) 'notable-note-id))) +(defun notable--archive-note-at-point () + (interactive) + (notable--archive-note (get-text-property (point) 'notable-note-id))) + ;; Note list buffer implementation (define-derived-mode notable-list-mode fundamental-mode "notable" @@ -175,6 +196,7 @@ (setq notable-list-mode-map (let ((map (make-sparse-keymap))) + (define-key map "a" 'notable--archive-note-at-point) (define-key map "q" 'kill-current-buffer) (define-key map "g" 'notable-list-notes) (define-key map (kbd "RET") 'notable--show-note-at-point) |