GNU bug report logs - #63626
[PATCH] Make forward and backward-to-word arg optional

Previous Next

Package: emacs;

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.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#63626: closed ([PATCH] Make forward and backward-to-word arg
 optional)
Date: Wed, 31 May 2023 13:16:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 31 May 2023 16:15:57 +0300
with message-id <838rd4fxpu.fsf <at> gnu.org>
and subject line Re: bug#63626: [PATCH] Make forward and backward-to-word arg optional
has caused the debbugs.gnu.org bug report #63626,
regarding [PATCH] Make forward and backward-to-word arg optional
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
63626: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63626
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Zaz Brown <zazbrown <at> zazbrown.com>
To: bug-gnu-emacs <at> gnu.org
Cc: dalanicolai <at> gmail.com
Subject: [PATCH] Make forward and backward-to-word arg optional
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.

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


[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: zazbrown <at> zazbrown.com, dalanicolai <at> gmail.com, 63626-done <at> debbugs.gnu.org
Subject: Re: bug#63626: [PATCH] Make forward and backward-to-word arg optional
Date: Wed, 31 May 2023 16:15:57 +0300
> 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.


This bug report was last modified 2 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.