Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Add an option to disable deactivating region hilighting whenever you edit something



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



Messages sorted by: Reverse Date, Date, Thread, Author