From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zachary Kanfer Newsgroups: gmane.emacs.bugs Subject: bug#62892: proposal to extend mark-sexp to go forward and backward on command Date: Wed, 17 May 2023 23:17:01 -0400 Message-ID: References: <86jzxwuedr.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000924a7a05fbef3dac" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21491"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Ruijie Yu , Stefan Monnier , "62892@debbugs.gnu.org" <62892@debbugs.gnu.org>, Juri Linkov To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 18 05:18:21 2023 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 1pzU9j-0005Ki-Kq for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 May 2023 05:18:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzU9V-0007ad-Fb; Wed, 17 May 2023 23:18:05 -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 1pzU9T-0007a7-35 for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 23:18:03 -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 1pzU9S-00079X-Rr for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 23:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzU9S-0007LW-D2 for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 23:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zachary Kanfer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 May 2023 03:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62892 X-GNU-PR-Package: emacs Original-Received: via spool by 62892-submit@debbugs.gnu.org id=B62892.168437984128185 (code B ref 62892); Thu, 18 May 2023 03:18:02 +0000 Original-Received: (at 62892) by debbugs.gnu.org; 18 May 2023 03:17:21 +0000 Original-Received: from localhost ([127.0.0.1]:51594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzU8m-0007KW-MJ for submit@debbugs.gnu.org; Wed, 17 May 2023 23:17:21 -0400 Original-Received: from mail-oi1-f180.google.com ([209.85.167.180]:60575) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzU8k-0007KF-9A for 62892@debbugs.gnu.org; Wed, 17 May 2023 23:17:19 -0400 Original-Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-394690088acso1195223b6e.0 for <62892@debbugs.gnu.org>; Wed, 17 May 2023 20:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684379832; x=1686971832; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1Tq8CTguT9sqhZgSDTUFqIrA/YdK4kyax/vqGzQB1E8=; b=TrDg+EWN1O1fNYLuZ3e29zfTG1ildc0TGAD0Un+/2xE2cNDpfET4uMRECZFdYjTSLD ytwH6O0rza84BsdRPqMUIeqD8/i4cg8rSkAX4DoNdcysZgcGUmx9G4Z+zxh9sLkhSmXd f6GbJLR2AgNem8rdcWemmsC0uyyXGK0qkIC8jRoSnx8tmTL7jnXw5YkfpW0gYirve58E 74/JKJbo9Z2puTlrMC5d7XMcA84yzWvZZdUIsVS9ZXfkLn9MfQfpa9QLxwWLFK14coWF Ak4BZuGu5TW8uI2Q6A6muMmF984xENDgnoXx6YiOUMZtTjP/yZae4fiEZG8kIULpbDwJ l3Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684379832; x=1686971832; 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=1Tq8CTguT9sqhZgSDTUFqIrA/YdK4kyax/vqGzQB1E8=; b=FB2AlxmjnKsD6/EUywWzDaXkrx3Xjtv2cRseB1ch4JAY8n3DVQIDa6zluF500AYpEY LSGD5xtL9K7vkMz/ZJ8xLF0quGgWBIljX36Sk3LRaKjVoV6+f62w9eerskii6QK9ERJF Hwch3gndveB2S7Y7Hqd3qA8VVz2P8NmFf2TJz111+aVUDh0C3DocZxMeyGR/1DXyAAqf ORtx/HQxLa5Idib0NYITrH6b9fhyJoNk+gat0IubHVpY5CWLB4707Sf1NkdSf9oa4/ge R1neEgn93A5gAKYBaajXDTM04p0HOGB46b2zPkR/tdhURnDobpFM0IczQ1ExPruOS0mz 4JwQ== X-Gm-Message-State: AC+VfDy1bCXJCiIvy53ulvMJHfHgxkxjIZrB5r82H3qdKiqV/1bCinEQ sd/gHcmAk5Cg8DnoRKP7f53/YF/D2+BZlhTk/a8= X-Google-Smtp-Source: ACHHUZ7DKxqETNDx90q+CkVaVZWXsgQfnTvTTRyYyuAuJrFBvcUV2W5IvFrKJrz4KWXFfuM2WSVKOwFrVevEld3KctE= X-Received: by 2002:a05:6808:5d4:b0:38b:fa17:5c99 with SMTP id d20-20020a05680805d400b0038bfa175c99mr444195oij.17.1684379832300; Wed, 17 May 2023 20:17:12 -0700 (PDT) In-Reply-To: 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261892 Archived-At: --000000000000924a7a05fbef3dac Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Is there anything I can do to make this patch easier to evaluate? As far as I'm aware, I've addressed all comments that have been made in this thread. On Mon, May 8, 2023 at 8:28=E2=80=AFAM Zachary Kanfer w= rote: > Attached is a patch with the following changes: > > * Uses the helper function to create mark-foo-forward, mark-foo-backward > for word, paragraph, sexp, page, and defun. > * Adds tests for all of these. > * Adds these new functions to etc/NEWS and various .texi files in > doc/emacs/. > > On Thu, May 4, 2023 at 12:48=E2=80=AFAM Zachary Kanfer wrote: > >> > Is it an "internal" function? Then its name should >> > maybe use `--'. (But why should it be internal?) >> >> Hrm, I figured it would be an internal function because it's intended to >> be wrapped by other code. But this describes a whole lot of functions. S= o >> it can't be that. >> >> I suppose that if there are other types of things that are created that >> one might want to mark, then a user could use this method to mark them. = So >> perhaps it shouldn't be internal -- it really could be used by other cod= e. >> >> > Is it a helper function? Then its name should maybe >> > use a suffix that indicates that, such as `-helper' >> > or `-1' (old-school Lisp, I suppose). >> >> It's certainly a helper function -- it's intended to be called by a bunc= h >> of different functions we write. >> >> > `mark-thing' should be reserved for a function that >> > takes a THING name as arg: `sexp', `page', etc., >> > instead of a movement function such as `forward-sexp'. >> >> This makes a lot of sense to me. >> >> On Fri, Apr 28, 2023 at 3:28=E2=80=AFPM Drew Adams wrote: >> >>> > > +(defun mark--helper (move-fn number-of-things) >>> > >>> > A nicer name would be 'mark-thing' as a reference to thingatpt.el. >>> >>> FWIW, I have a different take on this. >>> >>> Is it an "internal" function? Then its name should >>> maybe use `--'. (But why should it be internal?) >>> >>> Is it a helper function? Then its name should maybe >>> use a suffix that indicates that, such as `-helper' >>> or `-1' (old-school Lisp, I suppose). >>> >>> `mark-thing' should be reserved for a function that >>> takes a THING name as arg: `sexp', `page', etc., >>> instead of a movement function such as `forward-sexp'. >>> ___ >>> >>> FWIW, I think MOVE-FN is a fine name for the argument. >>> My own preference, and what I use in my code, is the >>> name FORWARD-THING-FUNCTION. >>> ___ >>> >>> FWIW, in my library isearch+.el), I use the arg name >>> THING for a thing name, not a movement or other >>> function. >>> >>> E.g.: Function `isearchp-in-thing-p' is a helper >>> function for defining specific THING-type predicates, >>> such as `isearch(-not)-in-email-address-p'. >>> ___ >>> >>> FWIW, my library `thing-cmds.el' has a command named >>> `mark-things', which prompts for a THING type as arg: >>> >>> mark-things is an alias for 'select-things' in 'thing-cmds.el'. >>> >>> (mark-things THING &optional ARG ALLOW-EXTEND) >>> >>> Set point at one end of THING and set mark ARG THINGs from point. >>> THING is a symbol that names a type of thing. Interactively, you are >>> prompted for it. Completion is available (lax). >>> >>> (If THING doesn't have an associated `forward-'THING operation then >>> do nothing.) >>> >>> Put mark at the same place command `forward-'THING would move point >>> with the same prefix argument. >>> >>> Put point at the beginning of THING, unless the prefix argument (ARG) >>> is negative, in which case put it at the end of THING. >>> >>> If `select-things' is repeated or if the mark is active (in Transient >>> Mark mode), then it marks the next ARG THINGs, after the ones already >>> marked. In this case the type of THING used is whatever was used the >>> last time `select-things' was called - you are not prompted for it. >>> >>> This region extension reusing the last type of THING happens even if >>> the active region is empty. This means that you can, for instance, >>> just use `C-SPC' to activate an empty region and then use >>> `select-things' to select more THINGS of the last kind selected. >>> >>> If there is no THING at point, and `thgcmd-use-nearest-thing-flag' is >>> non-nil, then select a THING near point. >>> >>> --000000000000924a7a05fbef3dac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Is there anything I can do to make this patch easier to ev= aluate? As far as I'm aware, I've addressed all comments that have = been made in this thread.

