]> git.madduck.net Git - etc/neomutt.git/blob - .config/neomutt/mkconf

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

buildmimetree.py: allow multipart/related instead of relative
[etc/neomutt.git] / .config / neomutt / mkconf
1 #!/bin/sh
2 #
3 # BEWARE THIS IS UGLY
4 #
5 # I like this approach because it imports the full documentation for each
6 # setting. However, `mutt -O -D` may be much better suited for your needs.
7 #
8 set -eu
9
10 FILE="${1:-${0%/*}/confvars}"
11 TARGET="${2:-}"
12
13 if [ ! -f "$FILE" ]; then
14   echo >&2 "E: File $FILE does not exist"
15   exit 1
16 fi
17
18 if [ -z "$TARGET" ]; then
19   TARGET="$FILE"
20 fi
21
22 TMPFILE="$(mktemp -t vit.XXXXXXXX)"
23 cleanup() { rm -f "$TMPFILE"; trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15; }
24 trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15
25
26 process_stanza() {
27   echo "$2"
28   local opt setting trailer
29   opt="$(sed -ne "/^set ${1}=/,/# 3\./p" $FILE)"
30   if [ -n "$opt" ]; then
31     opt="${opt%
32 *}"
33     setting="${opt%%
34 *}"
35     echo >&2 "Importing setting: $setting …"
36     echo "$setting"
37     echo "$opt" | grep '^#' || :
38   fi
39   echo
40   echo
41 }
42
43 option=
44 { zcat /usr/share/doc/neomutt/manual.txt.gz | \
45   sed -e '1,/^3\. Configuration Variables$/d;1d;/^4\./,$d' -e 's, , ,g';
46   echo END; } | \
47
48 while read first rest; do
49   line="$first ${rest%% }"
50   case "$first" in
51     (3.[0-9]*|END)
52       [ -z "$option" ] || \
53         process_stanza "$option" "${stanza}"
54       stanza="# $line"
55       option="$rest"
56       ;;
57     ('')
58       stanza="${stanza:+$stanza\n}#$line"
59       ;;
60     (*)
61       stanza="${stanza:+$stanza\n}# $line"
62       ;;
63   esac
64
65 done > $TMPFILE
66
67 cat <<_eof > "$TARGET"
68 # Auto-generated using mkconf from manual.txt
69 # on $(date +'%Y-%m-%d %H:%M:%S')
70 #
71 # Invoked as: $0${1:+ $@}
72 #
73
74 $(cat "$TMPFILE")
75
76 # vim:sw=12:noet:sts=12:ts=12:ft=muttrc
77 _eof
78 cleanup