From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60587: Patch for adding links to symbols' help documentation Date: Wed, 15 Feb 2023 22:08:01 -0500 Message-ID: References: <86y1qgr1bf.fsf@duenenhof-wilhelm.de> <86tu13qydg.fsf@duenenhof-wilhelm.de> <83h6x2u74b.fsf@gnu.org> <863588rfos.fsf@duenenhof-wilhelm.de> <83o7qw0yjy.fsf@gnu.org> <864jskx6a8.fsf@duenenhof-wilhelm.de> <831qnomh6l.fsf@gnu.org> <86wn5anw04.fsf@duenenhof-wilhelm.de> <86h6wboe2v.fsf@duenenhof-wilhelm.de> <86edr59bua.fsf@duenenhof-wilhelm.de> <86mt5j87qz.fsf@duenenhof-wilhelm.de> <86leky609i.fsf@duenenhof-wilhelm.de> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30664"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Juri Linkov , Eli Zaretskii , "60587@debbugs.gnu.org" <60587@debbugs.gnu.org>, Drew Adams To: "H. Dieter Wilhelm" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 16 04:11:59 2023 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 1pSUgh-0007lL-9N for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Feb 2023 04:11:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSUdr-0007F7-3k; Wed, 15 Feb 2023 22:09:03 -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 1pSUdp-0007Ew-WB for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 22:09:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSUdp-00005d-NL for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 22:09:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pSUdp-00011B-ID for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 22:09:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Feb 2023 03:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60587 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60587-submit@debbugs.gnu.org id=B60587.16765168953858 (code B ref 60587); Thu, 16 Feb 2023 03:09:01 +0000 Original-Received: (at 60587) by debbugs.gnu.org; 16 Feb 2023 03:08:15 +0000 Original-Received: from localhost ([127.0.0.1]:34555 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSUd5-000109-5X for submit@debbugs.gnu.org; Wed, 15 Feb 2023 22:08:15 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:59299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSUd0-0000zr-IK for 60587@debbugs.gnu.org; Wed, 15 Feb 2023 22:08:13 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 84B17442A05; Wed, 15 Feb 2023 22:08:04 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9B1BC442A00; Wed, 15 Feb 2023 22:08:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1676516882; bh=3X8ooGnS1kgboXiyXrvNFDkuGKplWgIdj+FT4AnJ1QQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Gbxc1LPmxuywfEBFB5lnUnlDSUTgsNXpavFb1Y/UTBOVsR/9S7aTOrfazbdEknVyT mNbg19f5ZyqHjySuryX7RTetWEQYQnpR/sHFeB/x++OVLy74n1+6FSPQrf1SFKJaZc 9kSuWcdQVDcKU1qONALVZ3toJr2uzgZDXjrq1EKR98NQYHb3JTOQDMpmlXJWhPnX4F SaSC9Yvm+XQJjFIwy7Zl7jcGEDQ0ee2LYjOhXKPcM5pgb2wYH16wpIl9u7DguEmTeY gtrehAb3tdSIVbLBXtyhNjcTvXV0rrmhWFbT/7utFX7aJ+J29h5I8iuUVm1t8CFKHJ tqZlK6a+KV7sw== Original-Received: from pastel (104-222-113-2.cpe.teksavvy.com [104.222.113.2]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 688EE1231FF; Wed, 15 Feb 2023 22:08:02 -0500 (EST) In-Reply-To: <86leky609i.fsf@duenenhof-wilhelm.de> (H. Dieter Wilhelm's message of "Wed, 15 Feb 2023 23:18:17 +0100") 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:255790 Archived-At: H. Dieter Wilhelm [2023-02-15 23:18:17] wrote: > Stefan Monnier writes: >>> +(define-minor-mode info-links-to-help-mode >>> + "The mode creates buttons on symbols linking to their documentation string. >>> +It shows their documentation in a *Help* buffers (in another >>> +window) when typing or clicking `mouse-2' on the buttons. >>> +These can be followed, as the regular Info manual references, >>> +with \\[Info-next-reference] and \\[Info-prev-reference]. >>> + >>> +For details about which symbols are considered and the linking >>> +process itself please see the function `info-make-links-to-help'." >>> + :init-value nil >>> + :lighter " Hlp" >>> + :group 'info >>> + :version "30.1" >>> + (if info-links-to-help-mode >>> + (progn >>> + (if (eq major-mode 'Info-mode) >>> + ;; we need this under Info-mode because of the narrowed >>> + ;; Info file >>> + (add-hook 'Info-selection-hook 'info-make-links-to-help)) >>> + (info-make-links-to-help)) ;for the current buffer >> >> The above `define-minor-mode` still defines a buffer-local minor mode > > I thought a minor mode is necessary when 'info-make-links-to-help' is > supposed to work for arbitrary major modes and buffers besides Info. I don't understand your remark. I'm pointing out that the way you use `define-minor-mode` above makes it buffer-local (if you want it to be global, which is probably simpler you need to say `:global t`). >> whereas the above `add-hook` is still global and hence affects all >> buffers. > I'm not sure I understand, it affects only Info buffers globally (eq > major-mode 'Info-mode). But it affects all Info-mode buffers whereas the `info-links-to-help-mode` variable will only be set buffer-locally in the current-buffer. So you'll have Info-mode buffers where `info-make-links-to-help` has been added to `Info-selection-hook` even though its `info-links-to-help-mode` var is nil and you can have others with the reverse. > Do you think it is better to use a global minor mode for all Info > buffers and a separate buffer local mode for other buffers (and major > modes)? If I were you, I'd just use a single global minor mode that affects all Info-mode buffers (and only Info-mode buffers). It should be rather rare for a user to want to enable this in some buffers but not all. We can easily add another global minor mode (using the same underlying code) for the NEWS files if we want. >> Better add a call to `info-links-to-help-mode` directly inside >> `Info-mode`. > (Please tell me why are you quoting with two grave accents and not with > apostrophes?) I try to follow the Markdown convention. > Do you think setting > > (defcustom Info-mode-hook '(turn-on-font-lock info-links-to-help-mode) > "Hook run when activating Info Mode." > :type 'hook > :version "29.1") > > is a possible alternative to call it into 'Info-mode'? I think I was confused because. IIUC what you're trying to do is to default this new minor mode to "enabled". In that case I think your code is somewhat OK though you should protect the `add-hook` with a test for the value of the minor-mode to make sure you only run it when the mode is enabled (which again only makes sense if the mode is global). Stefan