GNU bug report logs -
#63626
[PATCH] Make forward and backward-to-word arg optional
Previous Next
Reported by: Zaz Brown <zazbrown <at> zazbrown.com>
Date: Sun, 21 May 2023 07:33:02 UTC
Severity: normal
Tags: patch
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63626 in the body.
You can then email your comments to 63626 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Sun, 21 May 2023 07:33:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Zaz Brown <zazbrown <at> zazbrown.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 21 May 2023 07:33:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(forward-to-word) throws (wrong-number-of-arguments forward-to-word 0)
in spite of the doc string stating:
> Move forward until encountering the beginning of a word.
> With argument, do this that many times.
This behaviour is present in Spacemacs 28.2, and has been confirmed by
Daniel Nicolai on Emacs 30. It's also evident in the latest source code.
The same issue exists for (backward-to-word). But running each command
with M-x works with no argument.
I'm new to Emacs, so please take this with a grain of salt. Thank you!
---
lisp/misc.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git master/lisp/misc.el arg-optional/lisp/misc.el
index ca013d5..f97240e 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -166,18 +166,20 @@ is an upper-case character."
(upcase-region (point) (progn (forward-char arg) (point)))))
;;;###autoload
-(defun forward-to-word (arg)
+(defun forward-to-word (&optional arg)
"Move forward until encountering the beginning of a word.
With argument, do this that many times."
(interactive "^p")
+ (unless arg (setq arg 1))
(or (re-search-forward (if (> arg 0) "\\W\\b" "\\b\\W") nil t arg)
(goto-char (if (> arg 0) (point-max) (point-min)))))
;;;###autoload
-(defun backward-to-word (arg)
+(defun backward-to-word (&optional arg)
"Move backward until encountering the end of a word.
With argument, do this that many times."
(interactive "^p")
+ (unless arg (setq arg 1))
(forward-to-word (- arg)))
;;;###autoload
--
2.40.1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Fri, 26 May 2023 11:24:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 63626 <at> debbugs.gnu.org (full text, mbox):
> Cc: dalanicolai <at> gmail.com
> From: Zaz Brown <zazbrown <at> zazbrown.com>
> Date: Sat, 20 May 2023 21:33:51 -0700
>
> (forward-to-word) throws (wrong-number-of-arguments forward-to-word 0)
> in spite of the doc string stating:
>
> > Move forward until encountering the beginning of a word.
> > With argument, do this that many times.
>
> This behaviour is present in Spacemacs 28.2, and has been confirmed by
> Daniel Nicolai on Emacs 30. It's also evident in the latest source code.
>
> The same issue exists for (backward-to-word). But running each command
> with M-x works with no argument.
Thank you for your report.
Please tell why you think we should allow non-interactive invocation
of these functions with no argument. IOW, what exactly is wrong with
the current code, and in what situations you have found this to be a
problem?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Sat, 27 May 2023 07:03:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 63626 <at> debbugs.gnu.org (full text, mbox):
[Please use Reply All to reply, to keep everyone on the CC list.]
> From: Zaz Brown <zazbrown <at> zazbrown.com>
> Date: Fri, 26 May 2023 12:54:19 -0700
>
> It's more convenient to be able to use forward-to-word without the
> argument. For example, this would allow passing the function
> forward-to-word without having to use a lambda.
>
> Most importantly, though, the current definition of forward-to-word
> does not match the doc string. The doc string implies that with no
> argument, it goes forward 1 word. And this has already caused
> confusion.
The doc string says "with argument", most probably meaning "with
prefix numeric argument". IOW, it talks about interactive invocation.
In any case, the doc string is easy to fix/clarify.
But I'm still not convinced we need to change the signature of the
function. What are the use cases where you'd want to pass
forward-to-word as a function argument to another function?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Sat, 27 May 2023 23:55:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 63626 <at> debbugs.gnu.org (full text, mbox):
On Sat, May 27, 2023 at 12:02 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> But I'm still not convinced we need to change the signature of the
> function. What are the use cases where you'd want to pass
> forward-to-word as a function argument to another function?
I can't think of a good example and wasn't able to find an example of
a forward-to-word lambda on GitHub code search. So perhaps I'm
mistaken that this would be useful. I'll have to leave that
discussion to those who are more familiar with Emacs and Lisp.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Sun, 28 May 2023 05:17:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 63626 <at> debbugs.gnu.org (full text, mbox):
> From: Zaz Brown <zazbrown <at> zazbrown.com>
> Date: Sat, 27 May 2023 11:39:35 -0700
> Cc: dalanicolai <at> gmail.com, 63626 <at> debbugs.gnu.org
>
> On Sat, May 27, 2023 at 12:02 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > But I'm still not convinced we need to change the signature of the
> > function. What are the use cases where you'd want to pass
> > forward-to-word as a function argument to another function?
>
> I can't think of a good example and wasn't able to find an example of
> a forward-to-word lambda on GitHub code search. So perhaps I'm
> mistaken that this would be useful. I'll have to leave that
> discussion to those who are more familiar with Emacs and Lisp.
Thanks.
Does anyone else here have an opinion on this changeset?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Mon, 29 May 2023 15:25:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 63626 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I have no opinion about how this 'should work'.
I was just confused by the docstring, and I assumed from the docstring,
that the intention was for the argument to be optional like in
forward-word/line
(the docstring does not say that this command is meant for interactive use
only).
My idea was just to report this very low priority issue about the
'confusing' docstring
(and ask if maybe that argument was intended to be optional).
Here <https://emacs.stackexchange.com/a/77278/26163> is the motive for this
patch. It is used in an evil function, so I guess we could
just have used `evil-forward-WORD-begin` instead, and it is not necessary
to change
the `forward-to-word` function.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63626
; Package
emacs
.
(Mon, 29 May 2023 17:08:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 63626 <at> debbugs.gnu.org (full text, mbox):
> I have no opinion about how this 'should work'.
> I was just confused by the docstring, and I assumed from the docstring,
> that the intention was for the argument to be optional like in
> forward-word/line
Aren't all forward-like commands more permissive and allow their arg
to be optional? It looks like the standard signature, e.g.:
(defun forward-page (&optional count)
(interactive "p")
(or count (setq count 1))
(defun forward-paragraph (&optional arg)
(interactive "^p")
(or arg (setq arg 1))
(defun forward-sentence (&optional arg)
(interactive "^p")
(or arg (setq arg 1))
...
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Wed, 31 May 2023 13:16:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Zaz Brown <zazbrown <at> zazbrown.com>
:
bug acknowledged by developer.
(Wed, 31 May 2023 13:16:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 63626-done <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Zaz Brown <zazbrown <at> zazbrown.com>,
> 63626 <at> debbugs.gnu.org
> Date: Mon, 29 May 2023 19:46:59 +0300
>
> > I have no opinion about how this 'should work'.
> > I was just confused by the docstring, and I assumed from the docstring,
> > that the intention was for the argument to be optional like in
> > forward-word/line
>
> Aren't all forward-like commands more permissive and allow their arg
> to be optional? It looks like the standard signature, e.g.:
Thanks for the feedback, all of you. I've now installed those changes
on the master branch, and I'm therefore closing this bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 29 Jun 2023 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 317 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.