From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Control help- and Info-mode buffers from other buffers Date: Sat, 03 Jun 2023 15:53:22 +0200 Message-ID: References: <87h6ruf09e.fsf@ledu-giraud.fr> <861qixbum2.fsf@mail.linkov.net> <86wn0opgpi.fsf@mail.linkov.net> <86ilc78zc2.fsf@mail.linkov.net> <834jnrek7w.fsf@gnu.org> <86v8g77iof.fsf@mail.linkov.net> <83o7lzcxm8.fsf@gnu.org> <837csncfz1.fsf@gnu.org> <83o7lybaph.fsf@gnu.org> <83ttvpao80.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3426"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: juri@linkov.net, manuel@ledu-giraud.fr, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 03 15:55:53 2023 Return-path: Envelope-to: ged-emacs-devel@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 1q5RjS-0000dm-SU for ged-emacs-devel@m.gmane-mx.org; Sat, 03 Jun 2023 15:55:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5Riw-00016x-Tz; Sat, 03 Jun 2023 09:55:18 -0400 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 1q5RhE-0000pP-FH for emacs-devel@gnu.org; Sat, 03 Jun 2023 09:53:32 -0400 Original-Received: from mail-am6eur05olkn2082.outbound.protection.outlook.com ([40.92.91.82] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5Rh9-00025T-Js; Sat, 03 Jun 2023 09:53:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnaDd/oBotcN1gXR3aWx2e6puYb1+0do3/QaFCN01E4TMq6JaLhP2LiNv14hZHAlMst8ILHHcNWLPSrJhe6MltHIq36s5DIiFNoSEE8B1eANC2/cs0ZrhTPzuxIkd4jJD5JQTyPMTTY45TI6HjBjSpesLlSVXgHC4h8ElKqDRLAm+ma4L7ajgYJPNoSVbdQpJ+Bh2w60c1zR1GO/GdwIQd/JtQKv1+Axyt+tGrjaBzq/jyH1haBCsT9pv0OkrAGrh2qyiY8p3PYwVK0Cwc184bgyLHt8bRyuBLQ+8X3BgwkGwcgY5FgCfw0VkcJPUDFNH86onwNM2Mmy93DFMx3CuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9GLgKjS/Qy5UnvxETtuQO1E/r5gHUoZGc5ZX23UWJSA=; b=odM5FuJUASu4H+YCi66HCDVqII3OTG+LrR2xC12QkNFM5DJlUhG7f5/Lf55tCvJ8WCIgGGU5+eOp9azZOK5/6EfPuAgWR+k23fx8kBeuICOQygtF9Hseo2xVuuGvX1EKBtzF3t7a1fvJ7Su5eKFvQXaHtoI6Q1wK0eQLenXSZ20Reolpb9qjtPz96HgJnfoHAcD9cDLGSfiLW96O/32BVKx0355SqxR/5eWbKfhUQTgAkG8mDSu6YHPfqbgLraHrM6YDAQvNtLb5NTzF3n0Qr8Kx4b53gtBLAWgCwICtMbDlJvKynUuGCAEY/rHX1dGlclMt479xrq/L4J5gi2jZMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9GLgKjS/Qy5UnvxETtuQO1E/r5gHUoZGc5ZX23UWJSA=; b=WIxFXu/pTDvBgtkU7rPWj8jBqfzSHBkOR2WsrUE/x7Acz4NI0RrBNplIRUfmAwOfx4kDhcRbYonTuEF2ZLpl+boRlQB00Ov/JKoeSn1RJIY1Y24oWjK0lkxW2HON18sn+uLedBiigc7IHbOgGTbFjJJls6PKfTpgcAqY+jh8rup2uzNnHr+9QGT1Z4UARMsbngXatrtllm+Vj8qFakIlzgBAEnP/C3I1uRLEd8QFAxYS5tUbzNSdBsOzsM7Wlks5bDOJraNNDMWkKkNVlKe5aCO+Z+pScGNgBDk3HxEWNFWhBGjQpIT7aZlQgi1jfrxtMw1N4DDDCU4mikmNb5VyaA== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by DB9PR09MB6010.eurprd09.prod.outlook.com (2603:10a6:10:3dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.28; Sat, 3 Jun 2023 13:53:24 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::6983:1def:fb14:21bf]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::6983:1def:fb14:21bf%6]) with mapi id 15.20.6455.027; Sat, 3 Jun 2023 13:53:24 +0000 In-Reply-To: <83ttvpao80.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 02 Jun 2023 11:16:05 -0400") X-TMN: [iIApCscApFdwY0qrC+IsRizkigfUvlzy5pni5F4LKS8=] X-ClientProxiedBy: MM0P280CA0047.SWEP280.PROD.OUTLOOK.COM (2603:10a6:190:b::28) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87zg5gabzh.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR09MB4977:EE_|DB9PR09MB6010:EE_ X-MS-Office365-Filtering-Correlation-Id: b16e4c26-74e0-422e-ec33-08db6439e5d7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q5LrzflwOQsfy5Wx3Ko+Q3G4qRKVDoOvTi0FT6knqiX2hmGV8yVQjorppFhXljq3yHY1Ou9AMdWYJfTF6NJzLzM+auQT9vU6YS5zCr0bF0N5EGVVL/TjM/E2j4v0J85AoQHxyNWogUxW523T2HdBdS4bbrCtXebsfSTDDgYpgHZFvU5GwNYseKN0YEsNL0p7SiXEf0qBKb1/ZQ5lGjRFeJ2QVWkuHayUjnf0Ub2P3S20jekrwbI3a8Oo5Ct/SzrvfGnBV1y9sHdQxiNvRNS5FyD5dHasnnnATDnG5kgjIp+oqnwiBspvJo9JLyRaSmwmfkusv5UJMx57J1kFrVAm6GkPrMHeqd1eIOW0NdfTtCeHAfIKpWynPn57jsYdXhMueLpbDYCy6N2Sq75PzBCk43lIx4QTsi5JW//YJZtGOvQNpSYL9meJLe2RZVGHoodpb8UFxmsjZA5vONISBBLnzvUYCPqC9VhNBhBDrwjnkQFnyLrPEK+ExiouKCngKQy00FR5x1tUGVmU8jLwKjg3TX5eoqmsjO/N6dVwCABE0BKkdHfWj/xV510hGlr+iH5/TYCha+XtQvmU84lmfLMwsQa/OniuMPSeTXKbhguuyuL1pQUjsijSpHk70xze9XTY X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?reGlHVWxnB7MqvTwqr4Y4KHMKw3YcK95CsaG6jPlBzFaY8EbH2JMKyoYni98?= =?us-ascii?Q?NmmWImwo7BYyffNHopsgj65BBwCjfrpzq5p0fyGkYHwjHNbV44yY41fYhKVg?= =?us-ascii?Q?8rqRpeq4bcgRkxG7hn3Kl80N6rMJdOh6DSxEaNtCRbZodzxgL44LfLF84Oc8?= =?us-ascii?Q?f+P/LPOxMriK1O6xKgd0oqsTfVL8qcm34C98LLHT+ztDmFCBppWVh4dwgKnV?= =?us-ascii?Q?vuWXjjU1ZcNQXoGrzEVYzyzM/8/hlhmbr3B+YQvc2ZJpvOnAA7tBL3nlm78C?= =?us-ascii?Q?TbFHRQXxK6s0oq7U5A00MtRaKLTc/1pPYfEMdc/+iM7cikzsdfDfB92dmQq7?= =?us-ascii?Q?5D8Z1cMjsRocxK5FVD322yg79fy9S1jROkX1/uwEQp28w5pnK47w+R4NEMkB?= =?us-ascii?Q?CVBRTEYDoY8/VRngIlgRnBKxjzbnLbSHuhd15N1kk0r13glHL8rFtPT7rK8J?= =?us-ascii?Q?BrdnH7XQtd6Lpq78rLfcpODKx0Wz+GKFv4E66fhKo967gPojuar1rzQnbxHb?= =?us-ascii?Q?ozhmNqzxxbAa05sN+01YiBPyQprxbt5tMChTEvrXhlltqxr3LWBpPDxLbdM2?= =?us-ascii?Q?VcIfyaJ071dTPSOIMX7H40UZdN/hvXBysnez9SDr9KTCPjMRF75qI88QALPS?= =?us-ascii?Q?UY X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: b16e4c26-74e0-422e-ec33-08db6439e5d7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2023 13:53:24.1127 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR09MB6010 Received-SPF: pass client-ip=40.92.91.82; envelope-from=arthur.miller@live.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 03 Jun 2023 09:55:13 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306589 Archived-At: Eli Zaretskii writes: >> From: Arthur Miller >> Cc: juri@linkov.net, manuel@ledu-giraud.fr, emacs-devel@gnu.org >> Date: Fri, 02 Jun 2023 17:09:36 +0200 >> >> Eli Zaretskii writes: >> >> >> > (with-selected-window (get-buffer-window "*info*") >> >> > BODY... >> >> No you need a bit more than that sometimes. In case that interactive is doing >> >> some prompting and buffer dependent setup, you will have to wrap interactive >> >> body for itself, and function body for itself. See Info-mode or Info-find (I >> >> think) in patch, but conceptually, yes that is about it. If you can live with >> >> wrapping commands in with-selected-window. Due to fact that interactive form >> >> must be the first form in a function body. >> > >> > You also have call-interactively, which can work around this minor >> > obstacle. >> >> Can it? I am talking about interactive "marker" when in defun impelementation; not >> calling interactive functions. > > Maybe I don't understand the problem you have in mind. > > In any case, whatever the problem is, I'm sure we already have a > solution for it in gazillion other similar cases. I like the anser :-), but unfortunately I am affraid I will have to say it is one of those "fundamental problems". But perhaps I just don't know how to do it better; see this: #+begin_src emacs-lisp (defun Info-menu (menu-item &optional fork) "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM. The menu item should one of those listed in the current node's menu. Completion is allowed, and the default menu item is the one point is on. If FORK is non-nil (interactively with a prefix arg), show the node in a new Info buffer. If FORK is a string, it is the name to use for the new buffer." (interactive (let (;; If point is within a menu item, use that item as the default (default nil) (p (point)) beg (case-fold-search t) (mouse-autoselect-window nil) (info-window (get-buffer-window "*info*" t))) (unless (window-live-p info-window) (user-error "There is no visible Info buffer.")) (setq Info-jump (selected-window)) (select-window info-window) (save-excursion (goto-char (point-min)) (if (not (search-forward "\n* menu:" nil t)) (user-error "No menu in this node")) (setq beg (point)) (and (< (point) p) (save-excursion (goto-char p) (end-of-line) (if (re-search-backward (concat "\n\\* +\\(" Info-menu-entry-name-re "\\):") beg t) (setq default (match-string-no-properties 1)))))) (let ((item nil)) (while (null item) (setq item (let ((completion-ignore-case t) (Info-complete-menu-buffer (current-buffer))) (completing-read (format-prompt "Menu item" default) #'Info-complete-menu-item nil t nil nil default)))) (list item current-prefix-arg))) Info-mode) ;; there is a problem here in that if several menu items have the same ;; name you can only go to the node of the first with this command. (let ((info-window (get-buffer-window "*info*" t)) (mouse-autoselect-window nil)) (select-window info-window) (Info-goto-node (Info-extract-menu-item menu-item) (and fork (if (stringp fork) fork menu-item)))) (select-window Info-jump)) #+end_src The interactive form has to be the very first form in a function body, which makes it impossible to just wrap the entire function into with-selected-window. In this case I save selected-window in global var (Info-jump) and select that window back at the very end of the function. It is the same effect as if being wrapped into with-selected-window, but unfortunately it uses a global variable. I don't know how to do it otherwise, if there is a better way, pleae let me know, I would like to learn how to do it in a better way if there is one. However, that is just a side note as answer to your remark, but unfortunately I have found that there is a bigger problem. I am not sure if it is Emacs or my X11 window manager, but I do suspect the WM in this case. I have both in my WM and in Emacs that focus should follow mouse. Now what happens is that, despite the function jumpiing to correct Emacs window on another frame, due to cursor being in old frame, all input goes to the old frame, so at least this particular function does not work with multiple frames. According to the docs for select-window, both frame to which the window belongs, and the buffer displaying are made selected/current, so it is probably my WM spooking. I will try to test with some other WM and to boot into Windows and test there, but on systems where focus follows the mouse, I guess there is nothing to do? I suppose the same issue will happen with few other functions that prompt user for the input via minibuffer. It works well when Info window is on the same frame of course. I do have another question too: what is a good strategy if there are multiple info windows open? Prompt user to select with a completing read, or just leave as-is, i.e. return the first info window? I have tested all help-mode functions with multiple windows, and there are no problems there. thanks for help