emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: idea for capture anywhere in x
       [not found] <mailman.51.1599580808.12104.emacs-orgmode@gnu.org>
@ 2020-09-08 23:15 ` No Wayman
  2020-09-13 20:29   ` Bastien
  0 siblings, 1 reply; 24+ messages in thread
From: No Wayman @ 2020-09-08 23:15 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: emacs-orgmode-request


I use a deamon specifically for this. Here's a gist with my setup 
(thought slightly out of date, this will work as a base):

https://gist.github.com/progfolio/af627354f87542879de3ddc30a31adc1


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

* Re: idea for capture anywhere in x
  2020-09-08 23:15 ` idea for capture anywhere in x No Wayman
@ 2020-09-13 20:29   ` Bastien
  0 siblings, 0 replies; 24+ messages in thread
From: Bastien @ 2020-09-13 20:29 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode-request, emacs-orgmode

Hi No Wayman,

No Wayman <iarchivedmywholelife@gmail.com> writes:

> I use a deamon specifically for this. Here's a gist with my setup
> (thought slightly out of date, this will work as a base):
>
> https://gist.github.com/progfolio/af627354f87542879de3ddc30a31adc1

Thanks for sharing this, I've added (as 10e460b9) an entry on worg:
https://orgmode.org/worg/org-hacks.html

-- 
 Bastien


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

* Re: idea for capture anywhere in x
  2022-06-13 10:04                   ` Max Nikulin
@ 2022-06-13 14:02                     ` Michal Politowski
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Politowski @ 2022-06-13 14:02 UTC (permalink / raw)
  To: emacs-orgmode

Dnia Mon, 13 Jun 2022 17:04:46 +0700, Max Nikulin napisał(a):
> On 13/06/2022 16:10, Michal Politowski wrote:
> > 
> > $ xclip -selection clipboard -o -t text/x-moz-url-priv
> > https://orgmode.org/
> 
> Thank you for the trick.
> 
> Have you ever tried to set drag-n-drop handler for org buffers to invoke
> e.g. `org-store-link'? I mean dragging a link or URL from the address bar
> from a browser to an emacs window. I am curious how much information is
> available in such case.

No, I haven't. Sorry.

-- 
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.


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

* Re: idea for capture anywhere in x
  2022-06-13  9:10                 ` Michal Politowski
@ 2022-06-13 10:04                   ` Max Nikulin
  2022-06-13 14:02                     ` Michal Politowski
  0 siblings, 1 reply; 24+ messages in thread
From: Max Nikulin @ 2022-06-13 10:04 UTC (permalink / raw)
  To: emacs-orgmode

On 13/06/2022 16:10, Michal Politowski wrote:
> 
> $ xclip -selection clipboard -o -t text/x-moz-url-priv
> https://orgmode.org/

Thank you for the trick.

Have you ever tried to set drag-n-drop handler for org buffers to invoke 
e.g. `org-store-link'? I mean dragging a link or URL from the address 
bar from a browser to an emacs window. I am curious how much information 
is available in such case.



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

* Re: idea for capture anywhere in x
  2022-06-10  2:35               ` Samuel Wales
                                   ` (2 preceding siblings ...)
  2022-06-13  7:46                 ` Max Nikulin
@ 2022-06-13  9:10                 ` Michal Politowski
  2022-06-13 10:04                   ` Max Nikulin
  3 siblings, 1 reply; 24+ messages in thread
From: Michal Politowski @ 2022-06-13  9:10 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Dnia Thu,  9 Jun 2022 19:35:52 -0700, Samuel Wales napisał(a):
[...]
> otoh, if there is such a thing as "a cli command that will ask firefox
> for its current url" then it is possible.

Not exactly this (and what is current with many windows and tabs?), but it seems that when Firefox
owns a selection, you can ask it not only for the text but also for the URL:

$ xclip -selection clipboard -o -t text/plain
A GNU Emacs major mode for keeping notes, authoring documents,
computational notebooks, literate programming, maintaining to-do lists,
planning projects, and more \u2014 in a fast and effective plain text
system.

$ xclip -selection clipboard -o -t text/x-moz-url-priv
https://orgmode.org/

$ xclip -selection clipboard -o -t TARGETS
TIMESTAMP
TARGETS
MULTIPLE
SAVE_TARGETS
text/html
text/_moz_htmlcontext
text/_moz_htmlinfo
UTF8_STRING
COMPOUND_TEXT
TEXT
STRING
text/plain;charset=utf-8
text/plain
text/x-moz-url-priv

-- 
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.


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

