emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting X selection reliably (Re: idea for capture anywhere in x)


From: Max Nikulin
Subject: Re: Getting X selection reliably (Re: idea for capture anywhere in x)
Date: Sun, 4 Dec 2022 12:21:27 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]