aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mew2/files/user-install.in
blob: ee1a7ad4d9f42f9360c728a4c9b592f171ebb396 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
#!/bin/sh

PREFIX=%%PREFIX%%
EMACSDIR=%%EMACSDIR%%
ELISPDIR=%%ELISPDIR%%
SAMPLEDIR=%%SAMPLEDIR%%

AWK=%%AWK%%
CAT=%%CAT%%
CP=%%CP%%
ECHO=%%ECHO%%
MKDIR="%%MKDIR%%"
RM=%%RM%%
SED=%%SED%%
TOUCH=%%TOUCH%%
DIALOG=/usr/bin/dialog

select()
{
    local Language key
    Language="\
Choose a language when you write mails.\n\
    (Now is \"${language}\" selected.)"
    ${DIALOG} --title "Choose the Language" \
    --hline "Select Items and Quit when finished" \
    --menu "${Language}" -1 -1 2 \
    English     "English" \
    Japanese    "japanese" \
        2>  /tmp/menu.$$
    retval=$?
    key=`${CAT} /tmp/menu.$$|${SED} -e 's/\"//g'`
    ${RM} -f /tmp/menu.$$
    case $retval in
        0) if [ -z ${key} ]; then return; fi ;;
        1) return ;;
        255) return ;;
    esac
    language=${key}
#   echo citation:key=${key},dot_emacs=${dot_emacs}>>/tmp/temp
}

input_data()
# argument No.1 ($1) : Key words (string)
# argument No.2 ($2) : Variable for the Key words (string)
# argument No.3 ($3) : unit for the variable (string)
{
    local key
#   echo '$1='$1
#   echo '$2='$2
#   echo '$3='$3
#   exit 1
#   echo '${nameserver}='${mail_address}
#   eval echo '${'$2'}'
    eval key='${'$2'}'
#   echo key=${key}
#   exit 1
    if [ ! -z ${key} ]; then
        ${DIALOG} --title "Confirm $1" \
        --hline "Press Yes/No" \
        --yesno "$1 $3 has set \"${key}\". Is this OK?" -1 -1
        retval=$?
        if [ X"${retval}" = "X0" -o X"${retval}" = "X255" ]; then  return; fi
    fi
    ${DIALOG} --title "Set $1 $3" \
    --hline "Write $1 $3" \
    --inputbox "Specify $1 $3" -1 -1 \
        2>  /tmp/input.$$
    eval $2=`${CAT} /tmp/input.$$`
    ${RM} -f /tmp/input.$$
}

options()
{
    local Options keys del_keys
    Options="\
Please select Mew functions that you want to. To select a function, \n\
use the arrow keys to move to it and press [SPACE]. To de-select it, \n\
press [SPACE] again.  Select OK or Cancel to leave this menu."
    del_keys="Highlight Citation Cite_Change Sign_Change"
    ${DIALOG} --title "Select Mew functions" \
    --hline "" \
    --checklist "${Options}" -1 -1 4 \
    Highlight   "highlight body for Mew(Japanese)" ${options_Highlight} \
    Citation    "Citation with the mail." ${options_Citation} \
    Cite_Change "Change citation English <--> Japanese." ${options_Cite_Change} \
    Sign_Change "Change signature English <--> Japanese." ${options_Sign_Change} \
        2> /tmp/checklist.$$
    retval=$?
    keys=`${CAT} /tmp/checklist.$$|${SED} -e 's/\"//g'`
    ${RM} -f /tmp/checklist.$$
    case $retval in
        1)   return ;;
        255) return ;;
    esac
    dot_emacs=""
#   echo keys=$keys
    for k in ${keys}; do
        del_keys=`${ECHO} ${del_keys}|${SED} -e "s/ *${k}//g"`
#       echo del_keys=${del_keys}
#       echo k=$k
        case ${k} in
        Highlight)
            dot_emacs="${dot_emacs} dot.emacs-highlight-body.el"
            options_Highlight=ON
            ;;
        Citation)
            citation
#           echo options:key=${k},dot_emacs=${dot_emacs}>>/tmp/temp
            options_Citation=ON
            ;;
        Cite_Change)
            dot_emacs="${dot_emacs} dot.emacs-cite-change.el"
            options_Cite_Change=ON
            ;;
        Sign_Change)
            dot_emacs="${dot_emacs} dot.emacs-signature-change.el"
            options_Sign_Change=ON
            ;;
        esac
    done
#   exit 1
    for k in ${del_keys}; do
