Re: [O] capture with iceweasel/firefox -- nothing works

2016-09-19 Thread Samuel Wales
On 9/12/16, Adam Porter  wrote:
> Samuel, in case you missed it, you might find this message helpful:
>
> Message-ID: 

i don't have a client that reads message ids but i presume you mean
the alphapapa github package suggestion earlier in this thread.  i
will try that, thank you.

i should point out that trying the instructions in this thread has
left my firefox in an even worse state: capture does not work at all,
whereas before it was intermittent.  i followed them exactly, as far
as i know.

now every capture i make with org-capture extension OR the bookmark i
tried before OR the bookmark suggested in this thread creates a buffer
with the name like listed at the end here:

Greedy org-protocol handler.  Killing client.
No server buffers remain to edit
Use M-x make-directory RET RET to create the directory and its parents
When done with a buffer, type C-x #
/home/tsugi/org-protocol:/capture-html:/w/https%3A%2F%2Fwww.masteringemacs.org%2Farticle%2Fwhats-new-in-emacs-25-1/What's%20New%20in%20Emacs%2025.1%20-%20Mastering%20Emacs/For%20example%2C%20to%20get%20the%20old%20behavior%20--%20'*shell*'%20buffer%20displays%20in%20current%20window%20--%20use%20(add-to-list%20'display-buffer-alist%20%20%20%20%20%20'(%22%5E%5C%5C*shell%5C%5C*%24%22%20.%20(display-buffer-same-window))).

i wish i could get capture to work.



Re: [O] capture with iceweasel/firefox -- nothing works

2016-09-12 Thread Adam Porter
Samuel, in case you missed it, you might find this message helpful:

Message-ID: 




Re: [O] capture with iceweasel/firefox -- nothing works

2016-09-03 Thread Samuel Wales
i tried your instructions.  thank you very much for spelling
it out so explicitly for me.

unfortunately, they don't work.

i am using debian jessie firefox.  i put the desktop file as
you stated, and added the bookmark as you stated.

then i tested it on the gmail tab with nothing selected.  it
went to a new location in firefox (i expected it to do
nothing in firefox).  this new location is like this in the
url bar:

  
javascript:"org-protocol://capture?url=https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2Fh%2Fhtsxxrphy06a%2F%3F%26=Gmail
- Inbox="

and the tab contents has a grey background and like this text:

  
"org-protocol://capture?url=https://mail.google.com/mail/u/0/h/htsxxrphy06a/?&=Gmail
- Inbox=

if i hit the back button in firefox i get gmail again.

as for emacs, it has a new buffer that is visiting like this
file:

  
/home/samuel/org-protocol:/capture?url=https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2Fh%2Fhtsxxrphy06a%2F%3F%26=Gmail%20-%20Inbox=

the value of org-protocol-default-template-key is nil.  so i
tried changing it to "p" and "L" which have templates.

then i tried it on another site with a selection.  it popped
up emacs (i do not want this and my templates are set to
immediately finish) and said:

  Use M-x make-directory RET RET to create the directory and its parents
  When done with a buffer, type C-x #

it also created a blank buffer visiting a file.

then i tried it on a few other sites, and got similar
results, but sometimes with slight differences.

so i am still lost.

interstitial:

On 6/4/16, Matt Lundin  wrote:
>> will try.  this is supposed to imitate clicking on the unicorn or
>> calling the bookmark?
>
> This is the content of the bookmark. Pasting it into the location bar is
> just a quick way to test if everything is working prior to saving it
> permanently as a bookmark. But it might be easier to go straight to the
> bookmark step (see below).

ok

> Do you mean clicking on the unicorn icon installed with this extension?
>
> https://addons.mozilla.org/en-US/firefox/addon/org-mode-capture/
>
> If you have installed that extension, I think everything should just
> work with minimal configuration. The extension is distinct from the

i have installed that extension.  it fails most of the time, just like
the 2 bookmarks i tried fail most of the time.  when it stops working
it really stops working.  when it is working, it's maybe 50%.  but
sometimes it has runs of working.

> universal. Once you get it set up the protocol system-wide, the bookmark
> should work in any browser.

ah.

