imitate Apple in setting initial shell PATH -- especially relevant for MacTeX, MacPorts etc.;
5 # Isabelle application wrapper
7 THIS="$(cd "$(dirname "$0")"; pwd)"
8 THIS_APP="$(cd "$THIS/../.."; pwd)"
9 SUPER_APP="$(cd "$THIS/../../.."; pwd)"
12 # sane environment defaults
15 if [ -x /usr/libexec/path_helper ]; then
16 eval $(/usr/libexec/path_helper -s)
19 [ -z "$LANG" ] && export LANG=en_US.UTF-8
24 function choosefrom ()
31 [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
34 [ -z "$RESULT" ] && RESULT="$FILE"
41 ISABELLE_TOOL="$(choosefrom \
42 "$THIS/Isabelle/bin/isabelle" \
43 "$SUPER_APP/Isabelle/bin/isabelle" \
44 "$HOME/bin/isabelle" \
48 # Proof General / Emacs
50 PROOFGENERAL_EMACS="$(choosefrom \
51 "$THIS/Emacs.app/Contents/MacOS/Emacs" \
52 "$SUPER_APP/Emacs.app/Contents/MacOS/Emacs" \
53 /Applications/Emacs.app/Contents/MacOS/Emacs \
56 declare -a EMACS_OPTIONS=()
57 if [ -n "$PROOFGENERAL_EMACS" ]; then
58 EMACS_OPTIONS=(-p "$PROOFGENERAL_EMACS")
64 if [ ! -f "$HOME/Library/Fonts/STIXGeneral.ttf" -a ! -f "$HOME/Library/Fonts/STIXGeneral.otf" ]
66 cp -f "$THIS/STIXv1.0.0/Fonts"/STIXGeneral* "$HOME/Library/Fonts/"
70 EMACS_OPTIONS["${#EMACS_OPTIONS[@]}"]="-x"
71 EMACS_OPTIONS["${#EMACS_OPTIONS[@]}"]="true"
74 # run interface with error feedback
76 ISABELLE_INTERFACE_CHOICE="$("$ISABELLE_TOOL" getenv -b ISABELLE_INTERFACE_CHOICE)"
77 if [ "$ISABELLE_INTERFACE_CHOICE" != emacs -a "$ISABELLE_INTERFACE_CHOICE" != jedit ]
80 CHOICE=($("$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" dropdown \
82 --text "Which Isabelle interface?" \
83 --items "Emacs / Proof General" "Isabelle/jEdit PIDE" \
84 --button2 "OK, do not ask again" --button1 "OK"))
85 if [ "${CHOICE[1]}" = 0 ]; then
86 ISABELLE_INTERFACE_CHOICE=emacs
88 ISABELLE_INTERFACE_CHOICE=jedit
90 if [ "${CHOICE[0]}" = 2 ]; then
91 ISABELLE_HOME_USER="$("$ISABELLE_TOOL" getenv -b ISABELLE_HOME_USER)"
92 mkdir -p "$ISABELLE_HOME_USER/etc"
93 ( echo; echo "ISABELLE_INTERFACE_CHOICE=$ISABELLE_INTERFACE_CHOICE"; ) \
94 >> "$ISABELLE_HOME_USER/etc/settings"
95 "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" ok-msgbox \
98 --informative-text "ISABELLE_INTERFACE_CHOICE stored in $ISABELLE_HOME_USER/etc/settings" \
103 OUTPUT="/tmp/isabelle$$.out"
105 if [ "$ISABELLE_INTERFACE_CHOICE" = emacs ]; then
106 ( "$ISABELLE_TOOL" emacs "${EMACS_OPTIONS[@]}" "$@" ) > "$OUTPUT" 2>&1
109 rm -f "$OUTPUT" && touch "$OUTPUT"
110 "$ISABELLE_TOOL" jedit "$@"
114 if [ "$RC" != 0 ]; then
116 echo "Return code: $RC" >> "$OUTPUT"
119 if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then
120 "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \
122 --informative-text "Isabelle output" \
123 --text-from-file "$OUTPUT" \