#       echo k=$k
        case ${k} in
        Highlight)
            dot_emacs=`${ECHO} ${dot_emacs}|${SED} -e "s/ *dot\.emacs-highlight-body\.el//"`
            options_Highlight=OFF
            ;;
        Citation)
            options_Citation=OFF
            ;;
        Cite_Change)
            dot_emacs=`${ECHO} ${dot_emacs}|${SED} -e "s/ *dot\.emacs-cite-change\.el//"`
            options_Cite_Change=OFF
            ;;
        Sign_Change)
            dot_emacs=`${ECHO} ${dot_emacs}|${SED} -e "s/ *dot\.emacs-signature-change\.el//"`
            options_Sign_Change=OFF
            ;;
        esac
    done
#   echo dot_emacs=${dot_emacs}
#   echo del_keys=${del_keys}
#   exit 1
}

citation()
{
    dot_emacs=`${ECHO} ${dot_emacs}|${SED} -e "s/ *dot\.emacs-cite.[a-z]*//g"`
    case ${language} in
    English)
        dot_emacs="${dot_emacs} dot.emacs-cite.el"
        ;;
    Japanese)
        dot_emacs="${dot_emacs} dot.emacs-cite.ja.el"
        ;;
    esac
#   echo citation:key=${key},dot_emacs=${dot_emacs}>>/tmp/temp
}

case ${TERM} in
emacs)
    ${ECHO} "Here is \"Emacs\" shell. Try on other terminal."
    exit 1
    ;;
esac

version="%%VERSION%%"
#version="1.92"

SEDCMD='${SED}
    -e "s,%%prefix%%,${PREFIX},g"
    -e "s,%%emacsdir%%,${EMACSDIR},g"
    -e "s,%%elispdir%%,${ELISPDIR},g"
    -e "s,%%version%%,${version},g"
    -e "s,%%nameserver%%,${nameserver},g"
    -e "s,%%mail_address%%,${mail_address},g"
    -e "s,%%domain_name%%,${domain_name},g"
    -e "s,%%default_domain_name%%,${default_domain_name},g"
    -e "s,%%signature%%,${signature},g"'

###
# Check ~/.backup directory exist.
#
${MKDIR} ${HOME}/.backup

###
# Backup all files.
#
${CP} ${HOME}/${dot_emacs_file} ${HOME}/.backup/${dot_emacs_file}.$$
${CP} ${HOME}/.im/Config ${HOME}/.backup/Config.$$

###
# Check ~/.im/Config file exist.
#
if [ ! -f ${HOME}/.im/Config ]; then
    ${ECHO} "${HOME}/.im/Config: Not found. Do imsetup first."
    exit 1
else
    mail_address=`${AWK} '/^Address=/{sub(/^Address=/,"");print}' ${HOME}/.im/Config`
    domain_name=`${AWK} '/^FromDomain=/{sub(/^FromDomain=/,"");print}' ${HOME}/.im/Config`
    default_domain_name=`${AWK} '/^ToDomain=/{sub(/^ToDomain=/,"");print}' ${HOME}/.im/Config`
    if [ X"${mail_address}" = "X%%mail_address%%" ]; then
        mail_address=""
    else
        ${CP} ${HOME}/.im/Config ${HOME}/.backup/Config
        ${SED} -e 's/^\(Address=\).*$/\1%%mail_address%%/' \
            < ${HOME}/.backup/Config > ${HOME}/.im/Config
    fi
    if [ X"${domain_name}" = "X%%domain_name%%" ]; then
        domain_name=""
    else
        ${CP} ${HOME}/.im/Config ${HOME}/.backup/Config
        ${SED} -e 's/^\(FromDomain=\).*$/\1%%domain_name%%/' \
            < ${HOME}/.backup/Config > ${HOME}/.im/Config
    fi
    if [ X"${default_domain_name}" = "X%%default_domain_name%%" ]; then
        default_domain_name=""
    else
        ${CP} ${HOME}/.im/Config ${HOME}/.backup/Config
        ${SED} -e 's/^\(ToDomain=\).*$/\1%%default_domain_name%%/' \
            < ${HOME}/.backup/Config > ${HOME}/.im/Config
    fi
fi

###
# Copy "aliases" if none
#
if [ ! -f ${HOME}/.im/Aliases ]; then   
    ${CP} ${SAMPLEDIR}/Aliases ${HOME}/.im
fi

###
# Set user environment : nameserver, signature
#
options_Highlight=OFF
options_Citation=OFF
options_Cite_Change=OFF
options_Sign_Change=OFF
language=English
dot_emacs_file=.emacs

