Merge pull request #1828 from cornfeedhobo/composure-bump

Composure bump
pull/1788/head
Noah Gorny 2021-02-05 10:51:28 +02:00 committed by GitHub
commit 71116f785f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 14 deletions

16
vendor/github.com/erichs/composure/LICENSE generated vendored 100644
View File

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

View File

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

View File

@ -0,0 +1,2 @@
#!/bin/zsh
source ${0:h}/{composure,c_extras}.sh

View File

@ -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