On Mon, May 8, 2023 at 8:28=E2=80=AFAM Zachar= y Kanfer <zkanfer@gmail.com>= wrote:
Attached is a patch with the following changes:
* Uses the helper function to create mark-foo-forward, mark-foo= -backward for word, paragraph, sexp, page, and defun.
* Adds test= s for all of these.
* Adds these new functions to etc/NEWS and va= rious .texi files in doc/emacs/.

On Thu, May 4, 2023 at 12:48=E2= =80=AFAM Zachary Kanfer <zkanfer@gmail.com> wrote:
>=20 Is it an "internal" function?=C2=A0 Then its name should
> maybe use `--'.=C2=A0 (But why should it be internal?)

Hrm, I figured it would be an internal=20 function because it's intended to be wrapped by other code. But this=20 describes a whole lot of functions. So it can't be that.

=
I suppose that if there are other types of things that are created that=20 one might want to mark, then a user could use this method to mark them.=20 So perhaps it shouldn't be internal -- it really could be used by other= =20 code.

> Is it a helper function?=C2= =A0 Then its name should maybe
> use a suffix that indicates that, such as `-helper'
> or `-1' (old-school Lisp, I suppose).

<= div>It's certainly a helper function -- it's intended to be called = by a bunch of different functions we write.

= > `mark-thing' should be reserved for a function that
> takes = a THING name as arg: `sexp', `page', etc.,
> instead of a mov= ement function such as `forward-sexp'.

= This makes a lot of sense to me.

=
On Fri, Apr 28, 2023 at 3:28=E2=80=AF= PM Drew Adams <drew.adams@oracle.com> wrote:
> > +(defun mark--helper (move-fn number-of-th= ings)
>
> A nicer name would be 'mark-thing' as a reference to thingatpt= .el.

FWIW, I have a different take on this.

Is it an "internal" function?=C2=A0 Then its name should
maybe use `--'.=C2=A0 (But why should it be internal?)

