GNU bug report logs -
#69097
[PATCH] Add 'kill-region-or-word' command
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Tue, 13 Feb 2024 09:57:02 UTC
Severity: normal
Tags: patch
Done: Sean Whitton <spwhitton <at> spwhitton.name>
Bug is archived. No further changes may be made.
Full log
Message #194 received at 69097 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Fri 06 Sep 2024 at 11:36am +01, Sean Whitton wrote:
> diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
> index 37cfe264157..b576df82382 100644
> --- a/doc/lispref/positions.texi
> +++ b/doc/lispref/positions.texi
> @@ -275,6 +275,19 @@ Word Motion
> syntax tables.
> @end defun
>
> +@deffn Command forward-unix-word &optional arg delim
> +This function is like @code{forward-word}, except that words are always
> +delimited by whitespace, regardless of the buffer's syntax table. This
> +emulates how @kbd{C-w} at the Unix terminal or shell identifies words.
> +See the @code{unix-word-rubout} command in @xref{(readline)Commands For
> +Killing}.
> +
> +Lisp programs can pass the @var{delim} argument to specify the notion of
> +whitespace. This argument is a string listing the characters considered
> +whitespace, as might be passed to @code{skip-chars-forward}. The
> +default is @code{[:space:]\n}. Do not prefix a `^' character.
> +@end deffn
The `^' should use @code{}.
> diff --git a/lisp/simple.el b/lisp/simple.el
> index 2453a129d0a..f34eef9ac25 100644
> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -8892,6 +8892,36 @@ current-word
> ;; If we found something nonempty, return it as a string.
> (unless (= start end)
> (buffer-substring-no-properties start end)))))
> +
> +(defun forward-unix-word (&optional arg delim)
> + "Move forward to the end of the next whitespace-delimited word.
ARG is not optional, only DELIM, in fact. I will fix this.
I thought I should also explain this DELIM thing. In addition to
Philip's usage and unix-word-rubout, I would like to add
unix-filename-rubout, which I think is generally useful -- it's also in
(info "(readline)Commands For Killing"). DELIM is needed for that.
It also makes the function more generally useful to Lisp programmers --
you might want to drop \n, for example.
--
Sean Whitton
This bug report was last modified 243 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.