* Re: idea for capture anywhere in x
  2022-06-10  2:35               ` Samuel Wales
  2022-06-10  9:59                 ` Charles Philip Chan
  2022-06-11  4:11                 ` Ihor Radchenko
@ 2022-06-13  7:46                 ` Max Nikulin
  2022-06-13  9:10                 ` Michal Politowski
  3 siblings, 0 replies; 24+ messages in thread
From: Max Nikulin @ 2022-06-13  7:46 UTC (permalink / raw)
  To: emacs-orgmode

On 10/06/2022 09:35, Samuel Wales wrote:
> with the org capture firefox extension broken, i recalled this old
> thread, thinking it might be a fix,  and i think i understand the
> issue.  so i thought i would summarize here in this one post.

Samuel, have you managed to fix org-protocol setup? From other messages 
I am almost sure that the issue is not with the firefox add-on.

Anyway in this thread people suggested to use `org-capture' directly, so 
it may be a workaround for a while

     emacsclient --eval '(org-capture nil "c")'

You can add such command to your fluxbox menu. I have the following 
template:

      ("c" "Clipboard" entry
       (file "")
       "* %?%(org-get-x-clipboard 'CLIPBOARD)
" :empty-lines 1)

I do not remember why "%c" and "%x" substitutions did not work for me, 
perhaps too old org system package. 'PRIMARY should be even more convenient.

> otoh, if there is such a thing as "a cli command that will ask firefox
> for its current url" then it is possible.

It was you who found https://github.com/bitspook/spookfox I never tried 
it, but I do not see any way to fetch something from firefox besides 
this kind of extensions (KDE plasma integration or 
https://github.com/osnr/TabFS).

You can copy URL to clipboard, just select text and obtain both PRIMARY 
and CLIPBOARD from an org-capture template.

An idea for any application accordingly to the subject. It is possible 
to obtain window title, something like

  xdotool getactivewindow getwindowname

(untested), or more low level

     xprop -id "$(
         xprop -root -f _NET_ACTIVE_WINDOW 0x '=$0' _NET_ACTIVE_WINDOW |
         cut -f 2- -d =
     )" -f _NET_WM_NAME 8s '=$0' _NET_WM_NAME |
     cut -f 2- -d =

Finally a bonus for those who read mails till the end of the message. I 
have figured out how to get org markup from selection in firefox, 
libreoffice writer, etc. Unsure if such approach has some security 
issues, I never tried to evaluate to which degree pandoc is safe. It can 
be called from emacs to insert output into the current buffer or "| 
xclip -in" may be appended to replace selection buffer. More accurate 
script can check
"xclip -out -target TARGETS" for presence of "text/html" string

#!/bin/bash
set -o pipefail
selection=primary
xclip -selection "$selection" -out -target text/html 2>/dev/null |
      pandoc --from=html --to=org - ||
      xclip -selection "$selection" -out



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

* Re: idea for capture anywhere in x
  2022-06-10  2:35               ` Samuel Wales
  2022-06-10  9:59                 ` Charles Philip Chan
@ 2022-06-11  4:11                 ` Ihor Radchenko
  2022-06-13  7:46                 ` Max Nikulin
  2022-06-13  9:10                 ` Michal Politowski
  3 siblings, 0 replies; 24+ messages in thread
From: Ihor Radchenko @ 2022-06-11  4:11 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Nick Econopouly, Maxim Nikulin, emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> 2.
>
> in this thread i thought it would also be great to select text with
> mouse /in any running application in x/, then have selection be saved
> to an org entry.  this might be possible with the above possible
> solution, minus the url issue.

FYI, you can bind org-capture command in your WM and use %k in your
capture templates:

org-capture-templates is a variable defined in org-capture.el.
...
The template defines the text to be inserted.  Often this is an
Org mode entry (so the first line should start with a star) that
will be filed as a child of the target headline.  It can also be
freely formatted text.  Furthermore, the following %-escapes will
be replaced with content and expanded:
...
  %x          Content of the X clipboard.

Best,
Ihor


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

* Re: idea for capture anywhere in x
  2022-06-10  2:35               ` Samuel Wales
@ 2022-06-10  9:59                 ` Charles Philip Chan
  2022-06-11  4:11                 ` Ihor Radchenko
                                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 24+ messages in thread
From: Charles Philip Chan @ 2022-06-10  9:59 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Nick Econopouly, Maxim Nikulin, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Samuel Wales <samologist@gmail.com> writes:

Hi Samuel,

> with the org capture firefox extension broken, i recalled this old
> thread, thinking it might be a fix,  and i think i understand the
> issue.  so i thought i would summarize here in this one post.

This new addon:

     https://addons.mozilla.org/en-US/firefox/addon/org-protocol/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search

is working well for me.

Charles

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 219 bytes --]

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

