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, 26 Apr 2023 22:37:58 -0400 Message-ID: References: <835y9jupgg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000042592a05fa483ffb" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38512"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ruijie@netyu.xyz, monnier@iro.umontreal.ca, 62892@debbugs.gnu.org, mardani29@yahoo.es To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 27 04:39:34 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 1prrXi-0009pv-Fm for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Apr 2023 04:39:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prrXF-0002Bd-Fb; Wed, 26 Apr 2023 22:39: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 1prrXD-0002BQ-HQ for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 22:39: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 1prrXC-0006Gp-Rp for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 22:39:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1prrXC-0001qO-9r for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 22:39: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, 27 Apr 2023 02:39: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.16825630987028 (code B ref 62892); Thu, 27 Apr 2023 02:39:02 +0000 Original-Received: (at 62892) by debbugs.gnu.org; 27 Apr 2023 02:38:18 +0000 Original-Received: from localhost ([127.0.0.1]:57269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prrWT-0001pH-Qc for submit@debbugs.gnu.org; Wed, 26 Apr 2023 22:38:18 -0400 Original-Received: from mail-oo1-f50.google.com ([209.85.161.50]:58853) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prrWR-0001oz-E8 for 62892@debbugs.gnu.org; Wed, 26 Apr 2023 22:38:16 -0400 Original-Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-541b60e0a7fso4276653eaf.1 for <62892@debbugs.gnu.org>; Wed, 26 Apr 2023 19:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682563089; x=1685155089; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0h4t93m+/fBHggnpMpiaqRZBMgxg/sAtoezYGvn7RXk=; b=GenSydip0nV07YI2AVoXAxgHPrSbnpp1AILcHg2VyeJRDHnkJLBbZYVqLa3rC1rAQ8 4Xez968tQ6zd1fKT4zKTfc7/gZGLFAIM9eSVvUuvsFBEjTLnlKnDDY7VsqObYJxBcfZ6 htqXus5LWMQrp5YtGH22wCvQB945cRs8FoMapw+b75fQee6KxIs3BNTsvpWtWsfbUVpf iMpz4f3fBeqVn3rxl+3CBF06wGHsVVzLI+3kIlpePNecuDIivZPLsn8XzVdcEzhNAoB3 ck2ndratGqcuNr+DrnMsgCNMI+dvuDb7/ipBOoaxNGnhU//xELi/DP1ySdcfE4RL0RcK zZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682563089; x=1685155089; 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=0h4t93m+/fBHggnpMpiaqRZBMgxg/sAtoezYGvn7RXk=; b=csx7jkvIpILtvLkmaGxYHmr1CJeZCpFpdicxrTQhlOh97PEAcoP/m2pgwAfdSRdWBj Mvun6JvCPTZ8MN8/GUeCdpppTqar5Z8UidLGA379jOoyR9QzNDUuWJaKz2XA/Qrp//fJ je4p1fJ9IBsayarQwb4dHf+Nzt8T7Od2I8r71Q37TMEN46jcduxo7UWNEZf1K0RTtpNO Em8I5uwjm4QFfjwcMyUNc++UuREbIvhKhpFGDeAArr/DTglJlQWSg2hmGARQfZytNpVO VI9z7sRMtyyWd5Jfgfafxwvg/DzIQYgAPkPr/YS+HiszfD3bdds6y2ibTLESJgk6dHuH R1OA== X-Gm-Message-State: AC+VfDwqttO9bvZUF30kdSDyhWnSQauYFdniK4+q6d3vYZw/w62CAAHr xfCm8HpY9UqwbVqGTB3j1l1lTLfE4lZIKcTbaLA= X-Google-Smtp-Source: ACHHUZ7UQKiRb1/1mszLK1okYZcMpgiRDja9RscLNWqP2QoHOs4pklqP2uqViTJR53s2ykGVsv5o3SpU6Aj6xhNymuQ= X-Received: by 2002:a4a:c289:0:b0:546:ecb3:f42 with SMTP id b9-20020a4ac289000000b00546ecb30f42mr191090ooq.8.1682563089454; Wed, 26 Apr 2023 19:38:09 -0700 (PDT) In-Reply-To: <835y9jupgg.fsf@gnu.org> 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:260692 Archived-At: --00000000000042592a05fa483ffb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > Worse still is the next part: > > > > > Interactively, if this command is repeated > > > or (in Transient Mark mode) if the mark is active, > > > it marks the next ARG sexps after the ones already marked. > > > > This says it marks sexps *after* the ones already marked. This is incorrect; if point is *after* mark, and > > mark is active, this function marks sexps *before* the ones already marked. > > I cannot reproduce this behavior, if I understand your description > correctly. Please show a recipe, starting from "emacs -Q", to > reproduce. Open Emacs with: emacs -Q --eval '(progn (insert "foo bar baz") (goto-char 8) (set-mark 5))' It will insert "foo bar baz", put point after "bar", and mark before "bar". Region contains "bar". Then when we run mark-sexp, we expect to mark some sexps "after the ones already marked". That's what the docstring says. After running the command above to open emacs, press C-M-@ to run mark-sexp. We should see sexps marked "after the ones already marked"; that is, we should see "bar baz" marked. But we don't. Instead, we see that "foo bar" is highlighted. That is, we have marked sexps *before* the ones already marked. > > The documentation for mark-sexp says: > > > > > Set mark ARG sexps from point. > > > The place mark goes is the same place C-M- would > > > move to with the same argument. > > > > This is correct but misleading. > > Please elaborate: how could it mislead? "The same argument" is the misleading part. If I call mark-sexp with no argument, sometimes that code passes -1 to forward-sexp. So while I think I'm effectively passing a "1" to mark-sexp, instead -1 is passed to forward-sexp. This is somewhat explained by the next part of the docstring, but not entirely. Read with the rest of the docstring, it reinforces the belief that the command only marks sexps *after* point. > > > In my opinion, the description of that feature should not be part of the > > > mark-sexp command documentation, because the feature is actually > > > provided by C-x C-x (exchange-point-and-mark). > > > > One way for this situation to occur is by using C-x C-x, yes, but it's not the only way. You can set point, > > move forward sexps, and then calling mark-sexp will mark sexps backwards. > > > > There is specific code in mark-sexp to check which direction to move; it should be documented as > > such. > > Please also demonstrate this behavior and point to that code, so we > will know what you are alluding to. Here is the line of code: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/lisp.el#n1= 07. When the region is active, and no prefix arg is given to mark-sexp, the function resets `arg` as follows: (setq arg (if arg (prefix-numeric-value arg) (if (< (mark) (point)) -1 1))) When no prefix arg is given, when the region is active, it sets arg to either 1 or -1, depending on the relative positions of point and mark. The behavior can be seen in the instructions above, but here's a simpler way to see it: 1. `emacs -Q --eval '(progn (insert "foo bar baz") (goto-char 5))` 2. C-space. (Set mark) 3. M-f. (forward word). We have now set up the situation I was referring to -- point is set after mark, and mark is active. 4. C-M-@. Here, we see mark-sexp extend region backwards without ever using C-x C-x (exchange-point-and-mark). The feature of extending the region backwards cannot be provided by exchange-point-and-mark. On Wed, Apr 26, 2023 at 2:28=E2=80=AFAM Eli Zaretskii wrote: > > Cc: Ruijie Yu , Stefan Monnier < > monnier@iro.umontreal.ca>, > > 62892@debbugs.gnu.org > > From: Zachary Kanfer > > Date: Wed, 26 Apr 2023 00:41:45 -0400 > > > > The documentation for mark-sexp says: > > > > > Set mark ARG sexps from point. > > > The place mark goes is the same place C-M- would > > > move to with the same argument. > > > > This is correct but misleading. > > Please elaborate: how could it mislead? > > > Worse still is the next part: > > > > > Interactively, if this command is repeated > > > or (in Transient Mark mode) if the mark is active, > > > it marks the next ARG sexps after the ones already marked. > > > > This says it marks sexps *after* the ones already marked. This is > incorrect; if point is *after* mark, and > > mark is active, this function marks sexps *before* the ones already > marked. > > I cannot reproduce this behavior, if I understand your description > correctly. Please show a recipe, starting from "emacs -Q", to > reproduce. > > > > In my opinion, the description of that feature should not be part of > the > > > mark-sexp command documentation, because the feature is actually > > > provided by C-x C-x (exchange-point-and-mark). > > > > One way for this situation to occur is by using C-x C-x, yes, but it's > not the only way. You can set point, > > move forward sexps, and then calling mark-sexp will mark sexps backward= s. > > > > There is specific code in mark-sexp to check which direction to move; i= t > should be documented as > > such. > > Please also demonstrate this behavior and point to that code, so we > will know what you are alluding to. > > Thanks. > --00000000000042592a05fa483ffb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> > Worse still is the next part:
> >
&g= t; > > Interactively, if this command is repeated
> > > o= r (in Transient Mark mode) if the mark is active,
> > > it mark= s the next ARG sexps after the ones already marked.
> >
> &g= t; This says it marks sexps *after* the ones already marked. This is incorr= ect; if point is *after* mark, and
> > mark is active, this functi= on marks sexps *before* the ones already marked.
>
> I cannot r= eproduce this behavior, if I understand your description
> correctly.= =C2=A0 Please show a recipe, starting from "emacs -Q", to
>= reproduce.

Open Emacs with:

emacs -Q --eval '(progn (ins= ert "foo bar baz") (goto-char 8) (set-mark 5))'

It wil= l insert "foo bar baz", put point after "bar", and mark= before "bar". Region contains "bar".

Then when = we run mark-sexp, we expect to mark some sexps "after the ones already= marked". That's what the docstring says.

After runnin= g the command above to open emacs, press C-M-@ to run mark-sexp. We should = see sexps marked "after the ones already marked"; that is, we sho= uld see "bar baz" marked. But we don't. Instead, we see that = "foo bar" is highlighted. That is, we have marked sexps *before* = the ones already marked.


> > The documentatio= n for mark-sexp says:
> >
> > > Set mark ARG sexps fro= m point.
> > > The place mark goes is the same place C-M-<ri= ght> would
> > > move to with the same argument.
> >= ;
> > This is correct but misleading.
>
> Please elabo= rate: how could it mislead?

"The same argument" is th= e misleading part. If I call mark-sexp with no argument, sometimes that cod= e passes -1 to forward-sexp. So while I think I'm effectively passing a= "1" to mark-sexp, instead -1 is passed to forward-sexp. This is = somewhat explained by the next part of the docstring, but not entirely. Rea= d with the rest of the docstring, it reinforces the belief that the command= only marks sexps *after* point.

> > > In my opinion, the= description of that feature should not be part of the
> > > ma= rk-sexp command documentation, because the feature is actually
> >= > provided by C-x C-x (exchange-point-and-mark).
> >
> &= gt; One way for this situation to occur is by using C-x C-x, yes, but it= 9;s not the only way. You can set point,
> > move forward sexps, a= nd then calling mark-sexp will mark sexps backwards.
> >
> &= gt; There is specific code in mark-sexp to check which direction to move; i= t should be documented as
> > such.
>
> Please also de= monstrate this behavior and point to that code, so we
> will know wha= t you are alluding to.

Here is the line of code: http= s://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/lisp.el#n107. When the region is active, and no prefix arg is given to mark-sexp, the= function resets `arg` as follows:

(setq arg (if arg (prefix-numeric= -value arg)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (< (= mark) (point)) -1 1)))

