From: Pedro <pedro@cas.cat>
To: emacs-devel@gnu.org
Subject: Re: yank-media: allow users to limit image types that can be inserted
Date: Mon, 23 Sep 2024 17:45:46 -0300 [thread overview]
Message-ID: <55f70597-4f60-4831-8829-a4de99d57b84@cas.cat> (raw)
In-Reply-To: <8634lqfcaf.fsf@gnu.org>
[-- Attachment #1.1.1: Type: text/plain, Size: 4009 bytes --]
Eli, I think we can solve the three situations described with following
algorithm/idea/inspiration [1]: through a configurable variable
(yank-media-image-types ?). That would allow you to be able to select
among all options (that for certain cases could be interesting, say
"expert mode", I know what I am doing, verbose mode, etc.), and also, a
way to filter out certain candidates based on what you need.
Making that variable equal to nil would be as it is now, and configuring
it to "image/png", would only select one. I think others were thinking
about a regex. As you wish, I only need some sort of filter, and I don't
care too much on the detail of how it is configured.
[1]
#+begin_src emacs-lisp
(defun my/filter (lst allowed)
"Filter elements from LST based on ALLOWED. If no match is found,
return LST."
(if (null allowed)
lst
(let ((filtered
(delq nil (mapcar
(lambda (x)
(when
(member x allowed) x)) lst))))
(if (null filtered) lst filtered))))
(defun my/select (lst allowed)
(if (equal (length allowed) 1)
allowed
(completing-read
"Several types available, choose one:"
(my/filter lst allowed))))
(setq my/candidates '("image/png"
"image/pbm"
"image/xbm"
"image/xpm"
"image/jpeg"
"image/tiff"
"image/webp"))
;; 1. I only want png
(my/select my/candidates '("image/png"))
;; 2. I only want to select between png and/or jpeg
(my/select my/candidates '("image/png" "image/jpeg"))
;; 3. expert mode (just like it is now)
(my/select my/candidates nil)
;; example of how you would customize the variable
(setq yank-media-image-types '("image/png"))
#+end_src
On 2024-09-23 15:35, Eli Zaretskii wrote:
>> Date: Mon, 23 Sep 2024 15:00:54 -0300
>> Cc: visuweshm@gmail.com, emacs-devel@gnu.org
>> From: pinmacs <pinmacs@cas.cat>
>>
>> Before yank-media, I was using org-download [1], so I got used to just
>> insert a screenshot with no question to answer (such as the type of the
>> image).
>>
>> Recently, I moved to yank-media, but to have the same functionality, I
>> had to tweak it a little bit, full detail here [2].
>>
>> I see utility on asking for the image/png and image/jpeg and here you
>> have details why you would care about [3].
> This just says that PNG is always preferable to JPEG if both are
> available. As I already said, I'm okay with the idea of having C-y or
> similar key to decide which format to use, and so what you are saying
> (and I agree) that it should always choose PNG if Emacs supports it.
>
> What I still do not understand is what would be the reason for the
> user to prefer JPEG over PNG. More generally, if Emacs can support N
> formats out of those available in the clipboard, why would the user
> want to be shown only 1 < M < N out of them?
>
> Furthermore, your request was even more broad and general: it asked
> for some filtering infrastructure, and I'm still trying to understand
> why that would be needed. The discussion to which you point on the
> Org list doesn't explain the rationale, either.
>
> Bottom line: I'm okay with offering two yank-media alternatives:
>
> (1) via a command that selects a single most appropriate format based
> on some (yet to be defined) algorithm; and
> (2) via showing the list of all the formats that the running Emacs
> supports and asking the user to choose one.
>
> If we can agree on this, we should now discuss those algorithms for
> selecting a single media type.
>
> Thanks.
>
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3323 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2024-09-23 20:45 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-22 16:53 yank-media: allow users to limit image types that can be inserted pinmacs
2024-09-23 11:20 ` Eli Zaretskii
2024-09-23 13:46 ` Visuwesh
2024-09-23 14:30 ` Eli Zaretskii
2024-09-23 15:06 ` Visuwesh
2024-09-23 15:48 ` Eli Zaretskii
2024-09-23 15:09 ` Robert Pluim
2024-09-23 15:14 ` Visuwesh
2024-09-23 15:20 ` Robert Pluim
2024-09-23 15:58 ` Eli Zaretskii
2024-09-24 5:00 ` Visuwesh
2024-09-24 5:10 ` Visuwesh
2024-09-24 11:57 ` Eli Zaretskii
2024-09-24 12:42 ` Visuwesh
2024-09-23 15:54 ` Eli Zaretskii
2024-09-23 16:10 ` Robert Pluim
2024-09-23 16:34 ` Eli Zaretskii
2024-09-23 18:00 ` pinmacs
2024-09-23 18:35 ` Eli Zaretskii
2024-09-23 20:45 ` Pedro [this message]
2024-09-23 21:08 ` pinmacs
2024-09-24 8:15 ` Robert Pluim
2024-09-24 11:30 ` Eli Zaretskii
2024-09-24 12:18 ` Robert Pluim
2024-09-24 13:08 ` Eli Zaretskii
2024-09-24 13:38 ` Visuwesh
2024-09-24 13:50 ` Eli Zaretskii
2024-09-24 5:08 ` Visuwesh
2024-09-24 12:00 ` Eli Zaretskii
2024-09-24 12:50 ` Visuwesh
2024-09-24 13:23 ` Eli Zaretskii
2024-09-24 13:37 ` Visuwesh
2024-10-26 17:27 ` Ihor Radchenko
2024-10-26 19:09 ` Eli Zaretskii
2024-10-27 8:17 ` Ihor Radchenko
2024-10-27 9:14 ` Eli Zaretskii
2024-10-27 9:36 ` Visuwesh
2024-10-27 10:09 ` Eli Zaretskii
2024-10-27 15:02 ` Visuwesh
2024-10-27 17:11 ` Eli Zaretskii
2024-10-28 13:37 ` Visuwesh
2024-10-29 11:29 ` Visuwesh
2024-10-30 23:22 ` Pedro
2024-10-31 8:29 ` Eli Zaretskii
2024-10-31 10:47 ` pinmacs
2024-10-31 11:16 ` Eli Zaretskii
2024-10-31 11:51 ` pinmacs
2024-10-31 14:31 ` Eli Zaretskii
[not found] ` <c67bb616-710b-4272-919d-bf4ece8e7c99@imayhem.com>
2024-10-31 14:20 ` Eli Zaretskii
2024-10-31 18:21 ` Ihor Radchenko
2024-10-31 19:03 ` Eli Zaretskii
2024-10-31 19:08 ` Ihor Radchenko
2024-10-31 19:29 ` Eli Zaretskii
2024-10-31 19:42 ` Ihor Radchenko
2024-11-01 7:01 ` Eli Zaretskii
2024-10-31 8:48 ` Visuwesh
2024-10-31 8:24 ` Eli Zaretskii
2024-10-31 8:46 ` Visuwesh
2024-10-31 9:56 ` Eli Zaretskii
2024-11-01 5:20 ` Visuwesh
2024-11-01 7:38 ` Eli Zaretskii
2024-11-03 17:19 ` Ihor Radchenko
2024-11-03 18:47 ` Eli Zaretskii
2024-11-04 4:04 ` Visuwesh
2024-11-04 20:03 ` Ihor Radchenko
2024-11-04 20:19 ` Eli Zaretskii
2024-10-28 18:39 ` Ihor Radchenko
2024-10-28 18:50 ` Eli Zaretskii
2024-09-23 18:11 ` Eli Zaretskii
2024-09-24 8:38 ` Robert Pluim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55f70597-4f60-4831-8829-a4de99d57b84@cas.cat \
--to=pedro@cas.cat \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).