Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-09 Thread TRS-80

On 2021-01-07 01:29, Gerardo Moro wrote:

Thanks. Then why is in
https://orgmode.org/worg/org-contrib/org-protocol.html#installation
this confusing bit?

INSTALLATION

*

To load org-protocol.el add the following to your .emacs:

(server-start)
(add-to-list 'load-path "~/path/to/org/protocol/")
(require 'org-protocol)

El jue, 7 ene 2021 a las 8:17, Tom Gillespie ()
escribió:


It is built into the core org distribution.


Perhaps documentation should be updated?

Cheers,
TRS-80



Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Ihor Radchenko
Gerardo Moro  writes:

> Thanks. Then why is in
> https://orgmode.org/worg/org-contrib/org-protocol.html#installation this
> confusing bit?

Here is more detailed instruction: 
https://github.com/alphapapa/org-protocol-capture-html#org-protocol-instructions






Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Gerardo Moro
Thanks. Then why is in
https://orgmode.org/worg/org-contrib/org-protocol.html#installation this
confusing bit?

Installation

   -

   To load org-protocol.el add the following to your .emacs:

   (server-start)
   (add-to-list 'load-path "~/path/to/org/protocol/")
   (require 'org-protocol)




El jue, 7 ene 2021 a las 8:17, Tom Gillespie () escribió:

> It is built into the core org distribution.
>


Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Tom Gillespie
It is built into the core org distribution.



Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Gerardo Moro
Thanks. I have been trying to set org-protocol up, but... I can't find
where this package is (silly, innit?).
Where is the official org-protocol page where to download it?
Thanks!

El jue, 7 ene 2021 a las 7:10, Ihor Radchenko ()
escribió:

> Gerardo Moro  writes:
>
> > Thanks, guys.
> > I'll have a look.
> > I understand that using org-protocol in combo with org-capture I would
> have
> > to visit the Emacs window for capturing the copied text or not?
> > Because this is crucial, as I aim to avoid this step.
> > Thanks!
>
> If your capture template has :immediate-finish setting set to t, the
> capture is done in background without raising Emacs frame.
> See  v org-capture-templates  for more details.
>
> Best,
> Ihor
>
>


Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Ihor Radchenko
Gerardo Moro  writes:

> Thanks, guys.
> I'll have a look.
> I understand that using org-protocol in combo with org-capture I would have
> to visit the Emacs window for capturing the copied text or not?
> Because this is crucial, as I aim to avoid this step.
> Thanks!

If your capture template has :immediate-finish setting set to t, the
capture is done in background without raising Emacs frame.
See  v org-capture-templates  for more details.

Best,
Ihor




Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Gerardo Moro
This is very cool, thanks, and I very much use Automator.
I will have a look later, but it seems that you have to move focus to
Emacs, so it does not directly send something to a orgmode document
straight from the copy action in the browser.

El mié, 6 ene 2021 a las 17:56, Tim Visher ()
escribió:

> On Wed, Jan 6, 2021 at 1:43 AM Gerardo Moro 
> wrote:
>
>> Basically that: as I copy (Control-C) text from the browser (Chrome), I
>> would like those copied sentences to be sent to a ordered list in an
>> OrgMode document:
>>
>> - copied text 1
>> - copied text 2
>> - etc.
>>
>> Any ideas? This would be very useful.
>>
>
> On macOS I've done _similar_  things to this (albeit not exactly what
> you're asking) by simply generating org text for me to paste in.
>
> For instance I have an applescript `org-current-tab`:
>
> ```
> …
> on org_current_tab()
> tell application "Google Chrome"
> set the_title to title of active tab of front window
> set the_title to my replace_chars(the_title, "[", " ")
> set the_title to my replace_chars(the_title, "]", " ")
> return "[[" & URL of active tab of front window & "][" & the_title
> & "]]" as text
> end tell
> end org_current_tab
> ```
>
> Then from anywhere I can activate this applescript and all I need to do is
> whack `C-y` in emacs and I get the link pasted in.
>
> It's not hard then to extend this directly into emacs via the `osascript`
> executable:
>
> ```
> (defun org-current-tab
> ()
>   (interactive)
>   (unless (eq major-mode 'org-mode)
> (user-error "This command must be triggered in an org buffer."))
>   (let* ((output (with-temp-buffer
>(call-process
> "osascript" nil t nil
> "-e" "tell application \"Finder\" to set
> current_tab_handlers to (load script file \"current_tab_handlers.scpt\" of
> folder \"Dropbox\" of home as alias)"
> "-e" "tell current_tab_handlers to org_current_tab()")
>(substring-no-properties (thing-at-point 'line t) 0
> -1
> (insert output)))
> ```
>
> I'm not sure what environment you're in so you may not have access to a
> system's scripting tool like Applescript but depending on the scripting
> facilities of whatever you're targeting maybe you can get most of the way
> there. At the worst you could add whatever text you want to your clipboard
> and then write some elisp that processes it before writing it to your org
> buffer.
>


Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Bob Newell


I've done similar sorts of things in Linux with xdotool and
xclip. These are very useful tools although a bit fiddly in
their usage.

-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU/Linux/Emacs/Gnus/BBDB



Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Juan Manuel Macías
Gerardo Moro  writes:

> Basically that: as I copy (Control-C) text from the browser (Chrome),
> I would like those copied sentences to be sent to a ordered list in an
> OrgMode document:
>
> - copied text 1
> - copied text 2
> - etc.
>
> Any ideas? This would be very useful.
> Thanks!

I don't know if it is exactly what you are looking for, but maybe you
might be interested in this extension for chrome and firefox that uses
org-protocol:

https://github.com/sprig/org-capture-extension

Regards,

Juan Manuel 



Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Maxim Nikulin

On 06/01/2021 13:41, Gerardo Moro wrote:
Basically that: as I copy (Control-C) text from the browser (Chrome), I 
would like those copied sentences to be sent to a ordered list in an 
OrgMode document:


- copied text 1
- copied text 2
- etc.

Any ideas? This would be very useful.


To add to emacs a key binding that runs a script calling pandoc, 
something like (untested, you are asking for ideas), and inserting new 
text from clipboard


in_file=`mktemp --tmpdir convert.XX.html`
out_file=`mktemp --tmpdir convert.XX.org`
xclip -out -target text/html >"$in_file"
pandoc --output="$out_file" "$in_file"
xclip -in <"$out_file"

No need to setup org-protocol. Maybe it is possible to avoid temporary 
files.


TODO:
- Temporary files should be removed
- Unsure if pandoc is safe in respect to peculiar HTML formatting, maybe 
it has some special options for conversion of non-trusted files.






Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Tim Visher
On Wed, Jan 6, 2021 at 1:43 AM Gerardo Moro  wrote:

> Basically that: as I copy (Control-C) text from the browser (Chrome), I
> would like those copied sentences to be sent to a ordered list in an
> OrgMode document:
>
> - copied text 1
> - copied text 2
> - etc.
>
> Any ideas? This would be very useful.
>

On macOS I've done _similar_  things to this (albeit not exactly what
you're asking) by simply generating org text for me to paste in.

For instance I have an applescript `org-current-tab`:

```
…
on org_current_tab()
tell application "Google Chrome"
set the_title to title of active tab of front window
set the_title to my replace_chars(the_title, "[", " ")
set the_title to my replace_chars(the_title, "]", " ")
return "[[" & URL of active tab of front window & "][" & the_title
& "]]" as text
end tell
end org_current_tab
```

Then from anywhere I can activate this applescript and all I need to do is
whack `C-y` in emacs and I get the link pasted in.

It's not hard then to extend this directly into emacs via the `osascript`
executable:

```
(defun org-current-tab
()
  (interactive)
  (unless (eq major-mode 'org-mode)
(user-error "This command must be triggered in an org buffer."))
  (let* ((output (with-temp-buffer
   (call-process
"osascript" nil t nil
"-e" "tell application \"Finder\" to set
current_tab_handlers to (load script file \"current_tab_handlers.scpt\" of
folder \"Dropbox\" of home as alias)"
"-e" "tell current_tab_handlers to org_current_tab()")
   (substring-no-properties (thing-at-point 'line t) 0
-1
(insert output)))
```

I'm not sure what environment you're in so you may not have access to a
system's scripting tool like Applescript but depending on the scripting
facilities of whatever you're targeting maybe you can get most of the way
there. At the worst you could add whatever text you want to your clipboard
and then write some elisp that processes it before writing it to your org
buffer.


Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-05 Thread Gerardo Moro
Thanks, guys.
I'll have a look.
I understand that using org-protocol in combo with org-capture I would have
to visit the Emacs window for capturing the copied text or not?
Because this is crucial, as I aim to avoid this step.
Thanks!

El mié, 6 ene 2021 a las 8:49, Tom Gillespie () escribió:

> You can achieve something a bit like this using
> org-protocol-capture-html
> https://github.com/alphapapa/org-protocol-capture-html. I'm not
> entirely sure whether you can bind the equivalent of a hook in
> javascript to run every time you C-c, but if you can, then it should
> be possible to match this exactly. You might also be able to wire up
> org-protocol to the X clipboard (if you are on linux).
>
> Best,
> Tom
>


Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-05 Thread Tom Gillespie
You can achieve something a bit like this using
org-protocol-capture-html
https://github.com/alphapapa/org-protocol-capture-html. I'm not
entirely sure whether you can bind the equivalent of a hook in
javascript to run every time you C-c, but if you can, then it should
be possible to match this exactly. You might also be able to wire up
org-protocol to the X clipboard (if you are on linux).

Best,
Tom



Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-05 Thread Samuel Wales
there is a tricky org-protocol thing you can do with emacsclient and a
capture template, but i suspect that chrome has an extension just like
firefox does called org-capture that does some of that in the browser
itself.  in firefox-esr, i select text and click the unicorn icon.

you will have to read about capture templates to create your own to
match the one that the org-capture extension uses [a single letter].

On 1/5/21, Gerardo Moro  wrote:
> Basically that: as I copy (Control-C) text from the browser (Chrome), I
> would like those copied sentences to be sent to a ordered list in an
> OrgMode document:
>
> - copied text 1
> - copied text 2
> - etc.
>
> Any ideas? This would be very useful.
> Thanks!
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html



Possibility to copy text outside EMACS and send it to orgmode document

2021-01-05 Thread Gerardo Moro
Basically that: as I copy (Control-C) text from the browser (Chrome), I
would like those copied sentences to be sent to a ordered list in an
OrgMode document:

- copied text 1
- copied text 2
- etc.

Any ideas? This would be very useful.
Thanks!