From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#58839: [Patch] Re: bug#58839: 29.0.50; project-kill-buffer fails when Eglot is running Date: Tue, 1 Nov 2022 11:59:12 +0000 Message-ID: References: <87sfj8umwb.fsf@posteo.net> <87a65f3j40.fsf@posteo.net> <213f3549-de4e-25a7-5e27-d13893e557bc@yandex.ru> <87zgdfwkle.fsf@gmail.com> <8e31a89d-e35e-6dd0-a8e3-f0b9684c8bfa@yandex.ru> <87v8o3wgq1.fsf@gmail.com> <87ilk2x1si.fsf@gmail.com> <871qqq7l9p.fsf@posteo.net> <87eduqwekz.fsf@gmail.com> <87wn8invbx.fsf@posteo.net> <877d0iw8iq.fsf@gmail.com> <837d0hhlke.fsf@gnu.org> <46ff0065-5645-ef1e-2621-242fb6a73f98@yandex.ru> <87v8o0uxn5.fsf@gmail.com> <787a4362-7ff5-7dbb-9118-16e4bee5f328@yandex.ru> <87edunvhf2.fsf@gmail.com> <6d4d9e72-1bae-4d64-b7c1-c2b9c11e396f@yandex.ru> <87tu3jgdbv.fsf@posteo.net> <87h6zihq3q.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000061c0f005ec677090" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29444"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , manuel.uberti@inventati.org, 58839@debbugs.gnu.org, Dmitry Gutov To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 01 12:59:25 2022 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 1oppvR-0007QD-0i for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Nov 2022 12:59:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oppvG-0000g1-0B; Tue, 01 Nov 2022 07:59:14 -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 1oppv4-0000ea-TY for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 07:59:04 -0400 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 1oppv4-0001ZV-Lf for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 07:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oppv4-0008Bc-8N for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 07:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Nov 2022 11:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58839 X-GNU-PR-Package: emacs Original-Received: via spool by 58839-submit@debbugs.gnu.org id=B58839.166730390331345 (code B ref 58839); Tue, 01 Nov 2022 11:59:02 +0000 Original-Received: (at 58839) by debbugs.gnu.org; 1 Nov 2022 11:58:23 +0000 Original-Received: from localhost ([127.0.0.1]:42888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oppuQ-00089V-Cm for submit@debbugs.gnu.org; Tue, 01 Nov 2022 07:58:22 -0400 Original-Received: from mail-ot1-f53.google.com ([209.85.210.53]:45053) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oppuO-000896-Il for 58839@debbugs.gnu.org; Tue, 01 Nov 2022 07:58:21 -0400 Original-Received: by mail-ot1-f53.google.com with SMTP id p8-20020a056830130800b0066bb73cf3bcso8327341otq.11 for <58839@debbugs.gnu.org>; Tue, 01 Nov 2022 04:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JRk/8o4v6jXBCV4rY0cjToIEEdI6z+4sOOCgqpImxRc=; b=RlMLFWS+9mFBgiK7zC+Lifko9Hny7004Daw/cv4ZaAyRTn3dPPJ7rFKu0Co95nd0/S eESxWpirXHlXqK2ADydFCTeeAN+VzgoAML94vS+46LbeAOrRtY5+ZJTmxzr5kbuKJWxA QFf4V2OMBc4nfxqm63lVGNCgK6VB8zV6yV2tz5K/HIbpDWqwLF21imxWqzv+2Zqjp48L 0HWpsneFzJJFJDeTACYoq4VeK2SGobHWQRXpEL28XU2kvKLtVfzH+orVOlXZ07AhGWx8 YqsbwbD2CcQ4t670vkC2CaiQb2rwEN/4Rsl15/YZa+iz/L94sc2nwrIfrQ2IvJyZQc2w w41Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JRk/8o4v6jXBCV4rY0cjToIEEdI6z+4sOOCgqpImxRc=; b=foC9r3Ou58EHJi+0Lemcyu+UKUJHDITULrlPxco6ROk7eFq/tvM09Rx6UT12M4aNz0 NQGsiRxhlUr+kvwZ10ZYz2O+or+m+PvxfztH9Y5e+18ohF8iANIXMFM5ihzqkEIkf/T/ +CXHkTGf07W44j7RDPUBxZ11wGS7KdVVy4hMjbzCx5zj5f+3Fxr/7WKRIvnCYGgppSRV WMOE8SmquirPebe8k5spdY4O4a9FZldUheVok/pCYC2x9ZijRA5CnqcAJXaFlA7/sMhb drvf1a5V7EmpBsxHrFEsQzKi7VLuqx2mG3VSYL3z////ovFjBi39FA1V69fzWjipytF0 DHIg== X-Gm-Message-State: ACrzQf2LU2bCgfCXaLTlEUXORo6OrWA61XFSgE+xmgS6UVEDQNia1BUa kE+XWZPVD9C8qklkGylvyhRSpmj2vbu2XXuwf/8= X-Google-Smtp-Source: AMsMyM5uNPF8NhlpJ+DaKOYYtPuErdoNoVl8y4yNUWaTkgPtZzLSqrP2fc99B2hqybGz+tUy4VNRzua+KqU+xKeKefc= X-Received: by 2002:a9d:117:0:b0:666:e09d:577e with SMTP id 23-20020a9d0117000000b00666e09d577emr9504395otu.93.1667303894793; Tue, 01 Nov 2022 04:58:14 -0700 (PDT) In-Reply-To: <87h6zihq3q.fsf@posteo.net> 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: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246770 Archived-At: --00000000000061c0f005ec677090 Content-Type: text/plain; charset="UTF-8" On Tue, Nov 1, 2022 at 11:27 AM Philip Kaludercic wrote: > E.g. `display-buffer-alist' makes use of it to associate display-buffer > rules with buffers. Now you can add > > ((major-mode . help-mode) display-buffer-in-side-window) > > instead of trying to match being a regular expression to catch all > *Help* buffer names of a function along the lines of > > (lambda (buf _alist) > (with-current-buffer buf > (derived-mode-p 'help-mode))) > If you really want to save up on this typing, it's better to define a reusable helper function, or even a higher order function. (defun buffer-mode-matcher (mode) (lambda (b _alist) (with-current-buffer b (derived-mode-p 'help-mode)))) You can add buffer-mode-matcher to the library if it becomes useful enough. Then you add: `(,(buffer-mode-matcher 'help-mode) display-buffer-in-side-window) to display-buffer-alist. But if you really want a new language your language, then I suggest a simple adapter buffer-matcher utility that merges the two. That way one doesn't couple existing utilities to the new mini-language and simultaneously the new mini-language become useful in a much wider setting for those who appreciate such things. (defun buffer-matcher (condition) "Return unary predicate of a buffer matching the CONDITION mini-language." (lambda (buf &rest _whatever) ; make it even more lax (buffer-match-p condition))) Later on, you might even pass an (... &optional compiled) so that the return value is syntax checked and optimized in some way at compile time. IOW, (E)Lisp already gives you the tools for these composition without needing to invent new languages with the drawbacks I listed. --00000000000061c0f005ec677090 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Nov 1, 2022 at 11:27 AM Philip Kaludercic <philipk@posteo.net> wrote:
=C2= =A0
E.g. `display-buffer-alist' makes use of it to associate display-buffer=
rules with buffers.=C2=A0 Now you can add

=C2=A0 =C2=A0 =C2=A0 ((major-mode . help-mode) display-buffer-in-side-windo= w)

instead of trying to match being a regular expression to catch all
*Help* buffer names of a function along the lines of

=C2=A0 =C2=A0 =C2=A0 (lambda (buf _alist)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (with-current-buffer buf
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (derived-mode-p 'help-mode)))

If you really want to save up on this typing,= it's better to define
a reusable helper function, or even a = higher order function.

=C2=A0 (defun buffer-mode-m= atcher (mode)
=C2=A0 =C2=A0 (lambda (b _alist)
=C2=A0 =C2=A0=C2=A0=C2=A0 (with-current-buffer b (derived-mode-p 'help-= mode))))

You can add buffer-mode-matcher to the li= brary if it becomes
useful enough.=C2=A0 Then you add:
=

=C2=A0 `(,(buffer-mode-matcher 'help-mode) display-= buffer-in-side-window)

to display-buffer-alist.

But if you really want a new language your language,= then I suggest
a simple adapter buffer-matcher utility that merg= es the two.=C2=A0 That way one
doesn't couple existing utilit= ies to the new mini-language and simultaneously
the new mini-lang= uage become useful in a much wider setting for those who
apprecia= te such things.

=C2=A0 (defun buffer-matcher (cond= ition)
=C2=A0=C2=A0=C2=A0=C2=A0 "Return unary predicate of a= buffer matching the CONDITION mini-language."
=C2=A0=C2=A0= =C2=A0 (lambda (buf &rest _whatever) ; make it even more lax
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (buffer-match-p condition)))

Later on, you might even pass an (... &optional compile= d) so that the return value
is syntax checked and optimized in so= me way at compile time.

IOW, (E)Lisp already g= ives you the tools for these composition without
needing to = invent new languages with the drawbacks I listed.

--00000000000061c0f005ec677090--