zsh-workers
 help / color / mirror / code / Atom feed
ef7f9c1c866c5b8b252a35882bb3f4d3485bdbb9 blob 2291 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
 
#!/bin/zsh
# zed
#
# No other shell could do this.
# Edit small files with the command line editor.
# Use ^X^W to save, ^C to abort.
# Option -f: edit shell functions.  (Also if called as fned.)

local var opts zed_file_name
# We do not want timeout while we are editing a file
integer TMOUT=0 okargs=1 fun bind
local -a expand

zparseopts -D -A opts f b x:
fun=$+opts[-f]
bind=$+opts[-b]
if [[ $opts[-x] == <-> ]]; then
  expand=(-x $opts[-x])
elif (( $+opts[-x] )); then
  print -r "Integer expected after -x: $opts[-x]" >&2
  return 1
fi

[[ $0 = fned ]] && fun=1
(( bind )) && okargs=0

if (( $# != okargs )); then
    echo 'Usage:
zed filename
zed -f [ -x N ] function
zed -b' >&2
    return 1
fi

local curcontext=zed:::

zstyle -m ":completion:zed:*" insert-tab '*' ||
    zstyle ":completion:zed:*" insert-tab yes

if (( bind )) || ! bindkey -M zed >&/dev/null; then
  # Make the zed keymap a copy of the current main.
  bindkey -N zed main
  # Save the current main.  In zle widgets called from
  # zed we may want to set this temporally.
  bindkey -A main zed-normal-keymap

  # Assign some default keys.
  # Depending on your stty's, you may be able to use ^J as accept-line, else:

  # The following isn't useful if we are copying viins, but that's
  # a nicety.
  bindkey -M zed '^x^w' accept-line
  bindkey -M zed '^M' self-insert-unmeta

  # Make zed-set-file-name available.
  # Assume it's in fpath; there's no error at this point if it isn't
  autoload -Uz zed-set-file-name
  zle -N zed-set-file-name
fi
if (( bind )) || ! bindkey -M zed-vicmd >&/dev/null; then
  bindkey -N zed-vicmd vicmd

  bindkey -M zed-vicmd "ZZ" accept-line
fi

(( bind )) && return 0

# don't mangle !'s
setopt localoptions nobanghist

if ((fun)) then
  var="$(functions $expand -- $1)"
  # If function is undefined but autoloadable, load it
  if [[ $var = *\#\ undefined* ]] then
    var="$(autoload +X -- $1; functions -- $1)"
  elif [[ -z $var ]] then
    var="$1() {
}"
  fi
  vared -M zed -m zed-vicmd var && eval function "$var"
else
  zed_file_name=$1
  [[ -f $1 ]] && var="$(<$1)"
  while vared -M zed -m zed-vicmd var
  do
    {
      print -r -- "$var" >| $zed_file_name
    } always {
      (( TRY_BLOCK_ERROR = 0 ))
    } && break
    echo -n -e '\a'
  done
fi

return 0

# End of zed
debug log:

solving ef7f9c1 ...
found ef7f9c1 in https://inbox.vuxu.org/zsh-workers/1446000872-26311-1-git-send-email-llua@gmx.com/
found 1f6042e in https://inbox.vuxu.org/zsh-workers/1445968457-5930-1-git-send-email-llua@gmx.com/
found 010b69b in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 010b69bee8e08ca9e732b5e55fd1991eb048f775	Functions/Misc/zed

applying [1/2] https://inbox.vuxu.org/zsh-workers/1445968457-5930-1-git-send-email-llua@gmx.com/
diff --git a/Functions/Misc/zed b/Functions/Misc/zed
index 010b69b..1f6042e 100644


applying [2/2] https://inbox.vuxu.org/zsh-workers/1446000872-26311-1-git-send-email-llua@gmx.com/
diff --git a/Functions/Misc/zed b/Functions/Misc/zed
index 1f6042e..ef7f9c1 100644

Checking patch Functions/Misc/zed...
Applied patch Functions/Misc/zed cleanly.
Checking patch Functions/Misc/zed...
Applied patch Functions/Misc/zed cleanly.

index at:
100644 ef7f9c1c866c5b8b252a35882bb3f4d3485bdbb9	Functions/Misc/zed

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).