help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EWW func add url under point as bookmark


From: Alex
Subject: Re: EWW func add url under point as bookmark
Date: Fri, 15 Apr 2022 15:40:22 +0200

Yay! I get it!

#+begin_src elisp
;; Copyright 2022 Alex
;; Under GPLv3-or-later License

(defun eww-bookmark-add (url title)
  "Bookmark url with a title."
  (unless (stringp url)
    (user-error "invalid url string required"))
  (unless (stringp title)
    (user-error "invalid title string required"))
  (eww-read-bookmarks)
  (dolist (bookmark eww-bookmarks)
    (when (equal url (plist-get bookmark :url))
      (user-error "Already bookmarked")))
  (push (list :url url
              :title title
              :time (current-time-string))
        eww-bookmarks)
  (eww-write-bookmarks)
  (message "Bookmarked %s (%s)" url title))

(defun eww-bookmark-url-under-point (title)
  "Bookmark url under point"
  (interactive (list (read-string "Bookmark title: ")))
  (let ((str-url (thing-at-point 'url)))
    (eww-bookmark-add str-url title)))

;; test here:
;; cursor on url and M-x eww-bookmark-url-under-point RET
;; http://www.gnuhacker.org

#+end_src

-- 
Alex
Emacs Lover.
FSF Member.
Free/Libre Software supporter.
stallmansupport.org - Disinformation succeeds because so many people
care deeply about injustice but do not take the time to check the facts.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]