all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: pinmacs <pinmacs@cas.cat>
Cc: Eli Zaretskii <eliz@gnu.org>,  visuweshm@gmail.com,  emacs-devel@gnu.org
Subject: Re: yank-media: allow users to limit image types that can be inserted
Date: Tue, 24 Sep 2024 10:15:42 +0200	[thread overview]
Message-ID: <8734lpfowh.fsf@gmail.com> (raw)
In-Reply-To: <b0bdc64c-0eb1-43a2-8786-5b15171dd3f5@cas.cat> (pinmacs@cas.cat's message of "Mon, 23 Sep 2024 18:08:58 -0300")

>>>>> On Mon, 23 Sep 2024 18:08:58 -0300, pinmacs <pinmacs@cas.cat> said:

    pinmacs> Eli, I think we can solve the three situations described with following 
    pinmacs> algorithm/idea/inspiration [1]: through a configurable variable 
    pinmacs> (yank-media-image-types ?). That would allow you to be able to select 
    pinmacs> among all options (that for certain cases could be interesting, say 
    pinmacs> "expert mode", I know what I am doing, verbose mode, etc.), and also, a 
    pinmacs> way to filter out certain candidates based on what you need.

    pinmacs> Making that variable equal to nil would be as it is now, and configuring 
    pinmacs> it to "image/png", would only select one. I think others were thinking 
    pinmacs> about a regex. As you wish, I only need some sort of filter, and I don't 
    pinmacs> care too much on the detail of how it is configured.

    pinmacs> [1]

    pinmacs> #+begin_src emacs-lisp

    pinmacs> (defun my/filter (lst allowed)
    pinmacs>    "Filter elements from LST based on ALLOWED. If no match is found, 
    pinmacs> return LST."
    pinmacs>    (if (null allowed)
    pinmacs>        lst
    pinmacs>      (let ((filtered
    pinmacs>             (delq nil (mapcar
    pinmacs>                        (lambda (x)
    pinmacs>                          (when
    pinmacs>                              (member x allowed) x)) lst))))
    pinmacs>        (if (null filtered) lst filtered))))

    pinmacs> (defun my/select (lst allowed)
    pinmacs>    (if (equal (length allowed) 1)
    pinmacs>        allowed
    pinmacs>      (completing-read
    pinmacs>       "Several types available, choose one:"
    pinmacs>       (my/filter lst allowed))))

You need to filter the candidate list before you decide whether to use
`completing-read'. And use `cl-intersection' ☺️

Robert
-- 



  reply	other threads:[~2024-09-24  8:15 UTC|newest]

Thread overview: 34+ 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
2024-09-23 21:08                   ` pinmacs
2024-09-24  8:15                     ` Robert Pluim [this message]
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-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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734lpfowh.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=pinmacs@cas.cat \
    --cc=visuweshm@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.