* Re: idea for capture anywhere in x
  2020-09-12  8:48             ` Nick Econopouly
@ 2022-06-10  2:35               ` Samuel Wales
  2022-06-10  9:59                 ` Charles Philip Chan
                                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Samuel Wales @ 2022-06-10  2:35 UTC (permalink / raw)
  To: Nick Econopouly; +Cc: Maxim Nikulin, emacs-orgmode

with the org capture firefox extension broken, i recalled this old
thread, thinking it might be a fix,  and i think i understand the
issue.  so i thought i would summarize here in this one post.

i think i was not clear in this thread in a few places.  apologies for that.

1.

[current need, urgent] i want to select text with mouse in firefox,
then have plain text and url save to an org entry.

this would then replace the need for the firefox org-capture extension.

it seems like emacsclient calling org-capture can grab the selected
/text/.  [presumably in a capture template via a % format or via lisp
that calls gui-get-selection or something like that.]  a cli command
like this sounds good.

but saving the /url/ seems not possible in a cli command because it
will not have access to firefox's current url.

otoh, if there is such a thing as "a cli command that will ask firefox
for its current url" then it is possible.

if such a solution is possible then i can make it controllable
completely by mouse [i often cannot use keyboard] merely by adding the
cli command [such as an emacsclient call] to my fluxbox menu.  that
would be a complete solution.

2.

in this thread i thought it would also be great to select text with
mouse /in any running application in x/, then have selection be saved
to an org entry.  this might be possible with the above possible
solution, minus the url issue.

i can maybe work around the /firefox/ url issue by manually selecting
the url in the url bar after selecting text.  cli command creates
second entry in org; i clean up manually in emacs later.  kind of dumb
but maybe will work.


does this sound like a sensible thing to try to do to work around the
fact that the org capture extension is broken?

i like the idea that it will maybe be robust to firefox changes and
doesn't require me to yet again try to figure out org-protocol.  [i
never got org protocol to work in firefox.  which is why i liked the
org capture extension.]


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

* Re: idea for capture anywhere in x
  2020-09-10 14:23           ` Maxim Nikulin
@ 2020-09-12  8:48             ` Nick Econopouly
  2022-06-10  2:35               ` Samuel Wales
  0 siblings, 1 reply; 24+ messages in thread
From: Nick Econopouly @ 2020-09-12  8:48 UTC (permalink / raw)
  To: Maxim Nikulin; +Cc: emacs-orgmode

Just chiming in here, you are correct that org-protocol is 
unnecessary. Regular org-capture templates plus a call to 
emacsclient -e will do the trick. I happened to recently see a 
workflow like this in a blog post: 
https://yiufung.net/post/anki-org/


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

* Re: idea for capture anywhere in x
  2020-09-09  4:52         ` Maxim Nikulin
@ 2020-09-10 14:23           ` Maxim Nikulin
  2020-09-12  8:48             ` Nick Econopouly
  0 siblings, 1 reply; 24+ messages in thread
From: Maxim Nikulin @ 2020-09-10 14:23 UTC (permalink / raw)
  To: emacs-orgmode

09.09.2020 11:52, Maxim Nikulin wrote:
> 
> Capture templates allow calling of arbitrary lisp code, so you could 
> take value from kill ring or call low level gui-get-selection function. 
> The latter would allow separate templates for primary selection and for 
> clipboard.

Today I have noticed that there are %c and %x substitutions for capture 
templates (thanks to the patch suggesting %L). With default preferences 
emacs listen to X clipboard and adds its contents to kill-ring, so 
current clipboard content is available as %c. %x at first tries primary 
selection. So there is no need to call gui-get-selection directly. By 
default both variants of selection are available through substitutions. 
If emacs is tuned to use primary selection, there is a compatibility 
function org-get-x-clipboard.



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

* Re: idea for capture anywhere in x
  2020-09-09  8:40     ` Russell Adams
