Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org.
Full text available.Received: (at 73016) by debbugs.gnu.org; 14 Sep 2024 10:10:34 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 14 06:10:34 2024 Received: from localhost ([127.0.0.1]:44903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1spPje-0003Dj-1T for submit <at> debbugs.gnu.org; Sat, 14 Sep 2024 06:10:34 -0400 Received: from mout01.posteo.de ([185.67.36.65]:37617) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <philipk@HIDDEN>) id 1spPjb-0003DS-Ry for 73016 <at> debbugs.gnu.org; Sat, 14 Sep 2024 06:10:33 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 8FF42240028 for <73016 <at> debbugs.gnu.org>; Sat, 14 Sep 2024 12:10:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1726308615; bh=bmhZ0kWT97TSn9BbawNHSjH77mG6RsAjO1WUsD6qmWo=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=GxTH+gbLkMAo7lTzwVQHwpGUiRKkICJpJDEijOeREeOfRQm1EHBIYQPXxiNMoMCYY eG5+EfvYisLXVQ8nMtzcFe9XzKqDqIslQTWEhcukZHactPxMhzlaU2m7cCYhnb4RZ1 nGC2tAqdP19FF4tF8VIN/1COqnwpUL3ScTRqaTnNoR1GCaJf9xDLYFqQhGn7f8ZUee rP9EESJ6EIxn1adAFx1fO1o2+aDCYi72ZVlBhc0tlnU8b3sM1BjEz+UrWdPAcCQEjo mrP+a0dE3oGSPnOMWgG1DwZ3V4gIDuItrkxhuRroWEIV+J+N38WqQsYzICp8fCY9us UpWhUxrKLhD4w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4X5RkZ3wKFz9rxP; Sat, 14 Sep 2024 12:10:14 +0200 (CEST) From: Philip Kaludercic <philipk@HIDDEN> To: Tony Zorman <tonyzorman@HIDDEN> Subject: Re: bug#73016: Potential inclusion of kbd-mode, part of kmonad, in Non-GNU ELPA In-Reply-To: <87cyl6bp96.fsf@hyperspace> (Tony Zorman's message of "Sat, 14 Sep 2024 10:42:13 +0200") References: <875xrcfkiy.fsf@HIDDEN> <87wmjqjuiz.fsf@HIDDEN> <87cyl6bp96.fsf@hyperspace> Autocrypt: addr=philipk@HIDDEN; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=philipk@HIDDEN; url="https://keys.openpgp.org/vks/v1/by-email/philipk@HIDDEN"; preference=signencrypt Date: Sat, 14 Sep 2024 10:10:13 +0000 Message-ID: <871q1m4kca.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73016 Cc: Jeremy Bryant <jb@HIDDEN>, 73016 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Tony Zorman <tonyzorman@HIDDEN> writes: > On Thu, Sep 05 2024 09:53, Philip Kaludercic wrote: >>> :type '(repeat string) >>> :group 'kbd-highlight) >> >> Where is this group defined? The applies below. > > It was the first expression after the ";;;; Custom variables" comment. > I've moved it up to the other groups. 1+ >>> (defun kbd-mode--kill-demo-process () >>> "Kill demo kmonad process, if possible." >>> (when (get-buffer-process "*kmonad*") >>> (kill-process "*kmonad*"))) >> >> There might be a race condition here. > > Mh, can you expand on this? I don't think that the *kmonad* buffer is > created in the vicinity of this code. I believe I might have misread something, as I recall thinking about a `while'-loop. > Tony -- Philip Kaludercic on siskin
bug-gnu-emacs@HIDDEN:bug#73016; Package emacs.
Full text available.Received: (at 73016) by debbugs.gnu.org; 14 Sep 2024 08:43:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 14 04:43:08 2024 Received: from localhost ([127.0.0.1]:44756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1spON1-0006aI-OQ for submit <at> debbugs.gnu.org; Sat, 14 Sep 2024 04:43:08 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:50364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <tonyzorman@HIDDEN>) id 1spOMy-0006Zf-HK for 73016 <at> debbugs.gnu.org; Sat, 14 Sep 2024 04:43:06 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4X5Pn26Dwpz9tDX; Sat, 14 Sep 2024 10:42:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1726303334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mza1euw9e/3N5U8rlu1vISAVxSLE9qDBck4bDx6ZQP8=; b=UUMvRZ7/KcrbVPQ4Sf+4g4WsDlyxsXOpIcRW57Lra+lO7JgIyiOjQVS1WVs5VywI2R51wQ nESY/XYZknaRnOAxTM2grouuQoyzqqXv8xs7Tegca5mFbkmKJWTk5xAkhykY4RIKOty+5k 3yWku6xhUTYi2jcX8F0VNSaoyxstyXsa5na6TkLiiu/30L4afD8cMcT3qp2gr2fF01kneQ jbQ9z/aaGbH+fF622W70cqbPG7t/B3UlmN94LaulE6ueC7CnUMcjsxdXOcdsiK6JuQYZ3c dKUUPVWriLEahepwuSJRiNqiVHYIMis3UzXOa6xvJbkWI5bLf94sgaew8jSahw== From: Tony Zorman <tonyzorman@HIDDEN> To: Philip Kaludercic <philipk@HIDDEN>, Jeremy Bryant <jb@HIDDEN> Subject: Re: bug#73016: Potential inclusion of kbd-mode, part of kmonad, in Non-GNU ELPA In-Reply-To: <87wmjqjuiz.fsf@HIDDEN> References: <875xrcfkiy.fsf@HIDDEN> <87wmjqjuiz.fsf@HIDDEN> Date: Sat, 14 Sep 2024 10:42:13 +0200 Message-ID: <87cyl6bp96.fsf@hyperspace> MIME-Version: 1.0 Content-Type: text/plain X-MBO-RS-ID: 7d4cd1243c31d82d8b6 X-MBO-RS-META: t4woeycty11bke93hdnxdk6g1ssp41co X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73016 Cc: 73016 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) On Thu, Sep 05 2024 09:53, Philip Kaludercic wrote: >> :type '(repeat string) >> :group 'kbd-highlight) > > Where is this group defined? The applies below. It was the first expression after the ";;;; Custom variables" comment. I've moved it up to the other groups. >> (defun kbd-mode--kill-demo-process () >> "Kill demo kmonad process, if possible." >> (when (get-buffer-process "*kmonad*") >> (kill-process "*kmonad*"))) > > There might be a race condition here. Mh, can you expand on this? I don't think that the *kmonad* buffer is created in the vicinity of this code. Tony -- Tony Zorman | https://tony-zorman.com
bug-gnu-emacs@HIDDEN:bug#73016; Package emacs.
Full text available.
Received: (at 73016) by debbugs.gnu.org; 6 Sep 2024 11:49:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 06 07:49:46 2024
Received: from localhost ([127.0.0.1]:52354 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1smXTG-0001ZM-BU
for submit <at> debbugs.gnu.org; Fri, 06 Sep 2024 07:49:46 -0400
Received: from mout-p-102.mailbox.org ([80.241.56.152]:50350)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <tonyzorman@HIDDEN>) id 1smXTD-0001Ym-Ck
for 73016 <at> debbugs.gnu.org; Fri, 06 Sep 2024 07:49:44 -0400
Received: from smtp102.mailbox.org (smtp102.mailbox.org
[IPv6:2001:67c:2050:b231:465::102])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
(No client certificate requested)
by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4X0Y4j3sX2z9skX;
Fri, 6 Sep 2024 12:53:57 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
s=mail20150812; t=1725620037;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=OU1hmn9kxBQL7ANh3+ZoVkBCyvLJ7VQFg+nxmdyr9A8=;
b=G2/trzvtd8iny1oO/X5C6bsrDCgGUTbgzS0PSAEhf1ralBhpuXwr2v0qybZIEmks5a+zSB
uPc1gtBWbBOdMgFOMUSyVgFJWpHaZnNtmhT/M3BB6WWgVYGw73pTiYGVUQutKfsPvs5PGW
AfnGx4ADkftGIA3oWKLVvveW4ZSuJWsIKokiLUxgjnoJiJy0Vj6WdJbPapI/IF8bAkUfsq
AnYB3jPxFF/lOf+ih5EeOJmIUuHnlFWSeq1Hts7EdlbqloCR+ZL9lfZJtfOv8raURMv5ey
lZd6kgXar45jIEQrf1x0J78/qNaivUuO3e7bbfE072SVPq8b9RM97zQjEcWO8Q==
From: Tony Zorman <tonyzorman@HIDDEN>
To: Philip Kaludercic <philipk@HIDDEN>, Jeremy Bryant <jb@HIDDEN>
Subject: Re: bug#73016: Potential inclusion of kbd-mode, part of kmonad, in
Non-GNU ELPA
In-Reply-To: <87wmjqjuiz.fsf@HIDDEN>
References: <875xrcfkiy.fsf@HIDDEN> <87wmjqjuiz.fsf@HIDDEN>
Date: Fri, 06 Sep 2024 12:53:53 +0200
Message-ID: <87r09x59z2.fsf@hyperspace>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-MBO-RS-META: 6fexioocjq96nnbkizxqx66fxwnzo3ug
X-MBO-RS-ID: a623028260f8a805128
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 73016
Cc: 73016 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)
Hi,
thanks to Jeremy for submitting this, and to Philip for reviewing! I'm
travelling right now, so I'll keep this short; more to come in a few
days I hope.
=20
On Thu, Sep 05 2024 09:53, Philip Kaludercic wrote:
> [=E2=80=A6 12 lines elided =E2=80=A6]
>
>> On behalf of the author, Tony Zorman, I would like to request
>> consideration to include it in NON-GNU ELPA.
>
> Just for the sake of the protocol, is there a reason against adding the
> package to GNU ELPA?
There has been at least one non-trivial contribution to the package, as
well as several smaller ones. While I have assigned copyright to the FSF
for Emacs and ELPA related things, I don't know whether the same can be
said of the other contributors.
>> The author is conscious that the following snippet should be improved
>> and we are soliciting recommendations on how to improve it.
>> ;; HACK
>> (defadvice redisplay (after refresh-font-locking activate)
>> (when (derived-mode-p 'kbd-mode)
>> (font-lock-fontify-buffer))))
>
> I agree, we should get rid of that. But first, what is the intention?
> What breaks if we just remove this advice?
When specifying the keyboard layout, the configuration language accepts
most special symbols verbatim (as in, one can just write @ to have that
symbol bound to a key). This includes " for double quotes, meaning the
highlighting of strings has to be taken care of be the mode=E2=80=94at leas=
t, I
think so. This produces inconsistent behaviour that I was never really a
fan of, especially when moving things around. For example, going from=20
(f "string")
to=20
(f
"string")
would "unhighlight" the string until one refreshes the syntax
highlighting for the buffer via e.g. font-lock-update, or wait until
this happens by itself. The advice is nothing more but a band-aid such
that the latter happens more often.
It may well be that I overlooked something about Emacs's way of going
about string highlighting back when I wrote the mode, and so far I
haven't had the drive to look back into this.
Tony
--=20
Tony Zorman | https://tony-zorman.com
bug-gnu-emacs@HIDDEN:bug#73016; Package emacs.
Full text available.
Received: (at 73016) by debbugs.gnu.org; 5 Sep 2024 09:55:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 05 05:55:13 2024
Received: from localhost ([127.0.0.1]:36200 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1sm9Cq-0001VG-1Z
for submit <at> debbugs.gnu.org; Thu, 05 Sep 2024 05:55:13 -0400
Received: from mout02.posteo.de ([185.67.36.66]:43013)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <philipk@HIDDEN>) id 1sm9Cn-0001Uz-06
for 73016 <at> debbugs.gnu.org; Thu, 05 Sep 2024 05:55:10 -0400
Received: from submission (posteo.de [185.67.36.169])
by mout02.posteo.de (Postfix) with ESMTPS id BE2BD240103
for <73016 <at> debbugs.gnu.org>; Thu, 5 Sep 2024 11:53:57 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
t=1725530037; bh=EgGUrgLdXiCY/RMJy5wmTpNMWbLXB4lgwTaWCf0UuRM=;
h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version:
Content-Type:Content-Transfer-Encoding:From;
b=chBawEnTfknjS5RetVOak5RpvplfjPbOThY2XakJ7ui8/p5vjye5ixs5eM7km3iqb
nKNprjeN41ltEL8VXusF07YJr4Km2dlKhsouHYC4/uRq9qJOrZ2UJ8vb4T3dhLQq4O
/qpkZYU8TCGiWPsXZdAKTc5YlueWTIE3/bjGwmn1Sy8MFyzFjJeVJsKDqA9Yc9SzrN
XwfUvPXP9VayFY/rnEKIARMJfZAxtKz1l+a5t2Zt6qaIVrTLL/Iu3imsCq8uIPI+7e
/G8mU3SKy682oaj2GVLlveSamMo4AJG5oW8k3Lgic4mGP0L2IQnmIn5bNTZFPyW8As
yu0R8Ulsceqnw==
Received: from customer (localhost [127.0.0.1])
by submission (posteo.de) with ESMTPSA id 4Wzvnx09X4z6twR;
Thu, 5 Sep 2024 11:53:56 +0200 (CEST)
From: Philip Kaludercic <philipk@HIDDEN>
To: Jeremy Bryant <jb@HIDDEN>
Subject: Re: bug#73016: Potential inclusion of kbd-mode, part of kmonad, in
Non-GNU ELPA
In-Reply-To: <875xrcfkiy.fsf@HIDDEN> (Jeremy Bryant's message of
"Tue, 03 Sep 2024 23:19:01 +0100")
References: <875xrcfkiy.fsf@HIDDEN>
Autocrypt: addr=philipk@HIDDEN; keydata=
mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo
aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0
ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI
BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0
mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB
BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE
Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK
NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof
z4oM
OpenPGP: id=philipk@HIDDEN;
url="https://keys.openpgp.org/vks/v1/by-email/philipk@HIDDEN";
preference=signencrypt
Date: Thu, 05 Sep 2024 09:53:56 +0000
Message-ID: <87wmjqjuiz.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 73016
Cc: Tony Zorman <tonyzorman@HIDDEN>, 73016 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
Jeremy Bryant <jb@HIDDEN> writes:
> Hi,
>
> kmonad is a keyboard configuration tool under MIT license.
> https://github.com/kmonad/kmonad
>
> There is an Emacs major mode to edit the configuration file, based on
> s-expressions. The mode is under GPLv3.
> https://github.com/kmonad/kbd-mode
I don't see a reason to add the package in principle.
> On behalf of the author, Tony Zorman, I would like to request
> consideration to include it in NON-GNU ELPA.
Just for the sake of the protocol, is there a reason against adding the
package to GNU ELPA?
> The author is conscious that the following snippet should be improved
> and we are soliciting recommendations on how to improve it.
> ;; HACK
> (defadvice redisplay (after refresh-font-locking activate)
> (when (derived-mode-p 'kbd-mode)
> (font-lock-fontify-buffer))))
I agree, we should get rid of that. But first, what is the intention?
What breaks if we just remove this advice?
> Furthermore if there are any code reviews or recommendations, I attach
> the current version.
>
> I can volunteer some time for some of the changes.
>
> ;;; kbd-mode.el --- Font locking for kmonad's .kbd files -*- lexical-bind=
ing: t -*-
>
> ;; Copyright 2020=E2=80=932022 slotThe
> ;; URL: https://github.com/kmonad/kbd-mode
> ;; Version: 0.0.1
> ;; Package-Requires: ((emacs "24.3"))
>
> ;; This file is free software; you can redistribute it and/or modify
> ;; it under the terms of the GNU General Public License as published by
> ;; the Free Software Foundation; either version 3, or (at your option)
> ;; any later version.
> ;;
> ;; This file is distributed in the hope that it will be useful,
> ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
> ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> ;; GNU General Public License for more details.
> ;;
> ;; You should have received a copy of the GNU General Public License
> ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
>
> ;;; Commentary:
>
> ;; This file adds basic font locking support for `.kbd' configuration
> ;; files.
> ;;
> ;; To use this file, move it to a directory within your `load-path' and
> ;; require it. For example --- assuming that this file was placed
> ;; within the `~/.config/emacs/elisp' directory:
> ;;
> ;; (add-to-list 'load-path "~/.config/emacs/elisp/")
> ;; (require 'kbd-mode)
> ;;
> ;; If you use `use-package', you can express the above as
> ;;
> ;; (use-package kbd-mode
> ;; :load-path "~/.config/emacs/elisp/")
Installation instructions are usually out-of-place in the commentary
section. Perhaps add a `;;; Installation:` section instead, so that we
keep it apart from the documentation that describe-package displays?
> ;;
> ;; By default we highlight all keywords; you can change this by
> ;; customizing the `kbd-mode-' variables. For example, to disable the
> ;; highlighting of already defined macros (i.e. of "@macro-name"), you
> ;; can set `kbd-mode-show-macros' to `nil'.
> ;;
> ;; For keybindings, as well as commentary on the `kbd-mode-demo-mode'
> ;; minor mode, see the associated README.md file.
>
> ;;; Code:
>
> (require 'compile)
>
> (defgroup kbd nil
> "Major mode for editing `.kbd' files."
> :group 'languages)
>
> (defgroup kbd-demo nil
> "A minor mode to test your configuration."
> :group 'kbd)
>
> ;;;; Custom variables
>
> (defgroup kbd-highlight nil
> "Syntax highlighting for `kbd-mode'."
> :group 'kbd)
>
> (defcustom kbd-mode-kexpr
> '("defcfg" "defsrc" "defalias")
> "A K-Expression."
This documentation should be expanded on.
> :type '(repeat string)
> :group 'kbd-highlight)
Where is this group defined? The applies below.
>
> ;; HACK
> (defcustom kbd-mode-function-one
> '("deflayer")
> "Tokens that are treated as functions with one argument."
> :type '(repeat string)
> :group 'kbd-highlight)
>
> (defcustom kbd-mode-tokens
> '(;; input tokens
> "uinput-sink" "send-event-sink" "kext"
> ;; output tokens
> "device-file" "low-level-hook" "iokit-name")
> "Input and output tokens."
> :type '(repeat string)
> :group 'kbd-highlight)
>
> (defcustom kbd-mode-defcfg-options
> '("input" "output" "cmp-seq-delay" "cmp-seq" "init" "fallthrough" "allo=
w-cmd")
> "Options to give to `defcfg'."
> :type '(repeat string)
> :group 'kbd-highlight)
>
> (defcustom kbd-mode-button-modifiers
> '("around-next-timeout" "around-next-single" "around-next" "around"
> "tap-hold-next-release" "tap-hold-next" "tap-next-release" "tap-hold"
> "tap-macro-release" "tap-macro" "multi-tap" "tap-next" "layer-toggle"
> "layer-switch" "layer-add" "layer-rem" "layer-delay" "layer-next" "cm=
d-button")
> "Button modifiers."
> :type '(repeat string)
> :group 'kbd-highlight)
>
> (defcustom kbd-mode-show-string
> '("uinput-sink" "device-file" "cmd-button")
> "Syntax highlight strings in S-expressions.
> When an S-expression begins with any of these keywords, highlight
> strings (delimited by double quotes) inside it."
> :type '(repeat string)
> :group 'kbd-highlight)
>
> (defcustom kbd-mode-show-macros t
> "Whether to syntax highlight macros inside layout definitions.
> Default: t"
Documenting the default is usually not necessary, as customise already
remembers is.
> :type 'boolean
> :group 'kbd-highlight)
>
> (defcustom kbd-mode-magic-focus nil
> "Whether to enable magic focus.
> Whenever the `kbd-mode-demo-mode' buffer gets focused,
> automatically start try to start a new process for the config
> file. When switching back to the config file, kill that process.
>
> Default: nil"
> :type 'boolean
> :group 'kbd-demo)
>
> (defcustom kbd-mode-kill-kmonad nil
> "How to kill (or suspend) a running kmonad instance.
> This is used when invoking `kbd-mode-start-demo' and, in general,
> when entering `kbd-mode-demo-mode' because keyboards can't be
> grabbed twice."
> :type 'string
> :group 'kbd-demo)
>
> (defcustom kbd-mode-start-kmonad nil
> "How to restart (or resume) kmonad.
> If there was an active kmonad instance running, which was killed
> by `kbd-mode-kill-kmonad', then this (re)starts kmonad with the
> given command upon exiting `kbd-mode-demo-mode'."
> :type 'string
> :group 'kbd-demo)
>
> ;;;; Faces
>
> (defgroup kbd-highlight-faces nil
> "Faces used for highlighting in `kbd-mode'."
> :group 'kbd-highlight)
>
> (defface kbd-mode-kexpr-face
> '((t :inherit font-lock-keyword-face))
> "Face for a K-Expression."
> :group 'kbd-highlight-faces)
>
> (defface kbd-mode-token-face
> '((t :inherit font-lock-function-name-face))
> "Face for input and output tokens."
> :group 'kbd-highlight-faces)
>
> (defface kbd-mode-defcfg-option-face
> '((t :inherit font-lock-builtin-face))
> "Face for options one may give to `defcfg'."
> :group 'kbd-highlight-faces)
>
> (defface kbd-mode-button-modifier-face
> '((t :inherit font-lock-function-name-face))
> "Face for all the button modifiers."
> :group 'kbd-highlight-faces)
>
> (defface kbd-mode-variable-name-face
> '((t :inherit font-lock-variable-name-face))
> "Face for a variables, i.e. layer names, macros in layers,..."
> :group 'kbd-highlight-faces)
>
> (defface kbd-mode-string-face
> '((t :inherit font-lock-string-face))
> "Face for strings."
> :group 'kbd-highlight-faces)
>
> ;;;; Functions
>
> (defun kbd-mode--show-macros? (show-macros)
A -p would be more conventional for Elisp.
> "Decide whether to font-lock macros.
> If the argument SHOW-MACROS is non-nil, font-lock macros of the
> form `@MACRO-NAME' with `kbd-mode-variable-name-face'."
> (let ((macro-regexp '(("\\(:?\\(@[^[:space:]]+\\)\\)"
> (1 'kbd-mode-variable-name-face)))))
> (if show-macros
> (font-lock-add-keywords 'kbd-mode macro-regexp)
> (font-lock-remove-keywords 'kbd-mode macro-regexp))))
>
> ;;; Vars
>
> (defvar kbd-mode-syntax-table
> (let ((st (make-syntax-table)))
> ;; Use ;; for regular comments and #| |# for line comments.
> (modify-syntax-entry ?\; ". 12b" st)
> (modify-syntax-entry ?\n "> b" st)
> (modify-syntax-entry ?\# ". 14" st)
> (modify-syntax-entry ?\| ". 23" st)
> ;; We don't need to highlight brackets, as they're only used inside
> ;; layouts.
> (modify-syntax-entry ?\[ "." st)
> (modify-syntax-entry ?\] "." st)
> ;; We highlight the necessary strings ourselves.
> (modify-syntax-entry ?\" "." st)
> st)
> "The basic syntax table for `kbd-mode'.")
>
> (defvar kbd-mode--font-lock-keywords
> (let ((kexpr-regexp (regexp-opt kbd-mode-kexpr 'w=
ords))
> (token-regexp (regexp-opt kbd-mode-tokens 'w=
ords))
> (defcfg-options-regexp (regexp-opt kbd-mode-defcfg-options 'w=
ords))
> (button-modifiers-regexp (regexp-opt kbd-mode-button-modifiers 'w=
ords))
> (function-one-regexp
> (concat "\\(?:\\("
> (regexp-opt kbd-mode-function-one)
> "\\)\\([[:space:]]+[[:word:]]+\\)\\)"))
> ;; Only highlight these strings; configuration files may explicit=
ly
> ;; use a " to emit a double quote, so we can't trust the default
> ;; string highlighting.
> (string-regexp
> (concat "\\(['\(]"
> (regexp-opt kbd-mode-show-string)
> "\\)\\(\\S)+\\)\)")))
> `((,token-regexp (1 'kbd-mode-token-face ))
> (,kexpr-regexp (1 'kbd-mode-kexpr-face ))
> (,button-modifiers-regexp (1 'kbd-mode-button-modifier-face))
> (,defcfg-options-regexp (1 'kbd-mode-defcfg-option-face ))
> (,function-one-regexp
> (1 'kbd-mode-kexpr-face )
> (2 'kbd-mode-variable-name-face))
> (,string-regexp
> ("\"[^}]*?\""
> (progn (goto-char (match-beginning 0)) (match-end 0))
> (goto-char (match-end 0))
> (0 'kbd-mode-string-face t)))))
> "Keywords to be syntax highlighted.")
>
> ;;; Define Major Mode
>
> ;; Because the configuration language is in a lispy syntax, we can
> ;; inherit from any lisp mode in order to get good parenthesis handling
> ;; for free.
>
> (defvar kbd-mode-map
> (let ((map (make-sparse-keymap)))
> (define-key map (kbd "C-c C-c") #'kbd-mode-start-demo)
> (define-key map (kbd "C-c C-z") #'kbd-mode-switch)
> map))
>
> ;;;###autoload
> (define-derived-mode kbd-mode emacs-lisp-mode "Kbd"
> "Major mode for editing `.kbd' files.
>
> For details, see `https://github.com/kmonad/kmonad'."
> (set-syntax-table kbd-mode-syntax-table)
> (use-local-map kbd-mode-map)
> (font-lock-add-keywords 'kbd-mode kbd-mode--font-lock-keywords)
> (kbd-mode--show-macros? kbd-mode-show-macros)
> ;; HACK
> (defadvice redisplay (after refresh-font-locking activate)
> (when (derived-mode-p 'kbd-mode)
> (font-lock-fontify-buffer))))
I didn't realise that this was being evaluated every time the major mode
is initialised...
>
> ;; Associate the `.kbd' ending with `kbd-mode'.
> ;;;###autoload
> (add-to-list 'auto-mode-alist '("\\.kbd\\'" . kbd-mode))
>
> ;;;; Demo Minor Mode
>
> (defvar kbd-mode-demo-file nil
> "Path to the users configuration file.
> This is used in `kbd-mode-demo-mode' for deciding what
> configuration to compile.")
>
> (defvar kbd-mode-had-kmonad? nil
> "Whether the user had a running kmonad instance.
> This controls whether kmonad will be restarted by mean of
> `kbd-mode-start-kmonad' after exiting `kbd-mode-demo-mode'.")
>
> (defvar kbd-mode-demo-mode-map
> (let ((map (make-sparse-keymap)))
> (define-key map (kbd "C-c C-c") #'kbd-mode-stop-demo)
> (define-key map (kbd "C-c C-z") #'kbd-mode-switch)
> map))
>
> ;;;###autoload
> (define-minor-mode kbd-mode-demo-mode
> "Toggle kmonad demo mode.
> This is a minor mode, in which users can test their
> configurations."
> :lighter " kbd-demo"
> :keymap kbd-mode-demo-mode-map
This should be inferred.
>
> (when kbd-mode-demo-mode
> (unless (kbd-mode--valid-config?)
> (kbd-mode--show-error)))
>
> ;; Handle toggle
> (when kbd-mode-magic-focus
> (cond (kbd-mode-demo-mode
> (add-hook 'window-selection-change-functions #'kbd-mode--toggl=
e-demo nil t)
> (add-hook 'focus-in-hook #'kbd-mode--create-kmonad-process nil=
t)
> (add-hook 'focus-out-hook #'kbd-mode--kill-demo-process nil t))
> (t
> (remove-hook 'window-selection-change-functions #'kbd-mode--to=
ggle-demo t)
> (remove-hook 'focus-in-hook #'kbd-mode--create-kmonad-process =
t)
> (remove-hook 'focus-out-hook #'kbd-mode--kill-demo-process t))=
)))
>
> ;;;; Interactive Functions
>
> ;;;###autoload
> (defun kbd-mode-start-demo ()
> "Try the current configuration in a demo buffer.
> Use `kbd-mode-stop-demo' to stop the demo. If the configuration
> file has errors, the demo will not start and an error buffer will
> be shown instead."
> (interactive)
> (setq kbd-mode-demo-file
> (kbd-mode--find-kbd-file (buffer-file-name (current-buffer))))
> (if (not (kbd-mode--valid-config?))
> (kbd-mode--show-error)
> (when (shell-command "ps -C kmonad")
Shell-command is usually used for interactive stuff. And I don't know
what you are trying to test the return value for here.
(shell-command "true") ;;=3D> 0
(shell-command "false") ;;=3D> 1
(shell-command "foo") ;;=3D> 127
As the documentation says:
In Elisp, you will often be better served by calling =E2=80=98call-=
process=E2=80=99 or
=E2=80=98start-process=E2=80=99 directly, since they offer more con=
trol and do not
impose the use of a shell (with its need to quote arguments).
> (setq kbd-mode-had-kmonad? t)
> (kbd-mode--kill-kmonad))
> (kbd-mode--create-demo-buffer)
> (pop-to-buffer "*kmonad-demo*")
> (kbd-mode--create-kmonad-process)
> (kbd-mode-demo-mode t)))
>
> (defun kbd-mode-stop-demo ()
> "Stop the currently running demo."
> (interactive)
> (with-current-buffer "*kmonad-demo*"
> (kbd-mode-demo-mode 0)
> (kill-buffer-and-window)
> (kbd-mode--kill-demo-process)
> (when kbd-mode-had-kmonad?
> (kbd-mode--start-kmonad))))
>
> (defun kbd-mode-switch ()
> "Switch between the demo window and the config file."
> (interactive)
> (select-window (get-buffer-window
> (if (and (equal (buffer-name) "*kmonad-demo*")
> kbd-mode-demo-mode)
> (get-file-buffer kbd-mode-demo-file)
> "*kmonad-demo*"))))
>
> ;;;; Helper Functions
>
> (defun kbd-mode--create-demo-buffer ()
> "Create the *kmonad-demo* buffer."
> (unless (get-buffer "*kmonad-demo*")
> (display-buffer (get-buffer-create "*kmonad-demo*")
> '(display-buffer-at-bottom
> (window-height . 0.15)))))
>
> (defun kbd-mode--find-kbd-file (&optional file)
> "Find the config file.
> If the optional argument FILE is given, use it instead.
> Otherwise, prompt the user for a choice."
> (if (and file (string=3D (file-name-extension file) "kbd"))
> file
> (expand-file-name (read-file-name "Choose configuration file"))))
>
> (defun kbd-mode--valid-config? ()
> "Check if the current configuration is valid."
> (let ((command (kbd-mode--get-config-validation-command)))
> (eq 0 (shell-command command))))
>
> (defun kbd-mode--create-kmonad-process ()
> "Start the kmonad demo process in a dedicated buffer."
> (when (get-buffer-process "*kmonad*")
> (kbd-mode--kill-demo-process))
> (start-process "kmonad-emacs" "*kmonad*" "kmonad" kbd-mode-demo-file))
>
> (defun kbd-mode--kill-demo-process ()
> "Kill demo kmonad process, if possible."
> (when (get-buffer-process "*kmonad*")
> (kill-process "*kmonad*")))
There might be a race condition here.
>
> (defun kbd-mode--kill-kmonad ()
> "Kill (or suspend) a running kmonad instance.
> The command used to kill kmonad is given by the
> `kbd-mode-kill-kmonad' variable."
> (if kbd-mode-kill-kmonad
> (shell-command kbd-mode-kill-kmonad)
> (error "To kill the running kmonad instance, customize the `kbd-mode-=
kill-kmonad' variable!")))
>
> (defun kbd-mode--start-kmonad ()
> "Start (or resume) a new kmonad process.
> The command used to start kmonad is given by the
> `kbd-mode-start-kmonad' variable."
> (if kbd-mode-kill-kmonad
> (call-process-shell-command
> ;; Force the command to be executed asynchronously.
> (if (eq (aref kbd-mode-start-kmonad
If you always know that you are comparing character codes, I'd use =3D to
be more specific and trigger an error if something else occurs.
> (1- (length kbd-mode-start-kmonad)))
> ?&)
> kbd-mode-start-kmonad
> (concat kbd-mode-start-kmonad "&")))
> (error "To restart kmonad, customize the `kbd-mode-start-kmonad' vari=
able!")))
>
> (defun kbd-mode--toggle-demo (&optional _window)
> "Toggle the kmonad demo process.
> When the users exits the demo window, kill the demo process and
> start a \"normal\" kmonad process instead. When re-entering the
> demo window, do the opposite; i.e., kill the running kmonad
> instance and spawn a demo process."
> (cond ((kbd-mode--was-demo?)
> (kbd-mode--kill-demo-process)
> (kbd-mode--start-kmonad))
> ((kbd-mode--valid-config?)
> (kbd-mode--kill-kmonad)
> (kbd-mode--create-kmonad-process))
> (t
> (kbd-mode--start-kmonad)
> (kbd-mode--show-error))))
>
> (defun kbd-mode--was-demo? ()
> "Was the previous buffer the kmonad demo buffer?"
> (equal (window-buffer (previous-window))
eq should be enough here.
> (get-buffer "*kmonad-demo*")))
>
> (defun kbd-mode--show-error ()
> "Show configuration errors in a compilation buffer."
> (when kbd-mode-demo-mode
> (quit-window 'kill "*kmonad-demo*"))
> (compile (kbd-mode--get-config-validation-command)))
>
> (defun kbd-mode--get-config-validation-command ()
> "Get validation command for `kbd-mode-demo-file'."
> (concat "kmonad -d " kbd-mode-demo-file))
>
> ;;;; Integration with `compilation-mode'
>
> (add-to-list 'compilation-error-regexp-alist 'kbd)
> (add-to-list 'compilation-error-regexp-alist-alist
> '(kbd "^kmonad: Parse error at \\([0-9]+\\):\\([0-9]+\\)" ni=
l 1 2))
>
> (provide 'kbd-mode)
>
> ;;; kbd-mode.el ends here
All in all it looks fine, most of my superficial comments are nitpicks.
--=20
Philip Kaludercic on siskin
bug-gnu-emacs@HIDDEN:bug#73016; Package emacs.
Full text available.
Received: (at submit) by debbugs.gnu.org; 3 Sep 2024 22:20:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 03 18:20:19 2024
Received: from localhost ([127.0.0.1]:32959 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1slbsp-0001oC-3P
for submit <at> debbugs.gnu.org; Tue, 03 Sep 2024 18:20:19 -0400
Received: from lists.gnu.org ([209.51.188.17]:46970)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <jb@HIDDEN>) id 1slbsn-0001o3-85
for submit <at> debbugs.gnu.org; Tue, 03 Sep 2024 18:20:17 -0400
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 <jb@HIDDEN>)
id 1slbrm-0002FR-5l
for bug-gnu-emacs@HIDDEN; Tue, 03 Sep 2024 18:19:14 -0400
Received: from out-189.mta0.migadu.com ([91.218.175.189])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <jb@HIDDEN>)
id 1slbri-0000dD-Un
for bug-gnu-emacs@HIDDEN; Tue, 03 Sep 2024 18:19:13 -0400
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net;
s=key1; t=1725401943;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:cc:mime-version:mime-version:content-type:content-type;
bh=sYwrECLLNzRBsWcK2vByEsRbruW1+puby50ghR4AQJs=;
b=Y6Mu3uf1w0rMj8CrrJG6ZQ2/EdecCalQ6GYXJxACuogoZqk/K4KUcZ2C96BCFPEPD1ppeq
SYpzo1yeMsv3bOLw1fl5eRAPeEznv1/xFdGL3rqs0cZo9ygVPJeJ74mJtLi1SLU/TEsrTU
iRryHaJJw5LvjCT/ao522qXyz4VQcv/H6DwZ//ZxiDup994zNj0NjqcOq0Sl9W4o03Bnjx
gBDJ10RCt+GnoBjXWsy0AarXnXJ1CLmQirDbSRK1z7g9wXg/LaHGLZezexW9156upG86cw
0AQDZrpfRNDp/3MHezlkoty08DA2QVHHQSxLWHpmz/vtpRO/2sp0JbwQ4z2IJA==
From: Jeremy Bryant <jb@HIDDEN>
To: bug-gnu-emacs@HIDDEN, Philip Kaludercic <philipk@HIDDEN>
Subject: Potential inclusion of kbd-mode, part of kmonad, in Non-GNU ELPA
Date: Tue, 03 Sep 2024 23:19:01 +0100
Message-ID: <875xrcfkiy.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Migadu-Flow: FLOW_OUT
Received-SPF: pass client-ip=91.218.175.189; envelope-from=jb@HIDDEN;
helo=out-189.mta0.migadu.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,
RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: Tony Zorman <tonyzorman@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)
--=-=-=
Content-Type: text/plain
Hi,
kmonad is a keyboard configuration tool under MIT license.
https://github.com/kmonad/kmonad
There is an Emacs major mode to edit the configuration file, based on
s-expressions. The mode is under GPLv3.
https://github.com/kmonad/kbd-mode
On behalf of the author, Tony Zorman, I would like to request
consideration to include it in NON-GNU ELPA.
The author is conscious that the following snippet should be improved
and we are soliciting recommendations on how to improve it.
;; HACK
(defadvice redisplay (after refresh-font-locking activate)
(when (derived-mode-p 'kbd-mode)
(font-lock-fontify-buffer))))
Furthermore if there are any code reviews or recommendations, I attach
the current version.
I can volunteer some time for some of the changes.
--=-=-=
Content-Type: application/emacs-lisp
Content-Disposition: attachment; filename=kbd-mode.el
Content-Transfer-Encoding: quoted-printable
;;; kbd-mode.el --- Font locking for kmonad's .kbd files -*- lexical-bindin=
g: t -*-
;; Copyright 2020=E2=80=932022 slotThe
;; URL: https://github.com/kmonad/kbd-mode
;; Version: 0.0.1
;; Package-Requires: ((emacs "24.3"))
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file adds basic font locking support for `.kbd' configuration
;; files.
;;
;; To use this file, move it to a directory within your `load-path' and
;; require it. For example --- assuming that this file was placed
;; within the `~/.config/emacs/elisp' directory:
;;
;; (add-to-list 'load-path "~/.config/emacs/elisp/")
;; (require 'kbd-mode)
;;
;; If you use `use-package', you can express the above as
;;
;; (use-package kbd-mode
;; :load-path "~/.config/emacs/elisp/")
;;
;; By default we highlight all keywords; you can change this by
;; customizing the `kbd-mode-' variables. For example, to disable the
;; highlighting of already defined macros (i.e. of "@macro-name"), you
;; can set `kbd-mode-show-macros' to `nil'.
;;
;; For keybindings, as well as commentary on the `kbd-mode-demo-mode'
;; minor mode, see the associated README.md file.
;;; Code:
(require 'compile)
(defgroup kbd nil
"Major mode for editing `.kbd' files."
:group 'languages)
(defgroup kbd-demo nil
"A minor mode to test your configuration."
:group 'kbd)
;;;; Custom variables
(defgroup kbd-highlight nil
"Syntax highlighting for `kbd-mode'."
:group 'kbd)
(defcustom kbd-mode-kexpr
'("defcfg" "defsrc" "defalias")
"A K-Expression."
:type '(repeat string)
:group 'kbd-highlight)
;; HACK
(defcustom kbd-mode-function-one
'("deflayer")
"Tokens that are treated as functions with one argument."
:type '(repeat string)
:group 'kbd-highlight)
(defcustom kbd-mode-tokens
'(;; input tokens
"uinput-sink" "send-event-sink" "kext"
;; output tokens
"device-file" "low-level-hook" "iokit-name")
"Input and output tokens."
:type '(repeat string)
:group 'kbd-highlight)
(defcustom kbd-mode-defcfg-options
'("input" "output" "cmp-seq-delay" "cmp-seq" "init" "fallthrough" "allow-=
cmd")
"Options to give to `defcfg'."
:type '(repeat string)
:group 'kbd-highlight)
(defcustom kbd-mode-button-modifiers
'("around-next-timeout" "around-next-single" "around-next" "around"
"tap-hold-next-release" "tap-hold-next" "tap-next-release" "tap-hold"
"tap-macro-release" "tap-macro" "multi-tap" "tap-next" "layer-toggle"
"layer-switch" "layer-add" "layer-rem" "layer-delay" "layer-next" "cmd-=
button")
"Button modifiers."
:type '(repeat string)
:group 'kbd-highlight)
(defcustom kbd-mode-show-string
'("uinput-sink" "device-file" "cmd-button")
"Syntax highlight strings in S-expressions.
When an S-expression begins with any of these keywords, highlight
strings (delimited by double quotes) inside it."
:type '(repeat string)
:group 'kbd-highlight)
(defcustom kbd-mode-show-macros t
"Whether to syntax highlight macros inside layout definitions.
Default: t"
:type 'boolean
:group 'kbd-highlight)
(defcustom kbd-mode-magic-focus nil
"Whether to enable magic focus.
Whenever the `kbd-mode-demo-mode' buffer gets focused,
automatically start try to start a new process for the config
file. When switching back to the config file, kill that process.
Default: nil"
:type 'boolean
:group 'kbd-demo)
(defcustom kbd-mode-kill-kmonad nil
"How to kill (or suspend) a running kmonad instance.
This is used when invoking `kbd-mode-start-demo' and, in general,
when entering `kbd-mode-demo-mode' because keyboards can't be
grabbed twice."
:type 'string
:group 'kbd-demo)
(defcustom kbd-mode-start-kmonad nil
"How to restart (or resume) kmonad.
If there was an active kmonad instance running, which was killed
by `kbd-mode-kill-kmonad', then this (re)starts kmonad with the
given command upon exiting `kbd-mode-demo-mode'."
:type 'string
:group 'kbd-demo)
;;;; Faces
(defgroup kbd-highlight-faces nil
"Faces used for highlighting in `kbd-mode'."
:group 'kbd-highlight)
(defface kbd-mode-kexpr-face
'((t :inherit font-lock-keyword-face))
"Face for a K-Expression."
:group 'kbd-highlight-faces)
(defface kbd-mode-token-face
'((t :inherit font-lock-function-name-face))
"Face for input and output tokens."
:group 'kbd-highlight-faces)
(defface kbd-mode-defcfg-option-face
'((t :inherit font-lock-builtin-face))
"Face for options one may give to `defcfg'."
:group 'kbd-highlight-faces)
(defface kbd-mode-button-modifier-face
'((t :inherit font-lock-function-name-face))
"Face for all the button modifiers."
:group 'kbd-highlight-faces)
(defface kbd-mode-variable-name-face
'((t :inherit font-lock-variable-name-face))
"Face for a variables, i.e. layer names, macros in layers,..."
:group 'kbd-highlight-faces)
(defface kbd-mode-string-face
'((t :inherit font-lock-string-face))
"Face for strings."
:group 'kbd-highlight-faces)
;;;; Functions
(defun kbd-mode--show-macros? (show-macros)
"Decide whether to font-lock macros.
If the argument SHOW-MACROS is non-nil, font-lock macros of the
form `@MACRO-NAME' with `kbd-mode-variable-name-face'."
(let ((macro-regexp '(("\\(:?\\(@[^[:space:]]+\\)\\)"
(1 'kbd-mode-variable-name-face)))))
(if show-macros
(font-lock-add-keywords 'kbd-mode macro-regexp)
(font-lock-remove-keywords 'kbd-mode macro-regexp))))
;;; Vars
(defvar kbd-mode-syntax-table
(let ((st (make-syntax-table)))
;; Use ;; for regular comments and #| |# for line comments.
(modify-syntax-entry ?\; ". 12b" st)
(modify-syntax-entry ?\n "> b" st)
(modify-syntax-entry ?\# ". 14" st)
(modify-syntax-entry ?\| ". 23" st)
;; We don't need to highlight brackets, as they're only used inside
;; layouts.
(modify-syntax-entry ?\[ "." st)
(modify-syntax-entry ?\] "." st)
;; We highlight the necessary strings ourselves.
(modify-syntax-entry ?\" "." st)
st)
"The basic syntax table for `kbd-mode'.")
(defvar kbd-mode--font-lock-keywords
(let ((kexpr-regexp (regexp-opt kbd-mode-kexpr 'wor=
ds))
(token-regexp (regexp-opt kbd-mode-tokens 'wor=
ds))
(defcfg-options-regexp (regexp-opt kbd-mode-defcfg-options 'wor=
ds))
(button-modifiers-regexp (regexp-opt kbd-mode-button-modifiers 'wor=
ds))
(function-one-regexp
(concat "\\(?:\\("
(regexp-opt kbd-mode-function-one)
"\\)\\([[:space:]]+[[:word:]]+\\)\\)"))
;; Only highlight these strings; configuration files may explicitly
;; use a " to emit a double quote, so we can't trust the default
;; string highlighting.
(string-regexp
(concat "\\(['\(]"
(regexp-opt kbd-mode-show-string)
"\\)\\(\\S)+\\)\)")))
`((,token-regexp (1 'kbd-mode-token-face ))
(,kexpr-regexp (1 'kbd-mode-kexpr-face ))
(,button-modifiers-regexp (1 'kbd-mode-button-modifier-face))
(,defcfg-options-regexp (1 'kbd-mode-defcfg-option-face ))
(,function-one-regexp
(1 'kbd-mode-kexpr-face )
(2 'kbd-mode-variable-name-face))
(,string-regexp
("\"[^}]*?\""
(progn (goto-char (match-beginning 0)) (match-end 0))
(goto-char (match-end 0))
(0 'kbd-mode-string-face t)))))
"Keywords to be syntax highlighted.")
;;; Define Major Mode
;; Because the configuration language is in a lispy syntax, we can
;; inherit from any lisp mode in order to get good parenthesis handling
;; for free.
(defvar kbd-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") #'kbd-mode-start-demo)
(define-key map (kbd "C-c C-z") #'kbd-mode-switch)
map))
;;;###autoload
(define-derived-mode kbd-mode emacs-lisp-mode "Kbd"
"Major mode for editing `.kbd' files.
For details, see `https://github.com/kmonad/kmonad'."
(set-syntax-table kbd-mode-syntax-table)
(use-local-map kbd-mode-map)
(font-lock-add-keywords 'kbd-mode kbd-mode--font-lock-keywords)
(kbd-mode--show-macros? kbd-mode-show-macros)
;; HACK
(defadvice redisplay (after refresh-font-locking activate)
(when (derived-mode-p 'kbd-mode)
(font-lock-fontify-buffer))))
;; Associate the `.kbd' ending with `kbd-mode'.
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.kbd\\'" . kbd-mode))
;;;; Demo Minor Mode
(defvar kbd-mode-demo-file nil
"Path to the users configuration file.
This is used in `kbd-mode-demo-mode' for deciding what
configuration to compile.")
(defvar kbd-mode-had-kmonad? nil
"Whether the user had a running kmonad instance.
This controls whether kmonad will be restarted by mean of
`kbd-mode-start-kmonad' after exiting `kbd-mode-demo-mode'.")
(defvar kbd-mode-demo-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") #'kbd-mode-stop-demo)
(define-key map (kbd "C-c C-z") #'kbd-mode-switch)
map))
;;;###autoload
(define-minor-mode kbd-mode-demo-mode
"Toggle kmonad demo mode.
This is a minor mode, in which users can test their
configurations."
:lighter " kbd-demo"
:keymap kbd-mode-demo-mode-map
(when kbd-mode-demo-mode
(unless (kbd-mode--valid-config?)
(kbd-mode--show-error)))
;; Handle toggle
(when kbd-mode-magic-focus
(cond (kbd-mode-demo-mode
(add-hook 'window-selection-change-functions #'kbd-mode--toggle-=
demo nil t)
(add-hook 'focus-in-hook #'kbd-mode--create-kmonad-process nil t)
(add-hook 'focus-out-hook #'kbd-mode--kill-demo-process nil t))
(t
(remove-hook 'window-selection-change-functions #'kbd-mode--togg=
le-demo t)
(remove-hook 'focus-in-hook #'kbd-mode--create-kmonad-process t)
(remove-hook 'focus-out-hook #'kbd-mode--kill-demo-process t)))))
;;;; Interactive Functions
;;;###autoload
(defun kbd-mode-start-demo ()
"Try the current configuration in a demo buffer.
Use `kbd-mode-stop-demo' to stop the demo. If the configuration
file has errors, the demo will not start and an error buffer will
be shown instead."
(interactive)
(setq kbd-mode-demo-file
(kbd-mode--find-kbd-file (buffer-file-name (current-buffer))))
(if (not (kbd-mode--valid-config?))
(kbd-mode--show-error)
(when (shell-command "ps -C kmonad")
(setq kbd-mode-had-kmonad? t)
(kbd-mode--kill-kmonad))
(kbd-mode--create-demo-buffer)
(pop-to-buffer "*kmonad-demo*")
(kbd-mode--create-kmonad-process)
(kbd-mode-demo-mode t)))
(defun kbd-mode-stop-demo ()
"Stop the currently running demo."
(interactive)
(with-current-buffer "*kmonad-demo*"
(kbd-mode-demo-mode 0)
(kill-buffer-and-window)
(kbd-mode--kill-demo-process)
(when kbd-mode-had-kmonad?
(kbd-mode--start-kmonad))))
(defun kbd-mode-switch ()
"Switch between the demo window and the config file."
(interactive)
(select-window (get-buffer-window
(if (and (equal (buffer-name) "*kmonad-demo*")
kbd-mode-demo-mode)
(get-file-buffer kbd-mode-demo-file)
"*kmonad-demo*"))))
;;;; Helper Functions
(defun kbd-mode--create-demo-buffer ()
"Create the *kmonad-demo* buffer."
(unless (get-buffer "*kmonad-demo*")
(display-buffer (get-buffer-create "*kmonad-demo*")
'(display-buffer-at-bottom
(window-height . 0.15)))))
(defun kbd-mode--find-kbd-file (&optional file)
"Find the config file.
If the optional argument FILE is given, use it instead.
Otherwise, prompt the user for a choice."
(if (and file (string=3D (file-name-extension file) "kbd"))
file
(expand-file-name (read-file-name "Choose configuration file"))))
(defun kbd-mode--valid-config? ()
"Check if the current configuration is valid."
(let ((command (kbd-mode--get-config-validation-command)))
(eq 0 (shell-command command))))
(defun kbd-mode--create-kmonad-process ()
"Start the kmonad demo process in a dedicated buffer."
(when (get-buffer-process "*kmonad*")
(kbd-mode--kill-demo-process))
(start-process "kmonad-emacs" "*kmonad*" "kmonad" kbd-mode-demo-file))
(defun kbd-mode--kill-demo-process ()
"Kill demo kmonad process, if possible."
(when (get-buffer-process "*kmonad*")
(kill-process "*kmonad*")))
(defun kbd-mode--kill-kmonad ()
"Kill (or suspend) a running kmonad instance.
The command used to kill kmonad is given by the
`kbd-mode-kill-kmonad' variable."
(if kbd-mode-kill-kmonad
(shell-command kbd-mode-kill-kmonad)
(error "To kill the running kmonad instance, customize the `kbd-mode-ki=
ll-kmonad' variable!")))
(defun kbd-mode--start-kmonad ()
"Start (or resume) a new kmonad process.
The command used to start kmonad is given by the
`kbd-mode-start-kmonad' variable."
(if kbd-mode-kill-kmonad
(call-process-shell-command
;; Force the command to be executed asynchronously.
(if (eq (aref kbd-mode-start-kmonad
(1- (length kbd-mode-start-kmonad)))
?&)
kbd-mode-start-kmonad
(concat kbd-mode-start-kmonad "&")))
(error "To restart kmonad, customize the `kbd-mode-start-kmonad' variab=
le!")))
(defun kbd-mode--toggle-demo (&optional _window)
"Toggle the kmonad demo process.
When the users exits the demo window, kill the demo process and
start a \"normal\" kmonad process instead. When re-entering the
demo window, do the opposite; i.e., kill the running kmonad
instance and spawn a demo process."
(cond ((kbd-mode--was-demo?)
(kbd-mode--kill-demo-process)
(kbd-mode--start-kmonad))
((kbd-mode--valid-config?)
(kbd-mode--kill-kmonad)
(kbd-mode--create-kmonad-process))
(t
(kbd-mode--start-kmonad)
(kbd-mode--show-error))))
(defun kbd-mode--was-demo? ()
"Was the previous buffer the kmonad demo buffer?"
(equal (window-buffer (previous-window))
(get-buffer "*kmonad-demo*")))
(defun kbd-mode--show-error ()
"Show configuration errors in a compilation buffer."
(when kbd-mode-demo-mode
(quit-window 'kill "*kmonad-demo*"))
(compile (kbd-mode--get-config-validation-command)))
(defun kbd-mode--get-config-validation-command ()
"Get validation command for `kbd-mode-demo-file'."
(concat "kmonad -d " kbd-mode-demo-file))
;;;; Integration with `compilation-mode'
(add-to-list 'compilation-error-regexp-alist 'kbd)
(add-to-list 'compilation-error-regexp-alist-alist
'(kbd "^kmonad: Parse error at \\([0-9]+\\):\\([0-9]+\\)" nil =
1 2))
(provide 'kbd-mode)
;;; kbd-mode.el ends here
--=-=-=--
Jeremy Bryant <jb@HIDDEN>:bug-gnu-emacs@HIDDEN.
Full text available.bug-gnu-emacs@HIDDEN:bug#73016; Package emacs.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.