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: Fri, 02 Jun 2023 03:10:41 +0200 Message-ID: References: <87h6ruf09e.fsf@ledu-giraud.fr> <861qixbum2.fsf@mail.linkov.net> <86wn0opgpi.fsf@mail.linkov.net> <86ilc78zc2.fsf@mail.linkov.net> <86mt1j16ht.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40264"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Manuel Giraud , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 02 07:20:00 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 1q4xCg-000ADe-Qg for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jun 2023 07:19:59 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4xBc-0007dJ-KX; Fri, 02 Jun 2023 01:18:52 -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 1q4tJZ-0008UO-26 for emacs-devel@gnu.org; Thu, 01 Jun 2023 21:10:50 -0400 Original-Received: from mail-he1eur04olkn2017.outbound.protection.outlook.com ([40.92.73.17] helo=EUR04-HE1-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 1q4tJW-00011s-Gj for emacs-devel@gnu.org; Thu, 01 Jun 2023 21:10:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4fdSO5hUEA5vNBdCcqVylxf0jvBfafIuJiyi4ISgYuzAn1gmHryq5pHBMQCnOuVJOH4gL2Cd1+GCtIoWoOW1d2Zicmgjqg9sqsGO64whqUivD76sVMccKt/Loa7Y5DxAnmE0ef30lOA5dPJDSCUWmKG2FSJdygMiKnbzYETOyBJosy8N2+/eaokIgqiFKzpXchBvt3O+ujNqd4OJ23Hz0jHXHUWxWcd/LoUL963ZjPPkPSxjGJb59HnKz87KaRXN9Ird30xx0Dp7uOP890RrEfFWadQvxLQ2WS5hEZCv/z79TouJ55F43QBVTQiXPF6OlwC9oVkhTJNOwqDy9hzcQ== 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=AgJ5SKkoKgyXZMfemTdqpkfBW/JTZ+ygrWpu+JdehXw=; b=aHd4QhIzfMBU8iyYe05tK7aDVts0T1gm7HSg2ywAaMbGKXhjLNk/MbjjxJtYOWNDxIZ8dihafPNPZJ48UBYohwy0S12OCUw5nzdpoVw/4QEmCKwfAhq0IF9UDScyWHqf4eKKe6VCaNMXCEEyjg9OlOvJOwB4xVVggNjgrgJMtgnjXTIKDNVD/Xn04zldwXyrnI9n3QJ8i7xcc4t0dVoEvWBiDnJSeKNwMDkjcVvhYNG6RTBVPVbZOR0T/L68+c7FGABuPPVUshdy+HTA4XMeY7r+faRzKnEXasUtWAJVnqzs+n/byzJooCAb+6yINOH+RD/eKdu/vhXnqDD8LwG8qA== 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=AgJ5SKkoKgyXZMfemTdqpkfBW/JTZ+ygrWpu+JdehXw=; b=VaSI+Wmixn9sdGNbVN7wKFMRlpRqUfLnP8XxxULLJHGoGNjUavtyC1jQ+f76Tl8NGliM9qXR5qWCxXlILeIoWf6fn7vq37kT+c8RtW6dLub9volngYuaJiXOO8XV9fHI3KDIfHzFFeZpdWMTx7SNXCM8k+K1BxOsbS0mD1jM5C5LIyKqfEzfNfnFiLDFGpC0BxXLbOOPXBn06JHED/LUwXgRA7l6e2izS+/rBC4xwwWItYlfJ9SBNA2oPx7IYSmnS02r6lTj5hcgJLxPJ97dxhrp9FkXMgTbXY6zfGBbbzS8fgi7ecGoIgZgv+TcUPghWGNqk4OG/as/b9VBdcopOA== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by DU0PR09MB5930.eurprd09.prod.outlook.com (2603:10a6:10:3ea::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Fri, 2 Jun 2023 01:10:43 +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.020; Fri, 2 Jun 2023 01:10:42 +0000 In-Reply-To: <86mt1j16ht.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 01 Jun 2023 19:39:58 +0300") X-TMN: [y3P+l45SLIa9BMW5uruT2p7TNOGl7M1Z] X-ClientProxiedBy: BE1P281CA0039.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::10) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <82pm6efz3i.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR09MB4977:EE_|DU0PR09MB5930:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c6150d8-2cd4-4bee-bd3e-08db63062f77 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9DKV3sNG+X7Y1Rvmeu+jcZvuragMH8BR6npKNCXPWN0cCKX+sQlUSGfWkx8mR0JYxci+L1eWBi8L3RlVlzZysWkW0M+G5IlyEdlYCQPC163xQBIfIwHQW7hJHZNUQJrFbnGBjktsZJypyEPOzR3LxBItXoMT1NhESku1tFQNFsIYx4CiLR9F9unYaWXzYjTP/Xgn0S/vqTukBGjZnRvyDEA9wZgCJbnbLxAbG8FpoIamLXOgSjLwq9+O8GzkHcxJ3rJVl7kBDHLjA/r2jqGpcjMb5NercIuK1R8Qcfgr5biqdEYmSr3nv7ekhHNbS5t/v6czbvv9i1ZXddFvDcfm1obdlRYQ63f8FdlIjHA/++2XK/+W0fPrNIle4+3teBR4tPErvRCejZmVY+9or06iFFePY5Siq9hbo1soHOwipb6htKIdWTidB9CVTplcXSagBMR1l6Pzz09PO1OpTajgNayR3dW3x0r3m3G/eihMyCEBc4er3Mi9NPR2jqfhD/4NvkgJnp2Z+c6YlkfLim8hElx20Hn/wQ+HCrmi1f1mV6jabGKLmpfcCEW6J1W4FIKjobvwzu7+wH8lYDjoYHayWNlUqI4YiCOdV/ML6Zy1flEgZCMm267xBwsDIi7YcTx1 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ks1T79nllPp46f+ztbKan4DBPBNYH4edqHG5vfrLqDh9k6AagUUFElgzT4A3?= =?us-ascii?Q?kmNFGAzt7LUgj7iNelP5+pRxxyQkpJ5UrVLGpO/XJwhPnYT5n/2eskK+VcNS?= =?us-ascii?Q?d7x/zYHKhM1kbnY0cCNCj3KuEDX5z9Z8ozL1XuSs3n8R+mQX02R7g3xW7Kgx?= =?us-ascii?Q?CBClWJeiHg7TDYnP8cmelUkRGmTNXo0vOvArkdivjD98GGcnWDMcJymSQV3v?= =?us-ascii?Q?q0bBaT6JM/W8ZuH3J9Io/ByEzX+bs0BB1HqOFOjTKthEJUKjmASUYGl9Y2Gt?= =?us-ascii?Q?SnwhzleNfoXk+sUiQYahRjhMGZd2GIkDNj1WPaTRMzsWv1/UyRFzbYBUTUmL?= =?us-ascii?Q?JV30EvQ+VlytsqbFR1l+MUlP50rAjS5uUxkhCXGllebPhSNPFZ9BUptnJ5pR?= =?us-ascii?Q?zTwYZELCG8N8CusSOhCBp0E6BaBEjoAaNJPFj9F6kIdnwi+maogQBluDC2MU?= =?us-ascii?Q?CGBNEtf0PrA01YXTC04nOKWOqEO9k3sLozF4elU3fQCFYWSFNFl4XJ2azZQ8?= =?us-ascii?Q?XzYxoTlaCeC/f/TSNUQzQf1FJRYBwXo8SRz1bLAK+xztrgH88d/c63BvTTe9?= =?us-ascii?Q?Cxd43RHf53rHe9AEMQQEpBqcITD12lAh3C1dF+G3QSvulEzbyELfPDCmYR8v?= =?us-ascii?Q?SV X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 1c6150d8-2cd4-4bee-bd3e-08db63062f77 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 01:10:42.8092 (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: DU0PR09MB5930 Received-SPF: pass client-ip=40.92.73.17; envelope-from=arthur.miller@live.com; helo=EUR04-HE1-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: Fri, 02 Jun 2023 01:18:47 -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:306539 Archived-At: Juri Linkov writes: >> Anyway, pre/post hook hack is very useful, and works with many commands, but not >> with all, so it is not 100% failsafe and general.Try to execute Info-mode >> from other window but Info (shortcut 'm'). In my Emacs it does not work. > > I tried 'm' (Info-menu), and it works nicely without any problem. > As long as key prefixes are the same in both windows. Ok. Then perhaps I am doing something wrong? How do you run it, is the posted code snippet all you use, or is there something else there? For me it does not work at all. >> Another problem with the above is that this will work only for 'other-window' >> for which Emacs has an algorithm to figure out which window it is. But what when >> you have more then two windows, and wish to switch to a different window than >> what Emacs considers as 'other-window'? You will have to prompt the user, to >> choose one. The help or info buffers are seldom the 'other-buffer' so constanly >> choosing the window would be just as annoying as constantly switching to and >> from, in my opinion. > > Indeed, which window to use is a separate question. > > For the existing commands scroll-other-window, scroll-other-window-down, > recenter-other-window, beginning-of-buffer-other-window, > end-of-buffer-other-window, the user option that defines which window to use > is 'other-window-scroll-default', and it can be customized > to any function, for example, a function that looks for > a window with a Help/Info buffer on the current frame, > or on any other frame. Or to a function that uses > 'get-mru-window' to get the most recently used/displayed window. > All this is customizable. Sure it is, but is isn't a customization problem. We wouldn't like to customize the stuff before every run, right? In a case like this, where we wish to run in a specific window like help, info or perhaps working-buffer window in case of ielm, we do want to make some specific commands, which means we would like to wrap that general do-in-X-window command. Otherwise it would be annoying to every time have to choose help window. >> I would prefer if there was a code gen in form of a macro, as suggested, similar >> to define-minor-mode, that does this switching on pre-defined prefixes so that >> we get uniformity, and helps people write commands so they work from >> anywhere. Since it is not possible to completely automate it, perhaps lisp >> manual could mention how to write commands so they are callable from other >> windows then just selected one. > > The downside is that every command needs to be modified and its body > wrapped with a macro. And for some commands, which use more complicated interactive form, it has to be done separately for the body of interactive form and for the functon body, since you can't wrap interactive itself in anything (it has to be first form in function body), so yes indeed. It would be a ginormous janitor work to go through all Emacs commands and re-write them. I don't think it is even possible. So no I don't suggest that :). I suggest this only for writing new commands, and I give a rough sketch as an illustration of what I men: #+begin_src emacs-lisp (defun test-command (arg &optional kill window) (interactive "P") (let* ((window-alist (mapcar (lambda (w) (cons (format "%s" w) w)) (window-list))) (window (cond ((equal arg '(4)) (other-window-for-scrolling)) ((equal arg '(16)) (cdr (assoc (completing-read "Window: " window-alist) window-alist))) (t (window-normalize-window window))))) (with-selected-window window (message "Did someting in window: %s" window)))) #+end_src The let* wrapp could be generated on part of the user, in some way. > An alternative would be to put a new property > on the command symbol with a function that selects a window to redirect > input to. How are that property and function meant to be implemented? By the end user, or by the Emacs? Can end user just choose something like :run-in (one of nil, t, foo-mode, bar-mode, (some-predicate-p) some-function, etc), where "run-in" is the property you suggest, and the rest are constrains to choose from? I don't tink it is too much different from what I suggest, tbh, since it will anyway have to select somehow the window and that selection would probably be steared by some argument to the command, but it will be coded differently.