From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#75116: [PATCH] Make 'yank-media' autoselect the best media type Date: Mon, 06 Jan 2025 20:50:03 +0200 Message-ID: <868qrn6alg.fsf@gnu.org> References: <87o70yeiih.fsf@gmail.com> <86r05uxx4i.fsf@gnu.org> <871pxtcxiq.fsf@gmail.com> <86r05sro63.fsf@gnu.org> <87bjwkbls7.fsf@gmail.com> <87cygzhjw9.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29614"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pinmacs@cas.cat, rpluim@gmail.com, 75116@debbugs.gnu.org, visuweshm@gmail.com To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 06 19:51:23 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 1tUsCA-0007ZB-UE for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Jan 2025 19:51:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUsBt-0001Iu-26; Mon, 06 Jan 2025 13:51:05 -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 1tUsBq-0001IE-RV for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 13:51:02 -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 1tUsBq-0004WP-Db for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 13:51:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=UFMAWmhsfJ43A9wyOegWoeTdd9b+UN8N7bmRhDthR9g=; b=UomnSDrl5x37Uv0htQW8NkqTxVIu+Aw4nRIesRo4aDdlOrLVfXb/ysR+8dtxZoAVwmG1KiIeUzKwl8jlMWEkCCA+pHzCb2l3i99/zfulIMsSIjmIKH9jsAczzz2PCAdkNdvTqnLkyu9L/HKa//ntG7yDKna1kbD2mQuIMRBbZqL/eT7SZkLO8bSX0/Hv4iLyz3/Hpcy5Qa1Fg4iF8xaqmokdvbyfRWfQCnwWkanKHzxt6e8tadDCCgcSRn428fJZYvojAie7+xWTLkAJewk2xJQDAr/3Kagi6CUWs5dQmM/tKb8xpTA1VSYwC2VoRKDxhWaO27Faw8Evj8dXdV2ndw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUsBq-0004Od-7A for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 13:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Jan 2025 18:51: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.173618943216833 (code B ref 75116); Mon, 06 Jan 2025 18:51:02 +0000 Original-Received: (at 75116) by debbugs.gnu.org; 6 Jan 2025 18:50:32 +0000 Original-Received: from localhost ([127.0.0.1]:40083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUsBL-0004NR-Ga for submit@debbugs.gnu.org; Mon, 06 Jan 2025 13:50:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59676) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUsBJ-0004N7-Ji for 75116@debbugs.gnu.org; Mon, 06 Jan 2025 13:50:30 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUsBD-0004UF-D3; Mon, 06 Jan 2025 13:50:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=UFMAWmhsfJ43A9wyOegWoeTdd9b+UN8N7bmRhDthR9g=; b=fXkdkRn6qhsp oyrltblR3mdak+6lFdp6h1yIVDwb8AOLL35vfgfk78QMzNeE/Xz4h46RJb8p6iqwps9d9OtjkNXcp mmdR36IYmiIAAcefj6mYUNlzYcDCn+9QEr0wqiCJu8hiev8pf0LksZwhcDrKR/kZ+9W+hHTbwAnQo 7LWe06rrcLvnOaC0sI8zTUnYLKJnH+YM8BFinIvpd07d51PQAMssh/ieplfm2DabtDjI6ZyXMiny+ wtcXoHxMJnmTEUK08osuuRKYZ2rSIjpeLadPvgKe5X0xnUsZ6fpiZFbLBfULP5pSQNFkRKYCp6pAv pOF6Ctktxs40DV5XN4BjEQ==; In-Reply-To: <87cygzhjw9.fsf@localhost> (message from Ihor Radchenko on Mon, 06 Jan 2025 18:33:42 +0000) 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:298687 Archived-At: > From: Ihor Radchenko > Cc: Eli Zaretskii , 75116@debbugs.gnu.org, pinmacs@cas.cat, > rpluim@gmail.com > Date: Mon, 06 Jan 2025 18:33:42 +0000 > > 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. That's what I mean by "ask": use the default behavior of the command. Conceptually, it's the same as the paste operation in other applications: by default, the application decides which of the formats to use, and if the user wants to choose, he/she needs to pop up a menu of available formats in some way and select from there.