PreSet="\
This is the main menu of the Mew configuration pre-settings. Please \n\
select one of the options below by using the arrow keys or typing the \n\
first character of the option name you intend to set. Invoke an option \n\
by pressing [ENTER] or [TAB-ENTER] to exit the settings."

answer=None
while [ ! X"${answer}" = "XQuit" ]; do
    ${DIALOG} --title "Pre-set Mew configurations" \
    --hline "To select an item press [Enter] on the item" \
    --menu "${PreSet}" -1 -1 3 \
    Language    "Determine language in use on Mew" \
    DotEmacs    "Choose dot.emacs files being to use" \
    Quit        "Quit this menu" \
        2>  /tmp/menu.$$
    retval=$?
    answer=`${CAT} /tmp/menu.$$|${SED} -e 's/\"//g'`
    ${RM} -f /tmp/menu.$$
    case $retval in
        0) if [ -z ${answer} ]; then ${ECHO} "Nothing selected"; contiue; fi ;;
        1) break ;;
        255) break ;;
    esac
    case ${answer} in
        Language)
            select
            ;;
        DotEmacs)
            input_data "Emacs dot.emacs file name" "dot_emacs_file" ""
            ;;
        Quit)
            answer=Quit
            ;;
    esac
done

#echo language=${language}
#echo dot_emacs_file=${dot_emacs_file}
#exit 1

MainMenu="\
This is the main menu of the Mew configuration settings. Please select \n\
one of the options below by using the arrow keys or typing the first \n\
character of the option name you intend to set. Invoke an option by \n\
pressing [ENTER] or [TAB-ENTER] to exit the settings."

answer=None
while [ ! X"${answer}" = "XQuit" ]; do
    ${DIALOG} --title "Set Mew configurations" \
    --hline "Select Items and Quit when finished" \
    --menu "${MainMenu}" -1 -1 6 \
    NameServer  "Name server Domain name" \
    MailAddress "Your mail address (with FQDN)" \
    DomainName  "Your domain name" \
    DefaultDomain   "Default domain name in abbrivation" \
    Options     "Various options on using Mew" \
    Quit        "Quit this menu" \
        2>  /tmp/menu.$$
    retval=$?
    answer=`${CAT} /tmp/menu.$$`
    ${RM} -f /tmp/menu.$$
    case $retval in
        0)  if [ -z ${answer} ]; then
                ${ECHO} "Nothing selected"
                exit 1
            fi
            ;;
        1)  ${ECHO} "Cancel pressed."
            exit 1
            ;;
        255)    ${ECHO} "ESC pressed."
            exit 1
            ;;
    esac
    case ${answer} in
        NameServer)
            input_data "Name Server" "nameserver" ""
            ;;
        MailAddress)
            input_data "Mail Address" "mail_address" ""
            ;;
        DomainName)
            input_data "Domain Name" "domain_name" ""
            ;;
        DefaultDomain)
            input_data "Default Domain Name" "default_domain_name" ""
            ;;
        Options)
#           options
            ;;
        Quit)
            answer=Quit
            ;;
    esac
done

#echo 'nameserver='${nameserver}
#echo 'mail_address='${mail_address}
#echo 'domain_name='${domain_name}
#echo 'defaut_domain_name='${default_domain_name}

#exit 1

###
# Custumize startup files with selected options.
#
dot_emacs="dot.emacs.el ${dot_emacs}"
eval ${SEDCMD} < ${HOME}/.im/Config > ${HOME}/.backup/Config

###
# Add Mew startup setting to ~/.emacs
#
if [ -f ${dot_emacs_file} ]; then
    ${SED} -e '/^;;;* Mew ;*$/,/^;;; *Mew end$/d' < ${HOME}/${dot_emacs_file} \
    > ${HOME}/.backup/${dot_emacs_file}
else
    ${ECHO} "Create new \"dot.emacs\" file: ${dot_emacs_file}"
fi

#echo 'dot_emacs='${dot_emacs}
for f in ${dot_emacs}; do
    ${CAT} ${SAMPLEDIR}/dot.emacs/${f} |\
        eval ${SEDCMD} >> ${HOME}/.backup/${dot_emacs_file}
done
${ECHO} ";;;                                                       Mew end" \
    >> ${HOME}/.backup/${dot_emacs_file}
${CP} ${HOME}/.backup/${dot_emacs_file} ${HOME}/${dot_emacs_file}

###
# Copy im Config file  to ~/.im
#
${CP} ${HOME}/.backup/Config ${HOME}/.im/Config