zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Add an option to disable deactivating region hilighting whenever you edit something
Date: Fri,  7 Nov 2014 10:04:30 +0100	[thread overview]
Message-ID: <1415351070-22018-1-git-send-email-mikachu@gmail.com> (raw)
In-Reply-To: <8414.1415317703@thecus.kiddle.eu>

For allowing zle beep to end the region, you could just use REGION_ACTIVE=0 instead.

While we're on the topic of deactivating the region, I've had this patch lying around forever in my local tree, but never cared enough to send it. It just keeps the region on until the user disables it again, I use this very complicated widget:
  _toggle_region_active () {
    (( REGION_ACTIVE = !REGION_ACTIVE ))
  }

My use case for the above is doing a set-mark-command, typing a long thing, and then invoking quote-region, while maintaining visual feedback of the region. (Sometimes I forgot to do the set-mark-command and ended up quoting the whole line).

---
 Src/Zle/zle_utils.c | 6 ++++--
 Src/options.c       | 1 +
 Src/zsh.h           | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index ba7642b..a264a4b 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -803,7 +803,8 @@ spaceinline(int ct)
 	    }
 	}
     }
-    region_active = 0;
+    if (isset(EDITDEACTIVATESREGION))
+	region_active = 0;
 }
 
 /*
@@ -883,7 +884,8 @@ shiftchars(int to, int cnt)
 	}
 	zleline[zlell = to] = ZWC('\0');
     }
-    region_active = 0;
+    if (isset(EDITDEACTIVATESREGION))
+	region_active = 0;
 }
 
 /*
diff --git a/Src/options.c b/Src/options.c
index 45c1d11..444e9ef 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -122,6 +122,7 @@ static struct optname optns[] = {
 {{NULL, "cshnullcmd",	      OPT_EMULATE|OPT_CSH},	 CSHNULLCMD},
 {{NULL, "cshnullglob",	      OPT_EMULATE|OPT_CSH},	 CSHNULLGLOB},
 {{NULL, "debugbeforecmd",     OPT_ALL},			 DEBUGBEFORECMD},
+{{NULL, "editdeactivatesregion", OPT_ALL},               EDITDEACTIVATESREGION},
 {{NULL, "emacs",	      0},			 EMACSMODE},
 {{NULL, "equals",	      OPT_EMULATE|OPT_ZSH},	 EQUALS},
 {{NULL, "errexit",	      OPT_EMULATE},		 ERREXIT},
diff --git a/Src/zsh.h b/Src/zsh.h
index 642e290..583edd9 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2074,6 +2074,7 @@ enum {
     CSHNULLCMD,
     CSHNULLGLOB,
     DEBUGBEFORECMD,
+    EDITDEACTIVATESREGION,
     EMACSMODE,
     EQUALS,
     ERREXIT,
-- 
2.2.0-rc0


  parent reply	other threads:[~2014-11-07  9:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-06 23:48 PATCH: keep region active when widget fails Oliver Kiddle
2014-11-07  0:37 ` Bart Schaefer
2014-11-07  9:04 ` Mikael Magnusson [this message]
2014-11-07 10:15   ` PATCH: Add an option to disable deactivating region hilighting whenever you edit something Oliver Kiddle
2014-11-07 10:42     ` Mikael Magnusson
2014-11-07  9:36 ` PATCH: keep region active when widget fails Peter Stephenson

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=1415351070-22018-1-git-send-email-mikachu@gmail.com \
    --to=mikachu@gmail.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).