diff --git a/src/freedombone-app-emacs b/src/freedombone-app-emacs index a464a94c..c3048ec3 100755 --- a/src/freedombone-app-emacs +++ b/src/freedombone-app-emacs @@ -33,11 +33,6 @@ VARIANTS='full' emacs_variables=(USB_MOUNT MY_USERNAME) -function install_interactive_emacs { - echo -n '' - APP_INSTALLED=1 -} - function change_password_emacs { echo -n '' } @@ -109,9 +104,27 @@ function remove_emacs { apt-get -y remove --purge emacs24 update-alternatives --set editor /usr/bin/nano sed -i '/install_emacs/d' $COMPLETION_FILE + + # remove emacs as the mutt email editor + if [ -f /etc/Muttrc ]; then + if grep -q "set editor=" /etc/Muttrc; then + sed -i '/set editor=/d' /etc/Muttrc + fi + for d in /home/*/ ; do + USERNAME=$(echo "$d" | awk -F '/' '{print $3}') + if [[ $(is_valid_user "$USERNAME") == "1" ]]; then + if [ -f /home/$USERNAME/.muttrc ]; then + if grep -q "set editor=" /home/$USERNAME/.muttrc; then + sed -i '/set editor=/d' /home/$USERNAME/.muttrc + fi + fi + fi + done + fi } function install_emacs { + apt-get -y install emacs24 update-alternatives --set editor /usr/bin/emacs24 # A minimal emacs configuration @@ -186,7 +199,62 @@ function install_emacs { echo '(epa-file-enable)' >> /home/$MY_USERNAME/.emacs cp /home/$MY_USERNAME/.emacs /root/.emacs chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs + + # add a mutt entry to use emacs to compose emails + if [ -f /etc/Muttrc ]; then + if ! grep -q "set editor=" /etc/Muttrc; then + echo 'set editor="emacs -q --load ~/.emacs-mutt"' >> /etc/Muttrc + else + sed -i 's|set editor=.*|set editor="emacs -q --load ~/.emacs-mutt"|g' /etc/Muttrc + fi + for d in /home/*/ ; do + USERNAME=$(echo "$d" | awk -F '/' '{print $3}') + if [[ $(is_valid_user "$USERNAME") == "1" ]]; then + if [ -f /home/$USERNAME/.muttrc ]; then + if ! grep -q "set editor=" /home/$USERNAME/.muttrc; then + echo 'set editor="emacs -q --load ~/.emacs-mutt"' >> /home/$USERNAME/.muttrc + else + sed -i 's|set editor=.*|set editor="emacs -q --load ~/.emacs-mutt"|g' /home/$USERNAME/.muttrc + fi + fi + + # create an Emacs configuration specifically for use with Mutt, which + # has word wrap and spell checking on by default + if [ ! -f /home/$USERNAME/.emacs-mutt ]; then + echo "(add-hook 'before-save-hook 'delete-trailing-whitespace)" > /home/$USERNAME/.emacs-mutt + echo '(setq org-support-shift-select t)' >> /home/$USERNAME/.emacs-mutt + echo '(setq standard-indent 4)' >> /home/$USERNAME/.emacs-mutt + echo '(setq-default tab-width 4)' >> /home/$USERNAME/.emacs-mutt + echo '(setq c-basic-offset 4)' >> /home/$USERNAME/.emacs-mutt + echo '(mouse-wheel-mode t)' >> /home/$USERNAME/.emacs-mutt + echo '(setq make-backup-files t)' >> /home/$USERNAME/.emacs-mutt + echo '(setq version-control t)' >> /home/$USERNAME/.emacs-mutt + echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> /home/$USERNAME/.emacs-mutt + echo "(setq default-major-mode 'text-mode)" >> /home/$USERNAME/.emacs-mutt + echo "(dolist (hook '(text-mode-hook))" >> /home/$USERNAME/.emacs-mutt + echo ' (add-hook hook (lambda () (flyspell-mode 1))))' >> /home/$USERNAME/.emacs-mutt + echo '(setq-default fill-column 72)' >> /home/$USERNAME/.emacs-mutt + echo '(setq auto-fill-mode 0)' >> /home/$USERNAME/.emacs-mutt + echo "(add-hook 'text-mode-hook 'turn-on-auto-fill)" >> /home/$USERNAME/.emacs-mutt + echo "(setq-default auto-fill-function 'do-auto-fill)" >> /home/$USERNAME/.emacs-mutt + chown $USERNAME:$USERNAME /home/$USERNAME/.emacs-mutt + + # add the emacs mutt configuration to the user profile skeleton + if [ ! -f /etc/skel/.emacs-mutt ]; then + cp /home/$USERNAME/.emacs-mutt /etc/skel/.emacs-mutt + chown root:root /etc/skel/.emacs-mutt + fi + fi + + fi + done + fi + APP_INSTALLED=1 } +function install_interactive_emacs { + install_emacs +} + # NOTE: deliberately no exit 0 diff --git a/src/freedombone-base-email b/src/freedombone-base-email index 57c98dc5..8270a931 100755 --- a/src/freedombone-base-email +++ b/src/freedombone-base-email @@ -279,7 +279,6 @@ function email_client { echo 'set trash="+Trash"' >> /etc/Muttrc echo 'set spoolfile="~/Maildir"' >> /etc/Muttrc echo 'auto_view text/x-vcard text/html text/enriched' >> /etc/Muttrc - echo 'set editor="emacs -q --load ~/.emacs-mutt"' >> /etc/Muttrc echo 'set header_cache="+.cache"' >> /etc/Muttrc echo '' >> /etc/Muttrc echo 'macro index S "=.learn-spam" "move to learn-spam"' >> /etc/Muttrc @@ -356,36 +355,10 @@ function email_client { echo '# Optional relay of SMTP via ISP' >> /etc/Muttrc echo '#set smtp_url="smtps://username:password@isp_mail_domain:465/"' >> /etc/Muttrc - # create an Emacs configuration specifically for use with Mutt, which - # has word wrap and spell checking on by default - echo "(add-hook 'before-save-hook 'delete-trailing-whitespace)" > /home/$MY_USERNAME/.emacs-mutt - echo '(setq org-support-shift-select t)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq standard-indent 4)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq-default tab-width 4)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq c-basic-offset 4)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(mouse-wheel-mode t)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq make-backup-files t)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq version-control t)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> /home/$MY_USERNAME/.emacs-mutt - echo "(setq default-major-mode 'text-mode)" >> /home/$MY_USERNAME/.emacs-mutt - echo "(dolist (hook '(text-mode-hook))" >> /home/$MY_USERNAME/.emacs-mutt - echo ' (add-hook hook (lambda () (flyspell-mode 1))))' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq-default fill-column 72)' >> /home/$MY_USERNAME/.emacs-mutt - echo '(setq auto-fill-mode 0)' >> /home/$MY_USERNAME/.emacs-mutt - echo "(add-hook 'text-mode-hook 'turn-on-auto-fill)" >> /home/$MY_USERNAME/.emacs-mutt - echo "(setq-default auto-fill-function 'do-auto-fill)" >> /home/$MY_USERNAME/.emacs-mutt - - # add the emacs mutt configuration to the user profile skeleton - if [ ! -f /etc/skel/.emacs-mutt ]; then - cp /home/$MY_USERNAME/.emacs-mutt /etc/skel/.emacs-mutt - chown root:root /etc/skel/.emacs-mutt - fi - cp -f /etc/Muttrc /home/$MY_USERNAME/.muttrc cp -f /etc/Muttrc /etc/skel/.muttrc touch /home/$MY_USERNAME/.mutt-alias cp /home/$MY_USERNAME/.mutt-alias /etc/skel/.mutt-alias - chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs-mutt chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.muttrc chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.mutt-alias @@ -395,8 +368,6 @@ function email_client { chown ${GENERIC_IMAGE_USERNAME}:${GENERIC_IMAGE_USERNAME} /home/${GENERIC_IMAGE_USERNAME}/.muttrc touch /home/${GENERIC_IMAGE_USERNAME}/.mutt-alias chown ${GENERIC_IMAGE_USERNAME}:${GENERIC_IMAGE_USERNAME} /home/${GENERIC_IMAGE_USERNAME}/.mutt-alias - cp /etc/skel/.emacs-mutt /home/${GENERIC_IMAGE_USERNAME}/.emacs-mutt - chown ${GENERIC_IMAGE_USERNAME}:${GENERIC_IMAGE_USERNAME} /home/${GENERIC_IMAGE_USERNAME}/.emacs-mutt fi echo 'email_client' >> $COMPLETION_FILE diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index 9ca42a48..52a4d4a8 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -332,9 +332,6 @@ function setup_utils { function_check enforce_good_passwords enforce_good_passwords - function_check install_emacs - install_emacs - function_check change_login_message change_login_message