From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: capture with iceweasel/firefox -- nothing works Date: Fri, 3 Jun 2016 18:23:09 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b90Iz-0002WZ-V2 for emacs-orgmode@gnu.org; Fri, 03 Jun 2016 21:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b90Ix-0004z6-AX for emacs-orgmode@gnu.org; Fri, 03 Jun 2016 21:23:12 -0400 Received: from mail-vk0-x235.google.com ([2607:f8b0:400c:c05::235]:36358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b90Ix-0004z2-4N for emacs-orgmode@gnu.org; Fri, 03 Jun 2016 21:23:11 -0400 Received: by mail-vk0-x235.google.com with SMTP id a6so136592532vkg.3 for ; Fri, 03 Jun 2016 18:23:10 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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=3D%20'org-protocol://capture-html://w/'%= 20+%20encodeURIComponent(location.href)%20+%20'/'%20+%20encodeURIComponent(= document.title)%20+%20'/'%20+%20encodeURIComponent(function%20()%20{var%20h= tml%20=3D%20"";%20if%20(typeof%20document.getSelection%20!=3D%20"undefined"= )%20{var%20sel%20=3D%20document.getSelection();%20if%20(sel.rangeCount)%20{= var%20container%20=3D%20document.createElement("div");%20for%20(var%20i%20= =3D%200,%20len%20=3D%20sel.rangeCount;%20i%20<%20len;%20++i)%20{container.a= ppendChild(sel.getRangeAt(i).cloneContents());}%20html%20=3D%20container.in= nerHTML;}}%20else%20if%20(typeof%20document.selection%20!=3D%20"undefined")= %20{if%20(document.selection.type%20=3D=3D%20"Text")%20{html%20=3D%20docume= nt.selection.createRange().htmlText;}}%20var%20relToAbs%20=3D%20function%20= (href)%20{var%20a%20=3D%20document.createElement("a");%20a.href%20=3D%20hre= f;%20var%20abs%20=3D%20a.protocol%20+%20"//"%20+%20a.host%20+%20a.pathname%= 20+%20a.search%20+%20a.hash;%20a.remove();%20return%20abs;};%20var%20elemen= tTypes%20=3D%20[['a',%20'href'],%20['img',%20'src']];%20var%20div%20=3D%20d= ocument.createElement('div');%20div.innerHTML%20=3D%20html;%20elementTypes.= map(function(elementType)%20{var%20elements%20=3D%20div.getElementsByTagNam= e(elementType[0]);%20for%20(var%20i%20=3D%200;%20i%20<%20elements.length;%2= 0i++)%20{elements[i].setAttribute(elementType[1],%20relToAbs(elements[i].ge= tAttribute(elementType[1])));}});%20return%20div.innerHTML;}()); 3) a bookmark like this - javascript:location.href=3D'org-protocol://capture://L/'+encodeURICo= mponent(location.href)+'/'+encodeURIComponent(document.title)+'/'+encodeURI= Component(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. 5) i followed various instructions i currently using iceweasel 38.8.0 (debian jessie) and emacs-version "24.4.1". i understand elisp and org. however, i don't understand javascript or org-protocol's internal concepts. i am limited in concentration ability, so this could be a problem. i am also hazy on how to set up a bookmark, but i somehow managed to do it twice. =3D=3D=3D i am very often physically unable to use a keyboard. during these times i am often able to use a pointing device (2 mouses, one for clicking and one for moving). i am often using firefox (iceweasel) and want to capture things to org using only the mouse. that's why i want this feature to work so much. =3D=3D=3D i want to use org-capture extension or similar so that i can copy snippets of text like this: * [[link][descr]] text that i selected --- (the --- indicates that it came from iceweasel, and is not something i wrot= e.) or just the plain link like this if nothing is selected: * [[link][descr]] i have this working. it is just unreliable, failing randomly at random tim= es. (note: i don't want emacs to pop up and there should be no keyboard interaction. useful if emacs switches to the buffer it is saved to, however. i have all that stuff taken care of in my elisp. that part i understand and can fix by myself.) =3D=3D=3D i am stuck on this. after all that long-windedness, my question is this: *what is the most reliable set of instructions or code to get iceweasel to work with org?* i'd be grateful for any useful hints. thanks. samuel =3D=3D=3D here are just 2 of the many elisp-side things i tried over the years to get this to work. elisp i can handle. (setq org-capture-templates (append org-capture-templates `( ("p" "Protocol" entry (file+headline ,(concat org-directory "notes.org") "Inbox") "* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?") ("L" "Protocol Link" entry (file+headline ,(concat org-directory "notes.org") "Inbox") "* %? [[%:link][%:description]] \nCaptured On: %U") ))) ;; --- https://github.com/sprig/org-capture-extension#set-up-handlers-in-= emacs (cl-loop for key in '("L" "p") do (add-to-list 'org-capture-templates `(,key ,(format "Protocol %s" key) entry (file+headline ,org-default-notes-file ;; (concat org-directory "/executive--a.org") "xyzzy-remember") ;; \nkill %c\nselect %x ;; %:initial is like %i in org-protocol ;; if text, do -- ;; fixme i can perhaps remove my cleverness for whether ;; there is or is not selected text as in the ;; example above with begin quote. ;; https://github.com/sprig/org-capture-extension#set-up-handlers-in-emacs ;; ;; a future security fix might break this cleverness "%(alpha-org-protocol-string \"%:link\" \"%:description\" \"%= i\")" ;; "* [[%:link][%:description]]\n%(alpha-org-protocol-region \"%i\")" :prepend t ;; fixme set this to nil if you want to debug ka :immediate-finish t ;; ensure it worked ;; just remember to go to prev buffer for where you were :jump-to-captured t))) nil) (defun alpha-org-protocol-string (link description region) (format "* %s\n%s\n" (org-make-link-string link description) (alpha-org-protocol-region region))) (defun alpha-org-protocol-region (string) "If there is text, append dash to indicate quote." (if (=3D 0 (length string)) "" (concat string "\n---"))) --=20 The Kafka Pandemic: http://thekafkapandemic.blogspot.com The disease DOES progress. MANY people have died from it. And ANYBODY can get it. Denmark: free Karina Hansen NOW.