@ 2020-09-09 21:11       ` Samuel Wales
  0 siblings, 0 replies; 24+ messages in thread
From: Samuel Wales @ 2020-09-09 21:11 UTC (permalink / raw)
  To: emacs-orgmode

as some have mentioned keystrokes, i just wanted to point out htat the
idea here is select with mouse and run using mouse, with no keyboard
at all.  firefox org-capture does this for me.  in case there was any
confusion.

On 9/9/20, Russell Adams <RLAdams@adamsinfoserv.com> wrote:
> On Mon, Sep 07, 2020 at 10:05:38PM -0700, Samuel Wales wrote:
>> well for a non-emacs application, i want to select text and capture
>> using wm menu.
>
> I routinely capture programming and UNIX history. I select text (X11
> clipboard), and then I have a skel/abbrev to insert it into Emacs. I
> type "pexa<space>" and it creates an example source block and pastes
> the clipboard into it with proper indentation. "pexa" stands for
> "paste example".
>
> This is *so* fast compared to creating a new source block (C-c C-, e),
> then entering it (C-c C-'), pasting (C-y), and then exiting (C-c C-').
>
> ;; Org mode skeletons instead of yasnippet
> (define-skeleton rla-paste-example
>   "Insert an Org-mode example source block and paste the clipboard into it."
> nil
>   "#+BEGIN_EXAMPLE\n"
>   ;; indent to match the src block
>   (concat "  " (replace-regexp-in-string "\n" "\n  "
> (replace-regexp-in-string "\n$" "" (current-kill 0)))) "\n"
>   "#+END_EXAMPLE\n"
>   "\n"
>   -)
>
> (define-abbrev-table 'org-mode-abbrev-table '(("pexa" "" rla-paste-example
> 0)))
>
> Mind you this is in the current buffer I'm typing in. If I wanted to
> add from the CLI, I'd use a capture template with a predefined
> location and make sure it includes the clipboard in expansion.
>
> As some of the other replies have shown, triggering capture externally
> isn't too hard. You'll just need to figure out the WM hook.
>
> ------------------------------------------------------------------
> Russell Adams                            RLAdams@AdamsInfoServ.com
>
> PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/
>
> Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3
>
>


-- 
The Kafka Pandemic

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


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

* Re: idea for capture anywhere in x
  2020-09-08  5:05   ` Samuel Wales
  2020-09-08  5:21     ` Tim Cross
  2020-09-08  5:39     ` Maxim Nikulin
@ 2020-09-09  8:40     ` Russell Adams
  2020-09-09 21:11       ` Samuel Wales
  2 siblings, 1 reply; 24+ messages in thread
From: Russell Adams @ 2020-09-09  8:40 UTC (permalink / raw)
  To: emacs-orgmode

On Mon, Sep 07, 2020 at 10:05:38PM -0700, Samuel Wales wrote:
> well for a non-emacs application, i want to select text and capture
> using wm menu.

I routinely capture programming and UNIX history. I select text (X11
clipboard), and then I have a skel/abbrev to insert it into Emacs. I
type "pexa<space>" and it creates an example source block and pastes
the clipboard into it with proper indentation. "pexa" stands for
"paste example".

This is *so* fast compared to creating a new source block (C-c C-, e),
then entering it (C-c C-'), pasting (C-y), and then exiting (C-c C-').

;; Org mode skeletons instead of yasnippet
(define-skeleton rla-paste-example
  "Insert an Org-mode example source block and paste the clipboard into it." nil
  "#+BEGIN_EXAMPLE\n"
  ;; indent to match the src block
  (concat "  " (replace-regexp-in-string "\n" "\n  " (replace-regexp-in-string "\n$" "" (current-kill 0)))) "\n"
  "#+END_EXAMPLE\n"
  "\n"
  -)

(define-abbrev-table 'org-mode-abbrev-table '(("pexa" "" rla-paste-example 0)))

Mind you this is in the current buffer I'm typing in. If I wanted to
add from the CLI, I'd use a capture template with a predefined
location and make sure it includes the clipboard in expansion.

As some of the other replies have shown, triggering capture externally
isn't too hard. You'll just need to figure out the WM hook.

------------------------------------------------------------------
Russell Adams                            RLAdams@AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3


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

