* 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ messages in thread
* 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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; 46+ 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] 46+ 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
` (4 more replies)
0 siblings, 5 replies; 46+ 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] 46+ 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
` (3 subsequent siblings)
4 siblings, 0 replies; 46+ 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] 46+ 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
` (2 subsequent siblings)
4 siblings, 0 replies; 46+ 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] 46+ 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
2022-10-09 14:47 ` Jean Louis
4 siblings, 0 replies; 46+ 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] 46+ 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
2022-10-09 14:47 ` Jean Louis
4 siblings, 1 reply; 46+ 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] 46+ 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; 46+ 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] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-06-13 10:04 ` Max Nikulin
@ 2022-06-13 14:02 ` Michal Politowski
2022-10-12 1:09 ` Samuel Wales
0 siblings, 1 reply; 46+ 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] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-06-10 2:35 ` Samuel Wales
` (3 preceding siblings ...)
2022-06-13 9:10 ` Michal Politowski
@ 2022-10-09 14:47 ` Jean Louis
2022-10-09 16:40 ` Max Nikulin
4 siblings, 1 reply; 46+ messages in thread
From: Jean Louis @ 2022-10-09 14:47 UTC (permalink / raw)
To: Samuel Wales; +Cc: Nick Econopouly, Maxim Nikulin, emacs-orgmode
* Samuel Wales <samologist@gmail.com> [2022-06-10 05:37]:
> 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.
I have basic concept to capture X selection in file and get it in
Emacs. It is not really related to Org, one can capture X selection
and record it anyhow. There is no need for org-protocol this way.
File: ~/bin/capture-x-selection.sh
#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP
emacsclient -e "(rcd-handle-x-selection)"
Settings in my IceWM window manager, in the file: ~/.icewm/keys:
key Ctrl+F9 /home/data1/protected/bin/rcd/capture-x-selection.sh
That means anywhere in X I press C-F9 and will invoke the function
'rcd-handle-x-selection
(defun rcd-handle-x-selection ()
"Sample function to read X selection from file and switch to buffer."
(raise-frame)
(let* ((my-org-files '("~/myorg1.org" "~/myorg2.org"))
(my-org-file (completing-read "Choose Org file: " my-org-files)))
(find-file my-org-file)
(goto-char (point-max))
(rcd-my-note)
(save-some-buffers t)))
(define-skeleton rcd-my-note
"Fill template by using variables"
nil
"** " (skeleton-read "Heading: ") "\n\n"
(skeleton-read "Describe this capture: ")
(when (file-exists-p "/tmp/xselection.txt")
(with-temp-buffer
(insert-file-contents "/tmp/xselection.txt")
(buffer-string)))
"\n\n")
I could as well connect it to org-protocol, but I ask myself why, as I
do not append stuff to Org files, I don't like feeling maltreated by
limitations of Org programs. 👀
Workflow:
Condition is to use Emacs server with emacsclient.
1. Mark anything in X like any selection;
2. Press your favorite key binding in the X manager like Ctrl-F9
3. Emacs appears and runs skeleton rcd-my-note which in this case does
something similar like Org, but it is not related to Org
really. One can as well make this way Markdown notes or any other
types of notes by using Emacs.
Let us say this way for Asciidoc notes:
---------------------------------------
File: ~/bin/capture-x-selection.sh
#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP
emacsclient -e "(rcd-handle-x-selection)"
Settings in my IceWM window manager, in the file: ~/.icewm/keys:
key Ctrl+F9 /home/data1/protected/bin/rcd/capture-x-selection.sh
(defun rcd-handle-x-selection ()
"Sample function to read X selection from file and switch to buffer."
(raise-frame)
(let* ((my-files '("~/mynotes1.adoc" "~/mynotes2.adoc"))
(my-file (completing-read "Choose Asciidoc file: " my-files)))
(find-file my-file)
(goto-char (point-max))
(rcd-my-note)
(save-some-buffers t)))
(define-skeleton rcd-my-note
"Fill template by using variables"
nil
"== " (skeleton-read "Heading: ") "\n\n"
(skeleton-read "Describe this capture: ")
(when (file-exists-p "/tmp/xselection.txt")
(with-temp-buffer
(insert-file-contents "/tmp/xselection.txt")
(buffer-string)))
"\n\n")
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-09 14:47 ` Jean Louis
@ 2022-10-09 16:40 ` Max Nikulin
2022-10-09 17:08 ` Jean Louis
0 siblings, 1 reply; 46+ messages in thread
From: Max Nikulin @ 2022-10-09 16:40 UTC (permalink / raw)
To: emacs-orgmode
On 09/10/2022 21:47, Jean Louis wrote:
>
> I have basic concept to capture X selection in file and get it in
> Emacs. It is not really related to Org, one can capture X selection
> and record it anyhow. There is no need for org-protocol this way.
>
> File: ~/bin/capture-x-selection.sh
>
> #!/usr/bin/bash
> TEMP=/tmp/xselection.txt
> xsel -o > $TEMP
Jean, take a breath and think several minutes on your recipe. You will
figure out that (perhaps unsafe) intermediate file is redundant. Emacs
can access text/plain target of PRIMARY_SELECTION and CLIPBOARD directly
(anyway xsel, unlike xclip, is not your friend if you need more). In
default configuration C-y yanks from CLIPBOARD, mouse middle click from
PRIMARY_SELECTION.
The idea of org-protocol is to pass more data.
Outside of Org there is e.g. remember mode (info "remember")
https://www.gnu.org/software/emacs/manual/html_mono/remember.html
You might notice remnants of org-remember in docs related to org-capture.
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-09 16:40 ` Max Nikulin
@ 2022-10-09 17:08 ` Jean Louis
2022-10-10 17:16 ` Max Nikulin
0 siblings, 1 reply; 46+ messages in thread
From: Jean Louis @ 2022-10-09 17:08 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
* Max Nikulin <manikulin@gmail.com> [2022-10-09 19:41]:
> On 09/10/2022 21:47, Jean Louis wrote:
> >
> > I have basic concept to capture X selection in file and get it in
> > Emacs. It is not really related to Org, one can capture X selection
> > and record it anyhow. There is no need for org-protocol this way.
> >
> > File: ~/bin/capture-x-selection.sh
> >
> > #!/usr/bin/bash
> > TEMP=/tmp/xselection.txt
> > xsel -o > $TEMP
>
> Jean, take a breath and think several minutes on your recipe. You will
> figure out that (perhaps unsafe) intermediate file is redundant. Emacs can
> access text/plain target of PRIMARY_SELECTION and CLIPBOARD directly (anyway
> xsel, unlike xclip, is not your friend if you need more). In default
> configuration C-y yanks from CLIPBOARD, mouse middle click from
> PRIMARY_SELECTION.
Thank you.
Directly of courseworks, but that would mean that you have to make
several clicks, not just one click. It also implies you must have
Emacs in front of you, and not sitting around as server in background
or anywhere.
You must be on window manager workspace with Emacs to capture X
selection as without Emacs in front of you, how do you invoke it in
that case?
> The idea of org-protocol is to pass more data.
It is structured data, something like '(:url "https://www.example.com"
:title "Something" :body "More here") and it may be anything in
general.
But no, I don't find it appealing in itself apart from using those
ready made browser extensions.
In fact when we speak of capturing any selection from X, I would not
like relying on Emacs, it would be better using SQLite or PostgreSQL
for that. One can define templates and forms and use some graphical
dialogs like yad, zenity, which then insert things into database.
Once in Emacs, it is easy to convert it without doing anything, to Org
or any other type of file.
Of course I don't use Org capture browser extensions to insert
anything in Org files. Not when I have it faster and better.
> Outside of Org there is e.g. remember mode (info "remember")
> https://www.gnu.org/software/emacs/manual/html_mono/remember.html
> You might notice remnants of org-remember in docs related to org-capture.
That is great simplest note taking system.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
@ 2022-10-09 20:15 Ypo
2022-10-12 9:34 ` Ihor Radchenko
0 siblings, 1 reply; 46+ messages in thread
From: Ypo @ 2022-10-09 20:15 UTC (permalink / raw)
To: bugs, Org-mode
[-- Attachment #1: Type: text/plain, Size: 565 bytes --]
What if:
1. It were easy and immediate to open in ~eww~ any web page that we are
reading in "x".
2. Once on eww we could:
a. Emphasize (markup, "highlight") the text and save the
modifications for the future. Then we could continue reading the
emphasized web page.
b. Create and send to an org headline the desired regions of text.
I remember when I was happy reading e-books on my brand new Nokia N80.
Just plain text, just enough.
Eww is far superior to my old Nokia, so it could be great to work and
process webpages for taking notes.
[-- Attachment #2: Type: text/html, Size: 1019 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-09 17:08 ` Jean Louis
@ 2022-10-10 17:16 ` Max Nikulin
2022-10-10 22:06 ` Jean Louis
0 siblings, 1 reply; 46+ messages in thread
From: Max Nikulin @ 2022-10-10 17:16 UTC (permalink / raw)
To: emacs-orgmode
On 10/10/2022 00:08, Jean Louis wrote:
> * Max Nikulin [2022-10-09 19:41]:
>> On 09/10/2022 21:47, Jean Louis wrote:
>>>
>>> File: ~/bin/capture-x-selection.sh
>>>
>>> #!/usr/bin/bash
>>> TEMP=/tmp/xselection.txt
>>> xsel -o > $TEMP
>>
>> (perhaps unsafe) intermediate file is redundant. Emacs can
>> access text/plain target of PRIMARY_SELECTION and CLIPBOARD directly
>
> Directly of courseworks, but that would mean that you have to make
> several clicks, not just one click. It also implies you must have
> Emacs in front of you, and not sitting around as server in background
> or anywhere.
Jean, make a pause and think ones more. It does not mean extra click and
implies nothing different from you recipe.
Years ago I was taught to the following approach: when you came to a
solution, look at it and try to figure out if it is possible to achieve
the same in a shorter and more clear way.
If `yank' command can get selection contents then you can do the same in
your function and avoid problems with intermediate files.
In Org it can be achieved with a simple capture template (even
org-protocol is not necessary), but you prefer your own solution having
enough limitations.
If Emacs had generic enough functions to create captures then Org would
reuse it as it extends outline mode. Maybe such tools should be added to
Emacs, but they should be designed at first.
>> The idea of org-protocol is to pass more data.
>
> It is structured data, something like '(:url "https://www.example.com"
> :title "Something" :body "More here") and it may be anything in
> general.
>
> But no, I don't find it appealing in itself apart from using those
> ready made browser extensions.
A browser extension is a straightforward way to add page URL to the
quoted text.
> In fact when we speak of capturing any selection from X, I would not
> like relying on Emacs, it would be better using SQLite or PostgreSQL
> for that.
Plain text files stored in a version control system allows to review
changes done at specific time interval. Databases require a non-trivial
layer to allow reverting of particular changes. So a database is not
better, it is *different* use case.
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-10 17:16 ` Max Nikulin
@ 2022-10-10 22:06 ` Jean Louis
2022-10-11 9:11 ` Juan Manuel Macías
2022-10-12 17:16 ` Max Nikulin
0 siblings, 2 replies; 46+ messages in thread
From: Jean Louis @ 2022-10-10 22:06 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
> Jean, make a pause and think ones more. It does not mean extra click
> and implies nothing different from you recipe.
Instead of thinking, I am doing it.
Did you try to invoke Emacs without having Emacs in front of you? Once
you try, come back and tell me how would you capture anything from X
selection into Emacs without having Emacs window in front of you.
I do not know how. My thinking stops right there.
I have four workspaces, Emacs is not on each of them.
How do I invoke Emacs without having it in front of me with just 1 key
binding?
One solution is the one which I have presented, to configure desktop
environment short cut.
Here is updated bash file, as what if server does not run? Then Emacs
has to be invoked. You see, solution is there without loading many
packages.
Problem is that Emacs will still try to load
"(rcd-handle-x-selection)" as file, so the frame remains. Solution is
to (kill-emacs) after capturing, as it was invoked because there was
no server running, it capture the note in Org file and it can exit.
#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP
# Because emacsclient has to create new frame if none exists
emacsclient -c -a "emacs -q -l /home/admin/.emacs.d/capture.el" -e "(rcd-handle-x-selection)"
(defun rcd-handle-x-selection ()
"Sample function to read X selection from file and switch to buffer."
(let* ((my-org-files '("~/myorg1.org" "~/myorg2.org"))
(my-org-file (completing-read "Choose Org file: " my-org-files)))
(find-file my-org-file)
(goto-char (point-max))
(rcd-my-note)
(save-some-buffers t)))
(define-skeleton rcd-my-note
"Fill template by using variables"
nil
"** " (skeleton-read "Heading: ") "\n\n"
(skeleton-read "Describe this capture: ")
(setq my-x
(when (file-exists-p "/tmp/xselection.txt")
(with-temp-buffer
(insert-file-contents "/tmp/xselection.txt")
(buffer-string))))
"\n\n")
(rcd-handle-x-selection)
(kill-emacs)
In fact that solution does not even need to have Emacs as server
running, emacs client may default to Emacs, without server.
1. If Emacs is in front of you, you are not in other window, so no
bothering, and you can capture selection straight. That is what you
are describing. I am describing contexts below.
2. If you are in other window, your key bindings will work on that
other window, and not on Emacs, so you first need to find Emacs and
that means using mouse or keys before you can invoke Emacs key
binding to capture anything.
3. What if there are no Emacs frames visible? Your desktop environment
shortcut will bring Emacs in front of you, provided you are running
emacs server.
4. What if you are not running Emacs server? You do not need to, it
will simply capture by invoking new Emacs instance, without loading
your init files and what else.
Desktop shortcut or key binding is not Emacs keybinding.
> Years ago I was taught to the following approach: when you came to a
> solution, look at it and try to figure out if it is possible to achieve the
> same in a shorter and more clear way.
Thanks, must be that you have better solution 👁️
> If `yank' command can get selection contents then you can do the same in
> your function and avoid problems with intermediate files.
Of course, however, for yank to work condition is that you have Emacs
in front of you. And if you wish to capture selection from other
windows, condition is that you need to use mouse to at least move
focus from other X program to Emacs and then invoke yank.
When you do not have Emacs in front of you, when you do not have
Emacs server running, that is when you can use desktop environment
shortcuts.
> In Org it can be achieved with a simple capture template (even org-protocol
> is not necessary), but you prefer your own solution having enough
> limitations.
Capturing notes shall not IMHO be limited to Org mode as that limits
users to specific lightweight markup language (Org).
> If Emacs had generic enough functions to create captures then Org would
> reuse it as it extends outline mode. Maybe such tools should be added to
> Emacs, but they should be designed at first.
The example given with skeleton function will work for any type of
files.
Though I find skeleton way too complicated for final users just as
org-capture templates. To tell that templates are simple is not
objective. Good that I don't use it.
And is THIS below for end users?
It requires thoroughly reading manual until end user can understand
that. That is not a just a simple template, it is configuration set.
Hide Org Capture Templates:
Repeat:
INS DEL Choice: Value Menu Template entry:
Keys : p
Description : Protocol
Capture Type : Value Menu Org entry
Target location: Value Menu File & Headline:
Filename : Value Menu Literal: ~/Documents/Orgnotes.org
Headline: Inbox
Template : Value Menu String: * %^{Title}
Source: %u, %c
#+BEGIN_QUOTE
%i
#+END_QUOTE
%?
Plist:
[ ] Key: :prepend t
[ ] Key: :immediate-finish t
[ ] Key: :jump-to-captured t
[ ] Key: :empty-lines 1
[ ] Key: :empty-lines-before 1
[ ] Key: :empty-lines-after 1
[ ] Key: :clock-in t
[ ] Key: :clock-keep t
[ ] Key: :clock-resume t
[ ] Key: :time-prompt t
[ ] Key: :tree-type week
[ ] Key: :unnarrowed t
[ ] Key: :table-line-pos String:
[ ] Key: :kill-buffer t
And those functions above are nothing good for end users. In general
if your sibling, parent or child can't do it, forget it.
I find such design rather misconduct of what user interface should
look like.
Good that there is plethora of normal and human friendly note taking
applifcations apart from Org, let us say such as Osmo which are
intuitive and easy to use for any person. It has 4 distinctive and
visible main features, calendar, tasks, contacts, notes. One can use
tags and categories. Cherrytree, Leoeditor, and bunch of others also
show how user interfaces shall look like. Literate programming
included.
https://www.youtube.com/results?search_query=cherrytree+editor
> A browser extension is a straightforward way to add page URL to the
> quoted text.
I don't know which quoted text you mean and how to add page URL to
quoted text.
Though I understand you wish to add some more text to your files.
In general we need more interfaces and connections between various
formats and files.
Example:
https://addons.mozilla.org/en-US/firefox/addon/websites-notes/
That extension is way quicker to add notes related to domains and
pages. It is not perfect, does not provide title, but it is quick, and
need no immediate Emacs.
Emacs has json parsing funtions built-in so export from that
application to Emacs notes, or Org mode or any kind of lightweight
markup is possible.
There is plethora of note taking applications for browser:
https://addons.mozilla.org/en-US/firefox/search/?q=notes
Many of them are very usable, beautiful, useful, handy, way faster,
with almost no configuration.
It would be useful having interfaces or conversion from their formats
like SQLite, json, to text files like Org, markdown, Asciidoc, simple
text, other databases.
> > In fact when we speak of capturing any selection from X, I would not
> > like relying on Emacs, it would be better using SQLite or PostgreSQL
> > for that.
>
> Plain text files stored in a version control system allows to review
> changes done at specific time interval.
To use version control system is non-trivial. To use Emacs is
non-trivial. Org, anything. What is trivial is to use simple
applications how they are designed on mobile devices.
Database version control is not hard, I have diff between any version
to any version and single click or automatic version storage straight
into the database. It updates my package version number as well.
Emacs: RCD Version Control system with PostgreSQL backend:
https://hyperscope.link/3/6/7/9/6/Emacs-RCD-Version-Control-system-with-PostgreSQL-backend-36796.html
> Databases require a non-trivial layer to allow reverting of
> particular changes. So a database is not better, it is *different*
> use case.
Just as it is matter of thinking and setting up version control
system, so it is thinking on how to make version control for database.
Database has tables and columns. If there is a function to update
COLUMN in TABLE having ID number, then one can run simple function to
story the entry in other database tabl before the new entry:
(rcd-vc-db-revision table column id)
Then the function does it:
(defun rcd-vc-db-revision (table column id &optional description)
"Insert database entry into RCD Version Control."
(rcd-sql-first "INSERT INTO vc (vc_table, vc_column, vc_tableid,
vc_value, vc_description)
values ($1, $2, $3, $4, $5)
RETURNING vc_id"
rcd-vc-db table column id (rcd-db-get-entry table column id rcd-vc-db) description))
It is that simple. That is much less programming then let us say RCD
which does about some thing more or less, just this time without
thinking. The surrounding functions are just few.
Statistics is also trivial:
SELECT vc_table AS "Table", vc_column AS "Most Edited Database Columns",
count(vc_table) AS "Count"
FROM vc
GROUP by vc_table, vc_column
ORDER BY "Count" DESC
LIMIT 30;
┌───────────┬──────────────────────────────┬───────┐
│ Table │ Most Edited Database Columns │ Count │
├───────────┼──────────────────────────────┼───────┤
│ hyobjects │ hyobjects_rank │ 21428 │
│ hyobjects │ hyobjects_parent │ 11155 │
│ hyobjects │ hyobjects_text │ 5424 │
│ hlinks │ hlinks_rank │ 4842 │
│ hyobjects │ hyobjects_priorities │ 3978 │
│ hyobjects │ hyobjects_name │ 3321 │
│ hyobjects │ hyobjects_actionstatuses │ 2198 │
│ people │ people_rank │ 1973 │
│ pages │ pages_content │ 1832 │
│ hyobjects │ hyobjects_link │ 1525 │
│ hlinks │ hlinks_priorities │ 1356 │
│ people │ people_lastname │ 1295 │
│ people │ people_account1 │ 1194 │
│ hlinks │ hlinks_tags │ 998 │
│ hyobjects │ hyobjects_description │ 907 │
│ people │ people_firstname │ 841 │
│ people │ people_leadsource │ 819 │
│ hyobjects │ hyobjects_hyobjectypes │ 732 │
│ hlinks │ hlinks_description │ 672 │
│ hyobjects │ hyobjects_hyobjectstatuses │ 611 │
│ hlinks │ hlinks_name │ 587 │
│ accounts │ accounts_name │ 568 │
│ people │ people_description │ 563 │
│ hlinks │ hlinks_text │ 532 │
│ hyobjects │ hyobjects_hyobjectsubtypes │ 519 │
│ hyobjects │ hyobjects_hash │ 517 │
│ people │ people_name │ 482 │
│ people │ people_introducedby │ 475 │
│ commlines │ commlines_commlinestatuses │ 454 │
│ hyobjects │ hyobjects_report │ 394 │
└───────────┴──────────────────────────────┴───────┘
I also have headings, text, properties, and each heading is in the
version control without me thinking.
Computer thinks for me.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-10 22:06 ` Jean Louis
@ 2022-10-11 9:11 ` Juan Manuel Macías
2022-10-12 1:09 ` Samuel Wales
2022-10-12 17:16 ` Max Nikulin
1 sibling, 1 reply; 46+ messages in thread
From: Juan Manuel Macías @ 2022-10-11 9:11 UTC (permalink / raw)
To: Jean Louis; +Cc: emacs-orgmode
Jean Louis writes:
> Did you try to invoke Emacs without having Emacs in front of you? Once
> you try, come back and tell me how would you capture anything from X
> selection into Emacs without having Emacs window in front of you.
>
> I do not know how. My thinking stops right there.
>
> I have four workspaces, Emacs is not on each of them.
>
> How do I invoke Emacs without having it in front of me with just 1 key
> binding?
One solution is to let Emacs be your X window manager. I'm not saying
it's "the solution" to what's being discussed in this thread (sorry for
the noise), but in my case it is. With EXWM I don't need, for example,
anything like org-protocol. Even if I want to copy/cut/paste something
inside X, I have these three simultation keys defined in EXWM:
([?\C-y] . [?\C-v])
([?\C-w] . [?\C-x])
([?\M-w] . [?\C-c])
and I can use C-y, C-w or M-w in LibreOffice, Gimp or wherever.
One more example. If I'm in the external browser I normally use when I'm
not using eww (qutebrowser), I have a simple Org-capture template to
copy a url and create an Org heading with the link. I just hit yy on
qutebrowser and, without leaving there, call org-capture (C-c c). I have
another template to download images with org-download; another to create
a heading with the information extracted from google-scholar, etc. I
mean that using EXWM these problems don't exist, because, one way or
another, you're always in Emacs.
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-06-13 14:02 ` Michal Politowski
@ 2022-10-12 1:09 ` Samuel Wales
0 siblings, 0 replies; 46+ messages in thread
From: Samuel Wales @ 2022-10-12 1:09 UTC (permalink / raw)
To: Michal Politowski; +Cc: emacs-orgmode
> 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.
thank you. i think i fixed that outside firefox now and org-capture
works. i am still trying to get through all the ideas and information
and my drafts of replies and so on and will not be able to for a
while. i greatly appreciate all the help.
org-capture [and maybe anything similar like spookfox [am i ever on
tenterhooks until that thing becomes more stable as it oloks really
good iirc] and org-protocol extensions and others] is a big deal in my
case in firefox because i only need to select and click unicorn, and
do not need to use keyboard or paste or manage windows.
> 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")'
this seems useful for non-firefox or if org-capture or mime break.
one error in my summary post: i meant url and title as normal with
org-capture in firefox not just url. but everybody figured that
possibility out from context.
the idea of being able to get url and title from outside firefox also
sounds great as a possibility for robustness. if poss.
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-11 9:11 ` Juan Manuel Macías
@ 2022-10-12 1:09 ` Samuel Wales
2022-10-15 3:40 ` Max Nikulin
0 siblings, 1 reply; 46+ messages in thread
From: Samuel Wales @ 2022-10-12 1:09 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: Jean Louis, emacs-orgmode
fools [me] rush in where angels dare to tread, but
> Did you try to invoke Emacs without having Emacs in front of you? Once
> you try, come back and tell me how would you capture anything from X
i use the firefox org-capture extension. i click on a unicorn. url
and title are saved as an org link and any selected text.
emacs correctly does not end up in the wm's [fluxbox in my case] fg,
perhaps because of my org-capture settings. so i think i can say it
all works for firefox when the extension, which i adore, works.
incidentally all my applications are maximized or full screen for
accessibility reasons so anything popping up would be bad.
incidentally i always use kb or mouse for accessibility reasons and a
mixture does not work. i can't follow up to this discussion or engage
with you in a back and forth of any kind, just saying it works.
perhaps i misunderstood your challenge and post [reasonably likely].
the thread is about doing the same thing, or as much as possible of
it, more generally in x. for any application like an xterm, deluge,
maybe even emacs itself as an external to emacs buffer mode
independent facility. perhaps without requiring a firefox extension
even, although something would presumably have to grab the url and
title behind the scenes via .mozilla files or some hyopthetical
firefox api.
On 10/11/22, Juan Manuel Macías <maciaschain@posteo.net> wrote:
> Jean Louis writes:
>
>> Did you try to invoke Emacs without having Emacs in front of you? Once
>> you try, come back and tell me how would you capture anything from X
>> selection into Emacs without having Emacs window in front of you.
>>
>> I do not know how. My thinking stops right there.
>>
>> I have four workspaces, Emacs is not on each of them.
>>
>> How do I invoke Emacs without having it in front of me with just 1 key
>> binding?
>
> One solution is to let Emacs be your X window manager. I'm not saying
> it's "the solution" to what's being discussed in this thread (sorry for
> the noise), but in my case it is. With EXWM I don't need, for example,
> anything like org-protocol. Even if I want to copy/cut/paste something
> inside X, I have these three simultation keys defined in EXWM:
>
> ([?\C-y] . [?\C-v])
> ([?\C-w] . [?\C-x])
> ([?\M-w] . [?\C-c])
>
> and I can use C-y, C-w or M-w in LibreOffice, Gimp or wherever.
>
> One more example. If I'm in the external browser I normally use when I'm
> not using eww (qutebrowser), I have a simple Org-capture template to
> copy a url and create an Org heading with the link. I just hit yy on
> qutebrowser and, without leaving there, call org-capture (C-c c). I have
> another template to download images with org-download; another to create
> a heading with the information extracted from google-scholar, etc. I
> mean that using EXWM these problems don't exist, because, one way or
> another, you're always in Emacs.
>
> Best regards,
>
> Juan Manuel
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-09 20:15 Ypo
@ 2022-10-12 9:34 ` Ihor Radchenko
2022-10-12 10:43 ` Ypo
0 siblings, 1 reply; 46+ messages in thread
From: Ihor Radchenko @ 2022-10-12 9:34 UTC (permalink / raw)
To: Ypo; +Cc: bugs, Org-mode
Ypo <ypuntot@gmail.com> writes:
> What if:
> 1. It were easy and immediate to open in ~eww~ any web page that we are
> reading in "x".
Check out org-protocol.el commentary.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 9:34 ` Ihor Radchenko
@ 2022-10-12 10:43 ` Ypo
2022-10-12 11:37 ` Ihor Radchenko
2022-10-12 14:22 ` Juan Manuel Macías
0 siblings, 2 replies; 46+ messages in thread
From: Ypo @ 2022-10-12 10:43 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: bugs, Org-mode
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
Thanks, Ihor.
But I was referring to 2 possible workflows (not sure if org-protocol
would be the answer).
The first workflow would consist in emphasizing the web page permanently:
1. Open in ~eww~ the web page.
2. Emphasize with org-mode: highlight the text of the web page.
3. In the future, when opening again the web page, the highlights should
appear.
I don't know what would be the best way to do it. The only way I know
similar to that, is using "org-web-tools-insert-web-page-as-entry".
Best regards
El 12/10/2022 a las 11:34, Ihor Radchenko escribió:
> Ypo<ypuntot@gmail.com> writes:
>
>> What if:
>> 1. It were easy and immediate to open in ~eww~ any web page that we are
>> reading in "x".
> Check out org-protocol.el commentary.
>
[-- Attachment #2: Type: text/html, Size: 2247 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 10:43 ` Ypo
@ 2022-10-12 11:37 ` Ihor Radchenko
2022-10-12 16:55 ` Jean Louis
2022-10-12 14:22 ` Juan Manuel Macías
1 sibling, 1 reply; 46+ messages in thread
From: Ihor Radchenko @ 2022-10-12 11:37 UTC (permalink / raw)
To: Ypo; +Cc: bugs, Org-mode
Ypo <ypuntot@gmail.com> writes:
> Thanks, Ihor.
>
> But I was referring to 2 possible workflows (not sure if org-protocol
> would be the answer).
I was mostly answering about X website to eww website part. org-protocol
is a way to run arbitrary Elisp when Emacs is called with an arbitrary
data (not necessarily file).
> The first workflow would consist in emphasizing the web page permanently:
>
>
> 1. Open in ~eww~ the web page.
>
> 2. Emphasize with org-mode: highlight the text of the web page.
>
> 3. In the future, when opening again the web page, the highlights should
> appear.
>
>
> I don't know what would be the best way to do it. The only way I know
> similar to that, is using "org-web-tools-insert-web-page-as-entry".
https://github.com/nobiot/org-remark might help here. However, AFAIK, it
only supports file buffers. But I do not see why they couldn't add eww
support if you ask them.
Also, I recall 25.14 Enriched Text (Emacs manual). Not sure if it is
suitable though.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 10:43 ` Ypo
2022-10-12 11:37 ` Ihor Radchenko
@ 2022-10-12 14:22 ` Juan Manuel Macías
1 sibling, 0 replies; 46+ messages in thread
From: Juan Manuel Macías @ 2022-10-12 14:22 UTC (permalink / raw)
To: Ypo; +Cc: Ihor Radchenko, bugs, Org-mode
Ypo writes:
> The first workflow would consist in emphasizing the web page
> permanently:
I think what you are looking for is something similar to what certain
extensions for firefox or chrome do, like highlighter. It's useful, but
I'd say only for static pages.
> 1. Open in ~eww~ the web page.
As long as the webpage doesn't (unfortunately) use javascript.
> 2. Emphasize with org-mode: highlight the text of the web page.
> 3. In the future, when opening again the web page, the highlights
> should appear.
It wouldn't be too hard (I think) to implement something for shr or eww,
so that overlays would be applied to highlight the text in eww-mode, and
the position info would be saved somewhere, so that eww would retrieve
it on page reload. As Ihor has recommended to you, org-remark could have
a (possible) use there. I would investigate on that side; also with
org-remark you could associate notes in org-mode.
> I don't know what would be the best way to do it. The only way I know
> similar to that, is using "org-web-tools-insert-web-page-as-entry".
It seems safer to me to save the content of a page in one way or
another, because that page may one day cease to be online. org-web-tools
is a great tool. The only drawback I find is that pandoc conversions
from html to org are not always very clean (depends on the page you want
to save). To the above could be added the possibility of highlighting
the content of the page and saving everything locally, to later read the
page offline in eww-mode.
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 11:37 ` Ihor Radchenko
@ 2022-10-12 16:55 ` Jean Louis
2022-10-12 23:14 ` Ihor Radchenko
0 siblings, 1 reply; 46+ messages in thread
From: Jean Louis @ 2022-10-12 16:55 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Ypo, Org-mode
* Ihor Radchenko <yantar92@gmail.com> [2022-10-12 14:37]:
> I was mostly answering about X website to eww website part. org-protocol
> is a way to run arbitrary Elisp when Emacs is called with an arbitrary
> data (not necessarily file).
Sounds sensational, while it is not. According to (info "(org)
Protocols") it says that data has to conform to specific URL
specification. It is a way to standardize input to Org, rather then to
general Emacs and it was meant to be used from browsers. Then the
Emacs Lisp is run according to settings in Emacs which have to match
the Org Protocol URLs, right?
Even though it was made rather for browser, it may be used in many
ways with or without browser.
Though:
Emacs has in any case the capability to accept information in various
ways and then run we could say really arbitrary Emacs lisp, as the
command line options allow it. How data is sent from external programs
may be decided, coded, prepared by such programs.
The freedom shall not be forgotten. How I see it, people may think
that Org Protocol is the only way to add information to Emacs.
Neither it is not the only way to add Org information or notes to Org
or any other type of the file.
As Org headings begin with stars, one can easily concatenate various
information from various sources and convert it to Org file.
Let us say from places.sqlite where Firefox and derivate browsers'
bookmarks are held, with one liner it may be converted to Org
headings. It is not as sophisticated.
sqlite3 places.sqlite "select '** ' || title || char(10) || char(10) || title || ': ' || url || char(10) || char(10) FROM 'moz_places';"
It will give the output like:
** Libervia
Libervia: https://salut-a-toi.org/presentation#demo
** Libervia
Libervia: https://www.libervia.org/
** Libervia register new account
Libervia register new account: https://www.libervia.org/register?redirect_url=%2F
** flatpak invalid compressed data at DuckDuckGo
flatpak invalid compressed data at DuckDuckGo: https://html.duckduckgo.com/html/?q=flatpak+invalid+compressed+data
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-10 22:06 ` Jean Louis
2022-10-11 9:11 ` Juan Manuel Macías
@ 2022-10-12 17:16 ` Max Nikulin
2022-10-12 20:06 ` Jean Louis
1 sibling, 1 reply; 46+ messages in thread
From: Max Nikulin @ 2022-10-12 17:16 UTC (permalink / raw)
To: emacs-orgmode
On 11/10/2022 05:06, Jean Louis wrote:
>> Jean, make a pause and think ones more. It does not mean extra click
>> and implies nothing different from you recipe.
>
> Instead of thinking, I am doing it.
I consider it as a problem. It is better to think at first.
> Did you try to invoke Emacs without having Emacs in front of you?
Just because actually selected text in browser may be quite different
from expectations (due to various tricks on web pages, not to mention
that JS may completely overwrite clipboard content) I prefer to see
capture result. That is why I decided to ensure that an emacs frame is
created (if no one exists yet) when I invoke capture. (Without
additional efforts from my side the frame is marked as required
attention even if it is on another virtual desktop, so I can switch to
it using a DE shortcut.) Perhaps requirement of a frame is the reason
why I avoided a kind of pitfall you have in mind.
If there is no running Emacs daemon yet, it may be started on demand
either through systemd socket activation or by
emacsclient -a "" ...
I do not see any problem here.
If you mean that Emacs can not access X selection if no frames created
yet then I agree, behavior is strange. On the other hand I do not
understand why Emacs must be in front of me. A frame may be hidden.
emacsclient -a "" --eval "(server-select-display (getenv \"DISPLAY\"))"
emacsclient --eval "(require 'org-compat)" --eval "(org-get-x-clipboard
'CLIPBOARD)"
Emacs is not "in front of me", but selection is accessible. Such kind of
action may be assigned to DE or WM shortcut so I do not see any reason
why mouse must be involved to get selection (in a way quite similar to C-y).
> Here is updated bash file,
..
>
> #!/usr/bin/bash
> TEMP=/tmp/xselection.txt
> xsel -o > $TEMP
Such way to work with temporary files is unsafe.
> Capturing notes shall not IMHO be limited to Org mode as that limits
> users to specific lightweight markup language (Org).
I do not mind, but nobody has created a more generic solution that Org
can use as a base to implement its features. That is why I wrote
>> If Emacs had generic enough functions to create captures then Org would
>> reuse it as it extends outline mode. Maybe such tools should be added to
>> Emacs, but they should be designed at first.
>> A browser extension is a straightforward way to add page URL to the
>> quoted text.
>
> I don't know which quoted text you mean and how to add page URL to
> quoted text.
I mean a note consisting of page title, page URL, and a quote with text
selected on the page. Firefox exposes URL to selection, but I consider a
browser extension as a better variant. You mentioned one extension,
another one is https://github.com/sprig/org-capture-extension/
>> Plain text files stored in a version control system allows to review
>> changes done at specific time interval.
>
> To use version control system is non-trivial. To use Emacs is
> non-trivial. Org, anything. What is trivial is to use simple
> applications how they are designed on mobile devices.
Backups, history of changes, and compatibility over decades may be
serious issues with "simple applications".
> Computer thinks for me.
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 17:16 ` Max Nikulin
@ 2022-10-12 20:06 ` Jean Louis
0 siblings, 0 replies; 46+ messages in thread
From: Jean Louis @ 2022-10-12 20:06 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
I understand that by changing habits one can do many things. Just as
user may use Emacs Window Manager, and everything is solved.
> I do not mind, but nobody has created a more generic solution that Org can
> use as a base to implement its features. That is why I wrote
Capturing information is just matter of connecting dots. Win those who
have best integration. Org is far from having best
integration. Running Emacs server is not easy. Last Emacs survey has
shown that just few users use it.
Look here the count of users:
https://addons.mozilla.org/en-US/firefox/search/?q=notes
Org Capture is 603 users, versus Firefox standard notes. Integration
is what matters.
I use this extension:
https://github.com/vifon/org-protocol-for-firefox
https://addons.mozilla.org/en-US/firefox/addon/org-protocol/
It has 45 users. It works for me without problem.
Of course I do not enter information in Org, but into PostgreSQL
database, as not to waste time and efforts later.
> > I don't know which quoted text you mean and how to add page URL to
> > quoted text.
>
> I mean a note consisting of page title, page URL, and a quote with text
> selected on the page. Firefox exposes URL to selection, but I consider a
> browser extension as a better variant. You mentioned one extension, another
> one is https://github.com/sprig/org-capture-extension/
>
> > > Plain text files stored in a version control system allows to review
> > > changes done at specific time interval.
> >
> > To use version control system is non-trivial. To use Emacs is
> > non-trivial. Org, anything. What is trivial is to use simple
> > applications how they are designed on mobile devices.
>
> Backups, history of changes, and compatibility over decades may be serious
> issues with "simple applications".
Emacs Lisp is just glue to PostgreSQL, so I never had problem with
compatibility of SQL to some newer versions, that is why there are
standards involved.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 16:55 ` Jean Louis
@ 2022-10-12 23:14 ` Ihor Radchenko
2022-10-13 11:16 ` Jean Louis
0 siblings, 1 reply; 46+ messages in thread
From: Ihor Radchenko @ 2022-10-12 23:14 UTC (permalink / raw)
To: Jean Louis; +Cc: Ypo, Org-mode
Jean Louis <bugs@gnu.support> writes:
> Emacs has in any case the capability to accept information in various
> ways and then run we could say really arbitrary Emacs lisp, as the
> command line options allow it. How data is sent from external programs
> may be decided, coded, prepared by such programs.
>
> The freedom shall not be forgotten. How I see it, people may think
> that Org Protocol is the only way to add information to Emacs.
>
> Neither it is not the only way to add Org information or notes to Org
> or any other type of the file.
This is implied. Indeed, you can put information into Emacs by many other
means, including keyword input or command line invocation.
Protocol is particularly useful when used via bookmarklets in browsers
or when you want to limit information transfer between browser and Emacs
- protocols are a subject of security policy and users might only allow
the protocol types that are known to process date in a safe way, without
danger of running arbitrary Elisp.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 23:14 ` Ihor Radchenko
@ 2022-10-13 11:16 ` Jean Louis
0 siblings, 0 replies; 46+ messages in thread
From: Jean Louis @ 2022-10-13 11:16 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Ypo, Org-mode
Dear Ihor,
Thanks, I have always such joy to get your insights.
* Ihor Radchenko <yantar92@gmail.com> [2022-10-13 02:14]:
> This is implied. Indeed, you can put information into Emacs by many other
> means, including keyword input or command line invocation.
I was rather meaning through command line, or through files, including through standard input. I get information over CGI interface over web server into Emacs into Emacs data structure such as hash, which is then encrypted and sent by email safely and automatically, and such hash may be imported. This way I use no database server like so many other web applications. That is one of ways to get input.
> Protocol is particularly useful when used via bookmarklets in browsers
That is right, that is how it was meant to be used. Now I use it to transfer notes from web browser to PostgreSQL database. Then I use Asciidoc and Org to export information in nice ordered manner.
> or when you want to limit information transfer between browser and Emacs
> - protocols are a subject of security policy and users might only allow
> the protocol types that are known to process date in a safe way, without
> danger of running arbitrary Elisp.
Let us be realistic, users if not programmers, they cannot know what their browser extension is doing, and Emacs users using org protocol are just few who know how it works.
There is no real technical security with Emacs.
We have got social security, we are good people and friends because of Emacs, that is why we have decades without many computer security problems.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 1:09 ` Samuel Wales
@ 2022-10-15 3:40 ` Max Nikulin
2022-10-26 4:40 ` Samuel Wales
0 siblings, 1 reply; 46+ messages in thread
From: Max Nikulin @ 2022-10-15 3:40 UTC (permalink / raw)
To: Samuel Wales; +Cc: Org Mode List
On 12/10/2022 08:09, Samuel Wales wrote:
>
> the thread is about doing the same thing, or as much as possible of
> it, more generally in x.
Samuel, I assume that you are quite happy with org-capture Firefox
extension.
Have you managed to setup capturing text from other applications? From
my point of view all necessary moving parts have been discussed in this
or later threads. Have you assembled them to a working solution suitable
for you?
- Window manager menu item and shortcut calling
emacsclient --eval '(org-capture nil "c")'
- Capture template that fetches X PRIMARY_SELECTION or CLIPBOARD.
- Optionally try to get formatted text and convert it from HTML to Org
using pandoc.
- Perhaps try to get window title of the active application.
What I have not tried yet is if drag&drop API may provide more details
than X selection, but I am unsure if such workflow is suitable for you.
Probably it is better to discuss code in the context of particular
applications. Despite you wish a general approach, amount of information
exposed by applications may vary. Some code may depend on Emacs version
an I am unsure which one you are using currently.
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-15 3:40 ` Max Nikulin
@ 2022-10-26 4:40 ` Samuel Wales
2022-10-26 4:58 ` Ihor Radchenko
0 siblings, 1 reply; 46+ messages in thread
From: Samuel Wales @ 2022-10-26 4:40 UTC (permalink / raw)
To: Max Nikulin; +Cc: Org Mode List
hi max, thanks.
more below.
On 10/14/22, Max Nikulin <manikulin@gmail.com> wrote:
> Samuel, I assume that you are quite happy with org-capture Firefox
> extension.
yes i rely on it and adore it.
although i always fear it breaking or silently failing, as i have
emacs in the bg behind ff when i run it and do not want to do more
mousing and inspecting to find out if worked each time.
i think last time it broke was some kind of mime stuff. i know it
also has glitches of some kind but forgot what they were.
e.g. something about it not having enough of a firefox api to
distinguish whether you have changed tabs or some such. but i ahve
not noticed any issues latelyu. but then i do not look for them.
>
> Have you managed to setup capturing text from other applications? From
> my point of view all necessary moving parts have been discussed in this
> or later threads. Have you assembled them to a working solution suitable
> for you?
no, oi have not yet. for unrelated reasons, it takes me a lot of time
to do things.
the most critical application to catpreu from is firefox itself for
which i have above org capture extension.
it looks like i can do:
>
> - Window manager menu item and shortcut calling
> emacsclient --eval '(org-capture nil "c")'
this as an item in .fluxbox/menu, for non-emacs apps.
> - Capture template that fetches X PRIMARY_SELECTION or CLIPBOARD.
with a capture template that has percents for th3ese or so?
[n.b. i still have a mysterious capture bug where it puts newlines
above capturd entries. could be me, or version issue, or both.]
btw on occasion i wnt to capture from emacs using mouse only, but not
all modes have mouse context menu.
i am always either using keybaord or using mouse never both. emacs
would be second application for capturing via mouse.
other applications are pdf displayers, deluge, urxvt, console. other
stuff is rare.
> - Optionally try to get formatted text and convert it from HTML to Org
> using pandoc.
which is intruiguing but i will keep my expectations and needs and
priority low here but would want this to be using firefox cli/emacs
api or .mozilla files rather than e.g. a curl call for privacy. i
will assume not doing this but curious about it.
> - Perhaps try to get window title of the active application.
interesting! perhaps org-capture could run lisp to call one of those
xdo type tools or so. it would take a bit ot of me to do.
>
> What I have not tried yet is if drag&drop API may provide more details
> than X selection, but I am unsure if such workflow is suitable for you.
intresting idea re details. however, drag and drop per se is
impossible for me among apps as i always maximize and it irritates me
so much within that i trid to turn off due to the effects of mistaken
mouse movements or slwo machine.
>
> Probably it is better to discuss code in the context of particular
> applications. Despite you wish a general approach, amount of information
> exposed by applications may vary. Some code may depend on Emacs version
good point. i'm assuming a little tweaking here and there might be
usful where possible for url/title or equivalent or any other stuff.
huh, gathering such might make a nce package if anybody had the same
idea and wanted to do it. maybe spookfox will get more development
and include some features like this. or the above. merely
brainstorming.
one of th reasons i suggestd this anywhere in x idea was to act as a
fallback should org-capture break.
> an I am unsure which one you are using currently.
>
old as the hills. hoping to try if poss to upgrade over next few
months/years to 26 27 28+.
[perhaps one day i will natively compile! i have super-modern lexical
binding and don't use (` bq. :) oh and although i realy like
ido/ido-hacks/id-clever-match very much i sort of eye embark and its
inter-operable gang. someday in the futre.]
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-26 4:40 ` Samuel Wales
@ 2022-10-26 4:58 ` Ihor Radchenko
2022-10-26 5:05 ` Samuel Wales
0 siblings, 1 reply; 46+ messages in thread
From: Ihor Radchenko @ 2022-10-26 4:58 UTC (permalink / raw)
To: Samuel Wales; +Cc: Max Nikulin, Org Mode List
Samuel Wales <samologist@gmail.com> writes:
> although i always fear it breaking or silently failing, as i have
> emacs in the bg behind ff when i run it and do not want to do more
> mousing and inspecting to find out if worked each time.
You may hook notifications-notify to org-capture-after-finalize-hook to
see notification when the capture is successful.
>> - Capture template that fetches X PRIMARY_SELECTION or CLIPBOARD.
>
> with a capture template that has percents for th3ese or so?
Yes. From org-capture-templates docstring:
%x Content of the X clipboard.
> btw on occasion i wnt to capture from emacs using mouse only, but not
> all modes have mouse context menu.
What about menu bar entry?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: idea for capture anywhere in x
2022-10-26 4:58 ` Ihor Radchenko
@ 2022-10-26 5:05 ` Samuel Wales
0 siblings, 0 replies; 46+ messages in thread
From: Samuel Wales @ 2022-10-26 5:05 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, Org Mode List
more below.
On 10/25/22, Ihor Radchenko <yantar92@posteo.net> wrote:
> Samuel Wales <samologist@gmail.com> writes:
>
>> although i always fear it breaking or silently failing, as i have
>> emacs in the bg behind ff when i run it and do not want to do more
>> mousing and inspecting to find out if worked each time.
>
> You may hook notifications-notify to org-capture-after-finalize-hook to
> see notification when the capture is successful.
had not heard of this. i see that it is part of a pacage called
org-notify? it would flash screen discreetly or pop up a box in a
corner that would go away soon or some such thing? sounds like it
could be reassuring if it is not obtrusive.
>
>>> - Capture template that fetches X PRIMARY_SELECTION or CLIPBOARD.
>>
>> with a capture template that has percents for th3ese or so?
>
> Yes. From org-capture-templates docstring:
>
> %x Content of the X clipboard.
>
>> btw on occasion i wnt to capture from emacs using mouse only, but not
>> all modes have mouse context menu.
>
> What about menu bar entry?
with my font size menu bar woud not be desirable. for mouse
activation which is whati wouldneed it would need to be rclick. but
thats mode specific so it sounds like a rather troublesome task to
make it work in all the poaces i'd want it to work.
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 46+ messages in thread
end of thread, other threads:[~2022-10-26 5:06 UTC | newest]
Thread overview: 46+ 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
2022-10-09 20:15 Ypo
2022-10-12 9:34 ` Ihor Radchenko
2022-10-12 10:43 ` Ypo
2022-10-12 11:37 ` Ihor Radchenko
2022-10-12 16:55 ` Jean Louis
2022-10-12 23:14 ` Ihor Radchenko
2022-10-13 11:16 ` Jean Louis
2022-10-12 14:22 ` Juan Manuel Macías
-- strict thread matches above, loose matches on Subject: below --
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
2022-10-12 1:09 ` Samuel Wales
2022-10-09 14:47 ` Jean Louis
2022-10-09 16:40 ` Max Nikulin
2022-10-09 17:08 ` Jean Louis
2022-10-10 17:16 ` Max Nikulin
2022-10-10 22:06 ` Jean Louis
2022-10-11 9:11 ` Juan Manuel Macías
2022-10-12 1:09 ` Samuel Wales
2022-10-15 3:40 ` Max Nikulin
2022-10-26 4:40 ` Samuel Wales
2022-10-26 4:58 ` Ihor Radchenko
2022-10-26 5:05 ` Samuel Wales
2022-10-12 17:16 ` Max Nikulin
2022-10-12 20:06 ` Jean Louis
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).