999bab187c0a59301f4055fb6239a5352d3c96ab

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Emulate zsh in zlewidgets instead of static setopt command

This way the user can keep their preferred pushd syntax while enabling
us to use a standard syntax in our defined functions.

To explain further, without a clear value on the PUSHD_MINUS option, we
could be changing the +1/-0 values all we want, that some user would
find that it didn't work for him.

We have two options, then:
- Setting a particular value, which was my first approach.
- Using `emulate -L zsh` to ensure all options defined in the function's
  body won't be passed along to the main zsh instance.
  For more info see:
  http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html#index-emulate

Diff

 1diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh
 2index 1c4a0175a0951a8a787e9c8f0f65570e8232bc14..12b20ab04228b1be4a07819af06482b9a348ce68 100644
 3--- a/plugins/dircycle/dircycle.plugin.zsh
 4+++ b/plugins/dircycle/dircycle.plugin.zsh
 5@@ -7,15 +7,20 @@
 6 # NO_PUSHD_MINUS syntax:
 7 #  pushd +N: start counting from left of `dirs' output
 8 #  pushd -N: start counting from right of `dirs' output
 9-setopt nopushdminus
10 
11 insert-cycledleft () {
12+	emulate -L zsh
13+	setopt nopushdminus
14+
15 	builtin pushd -q +1 &>/dev/null || true
16 	zle reset-prompt
17 }
18 zle -N insert-cycledleft
19 
20 insert-cycledright () {
21+	emulate -L zsh
22+	setopt nopushdminus
23+
24 	builtin pushd -q -0 &>/dev/null || true
25 	zle reset-prompt
26 }