When no prefix arg is given, when the region = is active, it sets arg to either 1 or -1, depending on the relative positio= ns of point and mark.

The behavior can be seen in the instructions a= bove, but here's a simpler way to see it:

1. `emacs -Q --eval &#= 39;(progn (insert "foo bar baz") (goto-char 5))`
2. C-space. (= Set mark)
3. M-f. (forward word). We have now set up the situation I was= referring to -- point is set after mark, and mark is active.
4. C-M-@. = Here, we see mark-sexp extend region backwards without ever using C-x C-x (= exchange-point-and-mark). The feature of extending the region backwards can= not be provided by exchange-point-and-mark.

>= Cc: Ruijie Yu <ru= ijie@netyu.xyz>, Stefan Monnier <monnier@iro.umontreal.ca>,
>=C2=A0 62892= @debbugs.gnu.org
> From: Zachary Kanfer <zkanfer@gmail.com>
> Date: Wed, 26 Apr 2023 00:41:45 -0400
>
> The documentation for mark-sexp says:
>
> > Set mark ARG sexps from point.
> > The place mark goes is the same place C-M-<right> would
> > move to with the same argument.
>
> This is correct but misleading.

Please elaborate: how could it mislead?

> Worse still is the next part:
>
> > Interactively, if this command is repeated
> > or (in Transient Mark mode) if the mark is active,
> > it marks the next ARG sexps after the ones already marked.
>
> This says it marks sexps *after* the ones already marked. This is inco= rrect; if point is *after* mark, and
> mark is active, this function marks sexps *before* the ones already ma= rked.

I cannot reproduce this behavior, if I understand your description
correctly.=C2=A0 Please show a recipe, starting from "emacs -Q", = to
reproduce.

> > In my opinion, the description of that feature should not be part= of the
> > mark-sexp command documentation, because the feature is actually<= br> > > provided by C-x C-x (exchange-point-and-mark).
>
> One way for this situation to occur is by using C-x C-x, yes, but it&#= 39;s not the only way. You can set point,
> move forward sexps, and then calling mark-sexp will mark sexps backwar= ds.
>
> There is specific code in mark-sexp to check which direction to move; = it should be documented as
> such.

Please also demonstrate this behavior and point to that code, so we
will know what you are alluding to.

Thanks.
--00000000000042592a05fa483ffb--