Is it a helper function?=C2=A0 Then its name should maybe
use a suffix that indicates that, such as `-helper'
or `-1' (old-school Lisp, I suppose).

`mark-thing' should be reserved for a function that
takes a THING name as arg: `sexp', `page', etc.,
instead of a movement function such as `forward-sexp'.
___

FWIW, I think MOVE-FN is a fine name for the argument.
My own preference, and what I use in my code, is the
name FORWARD-THING-FUNCTION.
___

FWIW, in my library isearch+.el), I use the arg name
THING for a thing name, not a movement or other
function.

E.g.: Function `isearchp-in-thing-p' is a helper
function for defining specific THING-type predicates,
such as `isearch(-not)-in-email-address-p'.
___

FWIW, my library `thing-cmds.el' has a command named
`mark-things', which prompts for a THING type as arg:

=C2=A0mark-things is an alias for 'select-things' in 'thing-cmd= s.el'.

=C2=A0(mark-things THING &optional ARG ALLOW-EXTEND)

=C2=A0Set point at one end of THING and set mark ARG THINGs from point.
=C2=A0THING is a symbol that names a type of thing.=C2=A0 Interactively, yo= u are
=C2=A0prompted for it.=C2=A0 Completion is available (lax).

=C2=A0(If THING doesn't have an associated `forward-'THING operatio= n then
=C2=A0do nothing.)

=C2=A0Put mark at the same place command `forward-'THING would move poi= nt
=C2=A0with the same prefix argument.

=C2=A0Put point at the beginning of THING, unless the prefix argument (ARG)=
=C2=A0is negative, in which case put it at the end of THING.

=C2=A0If `select-things' is repeated or if the mark is active (in Trans= ient
=C2=A0Mark mode), then it marks the next ARG THINGs, after the ones already=
=C2=A0marked.=C2=A0 In this case the type of THING used is whatever was use= d the
=C2=A0last time `select-things' was called - you are not prompted for i= t.

=C2=A0This region extension reusing the last type of THING happens even if<= br> =C2=A0the active region is empty.=C2=A0 This means that you can, for instan= ce,
=C2=A0just use `C-SPC' to activate an empty region and then use
=C2=A0`select-things' to select more THINGS of the last kind selected.<= br>
=C2=A0If there is no THING at point, and `thgcmd-use-nearest-thing-flag'= ; is
=C2=A0non-nil, then select a THING near point.

--000000000000924a7a05fbef3dac--