bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Sun 01 Sep 2024 at 08:06pm GMT, Philip Kaludercic wrote: > Ping. I am not sure how to proceed on this patch. IIRC the issue was > that the notion of a word differs in Emacs and in Bash. I am still in > favour of utilising Emacs's definition, as it remains more useful > for some given major mode and the fact that it is easier to implement. Please take a look at my longer message. I don't think it has been addressed. -- Sean Whitton
bug#72952: 30.0.90; Want way to break out of Eshell for loop
X-debbugs-cc: jporterb...@gmail.com I am trying to run a series of tests like this: % for test in tests/tests/tagupl* { tests/using-intree $test } I want the command to give up as soon as one of the tests fails. But I don't think there is any way to break out of the loop? In POSIX sh, you could use 'break'. Thanks. -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Mon 02 Sep 2024 at 11:30am -07, Stefan Kangas wrote: > Binding C-w to backward-kill-word, or some version thereof, is an old > Emacs power user trick that has been recommended in many places over the > years. See, for example: > https://sites.google.com/site/steveyegge2/effective-emacs#h.p_ID_193 > https://emacs-fu.blogspot.com/2009/11/copying-lines-without-selecting-them.html > > So I think this command would be a good addition. Making the word > boundary behaviour into a tristate option sounds like a reasonable way > forward, which should make everyone happy and let people experiment with > what works best for them. For reference purposes while implementing the tristate, here is my implementation of the Unix behaviour from my init. Should be helpful, though there is lots of room for improvement :) (defun spw/unix-word-rubout (arg &optional pos neg) (interactive "p") ;; Do skip over \n because `backward-kill-word' does. (unless pos (setq pos "[:space:]\n")) (unless neg (setq neg "^[:space:]\n")) (undo-boundary) (let ((start (point))) ;; Go only backwards. (dotimes (_ (abs arg)) (skip-chars-backward pos) (skip-chars-backward neg)) ;; Skip forward over any read-only text (e.g. an Eshell or comint prompt). (when-let ((beg (and (get-char-property (point) 'read-only) (next-single-char-property-change (point) 'read-only nil start)))) (goto-char beg)) (kill-region start (point -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Mon 02 Sep 2024 at 08:39pm GMT, Philip Kaludercic wrote: > How about this suggestion: We add a generic kill-region-or-word > command, and a user option for a function (set to either > `backward-kill-word' or Sean's `unix-word-rubout'). I can prepare a > patch with the simpler version, and then Sean can add his behaviour in a > second patch so that the attribution remains correct. I think a tristate option is preferable to this. If the user wants something of their own they can just write their own command. -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Mon 02 Sep 2024 at 09:42pm +01, Sean Whitton wrote: > Hello, > > On Mon 02 Sep 2024 at 08:39pm GMT, Philip Kaludercic wrote: > >> How about this suggestion: We add a generic kill-region-or-word >> command, and a user option for a function (set to either >> `backward-kill-word' or Sean's `unix-word-rubout'). I can prepare a >> patch with the simpler version, and then Sean can add his behaviour in a >> second patch so that the attribution remains correct. > > I think a tristate option is preferable to this. > > If the user wants something of their own they can just write their own > command. Sorry, I wrote this too quickly, I don't think I actually understand your new proposal. Could you sketch it out? Thank you for your patience on this one. -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Tue 03 Sep 2024 at 04:32pm GMT, Philip Kaludercic wrote: > > +(defcustom kill-region-dwim nil > + "Behaviour when `kill-region' is invoked without an active region. > +If set to nil (default), then an error occurs and nothing is killed. If > +set to `emacs-word', then kill a the last word as defined by the current > +major mode. If set to `unix-word', then kill the last word in the style > +of a shell like Bash, disregarding the major mode." > + :type '(choice (const :tag "Kill a word like `backward-kill-word'" > emacs-word) > + (const :tag "Kill a word like Bash would" unix-word) > + (const :tag "Do not kill anything" nil)) > + :group 'killing) I think I'm missing something here. When it's nil and there is no *active* region, but there is a region, it should kill that, surely? With or without TMM. I very regularly kill inactive regions (e.g. after M->). > + ((eq region 'unix-word) > + (let ((end (point))) > +(save-excursion > + (skip-chars-backward "[:space:]") > + (skip-chars-backward "^[:space:]") > + (filter-buffer-substring > + (if (get-char-property (point) 'read-only) > + (next-single-char-property-change > +(point) 'read-only nil end) > + (point)) > + end 'delete > + (region > + (funcall region-extract-function 'delete)) > + ((filter-buffer-substring beg end 'delete) Shall I rather commit this as an independent unix-word-rubout? Improves attribution, and it's independently useful. -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Thu 05 Sep 2024 at 09:39am GMT, Philip Kaludercic wrote: >>> + ((eq region 'unix-word) >>> + (let ((end (point))) >>> +(save-excursion >>> + (skip-chars-backward "[:space:]") >>> + (skip-chars-backward "^[:space:]") >>> + (filter-buffer-substring >>> + (if (get-char-property (point) 'read-only) >>> + (next-single-char-property-change >>> +(point) 'read-only nil end) >>> + (point)) >>> + end 'delete >>> + (region >>> + (funcall region-extract-function 'delete)) >>> + ((filter-buffer-substring beg end 'delete) >> >> Shall I rather commit this as an independent unix-word-rubout? >> >> Improves attribution, and it's independently useful. > > As a standalone command? I mean, yeah, I have had it on my C-w for years. Probably some other people have implementations too. -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Thu 05 Sep 2024 at 02:38pm GMT, Philip Kaludercic wrote: > In that case, it would be difficult to use it directly in this > implementation, as kill-region needs a command that just moves the > point. I guess it would be possible to hack something together with > atomic change groups, but the cleanest strategy would probably be to > have a unix-word-forward command that goes in both directions, and use > that both in a standalone unix-word-rubout and this patch. But we can > do that after merging this patch -- assuming there are no more blocking > issues with the latest version: I think you're right, but I would like to commit my function first, so that I get attribution (it did take me some time to figure out what was useful in this area), and because I think it should be rewritten in terms of fields. Please take a look at the attached. unix-word-rubout to follow. -- Sean Whitton >From 4cb701150976cdb91658a1c82edd6e8270fd26c8 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 6 Sep 2024 11:35:46 +0100 Subject: [PATCH] New command forward-unix-word * lisp/simple.el (forward-unix-word): New command. * doc/lispref/positions.texi (Word Motion): * etc/NEWS: Document it. --- doc/lispref/positions.texi | 13 + etc/NEWS | 5 + lisp/simple.el | 30 ++ 3 files changed, 48 insertions(+) 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 + @node Buffer End Motion @subsection Motion to an End of the Buffer @cindex move to beginning or end of buffer diff --git a/etc/NEWS b/etc/NEWS index f3e719a34d3..8037fcfd1af 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,11 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch fonts, the wrapped text will now be lined up correctly so that it's exactly below the text after the prefix on the first line. +** New command 'forward-unix-word'. +This command is like 'forward-word', except it always considers words to +be delimited by whitespace, regardless of the buffer's syntax table. +It thus emulates how C-w at the Unix terminal or shell identifies words. * Changes in Specialized Modes and Packages in Emacs 31.1 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. +With argument ARG, do this that many times; the default is once. +With negative ARG, go backwards to the beginning of whitespace-delimited +words. +DELIM is a string specifying what characters are considered whitespace, +as might be passed to `skip-chars-forward'. +The default is \"[:space:]\\n\". Do not prefix a `^' character. + +This command is like `forward-word' except that words are always +delimited by whitespace, regardless of the buffer's syntax table. +Like `forward-word', this command respects fields. + +This emulates how C-w at the Unix terminal or shell identifies words. +See the `unix-word-rubout' command in Info node `(readline)Commands For +Killing'." + (interactive "^p") + (unless (zerop arg) +;; We do skip over \n by default because `backward-word' does. +(let* ((delim (or delim "[:space:]\n")) + (ndelim (format "^%s" delim)) + (start (point)) + (fun (if (> arg 0) +#'skip-chars-forward + #'skip-chars-backward))) + (dotimes (_ (abs arg)) +(funcall fun delim) +(funcall fun ndelim)) + (constrain-to-field nil start (defcustom fill-prefix nil "String for filling to insert at front of new line, or nil for none." -- 2.39.2
bug#69097: [PATCH] Add 'kill-region-or-word' command
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
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Fri 06 Sep 2024 at 02:30pm +03, Eli Zaretskii wrote: > Thanks, but I see no reason to document this command in the manual, > certainly not in the ELisp reference (it's a command, not a function). > IMO it's obscure enough to be documented only in NEWS. That's quite fine with me. > Should this be "[:space:]\\n\\r" instead? if not, why not? > > Also note that [:space:] depends on mode-specific syntax table, so I > question the wisdom of using it in a command that's supposed to be > mode-agnostic. Both excellent points, thank you. I looked at the POSIX standard and came up with a new default value. >> +This command is like `forward-word' except that words are always >> +delimited by whitespace, regardless of the buffer's syntax table. >> +Like `forward-word', this command respects fields. >> + >> +This emulates how C-w at the Unix terminal or shell identifies words. >> +See the `unix-word-rubout' command in Info node `(readline)Commands For >> +Killing'." > > This should try to be more explicit about what "word" means for this > command. Since it's so different from any notion of "word" in Emacs, > I would even seriously consider not to use that word, or maybe quote > it (in addition to explaining what it means). This is very helpful. You're right. In the attached, I've tried using "unix-word". Let me know what you think of that. > Also, since this is a command, its doc string should clearly separate > what happens in interactive invocation from what happens when called > from Lisp. DELIM belongs to the latter. (Is it even useful to > provide that option for Lisp-only calls? what's the use case for > that?) > > And finally, I wonder why we need this command? AFAIU, the original > intent was to implement something similar to unix-word-rubout, not a > new movement command. If the plan has changed, I think we need to > discuss the need once again. I think it was unhelpful of me to send this in without callers. I'm sorry about that. The reason for adding this is that it factors out what is in common between what Philip is doing, and unix-word-rubout. So in the attached revised patch, I've included unix-word-rubout. I've also included a second readline command which I have bound in my own init. It demonstrates why there is a need for DELIM. By the way, forward-unix-word could also be a plain function. I made it a command because, well, why not. Let me know if you think it should be switched back to a function. -- Sean Whitton >From c047e640399bb923728ed9967e8545d53b22ea5c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 6 Sep 2024 11:35:46 +0100 Subject: [PATCH] New commands for moving and killing unix-words * lisp/simple.el (forward-unix-word, unix-word-rubout) (unix-filename-rubout): New commands. * etc/NEWS: Document them. --- etc/NEWS | 7 +++ lisp/simple.el | 57 ++ 2 files changed, 64 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index f3e719a34d3..54cf0a3df52 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,13 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch fonts, the wrapped text will now be lined up correctly so that it's exactly below the text after the prefix on the first line. +--- +** New commands for moving and killing unix-words. +Unix-words are words separated by whitespace regardless of the buffer's +syntax table. In a Unix terminal or shell, C-w kills by unix-word. +The new commands 'forward-unix-word', 'unix-word-rubout' and +'unix-filename-rubout' allow you to bind keys to operate more similarly +to the terminal. * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/simple.el b/lisp/simple.el index 2453a129d0a..0322ac0cd8c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8892,6 +8892,63 @@ 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 (arg &optional delim) + "Move forward ARG unix-words. +A unix-word is whitespace-delimited. +Interactively, ARG is the numeric prefix argument, defaulting to 1. +A negative ARG means go backwards to the beginning of unix-words. + +Unix-words differ from Emacs words in that they are always delimited by +whitespace, regardless of the buffer's syntax table. This command +emulates how C-w at the Unix terminal or shell identifies words. + +When called from Lisp, DELIM specifies what characters are considered +whitespace. It is a string as might be passed to `skip-chars-forward'. +The default is \" \\f\\n\\r\\t\\v\". Do not prefix a `^
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, Thank you both for the feedback. Attached is an updated version. A few replies: On Fri 06 Sep 2024 at 04:32pm GMT, Philip Kaludercic wrote: > Won't there be an error here if the command is invoked with a negative > argument? Do you mean that you think there should be an error? I don't see any need for that. On Sat 07 Sep 2024 at 12:52pm +03, Eli Zaretskii wrote: > I again ask whether we need this command. It is okay to have a > function (perhaps even an internal one) to move by Unix-words, but > what are the use cases for such a command? That's fine. I've turned it back into a function. > Should we also treat a backslash as delimiter, for MS-Windows? Good idea. That's more useful. -- Sean Whitton >From 9163f6ab16816702f8bc6acb6f22734eb57acfc7 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 6 Sep 2024 11:35:46 +0100 Subject: [PATCH v3] New commands for moving and killing unix-words * lisp/simple.el (forward-unix-word): New function. (unix-word-rubout, unix-filename-rubout): New commands. * etc/NEWS: Announce the new commands. --- etc/NEWS | 6 ++ lisp/simple.el | 57 ++ 2 files changed, 63 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index f3e719a34d3..104941425c2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,12 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch fonts, the wrapped text will now be lined up correctly so that it's exactly below the text after the prefix on the first line. +--- +** New commands 'unix-word-rubout' and 'unix-filename-rubout'. +Unix-words are words separated by whitespace regardless of the buffer's +syntax table. In a Unix terminal or shell, C-w kills by Unix-word. +The new commands 'unix-word-rubout' and 'unix-filename-rubout' allow +you to bind keys to operate more similarly to the terminal. * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/simple.el b/lisp/simple.el index 2453a129d0a..1b910b0ed22 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8892,6 +8892,63 @@ 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 (n &optional delim) + "Move forward N Unix-words. +A Unix-word is whitespace-delimited. +A negative N means go backwards to the beginning of Unix-words. + +Unix-words differ from Emacs words in that they are always delimited by +whitespace, regardless of the buffer's syntax table. This function +emulates how C-w at the Unix terminal or shell identifies words. + +Optional argument DELIM specifies what characters are considered +whitespace. It is a string as might be passed to `skip-chars-forward'. +The default is \"\\s\\f\\n\\r\\t\\v\". Do not prefix a `^' character." + (when (and delim (string-prefix-p "^" delim)) +(error "DELIM argument must not begin with `^'")) + (unless (zerop n) +;; We do skip over newlines by default because `backward-word' does. +(let* ((delim (or delim "\s\f\n\r\t\v")) + (ndelim (format "^%s" delim)) + (start (point)) + (fun (if (> n 0) +#'skip-chars-forward + #'skip-chars-backward))) + (dotimes (_ (abs n)) +(funcall fun delim) +(funcall fun ndelim)) + (constrain-to-field nil start + +(defun unix-word-rubout (arg) + "Kill ARG Unix-words backwards. +A Unix-word is whitespace-delimited. +Interactively, ARG is the numeric prefix argument, defaulting to 1. +A negative ARG means to kill forwards. + +Unix-words differ from Emacs words in that they are always delimited by +whitespace, regardless of the buffer's syntax table. +Thus, this command emulates C-w at the Unix terminal or shell. +See also this command's nakesake in Info node +`(readline)Commands For Killing'." + (interactive "^p") + (let ((start (point))) +(forward-unix-word (- arg)) +(kill-region start (point + +(defun unix-filename-rubout (arg) + "Kill ARG Unix-words backwards, also treating `/' as delimiting words. +A Unix-word is whitespace-delimited. +Interactively, ARG is the numeric prefix argument, defaulting to 1. +A negative ARG means to kill forwards. + +This is like `unix-word-rubout' (which see), but `/' is also treated as +a word delimiter. See this command's namesake in Info node +`(readline)Commands For Killing'." + (interactive "^p") + (let ((start (point))) +(forward-unix-word (- arg) "\\/\s\f\n\r\t\v") +(kill-region start (point (defcustom fill-prefix nil "String for filling to insert at front of new line, or nil for none." -- 2.39.2
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Sat 07 Sep 2024 at 10:08pm +01, Sean Whitton wrote: > Hello, > > Thank you both for the feedback. Attached is an updated version. I neglected to update the docstring for adding backslashes as delimiters in unix-filename-rubout. Fixed in the attached, along with a another few small fixes. -- Sean Whitton >From 059ca7388494f21d13c87f114965a2ec1fc1cc55 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 6 Sep 2024 11:35:46 +0100 Subject: [PATCH v4] New commands unix-word-rubout, unix-filename-rubout * lisp/simple.el (forward-unix-word): New function. (unix-word-rubout, unix-filename-rubout): New commands. * etc/NEWS: Announce the new commands. --- etc/NEWS | 6 ++ lisp/simple.el | 57 ++ 2 files changed, 63 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index f3e719a34d3..104941425c2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,12 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch fonts, the wrapped text will now be lined up correctly so that it's exactly below the text after the prefix on the first line. +--- +** New commands 'unix-word-rubout' and 'unix-filename-rubout'. +Unix-words are words separated by whitespace regardless of the buffer's +syntax table. In a Unix terminal or shell, C-w kills by Unix-word. +The new commands 'unix-word-rubout' and 'unix-filename-rubout' allow +you to bind keys to operate more similarly to the terminal. * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/simple.el b/lisp/simple.el index 2453a129d0a..18cc15f6f5d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8892,6 +8892,63 @@ 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 (n &optional delim) + "Move forward N Unix-words. +A Unix-word is whitespace-delimited. +A negative N means go backwards to the beginning of Unix-words. + +Unix-words differ from Emacs words in that they are always delimited by +whitespace, regardless of the buffer's syntax table. This function +emulates how C-w at the Unix terminal or shell identifies words. + +Optional argument DELIM specifies what characters are considered +whitespace. It is a string as might be passed to `skip-chars-forward'. +The default is \"\\s\\f\\n\\r\\t\\v\". Do not prefix a `^' character." + (when (string-prefix-p "^" delim) +(error "DELIM argument must not begin with `^'")) + (unless (zerop n) +;; We do skip over newlines by default because `backward-word' does. +(let* ((delim (or delim "\s\f\n\r\t\v")) + (ndelim (format "^%s" delim)) + (start (point)) + (fun (if (> n 0) +#'skip-chars-forward + #'skip-chars-backward))) + (dotimes (_ (abs n)) +(funcall fun delim) +(funcall fun ndelim)) + (constrain-to-field nil start + +(defun unix-word-rubout (arg) + "Kill ARG Unix-words backwards. +A Unix-word is whitespace-delimited. +Interactively, ARG is the numeric prefix argument, defaulting to 1. +A negative ARG means to kill forwards. + +Unix-words differ from Emacs words in that they are always delimited by +whitespace, regardless of the buffer's syntax table. +Thus, this command emulates C-w at the Unix terminal or shell. +See also this command's nakesake in Info node +`(readline)Commands For Killing'." + (interactive "^p") + (let ((start (point))) +(forward-unix-word (- arg)) +(kill-region start (point + +(defun unix-filename-rubout (arg) + "Kill ARG Unix-words backwards, also treating slashes as word delimiters. +A Unix-word is whitespace-delimited. +Interactively, ARG is the numeric prefix argument, defaulting to 1. +A negative ARG means to kill forwards. + +This is like `unix-word-rubout' (which see), but `/' and `\\' are also +treated as delimiting words. See this command's namesake in Info node +`(readline)Commands For Killing'." + (interactive "^p") + (let ((start (point))) +(forward-unix-word (- arg) "\\/\s\f\n\r\t\v") +(kill-region start (point (defcustom fill-prefix nil "String for filling to insert at front of new line, or nil for none." -- 2.39.2
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello Eli, Any comments on v4? I'd like to commit to unblock Philip. Thanks! -- Sean Whitton
bug#69097: [PATCH] Add 'kill-region-or-word' command
Hello, On Mon 09 Sep 2024 at 10:03pm +03, Eli Zaretskii wrote: >> From: Sean Whitton >> Cc: phil...@posteo.net, stefankan...@gmail.com, acora...@gnu.org, >> j...@linkov.net, r...@gnu.org, 69...@debbugs.gnu.org >> Date: Mon, 09 Sep 2024 18:54:16 +0100 >> >> Hello Eli, >> >> Any comments on v4? > > When I have time. Sorry, thought you might have missed it. -- Sean Whitton
bug#72952: 30.0.90; Want way to break out of Eshell for loop
Hello, On Sun 08 Sep 2024 at 05:59pm -07, Jim Porter wrote: > On 9/2/2024 1:26 AM, Sean Whitton wrote: >> X-debbugs-cc: jporterb...@gmail.com >> I am trying to run a series of tests like this: >> % for test in tests/tests/tagupl* { tests/using-intree $test } >> I want the command to give up as soon as one of the tests fails. But I >> don't think there is any way to break out of the loop? In POSIX sh, you >> could use 'break'. > > I actually have a patch sitting in my pile of branches that does this, but it > needs a fair bit more work to get right. The main thing it needs is to keep > 'break' from bubbling up too far (e.g. if you run an Eshell script from inside > a loop, 'break' at the top level of the script shouldn't break out of the > parent loop). > > Another way to do something like this would be to embrace the Lispy-ness of > Eshell and add a command-form for 'throw' and 'catch'. Something like: > > catch my-tag { > for i in *.el { > do-stuff > if something-or-other { throw my-tag } > } > } > > Or even support both 'throw'/'catch' *and* 'break'... Heh. throw/catch seems like overkill to me but supporting both would be cool! -- Sean Whitton