Squashed 'vendor/github.com/erichs/composure/' changes from 5c3698d..55fdb9f
55fdb9f Merge pull request #24 from bvberkum/pr-21 b360ca5 Use command name, not last argument as shell-name [#23] 5c458c9 22 - Document revise behavior with GUI editors 7de4304 Update LICENSE copyright f784e3a Merge pull request #20 from akatrevorjay/pr/zsh-plugin 1901dbe Merge pull request #19 from DrVanScott/master 6bcbc7b Add zsh-style plugin for easy load 37bccee fix _typeset_functions_about for functions starting with a dash 27623a9 fix zsh specific issues 2efc446 glossary: list only functions containing 'about' 7899d11 glossary: call _typeset_functions only once 072856e shell(): Fix for cygwin environment 2dc31de avoid error message if gprintf does not exist git-subtree-dir: vendor/github.com/erichs/composure git-subtree-split: 55fdb9fa3cd0f181208a46d90da4d87d5b7e4351pull/1828/head^2
parent
90dd69c8ad
commit
aebe193136
|
|
@ -0,0 +1,16 @@
|
||||||
|
License: The MIT License
|
||||||
|
Copyright © 2012, 2016 Erich Smith
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
without restriction, including without limitation the rights to use, copy, modify,
|
||||||
|
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||||
|
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||||
|
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
@ -238,3 +238,5 @@ text](http://mitpress.mit.edu/sicp/full-text/book/book.html):
|
||||||
## Known Issues
|
## Known Issues
|
||||||
|
|
||||||
'glossary ()' and 'reference ()' do not support nested functions with metadata.
|
'glossary ()' and 'reference ()' do not support nested functions with metadata.
|
||||||
|
|
||||||
|
`revise` works well if your editor is terminal-based, like Emacs or Vim. If you use a windowed editor like Atom, VSCode, or Sublime, you will need to check to see if your editor supports a flag argument that allows it to wait for the files to be closed before returning. If this is supported, you can create a small script to launch your editor in this mode, and specify that script path in your `EDITOR` var. See https://github.com/erichs/composure/issues/10.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
source ${0:h}/{composure,c_extras}.sh
|
||||||
40
composure.sh
40
composure.sh
|
|
@ -58,14 +58,14 @@ _determine_printf_cmd() {
|
||||||
if [ -z "$_printf_cmd" ]; then
|
if [ -z "$_printf_cmd" ]; then
|
||||||
_printf_cmd=printf
|
_printf_cmd=printf
|
||||||
# prefer GNU gprintf if available
|
# prefer GNU gprintf if available
|
||||||
[ -x "$(which gprintf)" ] && _printf_cmd=gprintf
|
[ -x "$(which gprintf 2>/dev/null)" ] && _printf_cmd=gprintf
|
||||||
export _printf_cmd
|
export _printf_cmd
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_longest_function_name_length ()
|
_longest_function_name_length ()
|
||||||
{
|
{
|
||||||
_typeset_functions | awk 'BEGIN{ maxlength=0 }
|
echo "$1" | awk 'BEGIN{ maxlength=0 }
|
||||||
{
|
{
|
||||||
for(i=1;i<=NF;i++)
|
for(i=1;i<=NF;i++)
|
||||||
if (length($i)>maxlength)
|
if (length($i)>maxlength)
|
||||||
|
|
@ -175,22 +175,33 @@ _transcribe ()
|
||||||
|
|
||||||
_typeset_functions ()
|
_typeset_functions ()
|
||||||
{
|
{
|
||||||
typeset f
|
# unfortunately, there does not seem to be a easy, portable way to list just the
|
||||||
for f in "$(_get_composure_dir)"/*.inc; do
|
# names of the defined shell functions...
|
||||||
# Without nullglob, we'll get back the glob
|
|
||||||
[[ -f "$f" ]] || continue
|
|
||||||
|
|
||||||
f="${f##*/}"
|
case "$(_shell)" in
|
||||||
f="${f%.inc}"
|
sh|bash)
|
||||||
echo "$f"
|
typeset -F | awk '{print $3}'
|
||||||
done | cat - <(echo "cite\ndraft\nglossary\nmetafor\nreference\nrevise\nwrite") | sort | uniq
|
;;
|
||||||
|
*)
|
||||||
|
# trim everything following '()' in ksh/zsh
|
||||||
|
typeset +f | sed 's/().*$//'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_typeset_functions_about ()
|
||||||
|
{
|
||||||
|
typeset f
|
||||||
|
for f in $(_typeset_functions); do
|
||||||
|
typeset -f -- "$f" | grep -qE "^about[[:space:]]|[[:space:]]about[[:space:]]" && echo -- "$f"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_shell () {
|
_shell () {
|
||||||
# here's a hack I modified from a StackOverflow post:
|
# here's a hack I modified from a StackOverflow post:
|
||||||
# get the ps listing for the current process ($$), and print the last column (CMD)
|
# get the ps listing for the current process ($$), and print the last column (CMD)
|
||||||
# stripping any leading hyphens shells sometimes throw in there
|
# stripping any leading hyphens shells sometimes throw in there
|
||||||
typeset this=$(ps -p $$ | tail -1 | awk '{print $4}' | sed 's/^-*//')
|
typeset this=$(ps -o comm -p $$ | tail -1 | awk '{print $NF}' | sed 's/^-*//')
|
||||||
echo "${this##*/}" # e.g. /bin/bash => bash
|
echo "${this##*/}" # e.g. /bin/bash => bash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,9 +340,10 @@ glossary ()
|
||||||
group 'composure'
|
group 'composure'
|
||||||
|
|
||||||
typeset targetgroup=${1:-}
|
typeset targetgroup=${1:-}
|
||||||
typeset maxwidth=$(_longest_function_name_length | awk '{print $1 + 5}')
|
typeset functionlist="$(_typeset_functions_about)"
|
||||||
|
typeset maxwidth=$(_longest_function_name_length "$functionlist" | awk '{print $1 + 5}')
|
||||||
|
|
||||||
for func in $(_typeset_functions); do
|
for func in $(echo $functionlist); do
|
||||||
|
|
||||||
if [ "X${targetgroup}X" != "XX" ]; then
|
if [ "X${targetgroup}X" != "XX" ]; then
|
||||||
typeset group="$(typeset -f -- $func | metafor group)"
|
typeset group="$(typeset -f -- $func | metafor group)"
|
||||||
|
|
@ -528,7 +540,7 @@ _bootstrap_composure
|
||||||
: <<EOF
|
: <<EOF
|
||||||
License: The MIT License
|
License: The MIT License
|
||||||
|
|
||||||
Copyright © 2012, 2013 Erich Smith
|
Copyright © 2012, 2016 Erich Smith
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
software and associated documentation files (the "Software"), to deal in the Software
|
software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue