* EWW func add url under point as bookmark
@ 2022-04-14 19:25 Alex
2022-04-14 20:08 ` [External] : " Drew Adams
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Alex @ 2022-04-14 19:25 UTC (permalink / raw)
To: Help GNU Emacs
When Im reading mails, or when Im in IRC or browsing pages with EWW,
sometimes I get an interesting url, then I want save it as eww bookmark
to read it in other moment.
I was searching a function that add a bookmark from the url under cursor
(point), but there aren't some like it.
I want write a func for it, so I was searching a func that add a
bookmark from a string.
Ex:
(defun eww-add-bookmark (&optional str)
"Bookmark the current page or string"
...)
But `eww-add-bookmark' dont support arguments
Any help?
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [External] : EWW func add url under point as bookmark
2022-04-14 19:25 EWW func add url under point as bookmark Alex
@ 2022-04-14 20:08 ` Drew Adams
2022-04-14 23:31 ` Michael Heerdegen
2022-04-14 21:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
` (2 subsequent siblings)
3 siblings, 1 reply; 14+ messages in thread
From: Drew Adams @ 2022-04-14 20:08 UTC (permalink / raw)
To: Alex, Help GNU Emacs
> When Im reading mails, or when Im in IRC or browsing pages with EWW,
> sometimes I get an interesting url, then I want save it as eww bookmark
> to read it in other moment.
>
> I was searching a function that add a bookmark from the url under
> cursor (point), but there aren't some like it.
I can't speak for EWW (so-called) "bookmarks".
But if you want a regular, real, good-old Emacs
bookmark to a URL at point then that's available
out of the box with Bookmark+.
`bmkp-url-target-set' prompts for a URL, with
the URL at point as the default.
It works anywhere, including when in EWW or W3M.
___
If you don't want to be prompted for a URL and
thus have to hit RET to accept the URL at point,
you can write a simple wrapper command for
`bmkp-url-target-set' that just uses a URL at
point or does nothing (or raises an error) if
there's no URL at point. You can likewise
choose a bookmark name automatically (e.g. the
URL or page title).
___
https://www.emacswiki.org/emacs/BookmarkPlus#BookmarkingFileOrUrl
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [External] : EWW func add url under point as bookmark
2022-04-14 20:08 ` [External] : " Drew Adams
@ 2022-04-14 23:31 ` Michael Heerdegen
0 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2022-04-14 23:31 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
> But if you want a regular, real, good-old Emacs
> bookmark to a URL at point then that's available
> out of the box with Bookmark+.
>
> `bmkp-url-target-set' prompts for a URL, with
> the URL at point as the default.
>
> It works anywhere, including when in EWW or W3M.
"Good-old Emacs bookmark" support also has been added to eww recently.
You can check: An eww version supports standard bookmarks when
`bookmark-make-record-function' is bound to `eww-bookmark-make-record'
in any eww buffer.
But the url can't be changed when using `bookmark-set' (C-x r m), it's
always the current page's url. Would be easy change that, though.
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-14 19:25 EWW func add url under point as bookmark Alex
2022-04-14 20:08 ` [External] : " Drew Adams
@ 2022-04-14 21:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-15 13:40 ` Alex
[not found] ` <87ee1z8jap.fsf@zoho.eu>
3 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-04-14 21:08 UTC (permalink / raw)
To: help-gnu-emacs
Alex wrote:
> When Im reading mails, or when Im in IRC or browsing pages
> with EWW, sometimes I get an interesting url, then I want
> save it as eww bookmark to read it in other moment.
>
> I was searching a function that add a bookmark from the url
> under cursor (point), but there aren't some like it.
>
> I want write a func for it, so I was searching a func that
> add a bookmark from a string [...]
>
> But `eww-add-bookmark' dont support arguments
Check out these for inspiration and code that you can adapt:
https://dataswamp.org/~incal/emacs-init/w3m/w3m-url.el
https://dataswamp.org/~incal/emacs-init/w3m/w3m-bookmark-more.el
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-14 19:25 EWW func add url under point as bookmark Alex
2022-04-14 20:08 ` [External] : " Drew Adams
2022-04-14 21:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-15 13:40 ` Alex
2022-04-15 14:17 ` Emanuel Berg via Users list for the GNU Emacs text editor
[not found] ` <87ee1z8jap.fsf@zoho.eu>
3 siblings, 1 reply; 14+ messages in thread
From: Alex @ 2022-04-15 13:40 UTC (permalink / raw)
To: Help GNU Emacs
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-15 13:40 ` Alex
@ 2022-04-15 14:17 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-16 14:34 ` Alex
0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-04-15 14:17 UTC (permalink / raw)
To: help-gnu-emacs
Alex wrote:
> (defun eww-bookmark-add (url title)
> "Bookmark url with a title."
"... URL with a TITLE."
> (defun eww-bookmark-url-under-point (title)
> "Bookmark url under point"
"... calling it TITLE"?
> (interactive (list (read-string "Bookmark title: ")))
(interactive "sTitle: ")
> (let ((str-url (thing-at-point 'url)))
> (eww-bookmark-add str-url title)))
Maybe should check if `thing-at-point' found anything ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-15 14:17 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-16 14:34 ` Alex
2022-04-16 18:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-16 19:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 14+ messages in thread
From: Alex @ 2022-04-16 14:34 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg writes:
> Alex wrote:
> (interactive "sTitle: ")
right
>> (let ((str-url (thing-at-point 'url)))
>> (eww-bookmark-add str-url title)))
> Maybe should check if `thing-at-point' found anything ...
Already checked in func `eww-bookmark-add'
(unless (stringp url)
(user-error "invalid url string required"))
new simplified version:
#+begin_src elisp
(defun eww-bookmark-url-under-point (title)
"Bookmark url under point calling it TITLE"
(interactive "sTitle: ")
(eww-bookmark-add (thing-at-point 'url) title))
#+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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-16 14:34 ` Alex
@ 2022-04-16 18:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-18 20:29 ` Alex
2022-04-16 19:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-04-16 18:51 UTC (permalink / raw)
To: help-gnu-emacs
Alex wrote:
> (defun eww-bookmark-url-under-point (title)
> "Bookmark url under point calling it TITLE"
Emacs thinks:
First sentence should end with punctuation
(look who's talking LOL)
>>> (interactive "sTitle: ")
>>> (eww-bookmark-add (thing-at-point 'url) title))
>>
>> Maybe should check if `thing-at-point' found anything ...
>
> Already checked in func `eww-bookmark-add'
OK, good, but then better yet you could remove the
interface/wrapper function and instead make eww-bookmark-add
interactive (as well as non-interactive from Lisp), and for
interactive use it'll read the URL from point.
Ironically then you have to get the title the way you
initially did!
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-16 18:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-18 20:29 ` Alex
2022-04-18 20:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 14+ messages in thread
From: Alex @ 2022-04-18 20:29 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> OK, good, but then better yet you could remove the interface/wrapper
> function and instead make eww-bookmark-add interactive (as well as
> non-interactive from Lisp), and for interactive use it'll read the URL
> from point.
new version:
#+begin_src elisp
;; Copyright 2022 Alex
;; under GPLv3-or-later License
(defun eww-bookmark-add (url title)
"Bookmark `URL' as `TITLE'."
(interactive (list (thing-at-point 'url)
(read-string "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))
#+end_src
> Ironically then you have to get the title the way you initially did!
right lol
--
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-18 20:29 ` Alex
@ 2022-04-18 20:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-18 22:13 ` Alex
0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-04-18 20:47 UTC (permalink / raw)
To: help-gnu-emacs
Alex wrote:
> (defun eww-bookmark-add (url title)
> "Bookmark `URL' as `TITLE'."
Just URL and TITLE is fine otherwise it looks like they are
part of Emacs.
> (interactive (list (thing-at-point 'url)
> (read-string "Title: ")))
> (unless (stringp url)
> (user-error "invalid url string required"))
> (unless (stringp title)
> (user-error "invalid title string required"))
> (eww-read-bookmarks)
From the `user-error' docstring:
In Emacs, the convention is that error messages start with
a capital letter but *do not* end with a period.
>> Ironically then you have to get the title the way you
>> initially did!
>
> right lol
:)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-18 20:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-18 22:13 ` Alex
2022-04-19 0:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 14+ messages in thread
From: Alex @ 2022-04-18 22:13 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> Just URL and TITLE is fine otherwise it looks like they are part of
> Emacs.
> In Emacs, the convention is that error messages start with a capital
> letter but *do not* end with a period.
fixed, thanks
PD: nice website Emanuel
Ok, now, Im browsing in EWW, and Im in a page with many interesting
urls, I want bookmarks all urls after point.
But moving the cursor, M-x eww-bookmark-add RET <title> RET with all
urls is painfull.
I need a func!
#+begin_src elisp
;; Copyright 2022 Alex
;; under GPLv3-or-later License
(defun eww-bookmark-buffer-urls ()
"Bookmark urls in current buffer"
(interactive)
(shr-next-link)
(let ((url-str (thing-at-point 'url)))
(eww-bookmark-add url-str url-str))
(if (save-excursion (shr-next-link))
(eww-bookmark-buffer-urls)))
#+end_src
Works, but sadly stop when find an url already bookmarked :/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-18 22:13 ` Alex
@ 2022-04-19 0:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-04-19 0:24 UTC (permalink / raw)
To: help-gnu-emacs
Alex wrote:
> PD: nice website Emanuel
PD? thanks :)
> Ok, now, Im browsing in EWW, and Im in a page with many
> interesting urls, I want bookmarks all urls after point.
Uhm, when you say URL, you mean hyperlink?
> But moving the cursor, M-x eww-bookmark-add RET <title> RET
> with all urls is painfull.
>
> I need a func!
>
> #+begin_src elisp
>
> ;; Copyright 2022 Alex
> ;; under GPLv3-or-later License
>
> (defun eww-bookmark-buffer-urls ()
> "Bookmark urls in current buffer"
That's (to the) right, period.
> (interactive)
> (shr-next-link)
> (let ((url-str (thing-at-point 'url)))
I still think it better to check for nil here.
> (if (save-excursion (shr-next-link))
> (eww-bookmark-buffer-urls)))
Hm, that's look sa bit weird ... instead drop recursion and
when you find what you are looking for, just get it and
go on. (Should be `when' BTW as it stands.)
> Works, but sadly stop when find an url already bookmarked :/
Sadly, you checked this in the other code and it is signalled
as an error if it happens, sounds like overkill indeed..
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: EWW func add url under point as bookmark
2022-04-16 14:34 ` Alex
2022-04-16 18:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-16 19:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-04-16 19:12 UTC (permalink / raw)
To: help-gnu-emacs
Here you go,
(defun eww-bookmark-add (url title)
"Bookmark URL as TITLE."
(interactive (list (thing-at-point 'url)
(read-string "Title: ") ))
(when (and url title)
(message "add %s as %s" url title) ))
;; tests:
;;
;; (eww-bookmark-add "https://dataswamp.org/~incal" "Pretty good site")
;;
;; (call-interactively #'eww-bookmark-add)https://dataswamp.org/~incal
;; ^ eval here
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <87ee1z8jap.fsf@zoho.eu>]
end of thread, other threads:[~2022-04-19 0:24 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-14 19:25 EWW func add url under point as bookmark Alex
2022-04-14 20:08 ` [External] : " Drew Adams
2022-04-14 23:31 ` Michael Heerdegen
2022-04-14 21:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-15 13:40 ` Alex
2022-04-15 14:17 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-16 14:34 ` Alex
2022-04-16 18:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-18 20:29 ` Alex
2022-04-18 20:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-18 22:13 ` Alex
2022-04-19 0:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-16 19:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
[not found] ` <87ee1z8jap.fsf@zoho.eu>
[not found] ` <CAJcAo8v7+CYd03EyFi_oK+E8crS+9gLea0jBqziN9wPMvGvvrQ@mail.gmail.com>
2022-04-17 0:16 ` [emacs-w3m:13862] " Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).