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: Sun, 04 Jun 2023 16:04:39 +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> <86a5xfzllr.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30299"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , manuel@ledu-giraud.fr, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 04 16:21:45 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 1q5oc4-0007i5-Dr for ged-emacs-devel@m.gmane-mx.org; Sun, 04 Jun 2023 16:21:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5obH-0006VQ-GB; Sun, 04 Jun 2023 10:20:55 -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 1q5oLf-00049m-5V for emacs-devel@gnu.org; Sun, 04 Jun 2023 10:04:47 -0400 Original-Received: from mail-am0eur02olkn2041.outbound.protection.outlook.com ([40.92.49.41] helo=EUR02-AM0-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 1q5oLb-0006IC-Tt; Sun, 04 Jun 2023 10:04:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=axwGvDq+fT26eNWZQF5YSXnvHAhbT0Vsq5DyX+uTM74v1/AOjhqlxSPKVuv/xhrl7sBmQy8yx9yv+QTV1qpEiY4PUMi6GB15NFzQWHdk+3bOW1W6QbmNcgmlLH2IPz6PXNyPLQjb8KeNNhlk7V1RER3gUMdtBQdNpyW5clSkBtR/aZond8PzHim0kXdM4HcjER7ppsOMrF5X6xq1rGQ9g1NrSF1dBBdmb1Vt+emHOOi8hgunuCxEfgbhB8WVn+aShmlhuRm2YKdEzj2H/auU54cx2U8wt5H5UVVGj+4YcC3Q5sanSlcD6s3/3kOPeDHcvnJYqJaxwd2+xlyJbNtL2Q== 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=3Y98v+NtzT+Q6Evy3z6QGSRylvmnq79ke29ogDaefWk=; b=ecPHctn2JQFYqVdAbKb1pE1+FtXufGSQxKlMenbIm3RT8PtILneAXkRmR8vXSNBrOJJxewlp1wYEa8/9zMKzY/W5oFII02MBq2v6fRn2rT0tqZesvoqN/XzqQGuT2vthlIwXYdY152i/rfC4QrIUjHGjfLYMIK6OI91x0FDnr8YgcJ5V4jtmmDHrUJ1lKTFAykmtIPohIPKlGHEDWaqTsNZgDxjQ2s1atCrkoLs3nx2cwGL+gcQhIq4jbqp2HrDGWyKU8lfLE4WEAr9TVBtNv+gKzGJSGx6fga5MlguQBdgOhKwU6AF11JSSTzzijRZa6hdvlheSmYa3YUVmvMDDrA== 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=3Y98v+NtzT+Q6Evy3z6QGSRylvmnq79ke29ogDaefWk=; b=pLez7S57FhSAcq1QlETs30XWDQl6g01UpOcDl+AIn2SIZYJL3RMGUFxxJVY1N/66+FSQyYdLv7R5/Oph375CDGMh5OpWaoPXJYfr7KDTp0thOpbwqtUG9djYTK7NEVYFhf0QZCWEaEHMZj1Kr5Vl3MjPqBSIY35dX9L2t002KwiVdW9EAXR4J02gYCiUhfl42a+Ol6EsMfSSzeiFr9neVz4pb6UC78yzvanVaqPGa+GKzFiZsqH8evXTyNT+wA7F6par8torWx6J2qfqZ3fZayYj+X2nMU3X5kxZMWSTD3VGhpviC0/SyAsTk2o+x8ofd6gqKotd9qx0N/VD0h0brg== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AS1PR09MB5568.eurprd09.prod.outlook.com (2603:10a6:20b:4a6::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.31; Sun, 4 Jun 2023 14:04:41 +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.030; Sun, 4 Jun 2023 14:04:41 +0000 In-Reply-To: <86a5xfzllr.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 04 Jun 2023 10:52:40 +0300") X-TMN: [FimQ8VSFKqoBghvm1vOcP3nCSK1c5o7GgScmB6tY+Do=] X-ClientProxiedBy: BE1P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::14) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87r0qr2uiw.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR09MB4977:EE_|AS1PR09MB5568:EE_ X-MS-Office365-Filtering-Correlation-Id: afb2d1b5-e2f7-43df-134c-08db6504a3c5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q3OMrkg3gcj1KHQsJ8Jo3BAWSBg1o4M7vC6eK3hWO/nULZFNSiY177PfF/ZPvIf2WaE85SF6EhxCFlscom4jlK8PbHNnLIGYn7NKE5EBX6Fd8Mo2YxDAx1P0BVO2GVHlIW8JEBlux/aAHUpLkBWdkr28Ry4Tsksi4Z54IfBOxPFik2TLT0NIrBWki3omI1uNV40Xt39BV6oVjgGmHh7L8jd1iyCf44uBlkBsS/VIa2WSIcQfXoHyDwtm/5cz+vO+noMAU3PjxInnPGXcjdht5tFer/hHQ3KnSfAPOAP0RzQbo9EKQFqmev9y8Fr7XOiBnWXZNEHsB7kE1y89AoLOkRxrZ5m54JUgHZRGJELS4adbq1zO83SVGm3pjWtJdMzL09t59M1Hn3vlBr/wxYgP9m+xWZEuthyl5UPg+KV8T5qO8JXNCZA8mPUxpU80UvoEyC5srWWiGqtjQt3krRKlPyMAn4LoRCtdI7+EHbaU1n54XjbVdeFYDAsEJJXrqfM97QU7EULHcCxc0ANG8n2425DEVbA4kSkok9iYRo+izPXrca1SHmihe27zexherUIia1QLFeRV6Jd689MliHi+zfBvG2ocbiD5A8nqzuWqh+SHYe///u92armUTUZKYQfD X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Q3VQU2V1Qm0zcTZiayttdFhNTE02N0hiT2ZyN0prRnVoVTJvd1E4SjBSakpu?= =?utf-8?B?OUFQOEx5anBOV3ZOazFXaWlzVzA2TnRnOEs4U3lVN1c3cnE3YkVrVE91S2V0?= =?utf-8?B?RWlqcUt2WmhuWmNHa2lTWm54NnpQRFRaOFhORjFXbzQyS3VrVHN6cGp1bExj?= =?utf-8?B?QWVlODJoTnplUE9kNzRIMzFUMkZqU1JXZjJOV3NJMjhLdUYwUU5idFdVK01Q?= =?utf-8?B?SW5PanY1UGlmTTdmbm5jVGNaK25Pd0w3YS9LdUFGMTA0WlFJZktEdXNabG9T?= =?utf-8?B?akwwbHBlN0lnRkR0VmhTL0ZDaTZQQnVsY1krUitHWFNkcldmR2xsUktWaVBR?= =?utf-8?B?RGc5L2FvalRrL05USDJsTTVRWWZ1SnI2UWpmdDJiYms2WXBuNjVHUGlQdnNr?= =?utf-8?B?aWhMNGlRNVBiMlFsaERhazhVajRSRGpFenltdmNzRjdQTTVnTTRzY3AyK3BY?= =?utf-8?B?NmFReUpIWFNhRFBiajVkV3BjMFpCS2J1enBkWUZ1cVNQUzVRakkyM2RUN0Vt?= =?utf-8?B?MFJhTjUxaGNxakNLSmRNL0pxaFdtd3pEUW5kck0rWWpKRHpZL1BLbm9ZTlpa?= =?utf-8?B?NU81NTJKNmxuL0I5MHM5VThyeGFuRUQ2T29FbmVvUDhBbkxLTEJ5djY5MXc4?= =?utf-8?B?enpPdm1hMkZhd1VtSVZseHhaRnJDVHVabkVPQW X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: afb2d1b5-e2f7-43df-134c-08db6504a3c5 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2023 14:04:40.9633 (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: AS1PR09MB5568 Received-SPF: pass client-ip=40.92.49.41; envelope-from=arthur.miller@live.com; helo=EUR02-AM0-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: Sun, 04 Jun 2023 10:20:52 -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:306617 Archived-At: Juri Linkov writes: >> The interactive form has to be the very first form in a function body, w= hich >> 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 unfor= tunately >> 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 b= etter >> way if there is one. > > Another way is to add a new argument WINDOW to all commands. > Then the interactive form could send the window value to the body. Sorry I wasn't answered to your last few mails; I am just busy and would to= get this done and over. Yeah I would myself pretty much like to have that pedal= to modify all commands like a piano player; but I am really bad with it, I for= gett the pedal all the time when I play. But I would gladly start a business and sel= l Emacs pedals if you are interested! If you think of the bit of code I sent in as test-command; I would like to = get that *effect*, not necessary to really paste in all that code in each and e= very command. Could it be possibly to create a function, that is called by each commands and that arranges to execute the command in correct context (other-window or user selected window)? I mean like you suggested, some sor= t of parameter, keyword etc? If you think of your idea, which seemed more flexib= le to me, but to achieve that effect, and if that would in some easy to user macr= o a l=C3=A1 define-minor-mode or use-package style. > But when an interactive selection of a window by the user is not involved= , > then you can just call the same function like 'other-window-for-scrolling= ' > twice: in the interactive form and in the body it should return the same. > >> I have both in my WM and in Emacs that focus should follow mouse. Now wh= at >> happens is that, despite the function jumpiing to correct Emacs window o= n >> another frame, due to cursor being in old frame, all input goes to the o= ld >> 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 p= robably >> my WM spooking. I will try to test with some other WM and to boot into W= indows >> and test there, but on systems where focus follows the mouse, I guess th= ere is >> nothing to do? I suppose the same issue will happen with few other funct= ions >> that prompt user for the input via minibuffer. It works well when Info w= indow is >> on the same frame of course. > > 'other-frame' explicitly calls 'select-frame-set-input-focus' at the end. I have just found a solution that will display menu in users selected frame= , so all good :-). #+begin_src emacs-lisp (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.")) (with-current-buffer (window-buffer 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 ni= l nil default)))) (list item current-prefix-arg)))) Info-mode) #+end_src As I got the idea yesterday while writing about it; It is possible to just = work in info-buffer, there is no need to also switch to window. The above intera= citve form is from Info-menu; and now I get the prompt displayed in the selected = frame not one with the *info* buffer and I can remove the ugly global var I used = for "the communication" too :). >> I do have another question too: what is a good strategy if there are mul= tiple info >> windows open? Prompt user to select with a completing read, or just leav= e as-is, >> i.e. return the first info window? > > I think a good default would be to use the most recently used window. Isn't that what would Emacs does per automatic, I mean what get-buffer or get-buffer-window chooses?