From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] Proposing to add express to ELPA Date: Tue, 01 Aug 2023 08:07:15 +0000 Message-ID: <87r0onjido.fsf@posteo.net> References: <0C0218D1-6C00-4E5A-9E6E-6282F170126A@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24335"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 01 10:08:13 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 1qQkQK-0005te-TO for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Aug 2023 10:08:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQkPY-0007sV-MT; Tue, 01 Aug 2023 04:07:20 -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 1qQkPX-0007pJ-Fq for emacs-devel@gnu.org; Tue, 01 Aug 2023 04:07:19 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQkPV-0007gC-GN for emacs-devel@gnu.org; Tue, 01 Aug 2023 04:07:19 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 3D67A240028 for ; Tue, 1 Aug 2023 10:07:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1690877236; bh=OwJDP8gsBrlvlmPhtZT/sHBJ8zXfegdC6t7nqe9lD50=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=TMo3nssrfWUkunSbVPxUq2yiz1g5Q9HDI9ZnFFFrRTR8zYwDKiMmvg9ZSLRSioGd6 AJ3ckJQresgaYzyur9NgpDka/b+wXJS/EKTTSW0OPkZBKAJgqBg4sHgK1I25BRfKgv ADI/V80RjNjAq6H1SY1X1J9O9MoxeIFNt7JMIjm5vyXJRBcrQcd4JdEopgUfxe0/eI hqMqSHPtSiCQ/aWvLL2SJPzqbLO6NTLeMMpFFWDOoezbnIqdmIGeZEf/4now8lcz1J Oqi6NQvkfkdPFVwSIakK5OZKPe9VFQ0ZdkW/Er3kitYPeK9O+LQzz1worjjlE1nI+H eB+obuO7jDKGQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RFSPv4Z8Hz6v4d; Tue, 1 Aug 2023 10:07:15 +0200 (CEST) In-Reply-To: <0C0218D1-6C00-4E5A-9E6E-6282F170126A@gmail.com> (Yuan Fu's message of "Mon, 31 Jul 2023 11:38:27 -0700") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 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_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:308232 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Yuan Fu writes: > Hi all, Hi, > Since Emacs 29 is now released, I=E2=80=99d like to propose adding expreg= to > ELPA. Expreg can be considered a lite version of expand-region. The > notable difference is its use of tree-sitter for language-specific > expansions. I also took the liberty to do things differently than > expand-region, eg, expreg uses a smaller number of expanders [1]; it > is easier to debug when the expansion isn=E2=80=99t what you expected; an= d it > only provides two functions for expansion and contraction, and one > variable for adding/removing expanders=E2=80=94no transient maps and other > =E2=80=9Csmart=E2=80=9D features, nor different variables to set for each= major mode. > > The obvious downsides is that, of course, it=E2=80=99s pretty useless on > anything other than lisp if you don=E2=80=99t have tree-sitter grammars a= nd > major mode installed. You can use it in a non-tree-sitter major mode, > as long the tree-sitter grammar exists. You only need to create a > parser and expreg will automatically use the parser [2]. > > I=E2=80=99ve been using it for months and ironed out all sorts of edge-ca= ses, and can recommend it for daily usage. this looks nice! I have a few comments that might be interesting: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/expreg.el b/expreg.el index 05459af..2147ce8 100644 --- a/expreg.el +++ b/expreg.el @@ -1,6 +1,6 @@ ;;; expreg.el --- Simple expand region -*- lexical-binding: t; -*- =20 -;; Copyright (C) 2022 Free Software Foundation, Inc. +;; Copyright (C) 2022, 2023 Free Software Foundation, Inc. ;; ;; Author: Yuan Fu ;; Maintainer: Yuan Fu @@ -79,8 +79,8 @@ (require 'subword) (require 'treesit) (eval-when-compile - (require 'cl-lib) - (require 'seq)) + (require 'cl-lib)) +(require 'seq) =20 ;;; Cutom options and variables =20 @@ -102,9 +102,9 @@ scan-error, like end-of-buffer, or unbalanced parenthes= es, etc.") =20 (defun expreg--sort-regions (regions) "Sort REGIONS by their span." - (cl-sort regions (lambda (a b) - (< (- (cddr a) (cadr a)) - (- (cddr b) (cadr b)))))) + (sort regions (lambda (a b) + (< (- (cddr a) (cadr a)) + (- (cddr b) (cadr b)))))) =20 (defvar expreg--validation-white-list '(list-at-point) "Regions produced by functions in this list skips filtering.") @@ -166,12 +166,11 @@ ORIG is the current position. Each region is (BEG . E= ND)." ;; OTOH, if there are regions that ends at ORIG, filter out ;; regions that starts AFTER ORIGN, eg, special cases in ;; =E2=80=98expreg--list-at-point=E2=80=99. - (setq regions (cl-remove-if - (lambda (region) - (and orig-at-end-of-something - (> (cadr region) orig))) - regions)) - regions)) + (cl-remove-if + (lambda (region) + (and orig-at-end-of-something + (> (cadr region) orig))) + regions))) =20 ;;; Syntax-ppss shorthands =20 @@ -199,7 +198,7 @@ POS defaults to point." ;;; Expand/contract =20 (defvar-local expreg--verbose nil - "If t, print debugging information.") + "Non-nil means print debugging information.") =20 (defvar-local expreg--next-regions nil "The regions we are going to expand to. @@ -209,12 +208,13 @@ This should be a list of (BEG . END).") "The regions we=E2=80=99ve expanded past. This should be a list of (BEG . END).") =20 +;;;###autoload (defun expreg-expand () "Expand region." (interactive) ;; Checking for last-command isn=E2=80=99t strictly necessary, but nice = to ;; have. - (when (not (and (region-active-p) + (when (not (and (use-region-p) (eq (region-beginning) (cadr (car expreg--prev-regions))) (eq (region-end) @@ -236,7 +236,7 @@ This should be a list of (BEG . END).") =20 ;; Go past all the regions that are smaller than the current region, ;; if region is active. - (when (region-active-p) + (when (use-region-p) (while (and expreg--next-regions (let ((beg (cadr (car expreg--next-regions))) (end (cddr (car expreg--next-regions)))) @@ -261,8 +261,8 @@ This should be a list of (BEG . END).") (defun expreg-contract () "Contract region." (interactive) - (when (and (region-active-p) - (> (length expreg--prev-regions) 1)) + (when (and (use-region-p) + (length> expreg--prev-regions 1)) =20 (push (pop expreg--prev-regions) expreg--next-regions) (set-mark (cddr (car expreg--prev-regions))) @@ -548,7 +548,7 @@ current string/comment and get lists inside." (defun expreg--comment () "Return a list of regions containing comment." (let ((orig (point)) - (beg (point)) + (beg (point)) ;perhaps use narrowing? (end (point)) result forward-succeeded trailing-comment-p) =20 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > You can find the repository here: https://github.com/casouri/expreg > And I attached a patch for ELPA. It=E2=80=99s been awhile since I last ma= de a > patch for ELPA, I hope I did it right. Looks OK. > [1] Default expanders include: expreg--subword expreg--word expreg--list = expreg--string expreg--treesit expreg--comment expreg--paragraph > > [2] Something like (add-hook 'xxx-mode-hook (lambda () (treesit-parser-cr= eate 'xxx))) > > PS. I find it amusing that, among the total 632 LOC, only 17 are > responsible for the tree-sitter support, the main purpose of this > package; all the rest are code dealing with correctly expanding lists, > strings and comments with syntax-ppss. > > Thanks, > Yuan > > From 7e201deb71f324e22d31331c06cf3999a105668b Mon Sep 17 00:00:00 2001 > From: Yuan Fu > Date: Mon, 31 Jul 2023 11:14:04 -0700 > Subject: [PATCH] * elpa-packages (expreg): New package. > > --- > elpa-packages | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/elpa-packages b/elpa-packages > index 48a0ada..e1470d5 100644 > --- a/elpa-packages > +++ b/elpa-packages > @@ -292,6 +292,7 @@ > :doc "doc/ess.texi") > (excorporate :url nil) > (expand-region :url "https://github.com/magnars/expand-region.el") > + (expreg :url "https://github.com/casouri/expreg.git") > (external-completion :core "lisp/external-completion.el") > (exwm :url "https://github.com/ch11ng/exwm.git") > (f90-interface-browser :url nil) ;; Was "https://github.com/wence-/f90-= iface" --=-=-=--