Skip to content
Browse files

Issue 49: Don't use readlink, options differ between systems

Signed-off-by: Julien Nicoulaud <julien.nicoulaud@gmail.com>
  • Loading branch information...
1 parent bc788f3 commit 19f16752bb169e5468d75f84f2be4b6ddf0d1af8 @nicoulaj nicoulaj committed Mar 2, 2011
Showing with 21 additions and 13 deletions.
  1. +21 −13 zsh-syntax-highlighting.zsh
View
34 zsh-syntax-highlighting.zsh
@@ -30,7 +30,7 @@
# -------------------------------------------------------------------------------------------------
-# Core highligting update system
+# Core highlighting update system
# -------------------------------------------------------------------------------------------------
# Array used by highlighters to declare overridable styles.
@@ -239,11 +239,11 @@ _zsh_main-highlight() {
# -------------------------------------------------------------------------------------------------
-# Setup
+# Setup functions
# -------------------------------------------------------------------------------------------------
-# Setup highlighting.
-_zsh_highlight_install() {
+# Intercept specified ZLE events to have highlighting triggered.
+_zsh_highlight_bind-events() {
# Resolve event names what have to be bound to.
zmodload zsh/zleparameter 2>/dev/null || {
@@ -277,15 +277,23 @@ _zsh_highlight_install() {
esac
fi
done
+}
- # Register the main highlighter.
- _zsh_highlight_add-highlighter _zsh_main-highlight _zsh_highlight_buffer-modified-p
-
- # Load additional highlighters if available.
- local highlighters_dir=${$(command readlink -f ${(%):-%N}):h}/highlighters
- if [[ -d $highlighters_dir ]]; then
- for highlighter_def ($highlighters_dir/*.zsh) . $highlighter_def
- fi
+# Load highlighters from specified directory if it exists.
+_zsh_highlight_load-highlighters() {
+ [[ -d $1 ]] && for highlighter_def ($1/*.zsh) . $highlighter_def
}
-_zsh_highlight_install "${(@f)"$(zle -la)"}"
+
+# -------------------------------------------------------------------------------------------------
+# Setup
+# -------------------------------------------------------------------------------------------------
+
+# Bind highlighting to all known events.
+_zsh_highlight_bind-events "${(@f)"$(zle -la)"}"
+
+# Register the main highlighter.
+_zsh_highlight_add-highlighter _zsh_main-highlight _zsh_highlight_buffer-modified-p
+
+# Load additional highlighters if available.
+_zsh_highlight_load-highlighters "${${(%):-%N}:h}/highlighters"

0 comments on commit 19f1675

Please sign in to comment.
Something went wrong with that request. Please try again.