Commits

Takafumi Arakaki  committed 16f69b6

added zaw-switch-editor.zsh

  • Participants
  • Parent commits 19a161c

Comments (0)

Files changed (1)

File zaw-switch-editor.zsh

+# -*- sh -*-
+zmodload zsh/parameter
+
+function zaw-src-switch-editor() {
+    candidates=("${(ps.:.)ZAW_SWITCH_EDITOR}")
+    actions=("zaw-callback-switch-editor-execute"
+        "zaw-callback-switch-editor-replace-buffer")
+    act_descriptions=("switch editor" "append to edit buffer")
+}
+
+zaw-register-src -n switch-editor zaw-src-switch-editor
+
+export ZAW_SWITCH_EDITOR="${EDITOR}:emacsclient:vim:jed:vi"
+
+function zaw-callback-switch-editor-execute() {
+    local orig_buffer="${BUFFER}"
+    BUFFER="export EDITOR='${(j:; :)@}'"
+    zle accept-line
+}
+
+function zaw-callback-switch-editor-replace-buffer() {
+    LBUFFER="export EDITOR='${(j:; :)@}'"
+    RBUFFER=""
+}