From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: This widget implementation feels a bit clunky (edit-quoted-word)
Date: Sat, 20 Jun 2015 18:06:59 +0100 [thread overview]
Message-ID: <20150620180659.735a6cc6@ntlworld.com> (raw)
In-Reply-To: <CAHYJk3RYUhLuQEvGWLF5sdAK-g=MpiJwV0x-UrfQ35e3r4dHAg@mail.gmail.com>
On Sat, 20 Jun 2015 11:16:20 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> I feel like it's unnecessarily hard to get the resulting text from a
> narrow-to-region session.
Would you want something like this?
diff --git a/Functions/Zle/narrow-to-region b/Functions/Zle/narrow-to-region
index 86fd7ac..d449540 100644
--- a/Functions/Zle/narrow-to-region
+++ b/Functions/Zle/narrow-to-region
@@ -11,6 +11,8 @@
# Either or both may be empty.
# -n Only replace the text before or after the region with
# the -p or -P options if the text was not empty.
+# -l lbufvar ) $lbufvar and $rbufvar will contain the value of $LBUFFER and
+# -r rbufvar ) $RBUFFER resulting from any recursive edit (i.e. not with -S or -R)
# -S statevar
# -R statevar
# Save or restore the state in/from the parameter named statevar. In
@@ -28,16 +30,20 @@ integer _ntr_start _ntr_end _ntr_swap _ntr_cursor=$CURSOR _ntr_mark=$MARK
integer _ntr_stat
local _ntr_opt _ntr_pretext _ntr_posttext _ntr_usepretext _ntr_useposttext
-local _ntr_nonempty _ntr_save _ntr_restore
+local _ntr_nonempty _ntr_save _ntr_restore _ntr_lbuffer _ntr_rbuffer
-while getopts "np:P:R:S:" _ntr_opt; do
+while getopts "l:np:P:r:R:S:" _ntr_opt; do
case $_ntr_opt in
+ (l) _ntr_lbuffer=$OPTARG
+ ;;
(n) _ntr_nonempty=1
;;
(p) _ntr_pretext=$OPTARG _ntr_usepretext=1
;;
(P) _ntr_posttext=$OPTARG _ntr_useposttext=1
;;
+ (r) _ntr_rbuffer=$OPTARG
+ ;;
(R) _ntr_restore=$OPTARG
;;
(S) _ntr_save=$OPTARG
@@ -101,6 +107,9 @@ fi
if [[ -z $_ntr_save && -z $_ntr_restore ]]; then
zle recursive-edit
_ntr_stat=$?
+
+ [[ -n $_ntr_lbuffer ]] && eval "${_ntr_lbuffer}=\${LBUFFER}"
+ [[ -n $_ntr_rbuffer ]] && eval "${_ntr_rbuffer}=\${RBUFFER}"
fi
if [[ -n $_ntr_restore || -z $_ntr_save ]]; then
next prev parent reply other threads:[~2015-06-20 17:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-20 9:16 Mikael Magnusson
2015-06-20 17:06 ` Peter Stephenson [this message]
2015-06-21 7:09 ` Mikael Magnusson
2015-06-21 17:17 ` Peter Stephenson
2015-06-22 2:26 ` Mikael Magnusson
2015-06-22 0:18 ` PATCH: Document narrow-to-region -l and -r Mikael Magnusson
2015-06-20 17:21 ` This widget implementation feels a bit clunky (edit-quoted-word) Bart Schaefer
2015-07-18 23:42 ` PATCH: narrow-to-region (was Re: This widget implementation feels a bit clunky) Bart Schaefer
2015-07-19 3:55 ` Oliver Kiddle
2015-07-19 8:23 ` Bart Schaefer
2015-07-20 9:19 ` Oliver Kiddle
2015-07-20 16:29 ` Bart Schaefer
2015-07-23 5:41 ` Undo and narrow-to-region (was Re: PATCH: narrow-to-region (was ...)) Bart Schaefer
2015-07-27 15:44 ` Oliver Kiddle
2015-08-12 17:00 ` PATCH: Re: Undo and narrow-to-region (was ...) Oliver Kiddle
2015-08-17 21:15 ` Daniel Hahler
2015-08-17 21:58 ` Bart Schaefer
2015-08-18 3:43 ` Bart Schaefer
2015-08-18 7:05 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150620180659.735a6cc6@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).