;; For composing/editing mail from Mutt, using the mutteditor script (setq mutteditor-pid-alist nil) (defun mutteditor-kill () (let ((a (assoc (current-buffer) mutteditor-pid-alist))) (when a (signal-process (cdr a) 'CONT) (setq mutteditor-pid-alist (delq a mutteditor-pid-alist)) ))) (add-hook 'kill-buffer-hook 'mutteditor-kill) ;(add-to-list 'auto-coding-alist ; `("/mutt-.*-[0-9]+-[0-9]+-[0-9]+\\'" . ,locale-coding-system)) (defun mutt-search-header (regexp) (goto-char (point-min)) (while (not (or (eolp) (looking-at regexp))) (forward-line 1)) (not (eolp)) ) (defun mutt-find-file-coding-system (arg-list) "\ Determine the coding system of a mail file. Use the current locale if the file doesn't declare a charset (in practice, when composing a mail message instead of editing one). This is a heuristic." (if (eq (car arg-list) 'insert-file-contents) (let ((case-fold-search t)) (save-excursion (goto-char (point-min)) (cond ((looking-at "^From:") ;; Composed mail (new mail or reply). locale-coding-system) ((and (mutt-search-header "Content-Transfer-Encoding: 8bit") (mutt-search-header "Content-Type:.*charset=\"?\\([-0-9a-z]*\\)")) (let ((charset (intern (downcase (match-string 1))))) (if (memq charset (coding-system-list)) (progn (message "Found charset %s in header." charset) charset) 'undecided-unix))) (t 'undecided-unix)))) 'undecided-unix) ) (modify-coding-system-alist 'file "/mutt-.*-[0-9]+-[0-9]+-[0-9]+\\'" 'mutt-find-file-coding-system) (add-hook 'find-file-hook (lambda () (when (string-match "^mutt-.*-[0-9]+-[0-9]+-[0-9]+$" (file-name-nondirectory (buffer-file-name))) (set (make-local-variable 'backup-inhibited) t) ;; The following code is executed only when composing messages ;; (new messages or replies), not when editing messages (which ;; start with "From ") from the mailbox. (when (looking-at "^From:") ;; See message <20070114224513$4fbd@prunille.vinc17.org> ;; in fr.comp.applications.emacs (2007-01-14T23:21:51Z). (flush-lines "^\\(> \n\\)*> -- \\(\\(\n> .*\\)+\\|$\\)") (not-modified) (search-forward "\n\n" nil t)) (mail-mode) (add-to-list 'mail-font-lock-keywords '("^X-Warning:" . font-lock-warning-face)) ))) ;; $Id: mutteditor.el 128006 2020-05-27 18:57:01Z vinc17/zira $