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: Fri, 28 Apr 2023 01:28:09 -0400 Message-ID: References: <835y9jupgg.fsf@gnu.org> <83r0s5se94.fsf@gnu.org> <86ttx19ot4.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b6eb1905fa5ebdb2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36881"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ruijie@netyu.xyz, Eli Zaretskii , monnier@iro.umontreal.ca, 62892@debbugs.gnu.org, mardani29@yahoo.es To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 28 07:29:24 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 1psGfc-0009Q4-B0 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 28 Apr 2023 07:29:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psGfI-0001Fs-Oj; Fri, 28 Apr 2023 01:29: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 1psGfG-0001FU-5k for bug-gnu-emacs@gnu.org; Fri, 28 Apr 2023 01:29:02 -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 1psGfF-0007jT-TY for bug-gnu-emacs@gnu.org; Fri, 28 Apr 2023 01:29:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1psGfF-0005nD-Lo for bug-gnu-emacs@gnu.org; Fri, 28 Apr 2023 01:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zachary Kanfer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Apr 2023 05:29:01 +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.168265970922216 (code B ref 62892); Fri, 28 Apr 2023 05:29:01 +0000 Original-Received: (at 62892) by debbugs.gnu.org; 28 Apr 2023 05:28:29 +0000 Original-Received: from localhost ([127.0.0.1]:60231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psGei-0005mF-6p for submit@debbugs.gnu.org; Fri, 28 Apr 2023 01:28:28 -0400 Original-Received: from mail-oa1-f52.google.com ([209.85.160.52]:62670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psGeg-0005lz-B3 for 62892@debbugs.gnu.org; Fri, 28 Apr 2023 01:28:27 -0400 Original-Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-18f16a2c329so9127256fac.0 for <62892@debbugs.gnu.org>; Thu, 27 Apr 2023 22:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682659700; x=1685251700; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=E9321AaRBPVfujaGuzl9DtfpOz5Xl9N0z67JrbbBZP0=; b=ObkholXh2FrDFkMC6g1IPOpNH8VTKs+fUiz+QalpvMJvkXgDGF2hU7AutQoyvrJXKD 3CshtCY5swS/3jbZvNGz4qORbUzv6F1tvdpAQzQ7wCD5YRGUf/i+LPp+LHFz+qh2mibm HsvpHTTCPK94xT4ol5NqMvYKoJcq/I2GnqXPWNx7/fqFtNY0SdtdnNvq/XQv5IiKqECA se6ionpJCyh3nyKmXFjSSYTcfta2J8FQu7n6FeESVNUX9Gnk+4Msmgjus2XYejHbMAY3 NUHeV2sBGcLEnqAcg0Al9Pw2Rw+9EUO7drGHYsNf9stMyDbl7yU0lyZgJlkuVPO74pq0 jSfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682659700; x=1685251700; 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=E9321AaRBPVfujaGuzl9DtfpOz5Xl9N0z67JrbbBZP0=; b=Ebd+s5o+XJBTmG4BV3XjWoUPXECpilc+3ECif/6lNIgFQMGBxef29YIW7HAYzXEZNZ cbL+CowMahQxt5JECsBQbUWZDUyMXKhXT612WV/fLmzihD5hmX42ISaD/Rny3AWgqdEe p25zRsS5zsz5ujfLwVxfCQMz/r4YKpwxI/EmQ1qWlLZNxC/DLdhP4i6KdiYNS+V4HocC kcEkp1JYwyqAmJlb/Q3JUA9uE7VxGGU8qns6PD16qW6H85Yxpg4wp2d35R9g5DAw7WNi wnMC3VsyJCPzAsA9dNpSGO/68e3r6mrIu4Wfi80ODFG3PiYnxY8AbzynynHLvRtD9xdz ifrg== X-Gm-Message-State: AC+VfDyqRvokiplEi/xMt7L8htjX49RsQqDGtnrBZ22S+EMIPbUSSzD1 Tav8adC5k3GBk1awTfx4U4hWsVU/xVjYH7UdLZI= X-Google-Smtp-Source: ACHHUZ7tsE+X21LuRgip0ar0RVDPcgSm/TmIoU8r45K8y9N+lGYPv49OSVD1t5YcN/okklW9luk7BBZ6btdHvzNLzTM= X-Received: by 2002:a05:6808:8ce:b0:383:e7ad:efaf with SMTP id k14-20020a05680808ce00b00383e7adefafmr1999385oij.8.1682659700303; Thu, 27 Apr 2023 22:28:20 -0700 (PDT) In-Reply-To: <86ttx19ot4.fsf@mail.linkov.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: , 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:260747 Archived-At: --000000000000b6eb1905fa5ebdb2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I made some minor changes below. Alongside my suggestions are explanations as to why. This is a hard command to describe! > (defun mark-sexp (&optional arg allow-extend) > "Set mark ARG sexps from point or move mark ARG sexps. Mark can be moved ARG steps. Press C-M-@ C-M-@ C-u 3 C-M-@. There will be five total sexps marked. I'm hoping this explains that case as well, and giving an intuition for what this command does ("move mark ARG steps"). > When invoked interactively without a prefix argument and no active > region, mark moves one sexp forward. I moved this first, both because I suspect it's the most common use case, but also because it's the the simplest to understand. > When invoked interactively without a prefix argument, and region > is active, mark moves one sexp away from point (i.e., forward > if mark is at or after point, back if mark is before point), thus > extending the region by one sexp. > With ALLOW-EXTEND non-nil (interactively, with prefix argument), > the place mark goes is the same place \\[forward-sexp] would move > with the same value of ARG; if the mark is active, it moves ARG > sexps from its current position, otherwise it is set ARG sexps > from point. Moved this earlier to keep the entire interactive block together. > When the region is active, the direction the region is extended > depends on the relative position of mark and point. This means the > direction can be changed by pressing \\[exchange-point-and-mark] > before this command.. I moved this to a separate section to simplify the earlier parts, and to call out that this is possible whenever the region is active. > When called from Lisp with ALLOW-EXTEND omitted or nil, mark is > set ARG (defaulting to 1) sexps from point. Removed extra m from "omitted". > This command assumes point is not in a string or comment." Altogether, the docstring with my suggestions looks like: > (defun mark-sexp (&optional arg allow-extend) > "Set mark ARG sexps from point or move mark ARG sexps. > When invoked interactively without a prefix argument and no active > region, mark moves one sexp forward. > When invoked interactively without a prefix argument, and region > is active, mark moves one sexp away from point (i.e., forward > if mark is at or after point, back if mark is before point), thus > extending the region by one sexp. > With ALLOW-EXTEND non-nil (interactively, with prefix argument), > the place mark goes is the same place \\[forward-sexp] would move > with the same value of ARG; if the mark is active, it moves ARG > sexps from its current position, otherwise it is set ARG sexps > from point. > When the region is active, the direction the region is extended > depends on the relative position of mark and point. This means the > direction can be changed by pressing \\[exchange-point-and-mark] > before this command. > When called from Lisp with ALLOW-EXTEND omitted or nil, mark is > set ARG (defaulting to 1) sexps from point. > This command assumes point is not in a string or comment." This is a complicated command, for sure -- which is partially why I want simple functions to mark sexps forward and backward: to not have to think about different cases. Can we fork off a discussion about those functions? Having simple functions allows the user to do what they want without having to learn complex nuance. On Thu, Apr 27, 2023 at 2:14=E2=80=AFPM Juri Linkov wrote= : > > I tried to describe the behavior in the doc string as follows: > > > > (defun mark-sexp (&optional arg allow-extend) > > "Set mark ARG sexps from point or move mark one sexp. > > When called from Lisp with ALLOW-EXTEND ommitted or nil, mark is > > set ARG sexps from point; ARG defaults to 1. > > With ALLOW-EXTEND non-nil (interactively, with prefix argument), > > the place mark goes is the same place \\[forward-sexp] would move > > with the same value of ARG; if the mark is active, it moves ARG > > sexps from its current position, otherwise it is set ARG sexps > > from point; ARG defaults to 1. > > When invoked interactively without a prefix argument and no active > > region, mark moves one sexp forward. > > When invoked interactively without a prefix argument, and region > > is active, mark moves one sexp away of point (i.e., forward > > if mark is at or after point, back if mark is before point), thus > > extending the region by one sexp. Since the direction of region > > extension depends on the relative position of mark and point, you > > can change the direction by \\[exchange-point-and-mark]. > > This command assumes point is not in a string or comment." > > > > It is still somewhat complicated and confusing, but at least it's > > accurate, I think. > > mark-sexp has a counterpart mark-word that has almost the same > implementation and docstring. So this could be fixed in both places. > --000000000000b6eb1905fa5ebdb2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I made some minor changes below. Alongside my suggestions = are explanations as to why. This is a hard command to describe!

