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: Sat, 5 Oct 2019 00:03:01 -0400 Message-ID: <39178daa-2edd-9cf2-9bb4-42942b6e2132@gmail.com> References: <14423aa7-36c3-9ab7-6483-d43624f99e17@gmail.com> <83pnjd7pud.fsf@gnu.org> <83h84p7nih.fsf@gnu.org> <837e5l7j8n.fsf@gnu.org> <83imp461do.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="22578"; 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 Sat Oct 05 06:03:16 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 1iGbHn-0005i1-E0 for ged-emacs-devel@m.gmane.org; Sat, 05 Oct 2019 06:03:15 +0200 Original-Received: from localhost ([::1]:54190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGbHl-0006Jo-GT for ged-emacs-devel@m.gmane.org; Sat, 05 Oct 2019 00:03:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41077) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGbHe-0006Jf-Es for emacs-devel@gnu.org; Sat, 05 Oct 2019 00:03:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGbHd-0003TI-1y for emacs-devel@gnu.org; Sat, 05 Oct 2019 00:03:06 -0400 Original-Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:34966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGbHc-0003SL-SV; Sat, 05 Oct 2019 00:03:05 -0400 Original-Received: by mail-qk1-x733.google.com with SMTP id w2so7793492qkf.2; Fri, 04 Oct 2019 21:03:04 -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=QkF3C9nV+JoJ942hICv4VdemXiHQb1Um4C98q7GdZaw=; b=Ct/mPZ98pHM6QLs5bBzuBMmYAXHe8cyByjMgQBnOXhVpWzJWXDmvZXRKy5/x+mtiiO M+QmBeeXcCSyxlpZlLdQ1ERH/JdERRTky6gPxACOq3iM+04Xp+cTUTcFbVZyj5pGgh15 gcXj1tlsiGT2g4nH37G/PuqTBOJxLK1sfBzLN2alg3U/OTyyaw1moKBfU0TWVu43B7ig 5edaayNhntyLt1tzT5wQ6oUWZL0buEYgHEzSSEK5j/NmD5dNXegPYi4ZU8/nswC6mKsL beNFYty0J8H9/hyIFHinqDjZLYeqIjI3ASbBy/aamWn4cSpEiP9fmFktTpcdZLvFPjZH /8/g== 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=QkF3C9nV+JoJ942hICv4VdemXiHQb1Um4C98q7GdZaw=; b=QvUxy1DPFcz15+F8QGIDK8RCMDMywylqWRbgAHxrReQZwcZcZieKboQV3jeZPeSUkR ZK/b34+k6yXKQZJUV7TMb/tZD/SrINoviCdOKVSw+C2AM1FwHvvTS7w74pz0Nvud2hqj 1okXoFCz2c89hZ2C96XQbABBIWjkfpid+lmvhyFpzTrHOB1XagoXwgoeMb5V0v3XKnbi 0C0FpdM+Hyk0g4OSw0reDRs6boiV+X208m3sYf2FlT2z9c+1hdX8fMzkr2pyfR70LnOy 3XMucFqRLMwqOxxRfFgNl/Win5cAf4jPsNoBAqo80Q8NcVQPe8iOEkVom3e0sCLmeH0z 0m0A== X-Gm-Message-State: APjAAAU2nZE14+CUwVKO4t9FALlh61kwQVHPgSCbG3xP/QyV8lbYWt5I ty9vhavfkQhmS5v/BDw6PB5PiLtl X-Google-Smtp-Source: APXvYqw+Ankd/ngZpbesfFZL36LK0YRnrZCqHZAfGGBp4Em/D6tY23wzpxyQs44fTgNac9hR8EVvJg== X-Received: by 2002:a37:4e84:: with SMTP id c126mr12992764qkb.334.1570248183811; Fri, 04 Oct 2019 21:03:03 -0700 (PDT) Original-Received: from ?IPv6:2601:184:4180:66e7:656c:d996:de5:9bda? ([2601:184:4180:66e7:656c:d996:de5:9bda]) by smtp.googlemail.com with ESMTPSA id z6sm3743456qkf.125.2019.10.04.21.03.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Oct 2019 21:03:02 -0700 (PDT) In-Reply-To: <83imp461do.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::733 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:240591 Archived-At: On 2019-10-04 10:17, Eli Zaretskii wrote: >> Cc: emacs-devel@gnu.org >> From: Clément Pit-Claudel >> Date: Fri, 4 Oct 2019 09:56:56 -0400 >> >>> Then why do you use APIs that are meant for keys and quoted strings? >>> Why not format the message yourself? >> >> Sorry, I do not understand what you mean. I want to display information when the mouse hovers on a portion of the buffer. Isn't the proper way to do that to set a help-echo property on the corresponding text? > > help-echo is for displaying documentation, not for displaying > general-purpose text strings. Understood. Thanks for taking the time to explain. In my experience, help-echo is very convenient (modulo this small issue with substituting command keys) for the general purpose of associating a small amount of help text to a buffer region, because everything is handled automagically for you. For example, both flycheck and flymake use it to attach errors or warnings to regions of the buffer. I have briefly reviewed the places where I use it in my code, and indeed it falls into two categories: * Places where I want to indicate to the user how to interact with the text (really, a button) under the cursor. There's are many places in Emacs that use it for this purpose, indeed, but most of them actually don't leverage the command substitution facility: lisp/help-mode.el:291:4: 'help-echo (purecopy "mouse-2, RET: visit theme file")) lisp/vc/vc-git.el:706:11: 'help-echo "mouse-3: Show stash menu… lisp/progmodes/compile.el:114:30: 'help-echo "Compiling; mouse-2: Goto Buffer" lisp/help-fns.el:1073:12: 'help-echo "mouse-2, RET: show value") * Places where I want to add some general information about the text at point. There are some places like that in Emacs too: lisp/net/shr.el:1499:8: 'help-echo title ;; This is the title of an tag lisp/net/shr.el:1237:4: 'help-echo (let ((parsed (url-generic-parse-url ;; This shows the URL a links points to lisp/progmodes/flymake.el:647:23: (default-maybe 'help-echo ;; This attaches a compiler message to a buffer region The motivation for using help-echo in the second case is that works very easily and very smoothly: users see the text in a tooltip if they hover, and in the echo area otherwise, and you don't have to do much on the package side at all. But the command-key substitution only makes sense in the first case: neither shr nor flymake want quotes transformed in the help-echos that they set, because these are data coming from the outside. > And a little ways down from that text you have a cross-reference to > "Help display", which leads to the description of show-help-function, > and that one does say the output is passed through > substitute-command-keys. Got it, thanks. My bad. > No reason to apologize or think you were wasting my time. Thanks for your patience :) > Please tell more about these inconsistencies. Specifically, which > APIs behave inconsistently? There are two main places that I know of in Emacs that use help-echo: help-at-pt, specifically display-local-help, which displays the contents of the help-echo in the echo area; and show_help_echo, in keyboard.c, which calls show-help-function after running substitute-command-keys. The inconsistency is that the former displays the help-echo property unmodified, whereas the latter displays it after running substitute-command-keys. > Tooltips by themselves don't substitute, you get in the tooltip the > exact text you've provided. Here's an example I just trried: […] > The substitution happens specifically in generating the help-echo, and > it happens before we pop up the tooltip. Indeed, you're absolutely correct. The convenience that help-echo provides is that it provides a very easy way to tell Emacs "display a tooltip with this text when the mouse hovers above this overlay". I think it's not easy to achieve this result otherwise, which makes help-echo a generally useful primitive. > It is possible that we need to provide some additional facilities to > make this stuff more flexible in specific situations, but I think we > should first be on the same page regarding the existing facilities and > what they are intended for. I hope the above helps with that. Thanks again for your help. Clément.