zsh-workers
 help / color / mirror / Atom feed
ad4fc30e5ae1910d5b8db713ecef4cda8fbc0550 blob 5662 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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
 
#!/bin/zsh -fi
# A zsh sticky-note ("post-it") application.  Load this file as a function:
#    autoload -Uz sticky-note
#
# It may then be bound as a widget:
#    zle -N sticky-note
# And/or run as a command:
#    sticky-note
#    sticky-note -b
#    sticky-note -l ...
# The -b option is like "zed -b": it installs keymaps/bindings only.
# Use the -l option to list previous sticky notes.  Most options of the
# "fc -l" command are supported, for selecting which notes to display.
# If "sticky-note -l" is run from inside a widget, the cursor is moved
# to the top left of the terminal before display and returned to its
# original position after display.  The -l option is implicitly added
# when sticky-note is called from zle-line-init, to avoid inadvertently
# trapping the user inside the note editor.
#
# Otherwise, invoke the line editor with the previous notes available
# as an editor history.  Two quick taps on the return/enter key finish
# the note, or you can use ^X^W as usual (ZZ in vicmd mode).

# The application is configured by four zstyles, all using the context
# ":sticky-note".  The first two styles are "notefile" and "maxnotes"
# to name the file in which notes are stored and the maximum number of
# notes to retain:
#   zstyle :sticky-note notefile ~/.zsticky
#   zstyle :sticky-note maxnotes 1000

# The "theme" style may be set to control the appearance of the notes.
# The style is an associative array; the current set of values (defaults
# in parens) are:
#   bg    => name or ANSI escape for background color (yellow)
#   fg    => name or ANSI escape for foreground color (black)
#   color => ANSI escape for color scheme ($theme[bg]$theme[fg])
#   reset => ANSI escape to restore "normal" colors
# Values given as names are looked up in the $bg and $fg arrays from the
# "colors" function.  If a "color" field is set, the "bg" and "fg" fields
# are not used.  Example:
#   zstyle :sticky-note theme \
#     bg red \
#     fg $fg_bold[yellow]

# Finally the "escapes" style may be used to control the intepretation of
# of character sequences such as '\Cx' and '%B' in the content of each
# note.  The style may be set to either one or two strings:
#   none    => no interpretation, other strings in the value are ignored
#   echo    => escape sequences of the "echo" command are interpreted
#   bindkey => escapes of the "bindkey" command are interpreted
#   prompt  => interpret prompt escapes, may be paired with echo or bindkey
# The default is "echo" for compatibility with previous versions.  Note
# that use of some escape sequences may garble the display, or clash
# with the "theme" style.

# For backwards compatibility with an earlier version, the notefile may
# also be named by the STICKYFILE variable (defaults to $HOME/.zsticky).
# The number of notes stored may be given by STICKYSIZE (1000).

# I encourage all you creative people to contribute enhancements ...

emulate -LR zsh
setopt nobanghist extendedhistory histignoredups

local STICKYFILE=${STICKYFILE:-$HOME/.zsticky}
local STICKYSIZE=${STICKYSIZE:-1000}
local sticky stickyfile stickysize

zstyle -s :sticky-note notefile stickyfile || stickyfile=$STICKYFILE
zstyle -s :sticky-note maxnotes stickysize || stickysize=$STICKYSIZE

# Set up keybindings (adapted from "zed")
if ! bindkey -M sticky >& /dev/null
then
  bindkey -N sticky main
  bindkey -M sticky ^X^W accept-line
  bindkey -M sticky ^M^M accept-line	# Two quick RETs ends note
  bindkey -M sticky ^M self-insert-unmeta
fi
if ! bindkey -M sticky-vicmd >& /dev/null 
then
  bindkey -N sticky-vicmd vicmd
  bindkey -M sticky-vicmd ZZ accept-line
fi

[[ "$1" == -b ]] && return 0

# Set escape handling
local -a escapes prop
if zstyle -a :sticky-note escapes escapes
then
  prop=(-r)
  if [[ $escapes != *none* ]]
  then
    case $escapes in
    (*bindkey*) prop=({$prop/-r/-b});;
    (*echo*) prop=(${prop/-r/});;
    esac
    [[ $escapes = *prompt* ]] && prop+=(-P)
  fi
fi

# Look up color theme
local -A theme
(($+bg && $+fg)) || { autoload -Uz colors; colors }
zstyle -m :sticky-note theme '*' || {
    zstyle :sticky-note theme bg yellow fg black
}
zstyle -a :sticky-note theme theme
(( ${+bg[$theme[bg]]} )) && theme[bg]=$bg[$theme[bg]]
(( ${+fg[$theme[fg]]} )) && theme[fg]=$fg[$theme[fg]]
(( ${+theme[color]} )) || theme[color]=$theme[bg]$theme[fg]
(( ${+theme[reset]} )) || theme[reset]=$reset_color

# If invoked as a widget, behave a bit like run-help
if zle
then
  zmodload -i zsh/parameter
  if [[ $* == -*l* || $functrace == *zle-line-init:* ]]
  then
    fc -ap $stickyfile $stickysize $stickysize
    echoti sc
    echoti home
    print -nr "$theme[color]"
    fc -l "${@:--1}" | while read -r sticky; do print $prop -- "$sticky"; done
    print -nr "$theme[reset]"
    echoti rc
  elif [[ $CONTEXT = (cont|select|vared) ]]
  then
    zle -M "No stickies during ${${(z)PREBUFFER}[1]:-$CONTEXT}, sorry"
    zle .beep
    zle -R
  else
    zle .push-line
    BUFFER=sticky-note
    zle .accept-line
  fi
  return 0
fi

# Invoked as a command, behave like zed, but write a history file
fc -ap $stickyfile $stickysize $stickysize

# With a -l option, list the existing sticky notes
if [[ "$*" == -*l* ]]
then
  print -nr "$theme[color]"
  # Use read/print loop to interpolate "\n" in history lines
  fc -f "$@" | while read -r sticky; do print $prop -- "$sticky"; done
  print -nr "$theme[reset]"
  return 0
fi

# Edit a new sticky note and add it to the stickyfile
while vared -h -p "%{$theme[color]%}" -M sticky -m sticky-vicmd sticky
do
  {
    [[ -n "$sticky" ]] && print -rs -- "$sticky"
  } always {
    (( TRY_BLOCK_ERROR = 0 ))
  } && break
  echo -n -e '\a'
done
return 0
debug log:

solving ad4fc30e5 ...
found ad4fc30e5 in http://inbox.vuxu.org/zsh-workers/CAH+w=7YSJwPwsA1D7xyVi_PoCvpVdB0Ng3OBdF+2UfAd2JeRDw@mail.gmail.com/
found efe5ec1eb in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 efe5ec1eb2eeabcc290369abc00dd8a200e7eba8	Functions/Misc/sticky-note

applying [1/1] http://inbox.vuxu.org/zsh-workers/CAH+w=7YSJwPwsA1D7xyVi_PoCvpVdB0Ng3OBdF+2UfAd2JeRDw@mail.gmail.com/
diff --git a/Functions/Misc/sticky-note b/Functions/Misc/sticky-note
index efe5ec1eb..ad4fc30e5 100644

Checking patch Functions/Misc/sticky-note...
Applied patch Functions/Misc/sticky-note cleanly.

index at:
100644 ad4fc30e5ae1910d5b8db713ecef4cda8fbc0550	Functions/Misc/sticky-note

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git