a.out.dSYM/
/config/version.c
/docs/contrib/sendfrom
+/etc/bash_completion_nmh
/etc/gen-ctype-checked
/etc/gen-ctype-checked.exe
/etc/mhn.defaults
## Stuff that should be cleaned via "make clean"
## automake 1.12.6 on FreeBSD 9 needs the sbr/dtimep.c.
##
-CLEANFILES = config/version.c sbr/sigmsg.h sbr/dtimep.c etc/mts.conf \
- etc/mhn.defaults man/man.sed man/mh-chart.man $(man_MANS) \
- *.plist
+CLEANFILES = config/version.c sbr/dtimep.c \
+ etc/bash_completion_nmh etc/mhn.defaults etc/mts.conf \
+ man/man.sed man/mh-chart.man $(man_MANS) *.plist
clean-local:
@rm -rf RPM a.out.dSYM uip/a.out.dSYM
@rm -rf test/testdir
## The same as above, but we don't include these in the distribution
## (because they're generated at compile time)
##
-nmhetc_DATA = etc/mhn.defaults etc/mts.conf
+nmhetc_DATA = etc/bash_completion_nmh etc/mhn.defaults etc/mts.conf
##
## Documentation that gets installed in docdir
##
dist_doc_DATA = COPYRIGHT INSTALL NEWS README VERSION \
- docs/COMPLETION-BASH docs/COMPLETION-TCSH \
- docs/COMPLETION-ZSH docs/DIFFERENCES docs/FAQ \
+ docs/COMPLETION-TCSH docs/COMPLETION-ZSH \
+ docs/DIFFERENCES docs/FAQ \
docs/MAIL.FILTERING docs/MAILING-LISTS docs/README-ATTACHMENTS \
docs/README-HOOKS docs/README-components docs/README.about \
docs/README.SASL docs/README.developers docs/README.manpages \
## Automake using the automatic rules
##
EXTRA_DIST = autogen.sh build_nmh config/version.sh sbr/icalparse.h \
- etc/mts.conf.in etc/mhn.defaults.sh etc/sendfiles \
+ etc/bash_completion_nmh-gen etc/mhn.defaults.sh etc/mts.conf.in \
+ etc/sendfiles \
$(MHNSEARCHPROG) DATE MACHINES \
docs/ChangeLog_MH-3_to_MH-6.6 \
docs/ChangeLog_MH-6.7.0_to_MH-6.8.4.html \
config/version.c: Makefile $(srcdir)/config/version.sh
env srcdir="$(srcdir)" sh $(srcdir)/config/version.sh $(VERSION) > ./config/version.c
+etc/bash_completion_nmh: $(srcdir)/etc/bash_completion_nmh-gen
+ $(MKDIR_P) $(@D) # FIXME: A better way?
+ $(srcdir)/etc/bash_completion_nmh-gen > $@
+
etc/mts.conf: $(srcdir)/etc/mts.conf.in Makefile
@rm -f $@
$(SED) -e 's,%mts%,$(MTS),' \
+++ /dev/null
-# nmh completion for bash
-# Copyright 2003 "Wade Richards" <wade@wabyn.net>
-# Permission granted to redistribute under the BSD license
-
-[ "$BASH_COMPLETION" ] || echo "ERROR: COMPLETION-BASH is not intended to be \
-sourced directly, but rather added to a bash-completion package installation."
-
-have show &&
-_nmh()
-{
- # args: command comp-word prev-word
- local command current prev folder origfolder i orig_opts
-
- COMPREPLY=()
- current=${COMP_WORDS[COMP_CWORD]}
- prev=${COMP_WORDS[COMP_CWORD-1]}
- command=$1
-
- orig_opts=$(shopt -p extglob)
- shopt -s extglob
-
- # Get the folder, if specified
- for (( i=0; i < ${#COMP_WORDS}-1; i++ ))
- do
- case "${COMP_WORDS[i]}" in
- \++([a-zA-Z_]) )
- folder=${COMP_WORDS[i]}
- origfolder=$( folder -f )
- ;;
- esac
- done
-
- case $current in
- -* )
- # Command-line switches for the most common commands.
- case $command in
- ali )
- # no sequences or messages
- options=(-alias -list -nolist -normalize -nonormalize -user
- -nouser -version -help)
- ;;
- burst )
- options=(-inplace -noinplace -quiet -noquiet -verbose
- -noverbose -version -help)
- ;;
- comp )
- options=(-form -use -nouse -file -draftfolder -draftmessage
- -nodraftfolder -editor -noedit -whatnowproc -nowhatnowproc
- -version -help )
- ;;
- flist* )
- options=(-sequence -all -noall -showzero -noshowzero
- -recurse -norecurse -fast -nofast -alpha -noalpha -version
- -help)
- ;;
- folder* )
- options=(-all -noall -create -nocreate -fast -nofast -header
- -noheader -recurse -norecurse -total -nototal -list -nolist
- -push -pop -pack -nopack -print -verbose -noverbose -version
- -help)
- ;;
- forw )
- options=(-annotate -noannotate -form -format -noformat
- -filter -inplace -noinplace -mime -nomime -draftfolder
- -draftmessage -nodraftfolder -editor -noedit -whatnowproc
- -nowhatnowproc -dashstuffing -nodashstuffing -build -file
- -version -help)
- ;;
- inc )
- options=(-audit -noaudit -changecur -nochangecur -form -format
- -file -silent -nosilent -truncate -notruncate -width -host
- -user -pack -nopack -apop -noapop -kpop -sasl -saslmech -snoop
- -version -help)
- ;;
- mark )
- options=(-sequence -add -delete -list -public -nopublic
- -zero -nozero -version -help)
- ;;
- next )
- options=(-showmimeproc -header -noheader -checkmime
- -nocheckmime -version -help)
- ;;
- packf )
- options=(-file -mbox -mmdf -version -help)
- ;;
- pick )
- options=(-and -or -not -lbrace -rbrace --component -cc
- -date -from -search -subject -to -after -before -datefield
- -sequence -public -nopublic -zero -nozero -list -nolist
- -version -help)
- ;;
- prev )
- options=(-showproc -showmimeproc -header -noheader -checkmime
- -nocheckmime -version -help)
- ;;
- refile )
- options=(-draft -link -nolink -preserve -nopreserve -unlink
- -nounlink -src -file -rmmproc -normmproc -version -help)
- ;;
- repl )
- options=(-annotate -noannotate -group -nogroup -cc
- -nocc -query -noquery -form -format -noformat -filter
- -inplace -noinplace -mime -nomime -fcc -width -draftfolder
- -draftmessage -nodraftfolder -editor -noedit -whatnowproc
- -nowhatnowproc -build -file -version -help)
- ;;
- rmf )
- options=(-interactive -nointeractive -version -help)
- ;;
- rmm )
- options=(-link -nolink -version -help)
- ;;
- scan )
- options=(-clear -noclear -form -format -header -noheader
- -width -reverse -noreverse -file -version -help )
- ;;
- show )
- options=(-draft -showproc -showmimeproc -header -noheader
- -checkmime -nocheckmime -version -help)
- ;;
- sortm )
- options=(-datefield -textfield -notextfield -limit -nolimit
- -verbose -noverbose -version -help)
- ;;
- whom )
- options=(-alias -check -nocheck -draft -draftfolder
- -draftmessage -nodraftfolder -version -help)
- ;;
- * )
- options=(-help -version -seq)
- ;;
- esac
- ;;
-
- +* )
- # Folders
- options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
- ;;
-
- +([0-9a-z])-* )
- # Partial range
- start=${current/%-*/}
- options=( $( scan $folder -format "%(msg)" "${start}-last" ) first prev cur next last )
- options=( ${options[@]//#/${start}-} )
- ;;
-
- +([0-9]) )
- # Message number, or start of range
- options=( $( scan $folder -format "%(msg)" ) first prev cur next last )
- options=( ${options[@]} ${options[@]//%/-} )
- ;;
-
- [fpcnlu]* )
- # special message aliases
- options=( first prev cur next last unseen )
- ;;
-
- # What about sequences? I can't quite see how to get the list of possible sequences, so I
- # guess the user will have to type them in the old-fashioned way.
-
- esac
-
- eval $orig_opts
-
- COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
- return 0
-}
-[ "$have" ] && complete -F _nmh ali anno burst comp dist flist flists folder folders forw inc mark mhbuild mhl mhlist mhmail mhn mhparam mhpath mhshow mhstore msgchk msh next packf pick prev prompter rcvdist rcvpack rcvstore rcvtty refile repl rmf rmm scan send sendfiles show slocal sortm whatnow whom
--- /dev/null
+#!/bin/sh
+#
+# Generates COMPLETION-BASH from man/mh-chart.man.
+#
+# This code is Copyright (c) 2016, by the authors of nmh.
+# See the COPYRIGHT file in the root directory of the nmh
+# distribution for complete copyright information.
+
+mhchart=man/mh-chart.man
+
+#### Extract switches for nmh program.
+function switches() {
+ local program=$1
+
+ #### Extract lines from just after .B program-name to just before
+ #### blank line, and then only those that start with .RB, e.g.,
+ #### .RB [ \-list " | " \-nolist ]
+ #### .RB " | " \-autoheaderencoding ]
+ #### .RB [ \-\|\-component
+ awk '/^.B.*(\/| )'"$program"'/,/^$/ {
+ if (/^\.RB /) print
+ }' "$mhchart" | \
+ tr -d '\n' | \
+ sed -e 's/\.RB //g' -e 's/\[//g' -e 's/\]//g' \
+ -e 's/\(\\\)*//g' -e 's/-|-/-/g' -e 's/" *| "//g' \
+ -e 's/^ *//' -e 's/ *$//' -e 's/ */ /g'
+}
+
+cat <<'EOF'
+# bash completions for nmh commands -*- shell-script -*-
+# This file was generated by COMPLETION-BASH-gen.
+#
+# This code is Copyright (c) 2016, by the authors of nmh.
+# See the COPYRIGHT file in the root directory of the nmh
+# distribution for complete copyright information.
+#
+# To use: source at a bash prompt or in an initialization file.
+
+_nmh() {
+ local -a switches
+
+ COMPREPLY=()
+
+ case ${COMP_WORDS[COMP_CWORD]} in
+ -*) case $1 in
+EOF
+
+#### Extract program names from lines such as:
+#### .B %nmhlibexecdir%/install\-mh
+#### .B new \-mode fnext
+programs=`egrep '\.B [^\-]' "$mhchart" | \
+ sed -e 's/^\.B //' -e 's/ .*//' -e 's|%[^%]*%/||' -e 's/\\-/-/'`
+for program in $programs; do
+ switches=`switches "$program"`
+ # Support mime as alias for mhbuild.
+ [ "$program" = mhbuild ] && program='mhbuild|mime'
+ printf ' %s) switches=(%s) ;;\n' "$program" "$switches"
+
+done
+programs="$programs mime"
+
+cat <<'EOF'
+ esac ;;
+
+ +*) switches=($(folder -all -fast -recurse | sed 's/^/+/')) ;;
+
+ [flc.np]*) switches=(first last cur . next prev) ;;
+ esac
+
+ #### Special case.
+ [ $1 = mhpath ] && switches=("${switches[*]}" + new)
+
+ COMPREPLY=($(compgen -W "${switches[*]}" -- ${COMP_WORDS[COMP_CWORD]}))
+}
+
+EOF
+
+#### There better not be an nmh program name with whitespace in it.
+echo complete -F _nmh $programs