From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#75116: [PATCH] Make 'yank-media' autoselect the best media type Date: Mon, 06 Jan 2025 18:33:42 +0000 Message-ID: <87cygzhjw9.fsf@localhost> References: <87o70yeiih.fsf@gmail.com> <86r05uxx4i.fsf@gnu.org> <871pxtcxiq.fsf@gmail.com> <86r05sro63.fsf@gnu.org> <87bjwkbls7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38158"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , pinmacs@cas.cat, rpluim@gmail.com, 75116@debbugs.gnu.org To: Visuwesh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 06 19:32:35 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1tUrty-0009mm-QI for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Jan 2025 19:32:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUrtX-0004tu-7p; Mon, 06 Jan 2025 13:32:08 -0500 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 1tUrtT-0004tZ-Ej for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 13:32:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUrtS-0002j9-Vs for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 13:32:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=gmhiv5CCSuXfclMf9nZB1r/lU7vPF2n5C0J4B3wryTs=; b=JxpLVtSYFxvPRKx2giBWsf9PuKetyR4qVFkaweuqnI+HObhoAXQvs/M/MGUrShhMnQx9KjjDM2MrIMELiPWlaHXig3TgB7SQcQvKVQnEoDM+08lJIp8SbQgQfp9MznnlU5MdhP4fb01bV60xZDf9P1IQ1OEnS6FmQfJgzFSQjEyfYN2Ojwv68cG0NCXpWDdwG7kLQA3BTiyWHETMzA2ychYf2TFoq2Gy/vVsQxg6NBlMt9VyEeKCznzWxcWxMwYe1d9LcMMiqE7NSDfC5iavWyc57ntmcaCVh8t1C4IjGr7VWkQEHLDBcP4QUlHdMOs/CDyePJ20ChRsbZb8JpoiVQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUrtS-0003Mx-GK for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 13:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Jan 2025 18:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 75116-submit@debbugs.gnu.org id=B75116.173618829512890 (code B ref 75116); Mon, 06 Jan 2025 18:32:02 +0000 Original-Received: (at 75116) by debbugs.gnu.org; 6 Jan 2025 18:31:35 +0000 Original-Received: from localhost ([127.0.0.1]:40039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUrt0-0003Lo-MU for submit@debbugs.gnu.org; Mon, 06 Jan 2025 13:31:35 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:49385) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUrsx-0003LW-Ns for 75116@debbugs.gnu.org; Mon, 06 Jan 2025 13:31:33 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 6D20A240027 for <75116@debbugs.gnu.org>; Mon, 6 Jan 2025 19:31:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1736188285; bh=tdRABS5tNDiiG7rr/IIHvUqAe3gE3XOapvrmdJxo5XM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=HGYXB/DgqIZwGPoIn+mEndVVpq1Xd0UCbqK7Je08Gy4R1frReeVYuie1lIT5J4f/E Pbkiflnz+BhRxK71gee3P1GN5GnaAv5eeR1Ci3XT50ZOjPIR5fKSJuUOKZ1Sgi21+3 VY05S0Ohma4R4y4BEHZgh+dcXRSF4bLcHGOSuRPR+SBNXqKyNrmKG+aHPTg55xGa0q cr+1PRw2F+/qYjvVoI5Xn3p632Jgi6V9qW4B3lf7eH3rb8Y2r3bh74WMZZgX84zgHk bKb2M0r52RVwZFaiOEU5ZjfkESj4vQfJei0Gf+hqBIDf1E0pvoua5HyY1/qrv9GYzc x9liy8zP49wSA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YRjSD0N82z9rxR; Mon, 6 Jan 2025 19:31:24 +0100 (CET) In-Reply-To: <87bjwkbls7.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298683 Archived-At: Visuwesh writes: >>> >> + (setq pref-type (and (null noselect) >>> >> + (funcall yank-media-autoselect-function >>> >> + (mapcar #'car all-types)))) >>> >> + (cond >>> >> + ;; We have one preferred mime type so use it unconditionally. >>> >> + ((and pref-type (symbolp pref-type)) >>> >> + (funcall (cdr (assq pref-type all-types)) pref-type >>> >> + (yank-media--get-selection pref-type))) >>> >> + ;; The user chose to not autoselect and there's just a single type, >>> >> + ;; just call the handler. >>> >> + ((and (null pref-type) (length= all-types 1)) >>> >> + (funcall (cdar all-types) (caar all-types) >>> >> + (yank-media--get-selection (caar all-types)))) >>> > >>> > This goes against what the doc string says. And I think the doc >>> > string describes a better behavior: if the user asked not to >>> > auto-select, we shouldn't, even if there's just one type available. >>> > We should instead ask the user whether to yank that type, because the >>> > user could decide she doesn't want that type, even it it's the only >>> > one. >>> ... >>> I want to ensure we are on the same page wrt UI here: >>> >>> User asks to autoselect: >>> 1. autoselect-function (a-s-f) returns one media type: we yank it. >> >> Yes. >> >>> 2. a-s-f returns multiple media types: we ask the user which one >>> to yank. >> >> No, we use the first one. > > Doesn't this mean there is pratically no difference between (1) and (2)? > Ihor, is this okay? Or did you have something else in mind when you > asked for the possibility to return multiple types? Eli, what exactly do you mean by "user asks to autoselect"? AFAIU, autoselect is done by default. User cannot ask for it. User can only supply a prefix argument to explicitly disable autoselection. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at