From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Escaping a string for substitute-command-keys Date: Thu, 3 Oct 2019 14:28:43 -0400 Message-ID: References: <14423aa7-36c3-9ab7-6483-d43624f99e17@gmail.com> <83pnjd7pud.fsf@gnu.org> <83h84p7nih.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="46884"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 03 20:29:55 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iG5rL-000C20-Ls for ged-emacs-devel@m.gmane.org; Thu, 03 Oct 2019 20:29:51 +0200 Original-Received: from localhost ([::1]:39264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iG5rK-0004xr-GT for ged-emacs-devel@m.gmane.org; Thu, 03 Oct 2019 14:29:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42632) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iG5qL-0004xg-BS for emacs-devel@gnu.org; Thu, 03 Oct 2019 14:28:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iG5qJ-0001C2-Ki for emacs-devel@gnu.org; Thu, 03 Oct 2019 14:28:48 -0400 Original-Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:45474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iG5qJ-0001Bk-H1; Thu, 03 Oct 2019 14:28:47 -0400 Original-Received: by mail-qt1-x832.google.com with SMTP id c21so4913049qtj.12; Thu, 03 Oct 2019 11:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pNDHHneeKOy8tG3RPmq/ZZY4vOQTlPMjkWN6FdiDAVw=; b=rikvfFTNZg2j+wDAzZMywZAsDY4sgEsu4wFFxEUKF8qaNaoBh27q3PRllCqRWOqNM7 3qhDAd4wVOkPeR3wqntJY9x6ycqw0Fouzwlm3GRebGKqqzT+RA7CZtD4pQVEsw/R2BEc 3LYYgwWSL037i8hypY9lCUdFD49gBUAklJm/WxXInimGKMouzkNfLf6heOMo/MIovMDH NVLUOCoeOt2PHo7fDnYpLiMx+2GQ5XBhnVl846Op8ac+nARrSZfgKuFb4q2Nz3tBDJkq 5YnzVI+yjThS+w1FrubVZZGbHsTS6kY9tWDGbOP+SSZbK2FdQtKavbByFs+RhKHhqtFe z6Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pNDHHneeKOy8tG3RPmq/ZZY4vOQTlPMjkWN6FdiDAVw=; b=b3MAEOt7JA4EJ6tmR2tXdl7/80WtMuKU7lI0sTLcSqEKi+H6/PfOOG2AJZctSNzLtW EENeu4VWjOS92Ocue4fqw00IH7hVbi0NYf5ONrXyj/MG2vAMD7G2QG7EUTa1KsH3tkYl TPop/kQUY1TvX7jdRrUyrzrq8+rU0JB7g3JpLpzrThHSnXx/Y0f+6C8dhi6ca25H7QA8 bMa8RoKo3VvHZS4eUdzMip8ZvF29NPwLRyxjQsdXO8gpEQLwNIk5FMxtuirSKlPyPLh9 gJ2MurK6ehu9tZmqKer1PyC/1yoCaxgFt/FRaUhlwmHkDW32yTyv58DfPbsgrGhJxM0c h+zg== X-Gm-Message-State: APjAAAW2UGzM8Ej+XNPI94IggON62pVs0vs1ykWxAJlOZ3vjZ8tNOZRB WkpwtCe6anmZuG9PwsRz41JgeP9f X-Google-Smtp-Source: APXvYqyBrh2Qn2ZLcnfwjVE6yQql/cj9biXq+59JgKZW/Is8CbWx3xcUS726p0nqEMzMBkjEUWx20A== X-Received: by 2002:ac8:7b97:: with SMTP id p23mr11405355qtu.292.1570127325749; Thu, 03 Oct 2019 11:28:45 -0700 (PDT) Original-Received: from [128.30.9.205] (30-9-205.wireless.csail.mit.edu. [128.30.9.205]) by smtp.googlemail.com with ESMTPSA id v85sm1832909qkb.25.2019.10.03.11.28.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Oct 2019 11:28:45 -0700 (PDT) In-Reply-To: <83h84p7nih.fsf@gnu.org> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::832 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240526 Archived-At: On 2019-10-03 13:21, Eli Zaretskii wrote: >> Cc: emacs-devel@gnu.org >> From: Clément Pit-Claudel >> Date: Thu, 3 Oct 2019 12:46:50 -0400 >> >>> If I understand what you are looking for, the answer is in the manual: >>> quote any character with \= (in a Lisp string, that's "\\=", of >>> course). See the node "Keys in Documentation" in the ELisp manual. >> >> I saw that part in the manual, but I was looking for a function that would do that. Is there an easy way to tell what needs escaping, or should I just escape all `, ', and \? (and if so, should we add a function that does that to subr-x.el or somewhere similar?) > > Is the problem only with quotes? Or also with other characters? Any characters: for example, \\[ should not trigger a replacement. The use case (displaying warnings and errors as overlays on code) does not require any string transformation, just to display what a tool (such as gcc or python) produced. Ideally, it would be best to be able to turn off that translation entirely, I think. I see why it is convenient, but it seems wasteful to mangle a string with escapes only for these escapes to be promptly removed right after. > I don't think we have a general solution, but yes, escaping every > character that makes trouble would be one way. That makes sense. There's an additional problem that I hadn't thought of at first: if I change the help-echo property on my help-echo strings, even though I'll get the right message when mousing over, now things will break for other renderings that do not use substitute-command-keys (in fact, most places that I see in lisp/ do not use substitute-command-keys on help-echo; most importantly, help-at-pt doesn't). In other words, at the moment I can either get "The footer should be: (provide 'xyz)…" in the echo area and "The footer should be: (provide ’xyz)…" when hovering; or "The footer should be: (provide \='xyz)…" in the echo area and "The footer should be: (provide 'xyz)…" when hovering; neither of these are good. Should all uses of help-echo be fixed to call substitute-command-keys, and should all code that sets help-echo and doesn't want substitutions changed to escape quotes and backlashes? Thanks for your help, Clément.