> To save it as a bookmark in firefox, right click on the bookmark bar,
> select "New Bookmark," and paste it into the Location field.
>
>> do i try with selecting and without selecting?
>
> The bookmark should work with and without selections.
>
>> which capture key does it call?
>
> This can be controlled with the emacs variable
> `org-protocol-default-template-key'. You can also specify a template
> shortcut by changing the bookmark. For instance, to call a template
> designated by "x", you could use the following:
>
> javascript:location.href='org-protocol://capture?template=x='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())
>
> Matt
>



Re: [O] capture with iceweasel/firefox -- nothing works

2016-07-21 Thread Adam Porter
Samuel Wales  gmail.com> writes:
 
> however, i never found any good instructions on what to do to add js
> to bookmarks.
> i have a menu bar and a location bar + icons.  i'd like a button or
> icon on the latter if possible.  my previous thrashing around caused a
> >> symbol which is a drop down menu which contains the bookmarks.
> i'll settle for that if nec.  but that is extra clicking i'd rather
> avoid, and one of them brings up a page with js on it.
> 
> is this knowledge something that everybody except me possesses?  :)

Sorry for the late reply; I haven't been watching the list lately and I
missed this thread.  But in case this helps Samuel or anyone else:

When I was putting together org-protocol-capture-html, I spent some time
testing and refining the instructions to set up org-protocol correctly. 
They can be found here:

https://github.com/alphapapa/org-protocol-capture-html#org-protocol-instructions

Also, Samuel, you said elsewhere in the thread that you wanted to be able to
capture to Org like this:

* [[link][title]]
Selected text

And that's exactly what org-protocol-capture-html does.  You said you only
have a limited amount of time and weren't sure if it was worth trying. 
Well, I think it is, but of course I am biased.  ;)  But if you have any
problems, just post an issue on the tracker and I'll be glad to help you if
I can.




Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-04 Thread Matt Lundin
Samuel Wales  writes:

> hi matt,
>
> thanks for your reply.
>
> On 6/3/16, Matt Lundin  wrote:
>> Here is the new style bookmark that works for me:
>>
>> javascript:location.href='org-protocol://capture?url='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())
>>
>>
>> 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.
>
> will try.  this is supposed to imitate clicking on the unicorn or
> calling the bookmark?

This is the content of the bookmark. Pasting it into the location bar is
just a quick way to test if everything is working prior to saving it
permanently as a bookmark. But it might be easier to go straight to the
bookmark step (see below).

Do you mean clicking on the unicorn icon installed with this extension?

https://addons.mozilla.org/en-US/firefox/addon/org-mode-capture/

If you have installed that extension, I think everything should just
work with minimal configuration. The extension is distinct from the
bookmark method. The difference is that a bookmark is a bit more
universal. Once you get it set up the protocol system-wide, the bookmark
should work in any browser.

> however, i never found any good instructions on what to do to add js
> to bookmarks.

> i have a menu bar and a location bar + icons.  i'd like a button or
> icon on the latter if possible.  my previous thrashing around caused a
>>> symbol which is a drop down menu which contains the bookmarks.
> i'll settle for that if nec.  but that is extra clicking i'd rather
> avoid, and one of them brings up a page with js on it.

To save it as a bookmark in firefox, right click on the bookmark bar,
select "New Bookmark," and paste it into the Location field.

> do i try with selecting and without selecting?

The bookmark should work with and without selections.

> which capture key does it call?

This can be controlled with the emacs variable
`org-protocol-default-template-key'. You can also specify a template
shortcut by changing the bookmark. For instance, to call a template
designated by "x", you could use the following:

javascript:location.href='org-protocol://capture?template=x='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())

Matt



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-04 Thread Philip Hudson
On 4 June 2016 at 02:23, Samuel Wales  wrote:
> over many years, i have been trying to get org-protocol (or
> anything similar) to work, and it is not working reliably.
> that's why i want this feature to work so much.
...
>   *what is the most reliable set of instructions or code to
>   get iceweasel to work with org?*

Ordinarily my advice would be: Don't. Use Conkeror instead.

However, I see that keyboard-orientation and JavaScript are exactly
what you don't want, which is a pity. Org-capture from Conkeror is
bulletproof for me, even with Emacs server running on a different host
on the same LAN segment.

Conkeror uses the same browser engine as Firefox, so some FF
extensions work with it, but with an "Emacsified" keyboard-oriented
front end (M-x, M-:, C-u, C-g, etc) -- all dynamically configurable
and extensible, though in JavaScript not Elisp. The JavaScripting
framework uses familiar Elisp idioms wherever possible, like hooks,
`provide' and `require', for example.

> i'd be grateful for any useful hints.

Maybe not for you given your no-JS/no-keyboard requirement, but for
others who find this thread:

* Use Conkeror:
http://conkeror.org
git clone git://repo.or.cz/conkeror.git
* Don't forget to compile the external-interface module:
http://conkeror.org/ConkerorSpawnHelper
(tl;dr: Just cd into the cloned repo and execute 'make')
* On an XDG-compliant system (most Unix-like OSes except OS X):
xdg-mime default conkeror.desktop x-scheme-handler/http
xdg-mime default conkeror.desktop x-scheme-handler/https
* On a debian-esque system:
sudo update-alternatives --config x-www-browser
* Expose Conkeror's JS innards using the 'MozREPL' FF extension:
http://conkeror.org/MozRepl
** Use Emacs to inspect, configure, drive and automate Conkeror:
 git clone 'https://github.com/bard/mozrepl.git'
 Elisp package 'moz.el' is in subdirectory 'chrome/content/'
