From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: yank-media: allow users to limit image types that can be inserted Date: Tue, 24 Sep 2024 10:15:42 +0200 Message-ID: <8734lpfowh.fsf@gmail.com> References: <79fc91f3-c2c3-44db-9817-595808917f26@cas.cat> <86ed5ahb08.fsf@gnu.org> <87zfnywki8.fsf@gmail.com> <86setqfnmq.fsf@gnu.org> <87frpqflv4.fsf@gmail.com> <86ikumfjri.fsf@gnu.org> <877cb2fj0c.fsf@gmail.com> <86cykufhw7.fsf@gnu.org> <3a015d0f-549a-401f-be1c-651c9dbd5d9a@cas.cat> <8634lqfcaf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23221"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , visuweshm@gmail.com, emacs-devel@gnu.org To: pinmacs Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 24 10:16:29 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1st0ij-0005td-5m for ged-emacs-devel@m.gmane-mx.org; Tue, 24 Sep 2024 10:16:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1st0i6-0006Nn-OW; Tue, 24 Sep 2024 04:15:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1st0i5-0006NZ-6c for emacs-devel@gnu.org; Tue, 24 Sep 2024 04:15:49 -0400 Original-Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1st0i2-0000S3-W2; Tue, 24 Sep 2024 04:15:48 -0400 Original-Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42cb0f28bfbso44729395e9.1; Tue, 24 Sep 2024 01:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727165744; x=1727770544; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Mp6I8Q5WoAoxhY+S0TvgwKe9pxHnkQzJuAH3rzxSKYU=; b=HUjqoURfIwYf6Aqa7+W9PaJmSZkNb+4IILSe5wYGiGVS5IK2glxC4xmBpnN6/wjgcd HngnrlXc/m3Gt/g0QCb7rr2fvz48U6QzI02Y4e/caaiq8QdpLqmh4QMmkuumuNquOs5v Xr/WRXVk74m08zfwtBVaD//Q2CjBDyeyjPFS+zyraOJTOnM4pY3gF+DgGA5IBsOi+d/1 g3Vw/ZCTNTTFrmLG54nvhyL30oPXbnvMlCwPN4++7GHPCpxu4Qp6G7RGXCSUNFZLqvIz DdCpxpJancVcdwhkU6UWnRQJbJ07BBiuAGdcjePe9ipykdjMQoIYxRzSxB95WSv1aVvs Q8kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727165744; x=1727770544; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mp6I8Q5WoAoxhY+S0TvgwKe9pxHnkQzJuAH3rzxSKYU=; b=o6dEPAeUxLiG4z5Bgb2xaJ8hAI3RIcxoxQfYQP6usioHWdwInzpitzhz6XZasuyOYx AZmn1iMr0P7Vccs60UUj9Ca8PwP3qQ92A/gHQ/aKHfccAUYlpIEmSVRFg4JpboUalfap eDJmqIbU5J8XmFPQZ8jJzG6khzQif5cEwZoVA6ZRfM0VxBbH1gbfqB87Jj5sCX2tCRid r1PnohX5qVv/Pt1MKvdr+uccly031ECL1VWia2ypgjmA4EHfL7g8VfnXOx7HLayG9PLu vQLhJgifwDNCI/fuJhsexCR5VyTS13N4y0/N3qgoZDUwoekG4SkZamgMH5ELFOiUwPtM Yq4g== X-Forwarded-Encrypted: i=1; AJvYcCXmzvYDjCIVsQzu94xE9nJiFJggFnURX02PZeynyxHQxJoOqMff9KAZcpgYfeLxDj9IEcdnvRII8n60pg==@gnu.org X-Gm-Message-State: AOJu0YyRK3cpE/tMEF/5eV8NAFMvOjJnjlzwA2YLEHz4sxsS9lBMisBZ mEjJ4edViJRwmNkFWDP2wh2AYA9xLqz/8RZpjaW8FcFmHteoU20ITBDEcw== X-Google-Smtp-Source: AGHT+IHayVoS5JdtX/ncAUSEPgGQiEnapLClmpZ1dw4B8nKa1rm8O5g/Gar5Ml7UCB2iGPSy/asUqw== X-Received: by 2002:a05:600c:474d:b0:42b:a2fd:3e52 with SMTP id 5b1f17b1804b1-42e7ad72dd4mr112213095e9.22.1727165744151; Tue, 24 Sep 2024 01:15:44 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb51:4318:aaaa:4cce:d340]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e7540e32fsm149468075e9.9.2024.09.24.01.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 01:15:43 -0700 (PDT) In-Reply-To: (pinmacs@cas.cat's message of "Mon, 23 Sep 2024 18:08:58 -0300") Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=rpluim@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324011 Archived-At: >>>>> On Mon, 23 Sep 2024 18:08:58 -0300, pinmacs said: pinmacs> Eli, I think we can solve the three situations described with = following=20 pinmacs> algorithm/idea/inspiration [1]: through a configurable variabl= e=20 pinmacs> (yank-media-image-types ?). That would allow you to be able to= select=20 pinmacs> among all options (that for certain cases could be interesting= , say=20 pinmacs> "expert mode", I know what I am doing, verbose mode, etc.), an= d also, a=20 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 c= onfiguring=20 pinmacs> it to "image/png", would only select one. I think others were = thinking=20 pinmacs> about a regex. As you wish, I only need some sort of filter, a= nd I don't=20 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,=20 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' =E2=98=BA=EF=B8=8F Robert --=20