From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#45536: [PATCH] Pretty-print keys without <> around modifiers Date: Tue, 29 Dec 2020 23:27:51 +0100 Message-ID: <5F3D56BD-12C6-4600-B912-EBE649976DDD@acm.org> References: <83sg7oidp6.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_93843DBC-E6B9-4260-88E3-E6A5A48FA7E9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25693"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 45536@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 29 23:29:11 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 1kuNUM-0006YM-NE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 23:29:10 +0100 Original-Received: from localhost ([::1]:33274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuNUL-0003Hg-5C for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 17:29:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuNUE-0003HX-N8 for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 17:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuNUE-0001XS-Ff for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 17:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kuNUE-000727-Bc for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 17:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Dec 2020 22:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45536-submit@debbugs.gnu.org id=B45536.160928088426967 (code B ref 45536); Tue, 29 Dec 2020 22:29:02 +0000 Original-Received: (at 45536) by debbugs.gnu.org; 29 Dec 2020 22:28:04 +0000 Original-Received: from localhost ([127.0.0.1]:40459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuNTI-00070s-0L for submit@debbugs.gnu.org; Tue, 29 Dec 2020 17:28:04 -0500 Original-Received: from mail1477c50.megamailservers.eu ([91.136.14.77]:41058 helo=mail118c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuNTE-00070K-T7 for 45536@debbugs.gnu.org; Tue, 29 Dec 2020 17:28:03 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1609280874; bh=wdVAh/DPX0Hu3vB5FyT2/+lT57XCfgR9+oJ2fwU7Hmw=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=F7h1YIfsNMm8IutvsMOc2qR5VQWH2ipA5UWMOhHcvC1i1W2y3lPPTwsiVxk6R1HSE hvd+tUO/IdXpYgO7igYgakmcRn9FoJ2N7XftFaJ8x8SNljEPY8uHM0MmvVxy9uJUeL LHUY9N2Wl+K47T6l1rLEVsGcvuFd5bVJikraerq0= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0BTMRpxm024409; Tue, 29 Dec 2020 22:27:53 +0000 In-Reply-To: <83sg7oidp6.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A742F1B.5FEBAD6A.0018, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=HYRqsRM8 c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=Ezilf68ot9k4BFwKfkEA:9 a=CjuIK1q_8ugA:10 a=DxyIfoUXH20MTcFkbywA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Origin-Country: SE 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:196983 Archived-At: --Apple-Mail=_93843DBC-E6B9-4260-88E3-E6A5A48FA7E9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 29 dec. 2020 kl. 21.01 skrev Eli Zaretskii : > IMO, making this kind of changes is just asking for trouble: the gains > are null and void (I don't see why we should care about consistency > here), while the potential for breaking something out there is very > real. The gains are not null and void (or the change would not have been = proposed). There is no evidence for it being likely to break anything, but we can = make the reform optional and turned off by default. That way, code for = which it is desirable and safe could bind a dynamic variable during the = pretty-printing. Updated patch attached. --Apple-Mail=_93843DBC-E6B9-4260-88E3-E6A5A48FA7E9 Content-Disposition: attachment; filename=0001-Pretty-print-keys-without-around-modifiers-bug-45536.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Pretty-print-keys-without-around-modifiers-bug-45536.patch" Content-Transfer-Encoding: quoted-printable =46rom=207aa5bef4a0949846ec565e42b9799e6c910aa492=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Tue,=2029=20Dec=202020=2016:55:06=20+0100=0A= Subject:=20[PATCH]=20Pretty-print=20keys=20without=20<>=20around=20= modifiers=20(bug#45536)=0A=0ABe=20consistent=20when=20pretty-printing=20= keys:=20put=20modifiers=20outside=20<>,=0Athus=20the=20more=20logical=20= C-M-=20instead=20of=20.=0AThis=20behaviour=20is=20= controlled=20by=20modifiers-inside-angle-brackets,=0Aby=20default=20t=20= (for=20compatibility).=0A=0A*=20src/keymap.c=20= (Fsingle_key_description):=20Optionally=20skip=20modifier=0Aprefix=20= before=20adding=20<>.=0A(syms_of_keymap):=20Add=20= modifiers-inside-angle-brackets.=0A---=0A=20src/keymap.c=20|=2034=20= +++++++++++++++++++++++++++++-----=0A=201=20file=20changed,=2029=20= insertions(+),=205=20deletions(-)=0A=0Adiff=20--git=20a/src/keymap.c=20= b/src/keymap.c=0Aindex=20ca2d33dba4..c167772311=20100644=0A---=20= a/src/keymap.c=0A+++=20b/src/keymap.c=0A@@=20-2013,6=20+2013,9=20@@=20= DEFUN=20("key-description",=20Fkey_description,=20Skey_description,=201,=20= 2,=200,=0A=20Optional=20arg=20PREFIX=20is=20the=20sequence=20of=20keys=20= leading=20up=20to=20KEYS.=0A=20For=20example,=20[?\C-x=20?l]=20is=20= converted=20into=20the=20string=20\"C-x=20l\".=0A=20=0A+Modifiers=20are=20= put=20inside=20angle=20brackets=20iff=20= `modifiers-inside-angle-brackets'=0A+is=20non-nil.=0A+=0A=20For=20an=20= approximate=20inverse=20of=20this,=20see=20`kbd'.=20=20*/)=0A=20=20=20= (Lisp_Object=20keys,=20Lisp_Object=20prefix)=0A=20{=0A@@=20-2229,6=20= +2232,8=20@@=20DEFUN=20("single-key-description",=20= Fsingle_key_description,=0A=20Control=20characters=20turn=20into=20= C-whatever,=20etc.=0A=20Optional=20argument=20NO-ANGLES=20non-nil=20= means=20don't=20put=20angle=20brackets=0A=20around=20function=20keys=20= and=20event=20symbols.=0A+Modifiers=20are=20put=20inside=20angle=20= brackets=20iff=20`modifiers-inside-angle-brackets'=0A+is=20non-nil.=0A=20= =0A=20See=20`text-char-description'=20for=20describing=20character=20= codes.=20=20*/)=0A=20=20=20(Lisp_Object=20key,=20Lisp_Object=20= no_angles)=0A@@=20-2260,11=20+2265,23=20@@=20DEFUN=20= ("single-key-description",=20Fsingle_key_description,=0A=20=20=20=20=20{=0A= =20=20=20=20=20=20=20if=20(NILP=20(no_angles))=0A=20=09{=0A-=09=20=20= Lisp_Object=20result;=0A-=09=20=20char=20*buffer=20=3D=20SAFE_ALLOCA=20= (sizeof=20"<>"=0A-=09=09=09=09=20=20=20=20=20=20+=20SBYTES=20= (SYMBOL_NAME=20(key)));=0A-=09=20=20esprintf=20(buffer,=20"<%s>",=20= SDATA=20(SYMBOL_NAME=20(key)));=0A-=09=20=20result=20=3D=20build_string=20= (buffer);=0A+=09=20=20Lisp_Object=20namestr=20=3D=20SYMBOL_NAME=20(key);=0A= +=09=20=20const=20char=20*sym=20=3D=20SSDATA=20(namestr);=0A+=09=20=20= ptrdiff_t=20len=20=3D=20SBYTES=20(namestr);=0A+=09=20=20/*=20Optionally=20= find=20the=20extent=20of=20the=20modifier=20prefix,=20like=20"C-M-",=0A+=09= =20=20=20=20=20to=20avoid=20putting=20modifiers=20around=20them.=20*/=0A= +=09=20=20int=20i=20=3D=200;=0A+=09=20=20if=20= (!modifiers_inside_angle_brackets)=0A+=09=20=20=20=20while=20(i=20<=20= len=20-=203=20&&=20sym[i=20+=201]=20=3D=3D=20'-'=0A+=09=09=20=20=20&&=20= strchr=20("CMSsHA",=20sym[i]))=0A+=09=20=20=20=20=20=20i=20+=3D=202;=0A+=09= =20=20char=20*buffer=20=3D=20SAFE_ALLOCA=20(len=20+=203);=0A+=09=20=20= memcpy=20(buffer,=20sym,=20i);=0A+=09=20=20buffer[i]=20=3D=20'<';=0A+=09=20= =20memcpy=20(buffer=20+=20i=20+=201,=20sym=20+=20i,=20len=20-=20i);=0A+=09= =20=20buffer=20[len=20+=201]=20=3D=20'>';=0A+=09=20=20buffer=20[len=20+=20= 2]=20=3D=20'\0';=0A+=09=20=20Lisp_Object=20result=20=3D=20build_string=20= (buffer);=0A=20=09=20=20SAFE_FREE=20();=0A=20=09=20=20return=20result;=0A= =20=09}=0A@@=20-3331,6=20+3348,13=20@@=20syms_of_keymap=20(void)=0A=20=20= =20Vwhere_is_preferred_modifier=20=3D=20Qnil;=0A=20=20=20= where_is_preferred_modifier=20=3D=200;=0A=20=0A+=20=20DEFVAR_BOOL=20= ("modifiers-inside-angle-brackets",=0A+=09=20=20=20=20=20=20=20= modifiers_inside_angle_brackets,=0A+=09=20=20=20=20=20=20=20doc:=20/*=20= Whether=20modifiers=20go=20inside=20<>=20in=20key=20descriptions.=0A= +When=20non-nil,=20=20with=20a=20Control=20modifier=20is=20= written=20;=0A+when=20nil,=20it=20is=20written=20C-.=20= */);=0A+=20=20modifiers_inside_angle_brackets=20=3D=20true;=0A+=0A=20=20=20= DEFSYM=20(Qmenu_bar,=20"menu-bar");=0A=20=20=20DEFSYM=20(Qmode_line,=20= "mode-line");=0A=20=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_93843DBC-E6B9-4260-88E3-E6A5A48FA7E9--