From: Matt Lundin <mdl@imapmail.org>
To: Samuel Wales <samologist@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: capture with iceweasel/firefox -- nothing works
Date: Fri, 03 Jun 2016 22:56:48 -0500 [thread overview]
Message-ID: <8760tphain.fsf@fastmail.fm> (raw)
In-Reply-To: <CAJcAo8tDt=aZ+9_3=-q_jG7N5LoECmP5_GphE_PWr-rpxvLYdg@mail.gmail.com> (Samuel Wales's message of "Fri, 3 Jun 2016 18:23:09 -0700")
Samuel Wales <samologist@gmail.com> writes:
> over many years, i have been trying to get org-protocol (or
> anything similar) to work, and it is not working reliably.
>
> intermittently, it says there is a greedy protocol. the success rate
> of capturing is around 50% maybe. when it is not working, it never
> works. i have noticed no correlation with anything that could cause
> this.
>
> sometimes it captures bogus text when i just want the link, but i
> don't care about that. at least it copied the link.
>
> i've tried:
>
> 1) org-capture firefox extension
> 2) a bookmark like this
> - javascript:location.href%20=%20'org-protocol://capture-html://w/'%20+%20encodeURIComponent(location.href)%20+%20'/'%20+%20encodeURIComponent(document.title)%20+%20'/'%20+%20encodeURIComponent(function%20()%20{var%20html%20=%20"";%20if%20(typeof%20document.getSelection%20!=%20"undefined")%20{var%20sel%20=%20document.getSelection();%20if%20(sel.rangeCount)%20{var%20container%20=%20document.createElement("div");%20for%20(var%20i%20=%200,%20len%20=%20sel.rangeCount;%20i%20<%20len;%20++i)%20{container.appendChild(sel.getRangeAt(i).cloneContents());}%20html%20=%20container.innerHTML;}}%20else%20if%20(typeof%20document.selection%20!=%20"undefined")%20{if%20(document.selection.type%20==%20"Text")%20{html%20=%20document.selection.createRange().htmlText;}}%20var%20relToAbs%20=%20function%20(href)%20{var%20a%20=%20document.createElement("a");%20a.href%20=%20href;%20var%20abs%20=%20a.protocol%20+%20"//"%20+%20a.host%20+%20a.pathname%20+%20a.search%20+%20a.hash;%20a.remove();%20return%20abs;};%20var%20elementTypes%20=%20[['a',%20'href'],%20['img',%20'src']];%20var%20div%20=%20document.createElement('div');%20div.innerHTML%20=%20html;%20elementTypes.map(function(elementType)%20{var%20elements%20=%20div.getElementsByTagName(elementType[0]);%20for%20(var%20i%20=%200;%20i%20<%20elements.length;%20i++)%20{elements[i].setAttribute(elementType[1],%20relToAbs(elements[i].getAttribute(elementType[1])));}});%20return%20div.innerHTML;}());
> 3) a bookmark like this
> - javascript:location.href='org-protocol://capture://L/'+encodeURIComponent(location.href)+'/'+encodeURIComponent(document.title)+'/'+encodeURIComponent(window.getSelection())
> 4) i know there's a new one that is supposed to capture
> format better (so you don't end up with a single
> paragraph when there were several paragraphs). that
> sounds wonderful! however, i am limited in computer
> use (4 minutes at a time), so i don't know if it is
> worth my trying or not. i have to use those 4 minutes responsibly.
Here is the new style bookmark that works for me:
javascript:location.href='org-protocol://capture?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())
I also placed the following in ~/.local/share/applications/emacsclient.desktop:
--8<---------------cut here---------------start------------->8---
[Desktop Entry]
Name=Emacs Client
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/org-protocol;
--8<---------------cut here---------------end--------------->8---
Since you are not using a desktop environment, you might also need to
make sure that the appropriate xdg tools are installed. On arch linux
the package is xdg-utils.
I'd recommend copying and pasting the javascript line above into the
location bar to confirm whether it works. If it does, you can then
easily add it to your bookmarks.
Note: There is a bug in the implementation of the new org-protocol url
processing that can lead to multiple "greedy protocol" warnings. (I
posted a bug report about this a week or so ago.)
Hope this helps.
Matt
next prev parent reply other threads:[~2016-06-04 3:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-04 1:23 capture with iceweasel/firefox -- nothing works Samuel Wales
2016-06-04 1:30 ` Samuel Wales
2016-06-04 1:33 ` Samuel Wales
2016-06-04 3:04 ` Xebar Saram
2016-06-04 4:05 ` Matt Lundin
2016-06-04 3:56 ` Matt Lundin [this message]
2016-06-04 4:00 ` Matt Lundin
2016-06-04 5:13 ` Samuel Wales
2016-06-04 15:11 ` Matt Lundin
2016-09-04 3:23 ` Samuel Wales
2016-09-12 23:14 ` Adam Porter
2016-09-20 1:38 ` Samuel Wales
2016-07-21 10:01 ` Adam Porter
2016-06-04 8:26 ` tumashu
2016-06-04 12:03 ` Philip Hudson
2016-06-04 20:53 ` [OT] " Matt Lundin
2016-06-04 23:01 ` Philip Hudson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8760tphain.fsf@fastmail.fm \
--to=mdl@imapmail.org \
--cc=emacs-orgmode@gnu.org \
--cc=samologist@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).