emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* capture with iceweasel/firefox -- nothing works
@ 2016-06-04  1:23 Samuel Wales
  2016-06-04  1:30 ` Samuel Wales
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Samuel Wales @ 2016-06-04  1:23 UTC (permalink / raw)
  To: emacs-orgmode

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.
  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.

===

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.

===

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 wrote.)

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 times.

(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.)

===

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

===

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 (= 0 (length string))
      ""
    (concat string "\n---")))


-- 
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.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-09-20  1:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).