* Re: idea for capture anywhere in x
  2020-09-08 22:40       ` Samuel Wales
@ 2020-09-09  4:52         ` Maxim Nikulin
  2020-09-10 14:23           ` Maxim Nikulin
  0 siblings, 1 reply; 24+ messages in thread
From: Maxim Nikulin @ 2020-09-09  4:52 UTC (permalink / raw)
  To: emacs-orgmode

09.09.2020 05:40, Samuel Wales wrote:
> On 9/7/20, Maxim Nikulin <manikulin@gmail.com> wrote:
>> Do you mean a tiny tool that takes content of X primary selection or
>> clipboard and passes it to emacs-client org-protocol argument?
> 
> maybe.  guessing probably.  i want it to take contents of x primary
> selection or clipboard and get it into emacs using a capture template
> item.  whether this requries oprg-protocl, idk.

Isn't Tim's suggestion suitable for you (to call emacsclient --eval 
'(org-capture)' directly without any additional tool or even 
org-protocol)? I noticed his answer after I sent my message.

Some wrapper to create a new frame may be necessary, but since you are 
likely happy with your desktop protocol handler, you could use very 
similar script with eval instead of org-protocol argument when 
emacsclient is invoked.

Capture templates allow calling of arbitrary lisp code, so you could 
take value from kill ring or call low level gui-get-selection function. 
The latter would allow separate templates for primary selection and for 
clipboard.

I do not know what is more convenient for you, to use emacs capture 
template dialog or dedicated menu items or hotkeys in window manager for 
access to primary selection and clipboard and passing additional 
argument to org-capture.

By the way, is there a convention for keystrokes that allows both 
clipboard and primary selection? I have seen that either option could be 
configured for default kill/yank but sometimes it is convenient to use both.

>> The harder part is extracting of formatted text (that could be
>> application specific) and converting it to org markup. I had a look
>> into emacs sources and did not find extension points to obtain
>> application-specific format, so external tool could provide some benefit
>> (e.g. capturing link with description from libreoffice).
> 
> while such features would be great, my needs are modest i think.  i
> would be delighted with just plain text.
> 
> but if possible i'd want it to be inserted as utf-8 even if the
> terminal or deluge or whatever uses some different encoding.

With spread of UTF-8 I almost forget problems with charsets. I hope, 
currently it should be workarounds for particular applications.

I have seen comments that modern pandoc could convert various formats to 
org. As to working with formatted text, previous time my curiosity was 
exhausted after the following commands for tcl

package require Tk
puts "[selection get -type TARGETS]"
puts "[selection get -type text/html -selection CLIPBOARD]

I have not searched which languages provide easy access to selection 
with minimal dependencies and if there are some ready to use libraries 
to extract rich text. Maybe sources of a browser or an office 
application should be expected (or of some simple application that still 
allows to copy-paste of rich text).



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

* Re: idea for capture anywhere in x
  2020-09-08  4:22 Samuel Wales
  2020-09-08  5:01 ` Tim Cross
@ 2020-09-09  1:07 ` Ihor Radchenko
  1 sibling, 0 replies; 24+ messages in thread
From: Ihor Radchenko @ 2020-09-09  1:07 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

> is something like this possible?


It's very easy. Below is a part of my capture (bash) script for qutebrowser:

emacsclient "org-protocol://capture?template=$TEMPLATE&url=$URL&title=$TITLE&body=$SELECTED_TEXT&html=$QUTE_HTML&qutebrowser-fifo=$QUTE_FIFO"

Best,
Ihor

Samuel Wales <samologist@gmail.com> writes:

> dunno if this is sensible, but istr you can capture using emacsclient?
>
> i really like hte org capture extension in firefox and want it for
> everything in x [which means emacs itself using mouse and what little
> else i run].
>
> my idea was, to emacsclient to call org protocol to a defined capture
> template just like the firefox extension.  this would be alled from
> the wm menu.
>
> is something like this possible?
>
> -- 
> The Kafka Pandemic
>
> Please learn what misopathy is.
> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: idea for capture anywhere in x
  2020-09-08  5:39     ` Maxim Nikulin
@ 2020-09-08 22:40       ` Samuel Wales
  2020-09-09  4:52         ` Maxim Nikulin
  0 siblings, 1 reply; 24+ messages in thread
From: Samuel Wales @ 2020-09-08 22:40 UTC (permalink / raw)
  To: Maxim Nikulin; +Cc: emacs-orgmode

On 9/7/20, Maxim Nikulin <manikulin@gmail.com> wrote:
> 08.09.2020 12:05, Samuel Wales wrote:
>> well for a non-emacs application, i want to select text and capture
>> using wm menu.
>
> Do you mean a tiny tool that takes content of X primary selection or
> clipboard and passes it to emacs-client org-protocol argument?

maybe.  guessing probably.  i want it to take contents of x primary
selection or clipboard and get it into emacs using a capture template
item.  whether this requries oprg-protocl, idk.

so basically fluxbox menu calls some trivial command which invokes
capoture on my already-existing capture template such as the one that
i already use for hte firefox org-capture extension to use.

