Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
✨ Add optional protection of toggle the read state of a pin
  • Loading branch information
davep committed Jun 4, 2019
1 parent 3c8b99e commit 22d95fb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pinboard.el
Expand Up @@ -63,6 +63,11 @@
:type 'function
:group 'pinboard)

(defcustom pinboard-confirm-toggle-read t
"Should we confirm toggling the read state of a pin?"
:type 'boolean
:group 'pinboard)

(defface pinboard-caption-face
'((t :inherit (bold font-lock-function-name-face)))
"Face used on captions in the Pinboard output windows."
Expand Down Expand Up @@ -588,9 +593,13 @@ evaluated, otherwise BODY is evaluated."
(pinboard-auth)
(pinboard-not-too-soon :pinboard-save
(pinboard-with-current-pin pin
(let ((current (alist-get 'toread pin)))
(setf (alist-get 'toread pin) (if (string= current "yes") "no" "yes"))
(pinboard-save-pin pin)))))
(let ((current (string= (alist-get 'toread pin) "yes")))
(when (or (not pinboard-confirm-toggle-read)
(y-or-n-p (format "Mark \"%s\" as %sread? "
(alist-get 'href pin)
(if current "" "un"))))
(setf (alist-get 'toread pin) (if current "no" "yes"))
(pinboard-save-pin pin))))))

(defvar pinboard-mode-map
(let ((map (make-sparse-keymap)))
Expand Down

0 comments on commit 22d95fb

Please sign in to comment.