>= (defun mark-sexp (&optional arg allow-extend)
> =C2=A0"Set = mark ARG sexps from point or move mark ARG sexps.

Mark can be moved = ARG steps. Press C-M-@ C-M-@ C-u 3 C-M-@. There will be five total sexps ma= rked. I'm hoping this explains that case as well, and giving an intuiti= on for what this command does ("move mark ARG steps").

>= ; When invoked interactively without a prefix argument and no active
>= ; region, mark moves one sexp forward.

I moved this first, both beca= use I suspect it's the most common use case, but also because it's = the the simplest to understand.

> When invoked interactively with= out a prefix argument, and region
> is active, mark moves one sexp aw= ay from point (i.e., forward
> if mark is at or after point, back if = mark is before point), thus
> extending the region by one sexp.
&g= t; With ALLOW-EXTEND non-nil (interactively, with prefix argument),
>= the place mark goes is the same place \\[forward-sexp] would move
> = with the same value of ARG; if the mark is active, it moves ARG
> sex= ps from its current position, otherwise it is set ARG sexps
> from po= int.

Moved this earlier to keep the entire interactive block togethe= r.

> When the region is active, the direction the region is exten= ded
> depends on the relative position of mark and point. This means = the
> direction can be changed by pressing \\[exchange-point-and-mark= ]
> before this command..

I moved this to a separate section t= o simplify the earlier parts, and to call out that this is possible wheneve= r the region is active.

> When called from Lisp with ALLOW-EXTEND= omitted or nil, mark is
> set ARG (defaulting to 1) sexps from point= .

Removed extra m from "omitted".

> This command= assumes point is not in a string or comment."

Altogether, the = docstring with my suggestions looks like:

> (defun mark-sexp (&am= p;optional arg allow-extend)
> =C2=A0"Set mark ARG sexps from po= int or move mark ARG sexps.
> When invoked interactively without a pr= efix argument and no active
> region, mark moves one sexp forward.> When invoked interactively without a prefix argument, and region
&= gt; is active, mark moves one sexp away from point (i.e., forward
> i= f mark is at or after point, back if mark is before point), thus
> ex= tending the region by one sexp.
> With ALLOW-EXTEND non-nil (interact= ively, with prefix argument),
> the place mark goes is the same place= \\[forward-sexp] would move
> with the same value of ARG; if the mar= k is active, it moves ARG
> sexps from its current position, otherwis= e it is set ARG sexps
> from point.
> When the region is active= , the direction the region is extended
> depends on the relative posi= tion of mark and point. This means the
> direction can be changed by = pressing \\[exchange-point-and-mark]
> before this command.
> W= hen called from Lisp with ALLOW-EXTEND omitted or nil, mark is
> set = ARG (defaulting to 1) sexps from point.
> This command assumes point = is not in a string or comment."

This is a complicated command, = for sure -- which is partially why I want simple functions to mark sexps fo= rward and backward: to not have to think about different cases. Can we fork= off a discussion about those functions? Having simple functions allows the= user to do what they want without having to learn complex nuance.
On Thu, A= pr 27, 2023 at 2:14=E2=80=AFPM Juri Linkov <juri@linkov.net> wrote:
> I tried to describe the behavior in the doc stri= ng as follows:
>
>=C2=A0 =C2=A0(defun mark-sexp (&optional arg allow-extend)
>=C2=A0 =C2=A0 =C2=A0"Set mark ARG sexps from point or move mark on= e sexp.
>=C2=A0 =C2=A0When called from Lisp with ALLOW-EXTEND ommitted or nil, m= ark is
>=C2=A0 =C2=A0set ARG sexps from point; ARG defaults to 1.
>=C2=A0 =C2=A0With ALLOW-EXTEND non-nil (interactively, with prefix argu= ment),
>=C2=A0 =C2=A0the place mark goes is the same place \\[forward-sexp] wou= ld move
>=C2=A0 =C2=A0with the same value of ARG; if the mark is active, it move= s ARG
>=C2=A0 =C2=A0sexps from its current position, otherwise it is set ARG s= exps
>=C2=A0 =C2=A0from point; ARG defaults to 1.
>=C2=A0 =C2=A0When invoked interactively without a prefix argument and n= o active
>=C2=A0 =C2=A0region, mark moves one sexp forward.
>=C2=A0 =C2=A0When invoked interactively without a prefix argument, and = region
>=C2=A0 =C2=A0is active, mark moves one sexp away of point (i.e., forwar= d
>=C2=A0 =C2=A0if mark is at or after point, back if mark is before point= ), thus
>=C2=A0 =C2=A0extending the region by one sexp.=C2=A0 Since the directio= n of region
>=C2=A0 =C2=A0extension depends on the relative position of mark and poi= nt, you
>=C2=A0 =C2=A0can change the direction by \\[exchange-point-and-mark]. >=C2=A0 =C2=A0This command assumes point is not in a string or comment.&= quot;
>
> It is still somewhat complicated and confusing, but at least it's<= br> > accurate, I think.

mark-sexp has a counterpart mark-word that has almost the same
implementation and docstring.=C2=A0 So this could be fixed in both places.<= br>
--000000000000b6eb1905fa5ebdb2--