commit
71116f785f
|
|
@ -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
|
||||
|
||||
'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
|
||||
|
|
@ -58,14 +58,14 @@ _determine_printf_cmd() {
|
|||
if [ -z "$_printf_cmd" ]; then
|
||||
_printf_cmd=printf
|
||||
# prefer GNU gprintf if available
|
||||
[ -x "$(which gprintf)" ] && _printf_cmd=gprintf
|
||||
[ -x "$(which gprintf 2>/dev/null)" ] && _printf_cmd=gprintf
|
||||
export _printf_cmd
|
||||
fi
|
||||
}
|
||||
|
||||
_longest_function_name_length ()
|
||||
{
|
||||
_typeset_functions | awk 'BEGIN{ maxlength=0 }
|
||||
echo "$1" | awk 'BEGIN{ maxlength=0 }
|
||||
{
|
||||
for(i=1;i<=NF;i++)
|
||||
if (length($i)>maxlength)
|
||||
|
|
@ -175,22 +175,33 @@ _transcribe ()
|
|||
|
||||
_typeset_functions ()
|
||||
{
|
||||
typeset f
|
||||
for f in "$(_get_composure_dir)"/*.inc; do
|
||||
# Without nullglob, we'll get back the glob
|
||||
[[ -f "$f" ]] || continue
|
||||
# unfortunately, there does not seem to be a easy, portable way to list just the
|
||||
# names of the defined shell functions...
|
||||
|
||||
f="${f##*/}"
|
||||
f="${f%.inc}"
|
||||
echo "$f"
|
||||
done | cat - <(echo "cite\ndraft\nglossary\nmetafor\nreference\nrevise\nwrite") | sort | uniq
|
||||
case "$(_shell)" in
|
||||
sh|bash)
|
||||
typeset -F | awk '{print $3}'
|
||||
;;
|
||||
*)
|
||||
# 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 () {
|
||||
# here's a hack I modified from a StackOverflow post:
|
||||
# get the ps listing for the current process ($$), and print the last column (CMD)
|
||||
# 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
|
||||
}
|
||||
|
||||
|
|
@ -329,9 +340,10 @@ glossary ()
|
|||
group 'composure'
|
||||
|
||||
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
|
||||
typeset group="$(typeset -f -- $func | metafor group)"
|
||||
|
|
@ -528,7 +540,7 @@ _bootstrap_composure
|
|||
: <<EOF
|
||||
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
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
|
|
|
|||
Loading…
Reference in New Issue