* 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; 69+ 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] 69+ messages in thread
* Re: idea for capture anywhere in x
2020-09-08 4:22 idea for capture anywhere in x 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ messages in thread
* Re: idea for capture anywhere in x
2020-09-08 4:22 idea for capture anywhere in x Samuel Wales
2020-09-08 5:01 ` Tim Cross
@ 2020-09-09 1:07 ` Ihor Radchenko
1 sibling, 0 replies; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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 ` idea for capture anywhere in x Max Nikulin
0 siblings, 2 replies; 69+ 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] 69+ 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 ` idea for capture anywhere in x Max Nikulin
1 sibling, 1 reply; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ messages in thread
* Re: idea for capture anywhere in x
2022-10-12 17:16 ` idea for capture anywhere in x Max Nikulin
@ 2022-10-12 20:06 ` Jean Louis
0 siblings, 0 replies; 69+ 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] 69+ 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; 69+ 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] 69+ 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; 69+ 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] 69+ 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
2022-10-27 6:33 ` Getting X selection reliably " Max Nikulin
0 siblings, 2 replies; 69+ 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] 69+ messages in thread
* Re: idea for capture anywhere in x
2022-10-26 4:58 ` Ihor Radchenko
@ 2022-10-26 5:05 ` Samuel Wales
2022-10-26 6:05 ` desktop notifications (Re: idea for capture anywhere in x) Max Nikulin
2022-10-27 6:33 ` Getting X selection reliably " Max Nikulin
1 sibling, 1 reply; 69+ 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] 69+ messages in thread
* desktop notifications (Re: idea for capture anywhere in x)
2022-10-26 5:05 ` Samuel Wales
@ 2022-10-26 6:05 ` Max Nikulin
2022-10-26 6:22 ` Samuel Wales
0 siblings, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-10-26 6:05 UTC (permalink / raw)
To: emacs-orgmode
On 26/10/2022 12:05, Samuel Wales wrote:
>
>> You may hook notifications-notify to org-capture-after-finalize-hook to
>> see notification when the capture is successful.
>
> sounds like it
> could be reassuring if it is not obtrusive.
Try the following command to get impression
notify-send "summary" "text"
Since you are using fluxbox, likely you need to add some daemon to
autostart (unless the package has an /etc/xdg/autostart entry active for
fluxbox)
apt-cache search notification-daemon
As a KDE user I can not suggest particular one. Perhaps
notification-daemon package is enough.
It is better to protect "&<>" characters as HTML entities "&" etc.
since the spec allows some basic formatting and active links.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: desktop notifications (Re: idea for capture anywhere in x)
2022-10-26 6:05 ` desktop notifications (Re: idea for capture anywhere in x) Max Nikulin
@ 2022-10-26 6:22 ` Samuel Wales
2022-10-26 7:41 ` Max Nikulin
0 siblings, 1 reply; 69+ messages in thread
From: Samuel Wales @ 2022-10-26 6:22 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
i have the daemon and the binary but notify-send "summary" "text"
seems to do nothing obvious. called from shell mode. my emacs is
maximized. so is firefox.
On 10/25/22, Max Nikulin <manikulin@gmail.com> wrote:
> On 26/10/2022 12:05, Samuel Wales wrote:
>>
>>> You may hook notifications-notify to org-capture-after-finalize-hook to
>>> see notification when the capture is successful.
>>
>> sounds like it
>> could be reassuring if it is not obtrusive.
>
> Try the following command to get impression
>
> notify-send "summary" "text"
>
> Since you are using fluxbox, likely you need to add some daemon to
> autostart (unless the package has an /etc/xdg/autostart entry active for
> fluxbox)
>
> apt-cache search notification-daemon
>
> As a KDE user I can not suggest particular one. Perhaps
> notification-daemon package is enough.
>
> It is better to protect "&<>" characters as HTML entities "&" etc.
> since the spec allows some basic formatting and active links.
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: desktop notifications (Re: idea for capture anywhere in x)
2022-10-26 6:22 ` Samuel Wales
@ 2022-10-26 7:41 ` Max Nikulin
2022-10-26 8:07 ` Samuel Wales
0 siblings, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-10-26 7:41 UTC (permalink / raw)
To: emacs-orgmode
On 26/10/2022 13:22, Samuel Wales wrote:
> i have the daemon and the binary but notify-send "summary" "text"
> seems to do nothing obvious. called from shell mode. my emacs is
> maximized. so is firefox.
Does notify-send complain (with some delay) concerning timeout during
attempt to connect to d-bus?
I have found an Eric's message recommending dunst as a notification
daemon for fluxbox.
Firefox has a fallback implementation to display notifications in the
case of d-bus failure, so it is not the best app to test their appearance.
Fluxbox released versions (e.g. from Debian and Ubuntu packages) has a
bug that may cause some applications, in particular Firefox, to be
displayed above other windows. So it may hide a notification window.
However if you have a terminal application in front of you, it should
not be your case.
I am unsure if functions from notifications.el are better than
notify-send in respect to error reporting.
Have you considered playing a tune as a notification?
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: desktop notifications (Re: idea for capture anywhere in x)
2022-10-26 7:41 ` Max Nikulin
@ 2022-10-26 8:07 ` Samuel Wales
2022-10-26 8:29 ` Max Nikulin
0 siblings, 1 reply; 69+ messages in thread
From: Samuel Wales @ 2022-10-26 8:07 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
i called notify-send from the cli in emacs shell mode running bash,
with emacs maximized as most of my apps are.
in fluxbox terminology at least, maximized means takes up the whole
screen. fullscreen would mean occupies the top.
no text result and no gui result from notify-send.
can dunst go away after a short period?
i launch dbus manually as fluxbox is not a dm
eval $(dbus-launch --sh-syntax --exit-with-session)
for context, with org-capture firefox says captured briefly but that
is no guarantee back from emacs which is why we are seeking
confirmation; i used to think it meant that it was captured but when
broken it id not capture.
unfamiliar with notifications.el. if recommended i can look into it.
plauing a sound would irritate me.
On 10/26/22, Max Nikulin <manikulin@gmail.com> wrote:
> On 26/10/2022 13:22, Samuel Wales wrote:
>> i have the daemon and the binary but notify-send "summary" "text"
>> seems to do nothing obvious. called from shell mode. my emacs is
>> maximized. so is firefox.
>
> Does notify-send complain (with some delay) concerning timeout during
> attempt to connect to d-bus?
>
> I have found an Eric's message recommending dunst as a notification
> daemon for fluxbox.
>
> Firefox has a fallback implementation to display notifications in the
> case of d-bus failure, so it is not the best app to test their appearance.
>
> Fluxbox released versions (e.g. from Debian and Ubuntu packages) has a
> bug that may cause some applications, in particular Firefox, to be
> displayed above other windows. So it may hide a notification window.
> However if you have a terminal application in front of you, it should
> not be your case.
>
> I am unsure if functions from notifications.el are better than
> notify-send in respect to error reporting.
>
> Have you considered playing a tune as a notification?
>
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: desktop notifications (Re: idea for capture anywhere in x)
2022-10-26 8:07 ` Samuel Wales
@ 2022-10-26 8:29 ` Max Nikulin
0 siblings, 0 replies; 69+ messages in thread
From: Max Nikulin @ 2022-10-26 8:29 UTC (permalink / raw)
To: emacs-orgmode
On 26/10/2022 15:07, Samuel Wales wrote:
>
> can dunst go away after a short period?
I have never tried it. Unsure if it has enough configuration options.
Does it mean that you get notification displayed? Have you tried?
notify-send --expire-time 2000 ...
> i launch dbus manually as fluxbox is not a dm
> eval $(dbus-launch --sh-syntax --exit-with-session)
I believe, notification daemon should be running is addition to d-bus
daemon. Notification daemon just register an additional interfaces on
d-bus and responsible for notification windows.
> unfamiliar with notifications.el. if recommended i can look into it.
I am unsure what is more convenient in your case to avoid shell
commands, org-notify from org-clock.el or functions from notifications.el
^ permalink raw reply [flat|nested] 69+ messages in thread
* Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-26 4:58 ` Ihor Radchenko
2022-10-26 5:05 ` Samuel Wales
@ 2022-10-27 6:33 ` Max Nikulin
2022-10-28 4:59 ` Samuel Wales
2022-11-13 4:54 ` Getting X selection reliably " Ihor Radchenko
1 sibling, 2 replies; 69+ messages in thread
From: Max Nikulin @ 2022-10-27 6:33 UTC (permalink / raw)
To: emacs-orgmode
On 26/10/2022 11:58, Ihor Radchenko wrote:
>
> Yes. From org-capture-templates docstring:
>
> %x Content of the X clipboard.
Ihor, I am afraid there are a couple of pitfalls with "%x" for Samuel
since he prefers to keep Emacs hidden so can not check result.
1. If something goes wrong, e.g. some application does not put
highlighted text to PRIMARY selection then wrong source (CLIPBOARD) or
empty string may be silently captured. I would prefer explicit source
however it will not protect against stale selection from the same source.
Simulate empty selection:
echo | xsel -bi ; echo | xsel -i ; killall xsel
2. Jean pointed out that Emacs ignores X selection if it does not have
an X frame. It was almost buried in the haystack of "SQL instead of Org"
noise. It happens if Emacs is running as a daemon. I am unsure which way
Samuel starts Emacs (xinit, systemd user session, systemd socket
activation, manually, etc.)
What I do not like that error text is captured and no error is returned
to emacsclient, so checks must be performed in advance.
My suggestion:
~/examples/org/capture-daemon.el
---- >8 ----
(defun nm-check-selection (selection)
(let ((display (org-string-nw-p (getenv "DISPLAY"))))
(if display
(server-select-display display)
(error "No DISPLAY")))
(if (org-get-x-clipboard selection)
t
(error "No %S selection" selection)))
(custom-set-variables
'(org-capture-templates
'(("x" "%x (test)" entry
(file "/tmp/capture-test.org")
"* Entry
%U
%x
"
:immediate-finish t)
("p" "primary" entry
(file "/tmp/capture-test.org")
"* Primary
%U
%(org-get-x-clipboard 'PRIMARY)
"
:immediate-finish t))))
(require 'org-capture)
---- 8< ----
emacs -Q -L ~/src/org-mode/lisp/ \
-L /usr/share/emacs/site-lisp/elpa/htmlize-1.55/ \
--daemon --load ~/examples/org/capture-daemon.el
emacsclient --eval "(nm-check-selection 'PRIMARY)" \
--eval '(org-capture nil "p")'
the latter command has non-zero exit code in the case of empty selection.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-27 6:33 ` Getting X selection reliably " Max Nikulin
@ 2022-10-28 4:59 ` Samuel Wales
2022-10-28 5:16 ` Max Nikulin
2022-11-13 4:54 ` Getting X selection reliably " Ihor Radchenko
1 sibling, 1 reply; 69+ messages in thread
From: Samuel Wales @ 2022-10-28 4:59 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
i do not use emacs daemon or systemd. have not tried running emacs
from cron i think.
i launch emacs from xinit or fluxbox menu. sometimes from a shell. i
run emacs as a cli batch thing from a shell.
[and i run emacs on linux console when nec. it is inaccessible for
reasons like blinking cursor.]
On 10/26/22, Max Nikulin <manikulin@gmail.com> wrote:
> On 26/10/2022 11:58, Ihor Radchenko wrote:
>>
>> Yes. From org-capture-templates docstring:
>>
>> %x Content of the X clipboard.
>
> Ihor, I am afraid there are a couple of pitfalls with "%x" for Samuel
> since he prefers to keep Emacs hidden so can not check result.
>
> 1. If something goes wrong, e.g. some application does not put
> highlighted text to PRIMARY selection then wrong source (CLIPBOARD) or
> empty string may be silently captured. I would prefer explicit source
> however it will not protect against stale selection from the same source.
>
> Simulate empty selection:
> echo | xsel -bi ; echo | xsel -i ; killall xsel
>
> 2. Jean pointed out that Emacs ignores X selection if it does not have
> an X frame. It was almost buried in the haystack of "SQL instead of Org"
> noise. It happens if Emacs is running as a daemon. I am unsure which way
> Samuel starts Emacs (xinit, systemd user session, systemd socket
> activation, manually, etc.)
>
> What I do not like that error text is captured and no error is returned
> to emacsclient, so checks must be performed in advance.
>
> My suggestion:
> ~/examples/org/capture-daemon.el
> ---- >8 ----
> (defun nm-check-selection (selection)
> (let ((display (org-string-nw-p (getenv "DISPLAY"))))
> (if display
> (server-select-display display)
> (error "No DISPLAY")))
> (if (org-get-x-clipboard selection)
> t
> (error "No %S selection" selection)))
>
> (custom-set-variables
> '(org-capture-templates
> '(("x" "%x (test)" entry
> (file "/tmp/capture-test.org")
> "* Entry
> %U
>
> %x
> "
> :immediate-finish t)
> ("p" "primary" entry
> (file "/tmp/capture-test.org")
> "* Primary
> %U
>
> %(org-get-x-clipboard 'PRIMARY)
> "
> :immediate-finish t))))
>
> (require 'org-capture)
> ---- 8< ----
>
> emacs -Q -L ~/src/org-mode/lisp/ \
> -L /usr/share/emacs/site-lisp/elpa/htmlize-1.55/ \
> --daemon --load ~/examples/org/capture-daemon.el
>
> emacsclient --eval "(nm-check-selection 'PRIMARY)" \
> --eval '(org-capture nil "p")'
>
> the latter command has non-zero exit code in the case of empty selection.
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-28 4:59 ` Samuel Wales
@ 2022-10-28 5:16 ` Max Nikulin
2022-10-28 8:39 ` Dr. Arne Babenhauserheide
2022-10-29 2:59 ` Ihor Radchenko
0 siblings, 2 replies; 69+ messages in thread
From: Max Nikulin @ 2022-10-28 5:16 UTC (permalink / raw)
To: emacs-orgmode
On 28/10/2022 11:59, Samuel Wales wrote:
>
> i launch emacs from xinit or fluxbox menu. sometimes from a shell. i
> run emacs as a cli batch thing from a shell.
Then you should always have an X11 Emacs frame, maybe behind other
windows, and the following command should work
emacsclient --eval '(org-capture nil "p")'
with appropriate template key name, e.g. as defined by the following
silly example:
("p" "primary" entry
(file "/tmp/capture-test.org")
"* Primary
%U
%(org-get-x-clipboard 'PRIMARY)
"
:immediate-finish t)
However to be at the safe side I would check if (org-get-x-clipboard
'PRIMARY) value is not nil at first.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-28 5:16 ` Max Nikulin
@ 2022-10-28 8:39 ` Dr. Arne Babenhauserheide
2022-10-28 16:38 ` Max Nikulin
2022-10-29 2:59 ` Ihor Radchenko
1 sibling, 1 reply; 69+ messages in thread
From: Dr. Arne Babenhauserheide @ 2022-10-28 8:39 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
Max Nikulin <manikulin@gmail.com> writes:
> Then you should always have an X11 Emacs frame, maybe behind other
> windows
This sounds like a tray application. Do you know whether something like
that already exitst (mark one frame as system tray entry)? Code the
other way round (emacs *as* system tray) seems to already exist in EXWM:
https://wiki.archlinux.org/title/EXWM#System_tray
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-28 8:39 ` Dr. Arne Babenhauserheide
@ 2022-10-28 16:38 ` Max Nikulin
2022-10-28 23:07 ` Samuel Wales
0 siblings, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-10-28 16:38 UTC (permalink / raw)
To: emacs-orgmode
On 28/10/2022 15:39, Dr. Arne Babenhauserheide wrote:
> Max Nikulin writes:
>
>> Then you should always have an X11 Emacs frame, maybe behind other
>> windows
>
> This sounds like a tray application. Do you know whether something like
> that already exitst (mark one frame as system tray entry)?
I was trying to say that Samuel should not be affected by the case when
X selection can not be obtained from Emacs due to absence of frames
(terminals) having type "x".
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-28 16:38 ` Max Nikulin
@ 2022-10-28 23:07 ` Samuel Wales
2022-10-29 3:21 ` Max Nikulin
0 siblings, 1 reply; 69+ messages in thread
From: Samuel Wales @ 2022-10-28 23:07 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
i am still lost in this and it will take me a while. although it
would be great to have everywhere, such as in emacs also with r click,
it is not a top priority for me at this time as long as the ff
org-capture extension works [i wrote the original when it did not work
for me] beecuse ff is the biggest plaec i need it and it would make a
good backup system and i hope i did not give the impression that it is
an urgent need.
as for fluxbox, it is just the .menu file and not a tray application.
pretty straightforward. :)
On 10/28/22, Max Nikulin <manikulin@gmail.com> wrote:
> On 28/10/2022 15:39, Dr. Arne Babenhauserheide wrote:
>> Max Nikulin writes:
>>
>>> Then you should always have an X11 Emacs frame, maybe behind other
>>> windows
>>
>> This sounds like a tray application. Do you know whether something like
>> that already exitst (mark one frame as system tray entry)?
>
> I was trying to say that Samuel should not be affected by the case when
> X selection can not be obtained from Emacs due to absence of frames
> (terminals) having type "x".
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-28 5:16 ` Max Nikulin
2022-10-28 8:39 ` Dr. Arne Babenhauserheide
@ 2022-10-29 2:59 ` Ihor Radchenko
2022-10-29 3:30 ` Max Nikulin
2022-10-29 4:50 ` Samuel Wales
1 sibling, 2 replies; 69+ messages in thread
From: Ihor Radchenko @ 2022-10-29 2:59 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> %(org-get-x-clipboard 'PRIMARY)
> "
> :immediate-finish t)
>
> However to be at the safe side I would check if (org-get-x-clipboard
> 'PRIMARY) value is not nil at first.
My approach to this is simply showing a popup with captured heading
after capture. If anything is wrong, I can quickly notice.
Not sure if it is suitable for Samuel 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] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-28 23:07 ` Samuel Wales
@ 2022-10-29 3:21 ` Max Nikulin
0 siblings, 0 replies; 69+ messages in thread
From: Max Nikulin @ 2022-10-29 3:21 UTC (permalink / raw)
To: emacs-orgmode
On 29/10/2022 06:07, Samuel Wales wrote:
> i am still lost in this and it will take me a while.
..
> it is not a top priority for me at this time as long as the ff
> org-capture extension works
Samuel, feel free came back with this question when you will have enough
spare time and motivation to continue. Currently I am unsure with which
pieces of the puzzle you still have difficulties.
I would separate the following cases:
- Emacs
- Application having dedicated plugins (Firefox works if I got it right)
- Other applications
As to Emacs, perhaps emacs-help mailing list is the appropriate place to
ask how to add global mouse action. E.g. is it possible to add a button
to modeline? If I am not mistaken, Emacs-28 has an option to enable
right click menu similar to other applications.
For other applications, since you have a requirement of maximized
application window and purely mouse action, I am unsure if you managed
to configure fluxbox to add a custom menu entry accessible in such
layout. By default only window and toolbar menu are available.
A tiny custom application displaying a tray icon might be a way to
initiate capture through mouse click. Unsure if Emacs can add such icon.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-29 2:59 ` Ihor Radchenko
@ 2022-10-29 3:30 ` Max Nikulin
2022-10-29 6:03 ` Samuel Wales
2022-10-29 4:50 ` Samuel Wales
1 sibling, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-10-29 3:30 UTC (permalink / raw)
To: emacs-orgmode
On 29/10/2022 09:59, Ihor Radchenko wrote:
> Max Nikulin writes:
>
>> %(org-get-x-clipboard 'PRIMARY)
>> "
>> :immediate-finish t)
>>
>> However to be at the safe side I would check if (org-get-x-clipboard
>> 'PRIMARY) value is not nil at first.
>
> My approach to this is simply showing a popup with captured heading
> after capture. If anything is wrong, I can quickly notice.
>
> Not sure if it is suitable for Samuel though.
I started with a small wrapper that checks if Emacs server is running
and creates a new frame if it does not exist yet. So I avoided a pitfall
with empty string instead of selection. I intentionally do not use
:immediate-finish to inspect capture and to add some comment.
Samuel wish to have minimal distraction: no sound, no popup window,
Emacs window is not raised in front of current application, visual
notification should disappear after some pause.
That is why I believe that additional checks are required in such silent
workflow to avoid missed data in notes.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-29 2:59 ` Ihor Radchenko
2022-10-29 3:30 ` Max Nikulin
@ 2022-10-29 4:50 ` Samuel Wales
2022-10-29 4:59 ` Ihor Radchenko
1 sibling, 1 reply; 69+ messages in thread
From: Samuel Wales @ 2022-10-29 4:50 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
not sure i am following everything but it seems a popup that goes away
after a very short period of time shows adequately that first contact
was made with emacs. then, including the captured text shows that
there isn't another issue?
On 10/28/22, Ihor Radchenko <yantar92@posteo.net> wrote:
> Max Nikulin <manikulin@gmail.com> writes:
>
>> %(org-get-x-clipboard 'PRIMARY)
>> "
>> :immediate-finish t)
>>
>> However to be at the safe side I would check if (org-get-x-clipboard
>> 'PRIMARY) value is not nil at first.
>
> My approach to this is simply showing a popup with captured heading
> after capture. If anything is wrong, I can quickly notice.
>
> Not sure if it is suitable for Samuel 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>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-29 4:50 ` Samuel Wales
@ 2022-10-29 4:59 ` Ihor Radchenko
2022-10-29 7:44 ` desktop notifications " Max Nikulin
0 siblings, 1 reply; 69+ messages in thread
From: Ihor Radchenko @ 2022-10-29 4:59 UTC (permalink / raw)
To: Samuel Wales; +Cc: Max Nikulin, emacs-orgmode
Samuel Wales <samologist@gmail.com> writes:
> not sure i am following everything but it seems a popup that goes away
> after a very short period of time shows adequately that first contact
> was made with emacs. then, including the captured text shows that
> there isn't another issue?
Let me elaborate.
What I have in mind is org-capture-before-finalize-hook.
Functions in this hook is executed at the end of the capture process
before the capture buffer is killed. You may reasonably assume that the
capture is successful if the hook is run.
Functions in org-capture-before-finalize-hook have access to the
contents of the capture buffer text. So, one can call `start-process' to
run notify-send shell command and put the actual captured text into the
notification (displayed briefly or for longer time according to the
switches passed to notify-send).
When notify-send displays notification, you can quickly eyeball if the
captured text is what you intended to capture without opening Emacs.
Hope it is more clear.
--
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] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-29 3:30 ` Max Nikulin
@ 2022-10-29 6:03 ` Samuel Wales
2022-10-29 7:33 ` Max Nikulin
2022-10-29 22:33 ` Samuel Wales
0 siblings, 2 replies; 69+ messages in thread
From: Samuel Wales @ 2022-10-29 6:03 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
if what we are talking about is checking the text or metadata as org
capture or emacs understands it against what we are capturing in a
maximized application, by means of a popup and a human [myself], then:
i'd say an emacs frame popping up over the application [whether the
application is emacs or firefox or whatever] as just another frame for
my normal emacs [which has some degree of optimization for ergo and
accessibiity], but frame shrunk to fit the text, would actually be
preferable to a separate popup application/notifier tool [which would
require unfamiliar configuration and might not even be ergo or
accessible or portable/lts], provided that it goes away after a
configured delay, and does not require the keyboard or the mouse to
make it go away. so an emacs frame is not a bad idea, just has to be
done right. i think.
> For other applications, since you have a requirement of maximized application window and purely mouse action, I am
unsure if you managed to configure fluxbox to add a custom menu entry
accessible in such layout.
fluxbox is the only wm or de that seems to do everything i need. in
this case, it is quite straightforward for me [or else i have put out
of my mind any annoyance at previous years' efforts in making it
work].
what it does is have a bar that drops down when mouse pointer hits top
edge of window. this only works if the application is maximized or
normalized rather than fullscreen in fluxbox's terminology. and that
is the case for everything i'd need to capture. the only fullscreen
apps i have are video players, and idk what the point of fullscreen is
but with video players they seem to get fit to screen right then as
opposed to having the video extend off teh edge of the screen or be
tiny or whatever. i do not need to capture from vlc or mpv.
[although a super-fancy doug englebart demo type of pov might have me
grabbing a few minutes of video and capturing it and then speech to
text from the video and metadata would be captured but i am not
holding my breath or expecting that.]
then rclick on that fluxbox bar drops down a fluxbox menu of highly
useful things, which i can add a line to in .fluxbox/.menu to add one.
usually shell commands. and also various fluxbox items like maximize
and close. and menus i never use courtesy of fluxbox and debian]. it
is copacetic. except for one rather annoying bug, which is that the
bar stays there if i select anything from that manu, so i have to move
pointer to the top again and then back to make it go away again. i
gave up trying to fix that bug, wish it could be fixed. but adding a
menu item is for me trivial. so that part is not part of the problem.
i just open .menu and cargo cult a line that says capture.
On 10/28/22, Max Nikulin <manikulin@gmail.com> wrote:
> On 29/10/2022 09:59, Ihor Radchenko wrote:
>> Max Nikulin writes:
>>
>>> %(org-get-x-clipboard 'PRIMARY)
>>> "
>>> :immediate-finish t)
>>>
>>> However to be at the safe side I would check if (org-get-x-clipboard
>>> 'PRIMARY) value is not nil at first.
>>
>> My approach to this is simply showing a popup with captured heading
>> after capture. If anything is wrong, I can quickly notice.
>>
>> Not sure if it is suitable for Samuel though.
>
> I started with a small wrapper that checks if Emacs server is running
> and creates a new frame if it does not exist yet. So I avoided a pitfall
> with empty string instead of selection. I intentionally do not use
> :immediate-finish to inspect capture and to add some comment.
>
> Samuel wish to have minimal distraction: no sound, no popup window,
> Emacs window is not raised in front of current application, visual
> notification should disappear after some pause.
>
> That is why I believe that additional checks are required in such silent
> workflow to avoid missed data in notes.
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-29 6:03 ` Samuel Wales
@ 2022-10-29 7:33 ` Max Nikulin
2022-10-29 22:33 ` Samuel Wales
1 sibling, 0 replies; 69+ messages in thread
From: Max Nikulin @ 2022-10-29 7:33 UTC (permalink / raw)
To: emacs-orgmode
On 29/10/2022 13:03, Samuel Wales wrote:
>
> fluxbox is the only wm or de that seems to do everything i need.
Then you should have no problem to call `org-capture' using emacsclient
as a menu entry action. Does it work for you? From my point of view
"capture anywhere in x" task should be roughly solved. The following
steps may be necessary to polish the approach and to make it reliable.
P.S. I forgot to post a link to a fluxbox bug that was quite annoying
for me when I was trying to test something in a lightweight environment.
I had to rebuild fluxbox package with an additional patch:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=743772
Cannot move Gnome 3.12 applications
^ permalink raw reply [flat|nested] 69+ messages in thread
* desktop notifications (Re: idea for capture anywhere in x)
2022-10-29 4:59 ` Ihor Radchenko
@ 2022-10-29 7:44 ` Max Nikulin
2022-10-29 23:07 ` Samuel Wales
0 siblings, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-10-29 7:44 UTC (permalink / raw)
To: emacs-orgmode
On 29/10/2022 11:59, Ihor Radchenko wrote:
>
> Functions in org-capture-before-finalize-hook have access to the
> contents of the capture buffer text. So, one can call `start-process' to
> run notify-send shell command and put the actual captured text into the
> notification (displayed briefly or for longer time according to the
> switches passed to notify-send).
I like this idea. Reading your message from Sat, 29 Oct 2022 02:59:51
+0000 I decided that for yourself you set up an Emacs frame as a pop-up
to display capture result. However I believe it is better to use either
org-clock or Emacs notify functions directly instead of notify-send tool.
Samuel, I suggested notify-send tool as a means to debug notifications
in isolation (without `org-capture'). Have you managed to configure
notification-daemon, dunst or some other alternative to get acceptable
appearance and proper timeout before notification disappears.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-29 6:03 ` Samuel Wales
2022-10-29 7:33 ` Max Nikulin
@ 2022-10-29 22:33 ` Samuel Wales
1 sibling, 0 replies; 69+ messages in thread
From: Samuel Wales @ 2022-10-29 22:33 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
i am still slightly lost [varying cognitive issues] but wanted to make
one correction. i think i have my capture set up so that my typical
capture location shows, although it is underneath ff so cannot be seen
at the time. so a new frame in many cases is not necessary; the
existing emacs frame could pop up for a brief period in principle.
not much of a correction but there it is.
On 10/28/22, Samuel Wales <samologist@gmail.com> wrote:
> if what we are talking about is checking the text or metadata as org
> capture or emacs understands it against what we are capturing in a
> maximized application, by means of a popup and a human [myself], then:
>
> i'd say an emacs frame popping up over the application [whether the
> application is emacs or firefox or whatever] as just another frame for
> my normal emacs [which has some degree of optimization for ergo and
> accessibiity], but frame shrunk to fit the text, would actually be
> preferable to a separate popup application/notifier tool [which would
> require unfamiliar configuration and might not even be ergo or
> accessible or portable/lts], provided that it goes away after a
> configured delay, and does not require the keyboard or the mouse to
> make it go away. so an emacs frame is not a bad idea, just has to be
> done right. i think.
>
>> For other applications, since you have a requirement of maximized
>> application window and purely mouse action, I am
> unsure if you managed to configure fluxbox to add a custom menu entry
> accessible in such layout.
>
> fluxbox is the only wm or de that seems to do everything i need. in
> this case, it is quite straightforward for me [or else i have put out
> of my mind any annoyance at previous years' efforts in making it
> work].
>
> what it does is have a bar that drops down when mouse pointer hits top
> edge of window. this only works if the application is maximized or
> normalized rather than fullscreen in fluxbox's terminology. and that
> is the case for everything i'd need to capture. the only fullscreen
> apps i have are video players, and idk what the point of fullscreen is
> but with video players they seem to get fit to screen right then as
> opposed to having the video extend off teh edge of the screen or be
> tiny or whatever. i do not need to capture from vlc or mpv.
> [although a super-fancy doug englebart demo type of pov might have me
> grabbing a few minutes of video and capturing it and then speech to
> text from the video and metadata would be captured but i am not
> holding my breath or expecting that.]
>
> then rclick on that fluxbox bar drops down a fluxbox menu of highly
> useful things, which i can add a line to in .fluxbox/.menu to add one.
> usually shell commands. and also various fluxbox items like maximize
> and close. and menus i never use courtesy of fluxbox and debian]. it
> is copacetic. except for one rather annoying bug, which is that the
> bar stays there if i select anything from that manu, so i have to move
> pointer to the top again and then back to make it go away again. i
> gave up trying to fix that bug, wish it could be fixed. but adding a
> menu item is for me trivial. so that part is not part of the problem.
> i just open .menu and cargo cult a line that says capture.
>
>
> On 10/28/22, Max Nikulin <manikulin@gmail.com> wrote:
>> On 29/10/2022 09:59, Ihor Radchenko wrote:
>>> Max Nikulin writes:
>>>
>>>> %(org-get-x-clipboard 'PRIMARY)
>>>> "
>>>> :immediate-finish t)
>>>>
>>>> However to be at the safe side I would check if (org-get-x-clipboard
>>>> 'PRIMARY) value is not nil at first.
>>>
>>> My approach to this is simply showing a popup with captured heading
>>> after capture. If anything is wrong, I can quickly notice.
>>>
>>> Not sure if it is suitable for Samuel though.
>>
>> I started with a small wrapper that checks if Emacs server is running
>> and creates a new frame if it does not exist yet. So I avoided a pitfall
>> with empty string instead of selection. I intentionally do not use
>> :immediate-finish to inspect capture and to add some comment.
>>
>> Samuel wish to have minimal distraction: no sound, no popup window,
>> Emacs window is not raised in front of current application, visual
>> notification should disappear after some pause.
>>
>> That is why I believe that additional checks are required in such silent
>> workflow to avoid missed data in notes.
>>
>>
>>
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: desktop notifications (Re: idea for capture anywhere in x)
2022-10-29 7:44 ` desktop notifications " Max Nikulin
@ 2022-10-29 23:07 ` Samuel Wales
2022-10-30 4:49 ` Ihor Radchenko
0 siblings, 1 reply; 69+ messages in thread
From: Samuel Wales @ 2022-10-29 23:07 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
i am lost in a sea of partial solutions and hints that myb rain cannot
process at this time, despite their straightforwardness. i do like
the idea of having confidence that a capture worked thgouh very much.
perhaps some fuction in org-capture-before-finalize-hook could raise
emacs for a tiny period of time or something, in the case that it is
invoked when emacs is not visible. if so, and idk if poss, i would
have to try it to find out if it wfm.
then i wouldn't hafe to keep trying notification tools ad try to get
them to have sufficient fonts colors sizes etc. and work. :)
On 10/29/22, Max Nikulin <manikulin@gmail.com> wrote:
> On 29/10/2022 11:59, Ihor Radchenko wrote:
>>
>> Functions in org-capture-before-finalize-hook have access to the
>> contents of the capture buffer text. So, one can call `start-process' to
>> run notify-send shell command and put the actual captured text into the
>> notification (displayed briefly or for longer time according to the
>> switches passed to notify-send).
>
> I like this idea. Reading your message from Sat, 29 Oct 2022 02:59:51
> +0000 I decided that for yourself you set up an Emacs frame as a pop-up
> to display capture result. However I believe it is better to use either
> org-clock or Emacs notify functions directly instead of notify-send tool.
>
> Samuel, I suggested notify-send tool as a means to debug notifications
> in isolation (without `org-capture'). Have you managed to configure
> notification-daemon, dunst or some other alternative to get acceptable
> appearance and proper timeout before notification disappears.
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: desktop notifications (Re: idea for capture anywhere in x)
2022-10-29 23:07 ` Samuel Wales
@ 2022-10-30 4:49 ` Ihor Radchenko
0 siblings, 0 replies; 69+ messages in thread
From: Ihor Radchenko @ 2022-10-30 4:49 UTC (permalink / raw)
To: Samuel Wales; +Cc: Max Nikulin, emacs-orgmode
Samuel Wales <samologist@gmail.com> writes:
> perhaps some fuction in org-capture-before-finalize-hook could raise
> emacs for a tiny period of time or something, in the case that it is
> invoked when emacs is not visible. if so, and idk if poss, i would
> have to try it to find out if it wfm.
>
> then i wouldn't hafe to keep trying notification tools ad try to get
> them to have sufficient fonts colors sizes etc. and work. :)
I use the following code to raise helm frames:
*** Run/search menu via Emacs helm
#launcher #runner
Inspired by [[id:Mattduckemacs_as_fuzzy_launc_and_alfred_replac6c6][[Mattduck] Emacs as a fuzzy launcher and Alfred-replacement]]
#+begin_src bash :tangle ~/.local/bin/emacs-helm-menu :shebang #!/bin/bash
if [[ "$(getactvwindclass)" == "emacs.Emacs" ]]; then
# Relies on my key bindings
xdotool key --clearmodifiers --delay 60 alt+l e h;
# release any pressed modifiers
xdotool keyup super alt ctrl shift
else
emacsclient -c --frame-parameters="((title . \"Helm frame\") (unsplittable . t))" -e "(let ((inhibit-message t) (helm-full-frame t) (helm-use-undecorated-frame-option nil)) (catch :quit (yant/helm-org-ql-agenda-files nil) (when (= 0 helm-exit-status) (let ((fr (selected-frame))) (make-frame) (delete-frame fr))) (unless (= 0 helm-exit-status) (user-error \"%s\" \"Exit frame\"))))";
fi
#+end_src
You may be interesteed in the --frame-parameters argument to
emacsclient. Similar alist can be passed to `make-frame' from Elisp.
You can refer to 30.4.3 Window Frame Parameters section of Elisp manual.
--
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] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-10-27 6:33 ` Getting X selection reliably " Max Nikulin
2022-10-28 4:59 ` Samuel Wales
@ 2022-11-13 4:54 ` Ihor Radchenko
2022-11-13 11:03 ` Max Nikulin
1 sibling, 1 reply; 69+ messages in thread
From: Ihor Radchenko @ 2022-11-13 4:54 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> On 26/10/2022 11:58, Ihor Radchenko wrote:
>>
>> Yes. From org-capture-templates docstring:
>>
>> %x Content of the X clipboard.
>
> Ihor, I am afraid there are a couple of pitfalls with "%x" for Samuel
> since he prefers to keep Emacs hidden so can not check result.
>
> 1. If something goes wrong, e.g. some application does not put
> highlighted text to PRIMARY selection then wrong source (CLIPBOARD) or
> empty string may be silently captured. I would prefer explicit source
> however it will not protect against stale selection from the same source.
>
> Simulate empty selection:
> echo | xsel -bi ; echo | xsel -i ; killall xsel
I am unsure what can be done here. AFAIU, Org just follows the %x
description. Nothing wrong on Org side.
The best we can do is alternative %?? that will do something more
reliable. But I am unsure what it can be.
> 2. Jean pointed out that Emacs ignores X selection if it does not have
> an X frame. It was almost buried in the haystack of "SQL instead of Org"
> noise. It happens if Emacs is running as a daemon. I am unsure which way
> Samuel starts Emacs (xinit, systemd user session, systemd socket
> activation, manually, etc.)
May we modify org-get-x-clipboard adding
(server-select-display (getenv \"DISPLAY\")) ?
Will it be enough?
--
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] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-11-13 4:54 ` Getting X selection reliably " Ihor Radchenko
@ 2022-11-13 11:03 ` Max Nikulin
2022-11-14 2:06 ` Ihor Radchenko
0 siblings, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-11-13 11:03 UTC (permalink / raw)
To: emacs-orgmode
On 13/11/2022 11:54, Ihor Radchenko wrote:
> Max Nikulin writes:
>> On 26/10/2022 11:58, Ihor Radchenko wrote:
>>>
>>> Yes. From org-capture-templates docstring:
>>>
>>> %x Content of the X clipboard.
>>
>> Ihor, I am afraid there are a couple of pitfalls with "%x" for Samuel
>> since he prefers to keep Emacs hidden so can not check result.
>>
>> 1. If something goes wrong, e.g. some application does not put
>> highlighted text to PRIMARY selection then wrong source (CLIPBOARD) or
>> empty string may be silently captured. I would prefer explicit source
>> however it will not protect against stale selection from the same source.
>>
>> Simulate empty selection:
>> echo | xsel -bi ; echo | xsel -i ; killall xsel
>
> I am unsure what can be done here. AFAIU, Org just follows the %x
> description. Nothing wrong on Org side.
>
> The best we can do is alternative %?? that will do something more
> reliable. But I am unsure what it can be.
Depending of particular capture template (even with :immediate-finish t)
empty selection may or may not be an error. In Samuel's case it is an
error. Unfortunately, while the template is processed, signaled errors
are caught and their text is inserted into the text. That is why in my
example I put checks outside of `org-capture'.
We may:
- Add a capture template option that allows errors to pass through to
the caller. Then a user may add %(...) expression with all necessary checks.
- Add a warning note to "%x" or :immediate-finish docs to make users
aware of possible pitfall.
>> 2. Jean pointed out that Emacs ignores X selection if it does not have
>> an X frame. It was almost buried in the haystack of "SQL instead of Org"
>> noise. It happens if Emacs is running as a daemon. I am unsure which way
>> Samuel starts Emacs (xinit, systemd user session, systemd socket
>> activation, manually, etc.)
>
> May we modify org-get-x-clipboard adding
> (server-select-display (getenv \"DISPLAY\")) ?
> Will it be enough?
It will work for most of users, however sometimes it is incorrect. There
are a number of options that should have higher priority than emacs
server DISPLAY environment
- emacsclient -display command line option,
- emacsclient process DISPLAY environment,
- emacs -display server argument.
I have no idea how to get "emacs -display" argument and I need to look
into emacsclient source and server.el to figure out which way client's
display argument is passed to the server process.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-11-13 11:03 ` Max Nikulin
@ 2022-11-14 2:06 ` Ihor Radchenko
2022-11-16 4:03 ` Samuel Wales
2022-12-04 5:21 ` Getting X selection reliably (Re: idea for capture anywhere in x) Max Nikulin
0 siblings, 2 replies; 69+ messages in thread
From: Ihor Radchenko @ 2022-11-14 2:06 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
>> I am unsure what can be done here. AFAIU, Org just follows the %x
>> description. Nothing wrong on Org side.
>>
>> The best we can do is alternative %?? that will do something more
>> reliable. But I am unsure what it can be.
>
> Depending of particular capture template (even with :immediate-finish t)
> empty selection may or may not be an error. In Samuel's case it is an
> error. Unfortunately, while the template is processed, signaled errors
> are caught and their text is inserted into the text. That is why in my
> example I put checks outside of `org-capture'.
Are you sure? `org-get-x-clipboard' returns nil in case of error and
`org-capture-fill-template' assigns empty string to v-x when no
clipboard value can be obtained.
> We may:
> - Add a capture template option that allows errors to pass through to
> the caller. Then a user may add %(...) expression with all necessary checks.
I am not very sure what kind of errors you are talking about. AFAIU, we
are talking about scenarios when user explicitly wants one of
PRIMARY/CLIPBOARD/SECONDARY, don't we?
>>> 2. Jean pointed out that Emacs ignores X selection if it does not have
>>> an X frame. It was almost buried in the haystack of "SQL instead of Org"
>>> noise. It happens if Emacs is running as a daemon. I am unsure which way
>>> Samuel starts Emacs (xinit, systemd user session, systemd socket
>>> activation, manually, etc.)
>>
>> May we modify org-get-x-clipboard adding
>> (server-select-display (getenv \"DISPLAY\")) ?
>> Will it be enough?
>
> It will work for most of users, however sometimes it is incorrect. There
> are a number of options that should have higher priority than emacs
> server DISPLAY environment
> - emacsclient -display command line option,
> - emacsclient process DISPLAY environment,
> - emacs -display server argument.
>
> I have no idea how to get "emacs -display" argument and I need to look
> into emacsclient source and server.el to figure out which way client's
> display argument is passed to the server process.
Maybe it can be considered an Emacs bug or something to improve on Emacs
side?
--
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] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-11-14 2:06 ` Ihor Radchenko
@ 2022-11-16 4:03 ` Samuel Wales
2022-11-16 16:46 ` Debugging firefox extension " Max Nikulin
2022-11-17 7:18 ` Getting X selection reliably " Jean Louis
2022-12-04 5:21 ` Getting X selection reliably (Re: idea for capture anywhere in x) Max Nikulin
1 sibling, 2 replies; 69+ messages in thread
From: Samuel Wales @ 2022-11-16 4:03 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
idk if related to this thread, but i sure do appreciate the effor in
this thread to solve such problems. it is a key feature for me
because i am often in mouse-only mode. it is thus a constant concern
that org-capture could stop working etc.
right now, it seems org-capture is broken for me again. clicking on
unicorn results in the momentary captured indication in huge text on
the screen [i like this indicator], but it does not get captured to my
org capture target.
this is with or without selecting any text.
could a kind soul remind me how to debug this again?
i have made no changes to my capture template or code in a very long
time. i don't think firefox-esr has updated recently.
On 11/13/22, Ihor Radchenko <yantar92@posteo.net> wrote:
> Max Nikulin <manikulin@gmail.com> writes:
>
>>> I am unsure what can be done here. AFAIU, Org just follows the %x
>>> description. Nothing wrong on Org side.
>>>
>>> The best we can do is alternative %?? that will do something more
>>> reliable. But I am unsure what it can be.
>>
>> Depending of particular capture template (even with :immediate-finish t)
>> empty selection may or may not be an error. In Samuel's case it is an
>> error. Unfortunately, while the template is processed, signaled errors
>> are caught and their text is inserted into the text. That is why in my
>> example I put checks outside of `org-capture'.
>
> Are you sure? `org-get-x-clipboard' returns nil in case of error and
> `org-capture-fill-template' assigns empty string to v-x when no
> clipboard value can be obtained.
>
>> We may:
>> - Add a capture template option that allows errors to pass through to
>> the caller. Then a user may add %(...) expression with all necessary
>> checks.
>
> I am not very sure what kind of errors you are talking about. AFAIU, we
> are talking about scenarios when user explicitly wants one of
> PRIMARY/CLIPBOARD/SECONDARY, don't we?
>
>>>> 2. Jean pointed out that Emacs ignores X selection if it does not have
>>>> an X frame. It was almost buried in the haystack of "SQL instead of
>>>> Org"
>>>> noise. It happens if Emacs is running as a daemon. I am unsure which
>>>> way
>>>> Samuel starts Emacs (xinit, systemd user session, systemd socket
>>>> activation, manually, etc.)
>>>
>>> May we modify org-get-x-clipboard adding
>>> (server-select-display (getenv \"DISPLAY\")) ?
>>> Will it be enough?
>>
>> It will work for most of users, however sometimes it is incorrect. There
>> are a number of options that should have higher priority than emacs
>> server DISPLAY environment
>> - emacsclient -display command line option,
>> - emacsclient process DISPLAY environment,
>> - emacs -display server argument.
>>
>> I have no idea how to get "emacs -display" argument and I need to look
>> into emacsclient source and server.el to figure out which way client's
>> display argument is passed to the server process.
>
> Maybe it can be considered an Emacs bug or something to improve on Emacs
> side?
>
> --
> 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] 69+ messages in thread
* Debugging firefox extension (Re: idea for capture anywhere in x)
2022-11-16 4:03 ` Samuel Wales
@ 2022-11-16 16:46 ` Max Nikulin
2022-11-17 3:16 ` Samuel Wales
2022-11-17 7:18 ` Getting X selection reliably " Jean Louis
1 sibling, 1 reply; 69+ messages in thread
From: Max Nikulin @ 2022-11-16 16:46 UTC (permalink / raw)
To: emacs-orgmode
On 16/11/2022 11:03, Samuel Wales wrote:
>
> right now, it seems org-capture is broken for me again. clicking on
> unicorn results in the momentary captured indication in huge text on
> the screen [i like this indicator], but it does not get captured to my
> org capture target.
Since recently we were discussing desktop notifications and temporary
rising emacs window, I am unsure if capture indication is related to the
firefox extension, notification daemon, or emacs.
> this is with or without selecting any text.
>
> could a kind soul remind me how to debug this again?
Max Nikulin. Re: org-capture firefox extension broken [silently] Sat, 11
Jun 2022 09:30:11 +0700.
https://list.orgmode.org/t80unm$7ud$1@ciao.gmane.io and the earlier
message https://list.orgmode.org/t7vdnm$ddo$1@ciao.gmane.io
Launching org-protocol handler from browser is unreliable, there is
almost no way to detect an error. One indirect technique relies on
switching focus from firefox to another application, but it is not
applicable for your workflow.
More robust approach is a native messaging application that is a bridge
between sandboxed firefox extension and emacs. It makes setup more
complicated however and no simple org-protocol extensions use this approach.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Debugging firefox extension (Re: idea for capture anywhere in x)
2022-11-16 16:46 ` Debugging firefox extension " Max Nikulin
@ 2022-11-17 3:16 ` Samuel Wales
2022-11-17 9:42 ` Jean Louis
2022-11-17 16:12 ` Max Nikulin
0 siblings, 2 replies; 69+ messages in thread
From: Samuel Wales @ 2022-11-17 3:16 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
more below.
On 11/16/22, Max Nikulin <manikulin@gmail.com> wrote:
> Since recently we were discussing desktop notifications and temporary
> rising emacs window, I am unsure if capture indication is related to the
> firefox extension, notification daemon, or emacs.
my brain is not connecting the first part of your sentence with the
second part [this has to do with my brain, not your english], but i
have been assuming that it is the firefox org-capture extension saying
"i sent the request".
in other words, you click unicorn, it does some org-protocol call, and
then it flashes that nice but misleading message.
misleading because it only indicates sending, not [desirable] emacs
receipt or [perhaps overkill?] emacs handling.
>
>> this is with or without selecting any text.
>>
>> could a kind soul remind me how to debug this again?
>
> Max Nikulin. Re: org-capture firefox extension broken [silently] Sat, 11
> Jun 2022 09:30:11 +0700.
> https://list.orgmode.org/t80unm$7ud$1@ciao.gmane.io and the earlier
> message https://list.orgmode.org/t7vdnm$ddo$1@ciao.gmane.io
oh /very nice/ thanks. it is going to take me a long time to digest
that but i want to start with trying "have you"'s.
>
> Launching org-protocol handler from browser is unreliable, there is
> almost no way to detect an error. One indirect technique relies on
> switching focus from firefox to another application, but it is not
> applicable for your workflow.
do you mean like popping up emacs frame? which would indeed
undesirably require me to move ff to front again? but would at least
prove that the capture worked as i can inspect the new subentry in my
xyzzy-remember entry?
at this point, ff capture is so needed for me that i'd consider
something like the following:
pop up emacs frame for a fraction of a second, which then, in elisp,
pops back down again. it might be possible to make it tolerabie
[visual overstimulation, cognitive burden] if the frame is full screen
on width but only a few lines on height.
i would have to try it to be sure but it seems worth trying. however,
idk if it is possible in elisp. i think i can maybe figure out the
frame dimensions part if there is a place to put it in capture
template.
>
> More robust approach is a native messaging application that is a bridge
> between sandboxed firefox extension and emacs. It makes setup more
> complicated however and no simple org-protocol extensions use this
> approach.
not sure i understand what native or sandboxed mean here or why, and
whether org-protocol is needed or if you are saying that there might
be a non-simple-to-install extension for it or so.
>
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-11-16 4:03 ` Samuel Wales
2022-11-16 16:46 ` Debugging firefox extension " Max Nikulin
@ 2022-11-17 7:18 ` Jean Louis
2022-11-17 15:30 ` Reliability of org-protocol browser extensions Max Nikulin
1 sibling, 1 reply; 69+ messages in thread
From: Jean Louis @ 2022-11-17 7:18 UTC (permalink / raw)
To: Samuel Wales; +Cc: Ihor Radchenko, Max Nikulin, emacs-orgmode
* Samuel Wales <samologist@gmail.com> [2022-11-16 07:06]:
> idk if related to this thread, but i sure do appreciate the effor in
> this thread to solve such problems. it is a key feature for me
> because i am often in mouse-only mode. it is thus a constant concern
> that org-capture could stop working etc.
>
> right now, it seems org-capture is broken for me again. clicking on
> unicorn results in the momentary captured indication in huge text on
> the screen [i like this indicator], but it does not get captured to my
> org capture target.
I am using reliable org-protocol extension, that can "store" link and
"capture", it is programmed by Wojciech Siewierski,
https://github.com/vifon/org-protocol-for-firefox
https://addons.mozilla.org/en-US/firefox/addon/org-protocol/reviews/
--
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] 69+ messages in thread
* Re: Debugging firefox extension (Re: idea for capture anywhere in x)
2022-11-17 3:16 ` Samuel Wales
@ 2022-11-17 9:42 ` Jean Louis
2022-11-17 16:12 ` Max Nikulin
1 sibling, 0 replies; 69+ messages in thread
From: Jean Louis @ 2022-11-17 9:42 UTC (permalink / raw)
To: Samuel Wales; +Cc: Max Nikulin, emacs-orgmode
* Samuel Wales <samologist@gmail.com> [2022-11-17 06:19]:
> in other words, you click unicorn, it does some org-protocol call, and
> then it flashes that nice but misleading message.
That is why I am using Emacs to tell me audibly that bookmark was
recorded.
Forgive me for not using really Org to record what org-protocol
extension does, but this example may help people by principle to
people to get better notification:
(defun hyperscope-org-protocol-store-link (query)
(if (hyperscope-user-www-set)
(let* ((splitparts (org-protocol-parse-parameters query t))
(uri (org-protocol-sanitize-uri (plist-get splitparts :url)))
(title (plist-get splitparts :title))
(hlink-exist (hyperscope-link-exists-p uri 2)))
(if hlink-exist
(progn
(rcd-warning-message "Link: %s already exists." uri)
(rcd-speak "Link exists already")
nil)
(let* ((parent (hyperscope-user-www-set))
(id (hyperscope-add-generic title uri nil 2 nil parent)))
(if id
(progn
(message "Added Hyperlink: %s to Hyperscope ID: %s" title id)
(hyperscope-update-tokens id)
(rcd-speak "Done")
;; speaking "Done" on my loud speaker tells me it was
;; made well
nil)
(progn
(message "Could not insert: %s" query)
(rcd-speak "Did not work")
nil)))))
(rcd-warning-message "Define WWW set for user `%s' in table `usersdefaults'" (rcd-db-current-user))))
--
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] 69+ messages in thread
* Reliability of org-protocol browser extensions
2022-11-17 7:18 ` Getting X selection reliably " Jean Louis
@ 2022-11-17 15:30 ` Max Nikulin
0 siblings, 0 replies; 69+ messages in thread
From: Max Nikulin @ 2022-11-17 15:30 UTC (permalink / raw)
To: emacs-orgmode
On 17/11/2022 14:18, Jean Louis wrote:
>
> I am using reliable org-protocol extension,
Out of curiosity, can you quickly capture let say 20 tabs (a second per
tab)? Is the extension able to detect that scheme handler is not
properly configured at the level of desktop environment?
> that can "store" link and
> "capture", it is programmed by Wojciech Siewierski,
> https://github.com/vifon/org-protocol-for-firefox
I do not think that the tabs.update() method from WebExtensions API
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/update
is unambiguously better than launching external handler from a content
script by assigning URI to window.location
https://developer.mozilla.org/en-US/docs/Web/API/Window/location
The latter method is used by https://github.com/sprig/org-capture-extension/
Launching external scheme handler from a web page or from an extension
is a shoot and forget method. Even if an error is reported to browser
console, it is inaccessible for JavaScript. It is a grey zone even
though enough applications relies on custom URI schemes. There are a
couple of tricks, but they do not always work. Browsers isolates web
pages and host system to prevent attacks. Protection causes enough
inconveniences already while I would not call it perfect.
I do not think that changing of extension will help Samuel. Looking into
the code I do not see real difference in respect to reliability. Either
there is a problem with desktop-wide protocol handler or browser blocks
attempts to launch it.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Debugging firefox extension (Re: idea for capture anywhere in x)
2022-11-17 3:16 ` Samuel Wales
2022-11-17 9:42 ` Jean Louis
@ 2022-11-17 16:12 ` Max Nikulin
1 sibling, 0 replies; 69+ messages in thread
From: Max Nikulin @ 2022-11-17 16:12 UTC (permalink / raw)
To: emacs-orgmode
On 17/11/2022 10:16, Samuel Wales wrote:
> On 11/16/22, Max Nikulin wrote:
>> Since recently we were discussing desktop notifications and temporary
>> rising emacs window, I am unsure if capture indication is related to the
>> firefox extension, notification daemon, or emacs.
>
> my brain is not connecting the first part of your sentence with the
> second part [this has to do with my brain, not your english],
I was writing about notify-send (or d-bus function) called in the case
of successful capture and notification-daemon or dunst:
Samuel Wales. Re: desktop notifications (Re: idea for capture anywhere
in x) Wed, 26 Oct 2022 01:07:18 -0700.
https://list.orgmode.org/CAJcAo8sp3dyUT0b8=3T1YeiQZzmDYS9Zah_6+LdczWHicnVX=w@mail.gmail.com
I am unsure if your managed to add such feature to your configuration.
> but i
> have been assuming that it is the firefox org-capture extension saying
> "i sent the request".
Check browser console for warnings and try to call emacsclient with some
org-protocol: URI from xterm or another terminal application (I would
avoid Emacs shell buffers for such tests).
> pop up emacs frame for a fraction of a second, which then, in elisp,
> pops back down again.
To raise and lower an existing window perhaps something like wmctrl,
xdotool or fluxbox-remote should be used.
Remaining withing Emacs I would consider temporary creating a new frame
and dismissing it. I am unsure concerning focus stealing protection in
window managers that may hide such window.
A simple command that might be a substitute to notification windows:
zenity --timeout 1 --info --title 'Title' --text 'Text'
There are a number of dialog tools similar to zenity: lightweight or
integrated with desktop environments. I have no idea which one you may
have installed and if it has timeout feature or sleep&kill workaround
should be used instead.
However I believe that not running some notification daemon may cause
problems with various application.
>> More robust approach is a native messaging application that is a bridge
>> between sandboxed firefox extension and emacs. It makes setup more
>> complicated however and no simple org-protocol extensions use this
>> approach.
>
> not sure i understand what native or sandboxed mean here or why, and
> whether org-protocol is needed or if you are saying that there might
> be a non-simple-to-install extension for it or so.
Browsers create sandboxes for web pages and extensions to isolate them
from host system. There is an API that allows communication of an add-on
with particular helper application running on host system:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging
A dedicated naive messaging helper allows to check emacsclient exit code
or stdout. The price is more complicated configuration. Of course, an
extension should support such communication protocol.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Getting X selection reliably (Re: idea for capture anywhere in x)
2022-11-14 2:06 ` Ihor Radchenko
2022-11-16 4:03 ` Samuel Wales
@ 2022-12-04 5:21 ` Max Nikulin
1 sibling, 0 replies; 69+ messages in thread
From: Max Nikulin @ 2022-12-04 5:21 UTC (permalink / raw)
To: emacs-orgmode
On 14/11/2022 09:06, Ihor Radchenko wrote:
> Max Nikulin writes:
>
>> Depending of particular capture template (even with :immediate-finish t)
>> empty selection may or may not be an error. In Samuel's case it is an
>> error. Unfortunately, while the template is processed, signaled errors
>> are caught and their text is inserted into the text. That is why in my
>> example I put checks outside of `org-capture'.
>
> Are you sure? `org-get-x-clipboard' returns nil in case of error and
> `org-capture-fill-template' assigns empty string to v-x when no
> clipboard value can be obtained.
I did not mean elisp error. It is a trouble from the point of view of a
user. Their expect to get selection text, but actually useless empty
string is inserted. However capturing stale selection (from previous
action) is an equally annoying trouble. That is why I believe, the only
reliable way is to present result of capture to the user, so if
something goes wrong then they may redo selection and capture. Samuel
may weight distracting popup vs. a chance of useless capture differently.
>> We may:
>> - Add a capture template option that allows errors to pass through to
>> the caller. Then a user may add %(...) expression with all necessary checks.
>
> I am not very sure what kind of errors you are talking about. AFAIU, we
> are talking about scenarios when user explicitly wants one of
> PRIMARY/CLIPBOARD/SECONDARY, don't we?
I mean a way to propagate an error signaled during capture expansion to
the caller of emacsclient, so user may be notified about the issue
instead of silently getting "[ERROR ...]" in the captured heading.
>> I have no idea how to get "emacs -display" argument and I need to look
>> into emacsclient source and server.el to figure out which way client's
>> display argument is passed to the server process.
>
> Maybe it can be considered an Emacs bug or something to improve on Emacs
> side?
See Max Nikulin to emacs-devel. How to get DISPLAY of emacsclient? Fri,
25 Nov 2022 22:17:54 +0700. mid:tlqmb3$ic$1@ciao.gmane.io
A workaround is
emacsclient --display "$DISPLAY" --eval ...
Unlike for most of X applications, --display option of emacsclient not
only overrides the value of the DISPLAY environment, in addition it
causes creation of a hidden frame, so `org-get-x-clipboard' is able to
get selection text. I am unsure concerning behavior in other OSes. At
least special values display are used internally, users are unlikely
familiar with the concept of display. Unfortunately I can not check
precise behavior for macOS or Windows. I would not mind to have an
option like --force-display that does not require fetching the value
from environment (to avoid explicit shell wrapper in .desktop files) or
special values on non-X systems.
Likely the "--display" hack should be mentioned in the manual and in the
templates docscring.
^ permalink raw reply [flat|nested] 69+ messages in thread
end of thread, other threads:[~2022-12-04 5:22 UTC | newest]
Thread overview: 69+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-08 4:22 idea for capture anywhere in x 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-26 6:05 ` desktop notifications (Re: idea for capture anywhere in x) Max Nikulin
2022-10-26 6:22 ` Samuel Wales
2022-10-26 7:41 ` Max Nikulin
2022-10-26 8:07 ` Samuel Wales
2022-10-26 8:29 ` Max Nikulin
2022-10-27 6:33 ` Getting X selection reliably " Max Nikulin
2022-10-28 4:59 ` Samuel Wales
2022-10-28 5:16 ` Max Nikulin
2022-10-28 8:39 ` Dr. Arne Babenhauserheide
2022-10-28 16:38 ` Max Nikulin
2022-10-28 23:07 ` Samuel Wales
2022-10-29 3:21 ` Max Nikulin
2022-10-29 2:59 ` Ihor Radchenko
2022-10-29 3:30 ` Max Nikulin
2022-10-29 6:03 ` Samuel Wales
2022-10-29 7:33 ` Max Nikulin
2022-10-29 22:33 ` Samuel Wales
2022-10-29 4:50 ` Samuel Wales
2022-10-29 4:59 ` Ihor Radchenko
2022-10-29 7:44 ` desktop notifications " Max Nikulin
2022-10-29 23:07 ` Samuel Wales
2022-10-30 4:49 ` Ihor Radchenko
2022-11-13 4:54 ` Getting X selection reliably " Ihor Radchenko
2022-11-13 11:03 ` Max Nikulin
2022-11-14 2:06 ` Ihor Radchenko
2022-11-16 4:03 ` Samuel Wales
2022-11-16 16:46 ` Debugging firefox extension " Max Nikulin
2022-11-17 3:16 ` Samuel Wales
2022-11-17 9:42 ` Jean Louis
2022-11-17 16:12 ` Max Nikulin
2022-11-17 7:18 ` Getting X selection reliably " Jean Louis
2022-11-17 15:30 ` Reliability of org-protocol browser extensions Max Nikulin
2022-12-04 5:21 ` Getting X selection reliably (Re: idea for capture anywhere in x) Max Nikulin
2022-10-12 17:16 ` idea for capture anywhere in x 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).