** Use the 'bash' shell to inspect, configure, drive and automate Conkeror:
 git clone 'https://github.com/PhilHudson/bash-mozrepl.git'


WRT Org capture protocol for those who do use a desktop env:
# Support org-protocol on Gnome (and XFCE, MATE, etc):
dbus-launch gconftool-2 -s
/desktop/gnome/url-handlers/org-protocol/command \
'/usr/local/bin/emacsclient %s' --type String
dbus-launch gconftool-2 -s
/desktop/gnome/url-handlers/org-protocol/enabled \
--type Boolean true


-- 
Phil Hudson   http://hudson-it.ddns.net
@UWascalWabbit PGP/GnuPG ID: 0x887DCA63



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-04 Thread tumashu
https://github.com/tumashu/org-capture-pop-frame

you can try above package


--
发自我的网易邮箱手机智能版


在 2016-06-04 09:23:09,"Samuel Wales"  写道:
>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")
>   )))
>  ;; --- 
> 

Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
hi matt,

thanks for your reply.

On 6/3/16, Matt Lundin  wrote:
> Here is the new style bookmark that works for me:
>
> javascript:location.href='org-protocol://capture?url='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+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---
>

will try.

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

debian
xdg-utils:
  Installed: 1.1.0~rc1+git20111210-7.4

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

will try.  this is supposed to imitate clicking on the unicorn or
calling the bookmark?

do i try with selecting and without selecting?

which capture key does it call?

i always run the emacs server in my regular emacs.  i don't
use the daemon.

however, i never found any good instructions on what to do to add js
to bookmarks.
i have a menu bar and a location bar + icons.  i'd like a button or
icon on the latter if possible.  my previous thrashing around caused a
>> symbol which is a drop down menu which contains the bookmarks.
i'll settle for that if nec.  but that is extra clicking i'd rather
avoid, and one of them brings up a page with js on it.

is this knowledge something that everybody except me possesses?  :)

===

the full error is:
Greedy org-protocol handler.  Killing client.
No server buffers remain to edit

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

thanks.


samuel



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Matt Lundin
Xebar Saram  writes:

> Hi 
>
> i will add that im exactly in the same situatuon
> i use a window manager (i3) on arch linux and have tried almost every
> solution out there (with FF, chrome etc) with no working method.
> i really wish org-protocol had a much simpler way of capturing
> links,text tec. im not a programmer but to me it seems so complicated.
> it the past before i was using org i had a simple bash script that
> yanked links/text from dwb (a simple web browser) and added that to a
> text file. something like this
>
> #!/bin/bash
> # dwb: xtm
> task add pro:dl +music $DWB_TITLE $DWB_URI 

> where the current title+URI of the webpage was added to a text file
> (task add) command.
>
> would love something simple like that for orgmode

I think you could put something like this in the script:

emacsclient "org-protocol://capture?url=$DWB_URI=$DWB_TITLE"

If you wanted to add the extra project and tag information (e.g.,
"music"), you could create a custom capture template and then designate
the template shortcut (e.g., "m") in the script:

emacsclient "org-protocol://capture?template=m=$DWB_URI=$DWB_TITLE"

Matt



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Matt Lundin
Matt Lundin  writes:

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

Another thought. Is the emacs server always running (either by starting
emacs as a daemon or by invoking server-start)?

Matt



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Matt Lundin
Samuel Wales  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)+'='+encodeURIComponent(document.title)+'='+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



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Xebar Saram
Hi

i will add that im exactly in the same situatuon
i use a window manager (i3) on arch linux and have tried almost every
solution out there (with FF, chrome etc) with no working method.
i really wish org-protocol had a much simpler way of capturing links,text
tec. im not a programmer but to me it seems so complicated. it the past
before i was using org i had a simple bash script that yanked links/text
from dwb (a simple web browser) and added that to a text file. something
like this

#!/bin/bash
# dwb: xtm
task add pro:dl +music $DWB_TITLE $DWB_URI

where the current title+URI of the webpage was added to a text file (task
add) command.

would love something simple like that for orgmode

best

Z




On Sat, Jun 4, 2016 at 4:33 AM, Samuel Wales  wrote:

> please note that i do not use a desktop environment, just a window
> manager.  if this is relevant, please tell me.  i do not understand
> mime or things like that.
>
>


Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
please note that i do not use a desktop environment, just a window
manager.  if this is relevant, please tell me.  i do not understand
mime or things like that.



Re: [O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
On 6/3/16, Samuel Wales  wrote:
>   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!

https://github.com/alphapapa/org-protocol-capture-html



[O] capture with iceweasel/firefox -- nothing works

2016-06-03 Thread Samuel Wales
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