> Implementation should have a few lines of code and should allow you to
> bind it to window manager menu or hotkeys. On the other hand I do not
> see great difference from pasting text directly to emacs. Customization
> glue (primary selection/clipboard, name of template, etc.) is thicker
> than code that do the actual job.
>
> The harder part is extracting of formatted text (that could be
> application specific) and converting it to org markup. I had a look
> into emacs sources and did not find extension points to obtain
> application-specific format, so external tool could provide some benefit
> (e.g. capturing link with description from libreoffice).

while such features would be great, my needs are modest i think.  i
would be delighted with just plain text.

but if possible i'd want it to be inserted as utf-8 even if the
terminal or deluge or whatever uses some different encoding.

>
>
>


-- 
The Kafka Pandemic

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


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

* Re: idea for capture anywhere in x
  2020-09-08  8:03         ` Diego Zamboni
@ 2020-09-08 16:08           ` Maxim Nikulin
  0 siblings, 0 replies; 24+ messages in thread
From: Maxim Nikulin @ 2020-09-08 16:08 UTC (permalink / raw)
  To: emacs-orgmode

08.09.2020 15:03, Diego Zamboni wrote:
> 
> Doom Emacs has an 'org-capture' script that uses emacsclient to 
> externally invoke a new frame with 'org-capture' in it. Maybe this could 
> be a good starting point?
> 
> https://github.com/hlissner/doom-emacs/blob/develop/bin/org-capture

Thank you for the link. I have found it interesting due to I am unaware 
what is considered as best practices in relation to invoking of emacsclient.

Though I am a bit lazy to try doom-emacs just now. Does the script works 
correctly if emacs server is already running but with no frames at the 
moment of script execution?

A couple of things I have noticed in the script:
- Systemd service file in emacs stops server without redefining of 
kill-emacs-hook.
- Despite it was not exactly the same problem, cleanup in shell script 
after completion of a child process was discussed in [1]. Some subtle 
aspects are better highlighted in the non-top rated answer. I suspect, 
in the case of emacs races might happen in different places.

[1] https://unix.stackexchange.com/a/444676 "Forward SIGTERM to child in 
Bash"



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

* Re: idea for capture anywhere in x
  2020-09-08  7:18       ` Maxim Nikulin
@ 2020-09-08  8:03         ` Diego Zamboni
  2020-09-08 16:08           ` Maxim Nikulin
  0 siblings, 1 reply; 24+ messages in thread
From: Diego Zamboni @ 2020-09-08  8:03 UTC (permalink / raw)
  To: Maxim Nikulin; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]

Doom Emacs has an 'org-capture' script that uses emacsclient to externally
invoke a new frame with 'org-capture' in it. Maybe this could be a good
starting point?

https://github.com/hlissner/doom-emacs/blob/develop/bin/org-capture


--Diego

On Tue, Sep 8, 2020 at 9:19 AM Maxim Nikulin <manikulin@gmail.com> wrote:

> 08.09.2020 12:21, Tim Cross wrote:
> >
> > How you add this to a window manager menu or key binding will depend on
> > your window manager, but essentially, you just calling emacscleint with
> > the argument -e (org-capture). You may need to quote the command to
> > prevent shell interpolation of the command and you may need to add other
> > arguments, such as -n or --no-wait etc.
>
> Good point. However playing with a script for org protocol, I realized
> that there could be no emacs frame yet, so I added --create-frame
> depending on output of
>
> emacsclient --quiet --eval \
>    "(seq-some (lambda (f) (if (eq 'x (framep f)) 'has-frame 'no-frame))
> (frame-list))" \
>    2>&1
>
> Another point is to provide feedback (notify-send, kdialog, zenity,
> etc.) if emacs server is not running at all (non-zero exit code of the
> shell command above). Though since Samuel is already using org-protocol,
> it should not be a problem.
>
>
>

[-- Attachment #2: Type: text/html, Size: 1857 bytes --]

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

* Re: idea for capture anywhere in x
  2020-09-08  5:21     ` Tim Cross
@ 2020-09-08  7:18       ` Maxim Nikulin
  2020-09-08  8:03         ` Diego Zamboni
  0 siblings, 1 reply; 24+ messages in thread
From: Maxim Nikulin @ 2020-09-08  7:18 UTC (permalink / raw)
  To: emacs-orgmode

08.09.2020 12:21, Tim Cross wrote:
> 
> How you add this to a window manager menu or key binding will depend on
> your window manager, but essentially, you just calling emacscleint with
> the argument -e (org-capture). You may need to quote the command to
> prevent shell interpolation of the command and you may need to add other
> arguments, such as -n or --no-wait etc.

