From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#43218: EWW handles default answer incorrectly when changing a select Date: Sat, 5 Sep 2020 21:41:00 -0700 (PDT) Message-ID: <3f6f1310-09f9-4ae9-99e3-451724ae7185@default> References: <86ft7wuoq0.fsf@hypra-xx> <878sdn22sf.fsf@gnus.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="22327"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43218@debbugs.gnu.org, Stefan Monnier To: Lars Ingebrigtsen , Nicolas Graner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 06 06:42:10 2020 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 1kEmVF-0005hR-Kl for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Sep 2020 06:42:09 +0200 Original-Received: from localhost ([::1]:60088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEmVE-0006Q2-NB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Sep 2020 00:42:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEmV8-0006Pl-Fp for bug-gnu-emacs@gnu.org; Sun, 06 Sep 2020 00:42:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kEmV8-0000aw-7N for bug-gnu-emacs@gnu.org; Sun, 06 Sep 2020 00:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kEmV8-0002t1-3k for bug-gnu-emacs@gnu.org; Sun, 06 Sep 2020 00:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Sep 2020 04:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43218 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 43218-submit@debbugs.gnu.org id=B43218.159936727611043 (code B ref 43218); Sun, 06 Sep 2020 04:42:02 +0000 Original-Received: (at 43218) by debbugs.gnu.org; 6 Sep 2020 04:41:16 +0000 Original-Received: from localhost ([127.0.0.1]:44499 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEmUN-0002s2-IA for submit@debbugs.gnu.org; Sun, 06 Sep 2020 00:41:15 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:53178) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEmUL-0002rp-CM for 43218@debbugs.gnu.org; Sun, 06 Sep 2020 00:41:14 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0864eb3c125164; Sun, 6 Sep 2020 04:41:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=EvahGgyNYTNH7x9RiRNHPMt6uH0stYvyxlufVpdjZL4=; b=Jb10Jc7d88bP8NYhxHyVf9KgjjphryDj5AJlyl9aVAsJo6X4+yDNkUMMFCcN6UKi07bU O0C35wrI5lWKgsrH+OnYTJTZCeMjIKCV8rZjZN7qn21XE0ats5W0aUG4hyST68kTKzQ/ /MJWnP95M4rsguVxNWlZotJRkIZJXTyX1j9sPiGOJ+S1xk71eTDq0gCpJVVAv3PbyBAF C57y0RwySsIWtG+8m+qUcl10dUeaGwmp5smu/ZiYMEAXQjES6waDqCg55oQgE9oVXh0q 4vxOqHXlulPN/0vd4r+749uv/Qm2CVysPvJ3m7QSqPfUrHMK96i/k0BKQHv/VJlKgy/Z 1g== Original-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 33c2mkj6hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 06 Sep 2020 04:41:07 +0000 Original-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0864es2E092703; Sun, 6 Sep 2020 04:41:07 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 33cmjw0bqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 06 Sep 2020 04:41:07 +0000 Original-Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0864f1bJ025063; Sun, 6 Sep 2020 04:41:01 GMT In-Reply-To: <878sdn22sf.fsf@gnus.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5044.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9735 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009060047 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9735 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 clxscore=1011 mlxlogscore=999 malwarescore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009060047 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" Xref: news.gmane.io gmane.emacs.bugs:187309 Archived-At: > > Activate the select and change its value to 'two'. > > Activate it again and answer to the prompt for value: the > > displayed value returns to 'one'. > > > > This is not critical as this situation is rare and the value sent to th= e > > server will be correct anyway, but it is confusing to the user who does > > not usually know the value of each option. >=20 > That's true... there's also a general problem with how the values are > selected: We're doing a completing-read over the display names, and then > mapping that back to the values. But this is perfectly valid: >=20 > >=20 > But there's no way to select the second value in eww. >=20 > Unfortunately, the Emacs primitives for prompting are very > text-oriented, and don't allow putting properties on the values we're > completing over, not even with: >=20 > --- > minibuffer-allow-text-properties is a variable defined in =E2=80=98src/mi= nibuf.c=E2=80=99. > Its value is nil >=20 > Probably introduced at or before Emacs version 20. >=20 > Documentation: > Non-nil means =E2=80=98read-from-minibuffer=E2=80=99 should not discard t= ext properties. > This also affects =E2=80=98read-string=E2=80=99, but it does not affect = =E2=80=98read-minibuffer=E2=80=99, > =E2=80=98read-no-blanks-input=E2=80=99, or any of the functions that do m= inibuffer input > with completion; they always discard text properties. > --- >=20 > I wonder what the logic behind this is? And I also have a vague feeling > I've asked this before... >=20 > Perhaps Stefan knows and or remembers. :-) >=20 > So the test case is: >=20 > (let ((minibuffer-allow-text-properties t)) > (completing-read "Foo: " (list (propertize "foo" 'data 'bar)) > nil 'require-match)) > =3D> "foo" >=20 > instead of #("foo" 0 3 (data bar)) Huge apologies for jumping in here, possibly missing the point completely, and probably not providing much that helps operationally. But I think I know what you're talking about. If so, first, note this: (let ((minibuffer-allow-text-properties t)) (read-from-minibuffer "Foo: " nil nil nil nil (propertize "foo" 'data 'bar))) Use `M-n RET'. The doc tells you that it only returns a propertized string that was in the _minibuffer_ when you hit RET. That's not the case for a chosen `completing-read' candidate. As you quoted from the doc string: > the functions that do minibuffer input with > completion ... always discard text properties. Second, I can speak a bit to how Icicles deals with this sort of thing. I tried (more than once) to get vanilla Emacs to let you use propertized strings as completion candidates, both (1) for display in *Completions* and (2) as returned value for `completing-read'. I see that in the Icicles doc I mention that in 2007 RMS agreed to fix Emacs to provide #1, but AFAIK that never happened. Icicles redefines `display-completion-alist' so that it does display propertized candidates. And Icicles redefines `completing-read' so it returns a propertized display-candidate string that you choose. You can do more. But already those two simple additions go a long way. Wrt the problem I think you raise above, which is dealing with multiple candidates that have the same display string but are associated with different "values" in some sense (the simplest being the cdr of an alist cons whose car is the display candidate): 1. When you cycle among candidates or use mouse-2 to choose one, there's the notion of "current candidate", so Icicles knows which alist element you choose (not just which display string). 2. If you bind `icicle-whole-cand-as-text-prop-p' to non-nil then an entire alist element is put on its car (the display string) as a property, so when `completing-read' returns that string the full candidate (the alist element) can be recovered. This takes care of distinguishing element ("foo" . 42) from element ("foo" 5 4 3). #2 is just this: (let ((text-cand (copy-sequence (car cand)))) (put-text-property 0 (length text-cand) 'icicle-whole-candidate (cdr cand) text-cand) (setcar cand text-cand) text-cand) Then: (and icicle-whole-candidate-as-text-prop-p (get-text-property 0 'icicle-whole-candidate string)) (I use the same "trick" in Bookmark+ to handle different bookmarks that have the same name.) Here are two doc pages that discuss this a bit: https://www.emacswiki.org/emacs/Icicles_-_Programming_with_Fancy_Candidates= #fancy_candidates https://www.emacswiki.org/emacs/Icicles_-_Candidates_with_Text_Properties