+(defun elpher-bookmarks-current-p ()
+ "Return true if current node is a bookmarks page."
+ (eq (elpher-address-type (elpher-node-address elpher-current-node)) 'bookmarks))
+
+(defun elpher-reload-bookmarks ()
+ "Reload bookmarks if current node is a bookmarks page."
+ (if (elpher-bookmarks-current-p)
+ (elpher-reload-current-node)))
+
+(defun elpher-bookmark-current ()
+ "Bookmark the current node."
+ (interactive)
+ (if (not (elpher-bookmarks-current-p))
+ (elpher-add-node-bookmark elpher-current-node)))
+
+(defun elpher-bookmark-link ()
+ "Bookmark the link at point."
+ (interactive)
+ (let ((button (button-at (point))))
+ (if button
+ (progn
+ (elpher-add-node-bookmark (button-get button 'elpher-node))
+ (elpher-reload-bookmarks))
+ (error "No link selected"))))
+
+(defun elpher-unbookmark-current ()
+ "Remove bookmark for the current node."
+ (interactive)
+ (if (not (elpher-bookmarks-current-p))
+ (elpher-remove-node-bookmark elpher-current-node)))
+
+(defun elpher-unbookmark-link ()
+ "Remove bookmark for the link at point."
+ (interactive)
+ (let ((button (button-at (point))))
+ (if button
+ (progn
+ (elpher-remove-node-bookmark (button-get button 'elpher-node))
+ (elpher-reload-bookmarks))
+ (error "No link selected"))))
+
+(defun elpher-bookmarks ()
+ "Visit bookmarks."
+ (interactive)
+ (elpher-visit-node
+ (elpher-make-node "Bookmarks"
+ elpher-current-node
+ (elpher-make-address 'bookmarks))))
+