Good point. However playing with a script for org protocol, I realized 
that there could be no emacs frame yet, so I added --create-frame 
depending on output of

emacsclient --quiet --eval \
   "(seq-some (lambda (f) (if (eq 'x (framep f)) 'has-frame 'no-frame)) 
(frame-list))" \
   2>&1

Another point is to provide feedback (notify-send, kdialog, zenity, 
etc.) if emacs server is not running at all (non-zero exit code of the 
shell command above). Though since Samuel is already using org-protocol, 
it should not be a problem.



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

* Re: idea for capture anywhere in x
  2020-09-08  5:05   ` Samuel Wales
  2020-09-08  5:21     ` Tim Cross
@ 2020-09-08  5:39     ` Maxim Nikulin
  2020-09-08 22:40       ` Samuel Wales
  2020-09-09  8:40     ` Russell Adams
  2 siblings, 1 reply; 24+ messages in thread
From: Maxim Nikulin @ 2020-09-08  5:39 UTC (permalink / raw)
  To: emacs-orgmode

08.09.2020 12:05, Samuel Wales wrote:
> well for a non-emacs application, i want to select text and capture
> using wm menu.

Do you mean a tiny tool that takes content of X primary selection or 
clipboard and passes it to emacs-client org-protocol argument? 
Implementation should have a few lines of code and should allow you to 
bind it to window manager menu or hotkeys. On the other hand I do not 
see great difference from pasting text directly to emacs. Customization 
glue (primary selection/clipboard, name of template, etc.) is thicker 
than code that do the actual job.

The harder part is extracting of formatted text (that could be 
application specific) and converting it to org markup. I had a look 
into emacs sources and did not find extension points to obtain 
application-specific format, so external tool could provide some benefit 
(e.g. capturing link with description from libreoffice).



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

* Re: idea for capture anywhere in x
  2020-09-08  5:05   ` Samuel Wales
@ 2020-09-08  5:21     ` Tim Cross
  2020-09-08  7:18       ` Maxim Nikulin
  2020-09-08  5:39     ` Maxim Nikulin
  2020-09-09  8:40     ` Russell Adams
  2 siblings, 1 reply; 24+ messages in thread
From: Tim Cross @ 2020-09-08  5:21 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode


Samuel Wales <samologist@gmail.com> writes:

> well for a non-emacs application, i want to select text and capture
> using wm menu.
>
> same thing for emacs, although it is roundabout.  i just don't know
> the code to set up context menus for every type of buffer is all.  so
> figured would just use the roundabout thing i would use for any
> non-emacs application.  this is for when keyboard cannot be used.
>
> On 9/7/20, Tim Cross <theophilusx@gmail.com> wrote:
>>
>> Samuel Wales <samologist@gmail.com> writes:
>>
>>> dunno if this is sensible, but istr you can capture using emacsclient?
>>>
>>> i really like hte org capture extension in firefox and want it for
>>> everything in x [which means emacs itself using mouse and what little
>>> else i run].
>>>
>>> my idea was, to emacsclient to call org protocol to a defined capture
>>> template just like the firefox extension.  this would be alled from
>>> the wm menu.
>>>
>>> is something like this possible?
>>
>> I don't really understand what it is your trying to do. I don't
>> understand why you would want org protocol from inside emacsclient when
>> you already have full access to capture in any emacs buffer, including
>> emacsclient? You can already start emacscleint and tell it to run a
>> command (like org-capture) and you could easily bind that to a window
>> manager shortcut or menu.
>> --
>> Tim Cross
>>
>>

You don't need org protocol for that. All you need to do is call
emacsclient with the -e or --eval argument, passing it the expression
(org-capture). This will open (on GUI) an emacs frame with the initial
org-capture buffer where you can select the template you want. Then, you
just past (yank) in whatever you have copied with the mouse.

How you add this to a window manager menu or key binding will depend on
your window manager, but essentially, you just calling emacscleint with
the argument -e (org-capture). You may need to quote the command to
prevent shell interpolation of the command and you may need to add other
arguments, such as -n or --no-wait etc. Once added to a menu or wm hot
key, you then just need to select the menu item or trigger the hotkey to
bring up emacscleint and the initial capture buffer. 
-- 
Tim Cross


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

