[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
forward-word - optional argument
From: |
Juri Linkov |
Subject: |
forward-word - optional argument |
Date: |
12 Aug 2003 19:52:21 +0300 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) |
While using the compare-windows with synchronization I recently posted here,
I found the following problem: if `compare-windows-sync' is set
to function `forward-word', then calling it by `funcall' without arguments
gives the error about wrong number of arguments. It's because the argument
of `forward-word' is not optional, whereas most other forward-related
functions have their argument optional:
(forward-char &optional N)
(forward-line &optional N)
(forward-list &optional ARG)
(forward-page &optional COUNT)
(forward-paragraph &optional ARG)
(forward-sentence &optional ARG)
(forward-sexp &optional ARG)
The following patch makes the argument of `forward-word'
and `backward-word' optional. By default, it uses the value 1.
BTW, the inconvenience caused by the lack of optional argument of
`forward-word' can be traced in ChangeLog files back to 1985-08-06!
I hope this patch finally fixes it.
emacs/src/ChangeLog:
2003-08-12 Juri Linkov <address@hidden>
* syntax.c (Fforward_word): Argument changed to optional.
Set default value to 1.
Index: emacs/src/syntax.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/syntax.c,v
retrieving revision 1.166
diff -c -r1.166 syntax.c
*** emacs/src/syntax.c 17 May 2003 12:50:24 -0000 1.166
--- emacs/src/syntax.c 12 Aug 2003 15:04:59 -0000
***************
*** 1277,1297 ****
return from;
}
! DEFUN ("forward-word", Fforward_word, Sforward_word, 1, 1, "p",
doc: /* Move point forward ARG words (backward if ARG is negative).
Normally returns t.
If an edge of the buffer or a field boundary is reached, point is left there
and the function returns nil. Field boundaries are not noticed if
`inhibit-field-text-motion' is non-nil. */)
! (count)
! Lisp_Object count;
{
int orig_val, val;
- CHECK_NUMBER (count);
! val = orig_val = scan_words (PT, XINT (count));
if (! orig_val)
! val = XINT (count) > 0 ? ZV : BEGV;
/* Avoid jumping out of an input field. */
val = XFASTINT (Fconstrain_to_field (make_number (val), make_number (PT),
--- 1277,1301 ----
return from;
}
! DEFUN ("forward-word", Fforward_word, Sforward_word, 0, 1, "p",
doc: /* Move point forward ARG words (backward if ARG is negative).
Normally returns t.
If an edge of the buffer or a field boundary is reached, point is left there
and the function returns nil. Field boundaries are not noticed if
`inhibit-field-text-motion' is non-nil. */)
! (arg)
! Lisp_Object arg;
{
int orig_val, val;
! if (NILP (arg))
! XSETFASTINT (arg, 1);
! else
! CHECK_NUMBER (arg);
!
! val = orig_val = scan_words (PT, XINT (arg));
if (! orig_val)
! val = XINT (arg) > 0 ? ZV : BEGV;
/* Avoid jumping out of an input field. */
val = XFASTINT (Fconstrain_to_field (make_number (val), make_number (PT),
===================================================================
emacs/lisp/ChangeLog:
2003-08-12 Juri Linkov <address@hidden>
* simple.el (backward-word, forward-to-indentation)
(backward-to-indentation): Argument changed to optional.
(next-line, previous-line): Use `or' instead of `unless'.
Index: emacs/lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.616
diff -c -r1.616 simple.el
*** emacs/lisp/simple.el 25 Jul 2003 12:18:04 -0000 1.616
--- emacs/lisp/simple.el 12 Aug 2003 15:02:03 -0000
***************
*** 352,366 ****
(insert-and-inherit char)
(setq arg (1- arg)))))
! (defun forward-to-indentation (arg)
"Move forward ARG lines and position at first nonblank character."
(interactive "p")
(forward-line arg)
(skip-chars-forward " \t"))
! (defun backward-to-indentation (arg)
"Move backward ARG lines and position at first nonblank character."
(interactive "p")
(forward-line (- arg))
(skip-chars-forward " \t"))
--- 352,368 ----
(insert-and-inherit char)
(setq arg (1- arg)))))
! (defun forward-to-indentation (&optional arg)
"Move forward ARG lines and position at first nonblank character."
(interactive "p")
+ (or arg (setq arg 1))
(forward-line arg)
(skip-chars-forward " \t"))
! (defun backward-to-indentation (&optional arg)
"Move backward ARG lines and position at first nonblank character."
(interactive "p")
+ (or arg (setq arg 1))
(forward-line (- arg))
(skip-chars-forward " \t"))
***************
*** 2697,2703 ****
using `forward-line' instead. It is usually easier to use
and more reliable (no dependence on goal column, etc.)."
(interactive "p")
! (unless arg (setq arg 1))
(if (and next-line-add-newlines (= arg 1))
(if (save-excursion (end-of-line) (eobp))
;; When adding a newline, don't expand an abbrev.
--- 2699,2705 ----
using `forward-line' instead. It is usually easier to use
and more reliable (no dependence on goal column, etc.)."
(interactive "p")
! (or arg (setq arg 1))
(if (and next-line-add-newlines (= arg 1))
(if (save-excursion (end-of-line) (eobp))
;; When adding a newline, don't expand an abbrev.
***************
*** 2729,2735 ****
`forward-line' with a negative argument instead. It is usually easier
to use and more reliable (no dependence on goal column, etc.)."
(interactive "p")
! (unless arg (setq arg 1))
(if (interactive-p)
(condition-case nil
(line-move (- arg))
--- 2731,2737 ----
`forward-line' with a negative argument instead. It is usually easier
to use and more reliable (no dependence on goal column, etc.)."
(interactive "p")
! (or arg (setq arg 1))
(if (interactive-p)
(condition-case nil
(line-move (- arg))
***************
*** 3109,3118 ****
(goto-char (car pos1))
(insert word2))))
! (defun backward-word (arg)
"Move backward until encountering the beginning of a word.
With argument, do this that many times."
(interactive "p")
(forward-word (- arg)))
(defun mark-word (arg)
--- 3111,3121 ----
(goto-char (car pos1))
(insert word2))))
! (defun backward-word (&optional arg)
"Move backward until encountering the beginning of a word.
With argument, do this that many times."
(interactive "p")
+ (or arg (setq arg 1))
(forward-word (- arg)))
(defun mark-word (arg)
===================================================================
--
http://www.jurta.org/emacs/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- forward-word - optional argument,
Juri Linkov <=