* Re: idea for capture anywhere in x
  2020-09-08  5:01 ` Tim Cross
@ 2020-09-08  5:05   ` Samuel Wales
  2020-09-08  5:21     ` Tim Cross
                       ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Samuel Wales @ 2020-09-08  5:05 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode

well for a non-emacs application, i want to select text and capture
using wm menu.

same thing for emacs, although it is roundabout.  i just don't know
the code to set up context menus for every type of buffer is all.  so
figured would just use the roundabout thing i would use for any
non-emacs application.  this is for when keyboard cannot be used.

On 9/7/20, Tim Cross <theophilusx@gmail.com> wrote:
>
> Samuel Wales <samologist@gmail.com> writes:
>
>> dunno if this is sensible, but istr you can capture using emacsclient?
>>
>> i really like hte org capture extension in firefox and want it for
>> everything in x [which means emacs itself using mouse and what little
>> else i run].
>>
>> my idea was, to emacsclient to call org protocol to a defined capture
>> template just like the firefox extension.  this would be alled from
>> the wm menu.
>>
>> is something like this possible?
>
> I don't really understand what it is your trying to do. I don't
> understand why you would want org protocol from inside emacsclient when
> you already have full access to capture in any emacs buffer, including
> emacsclient? You can already start emacscleint and tell it to run a
> command (like org-capture) and you could easily bind that to a window
> manager shortcut or menu.
> --
> Tim Cross
>
>


-- 
The Kafka Pandemic

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


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

* Re: idea for capture anywhere in x
  2020-09-08  4:22 Samuel Wales
@ 2020-09-08  5:01 ` Tim Cross
  2020-09-08  5:05   ` Samuel Wales
  2020-09-09  1:07 ` Ihor Radchenko
  1 sibling, 1 reply; 24+ messages in thread
From: Tim Cross @ 2020-09-08  5:01 UTC (permalink / raw)
  To: emacs-orgmode


Samuel Wales <samologist@gmail.com> writes:

> dunno if this is sensible, but istr you can capture using emacsclient?
>
> i really like hte org capture extension in firefox and want it for
> everything in x [which means emacs itself using mouse and what little
> else i run].
>
> my idea was, to emacsclient to call org protocol to a defined capture
> template just like the firefox extension.  this would be alled from
> the wm menu.
>
> is something like this possible?

I don't really understand what it is your trying to do. I don't
understand why you would want org protocol from inside emacsclient when
you already have full access to capture in any emacs buffer, including
emacsclient? You can already start emacscleint and tell it to run a
command (like org-capture) and you could easily bind that to a window
manager shortcut or menu. 
-- 
Tim Cross


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

* idea for capture anywhere in x
@ 2020-09-08  4:22 Samuel Wales
  2020-09-08  5:01 ` Tim Cross
  2020-09-09  1:07 ` Ihor Radchenko
  0 siblings, 2 replies; 24+ messages in thread
From: Samuel Wales @ 2020-09-08  4:22 UTC (permalink / raw)
  To: emacs-orgmode

dunno if this is sensible, but istr you can capture using emacsclient?

i really like hte org capture extension in firefox and want it for
everything in x [which means emacs itself using mouse and what little
else i run].

my idea was, to emacsclient to call org protocol to a defined capture
template just like the firefox extension.  this would be alled from
the wm menu.

is something like this possible?

-- 
The Kafka Pandemic

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


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

end of thread, other threads:[~2022-06-13 14:14 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.51.1599580808.12104.emacs-orgmode@gnu.org>
2020-09-08 23:15 ` idea for capture anywhere in x No Wayman
2020-09-13 20:29   ` Bastien
2020-09-08  4:22 Samuel Wales
2020-09-08  5:01 ` Tim Cross
2020-09-08  5:05   ` Samuel Wales
2020-09-08  5:21     ` Tim Cross
2020-09-08  7:18       ` Maxim Nikulin
2020-09-08  8:03         ` Diego Zamboni
2020-09-08 16:08           ` Maxim Nikulin
2020-09-08  5:39     ` Maxim Nikulin
2020-09-08 22:40       ` Samuel Wales
2020-09-09  4:52         ` Maxim Nikulin
2020-09-10 14:23           ` Maxim Nikulin
2020-09-12  8:48             ` Nick Econopouly
2022-06-10  2:35               ` Samuel Wales
2022-06-10  9:59                 ` Charles Philip Chan
2022-06-11  4:11                 ` Ihor Radchenko
2022-06-13  7:46                 ` Max Nikulin
2022-06-13  9:10                 ` Michal Politowski
2022-06-13 10:04                   ` Max Nikulin
2022-06-13 14:02                     ` Michal Politowski
2020-09-09  8:40     ` Russell Adams
2020-09-09 21:11       ` Samuel Wales
2020-09-09  1:07 ` Ihor Radchenko

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