Skip to content

Instantly share code, notes, and snippets.

@amuramatsu
Created April 24, 2017 14:44
Show Gist options
  • Save amuramatsu/3173b72d08c6f4d55b4e355fa0092922 to your computer and use it in GitHub Desktop.
Save amuramatsu/3173b72d08c6f4d55b4e355fa0092922 to your computer and use it in GitHub Desktop.
diff -ruN emh-1.14.1-orig/EMH-ELS emh-1.14.1/EMH-ELS
--- emh-1.14.1-orig/EMH-ELS 2000-12-20 17:53:25.000000000 +0900
+++ emh-1.14.1/EMH-ELS 2017-04-24 23:40:12.000000000 +0900
@@ -6,6 +6,6 @@
;; (require 'mh-e)
-(setq emh-modules '(emh emh-def emh-face emh-comp emh-setup))
+(setq emh-modules '(emh emh-def emh-face emh-comp emh-setup mh-e-hack))
;;; EMH-ELS ends here
diff -ruN emh-1.14.1-orig/emh.el emh-1.14.1/emh.el
--- emh-1.14.1-orig/emh.el 2000-12-25 18:44:56.000000000 +0900
+++ emh-1.14.1/emh.el 2013-11-17 00:25:42.000000000 +0900
@@ -67,6 +67,7 @@
(buffer-name folder-buffer)
folder-buffer)))
+(defun mh-display-msg-redefine ()
(defun mh-display-msg (msg-num folder &optional show-buffer mode)
"Display message number MSG-NUM of FOLDER.
This function uses `mime-view-mode' if MODE is not nil. If MODE is
@@ -149,6 +150,11 @@
folder msg-num)))
(set-buffer folder)
(setq mh-showing-with-headers nil)))))
+) ;; end of mh-display-msg-redefine
+;; redefine after load mh-show in mh-e version 8 or later
+(if (>= (string-to-number (car (split-string mh-version "\\."))) 8)
+ (eval-after-load "mh-show" '(mh-display-msg-redefine))
+ (mh-display-msg-redefine))
(defun emh-view-message (&optional msg)
"MIME decode and play this message."
diff -ruN emh-1.14.1-orig/mh-e-hack.el emh-1.14.1/mh-e-hack.el
--- emh-1.14.1-orig/mh-e-hack.el 1970-01-01 09:00:00.000000000 +0900
+++ emh-1.14.1/mh-e-hack.el 2013-11-16 23:44:31.000000000 +0900
@@ -0,0 +1,104 @@
+;;; mh-e-hack.el --- MH-E 7.8x hack for mh-jp.
+;;; $Id: mh-e-hack.el,v 1.8 2006/03/12 04:45:42 amura Exp $
+
+;; Author: MURAMATSU Atsushi <amura@tomato.sakura.ne.jp>
+;; Keywords: mh-e, mail, MIME
+
+;; Some codes are picked from MH-E 7.82
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; mh-jp does not have flist(s) command
+(setq mh-flists-present-flag nil)
+
+;; use iso-2022-jp for sendmail
+(setq sendmail-coding-system 'iso-2022-jp)
+
+;; Create message in iso-2022-jp
+(add-hook 'mh-letter-mode-hook
+ '(lambda ()
+ (set-buffer-file-coding-system 'iso-2022-jp)
+ (set-buffer-modified-p nil)))
+
+;; With t-gnus, Gnus composion does not activate.
+(setq mh-compose-insertion 'mhn)
+
+;; Without content-type, mh-e assume coding system as iso-2022-jp.
+(defadvice mm-decode-body (before mm-decode-body-jp activate)
+ (unless (ad-get-arg 0) (ad-set-arg 0 "ISO-2022-JP")))
+
+;; scan hack (fontlock)
+(eval-after-load "mh-folder" '(progn
+ (setq mh-scan-subject-hack-regexp "^ *[0-9]+........[ ]*\\(.\\)\\([^\n]*\\)")
+ (setq mh-scan-subject-re-regexp "\\s-[Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-")
+ (setq mh-scan-subject-end "\\(<<\\|\n\\)")
+ (setq mh-scan-name-width 18)
+
+ (defun mh-folder-font-lock-subject (limit)
+ "Return MH-E scan subject strings to font-lock between point and LIMIT."
+ (defun mh-xwidthpos (str width n)
+ (if (>= (string-width (substring str 0 n)) width)
+ n
+ (mh-xwidthpos str width (+ n 1))))
+ (if (not (re-search-forward mh-scan-subject-hack-regexp limit t))
+ nil
+ (let* ((ss-offset (match-beginning 1))
+ (ss (buffer-substring (match-beginning 1) (match-end 2)))
+ (s1 (mh-xwidthpos ss mh-scan-name-width 1))
+ (e1 (string-match mh-scan-subject-end ss s1))
+ (s (+ s1 ss-offset))
+ (e (+ (if (not e1) (length ss) e1) ss-offset)))
+ (if (string-match mh-scan-subject-re-regexp
+ (buffer-substring (- s 1) e))
+ (set-match-data (list s e s e nil nil))
+ (set-match-data (list s e nil nil s e)))
+ t)))))
+
+;; scan hack (thread)
+(eval-after-load "mh-thread" '(progn
+ (defun mh-thread-parse-scan-line (&optional string)
+ "Parse a scan line.
+If optional argument STRING is given then that is assumed to be the scan line.
+Otherwise uses the line at point as the scan line to parse."
+ (defun mh-xsubstring (str from &optional to)
+ (defun mh-xtruncwidth (str width start rev)
+ (if (< (string-width (substring str 0 start)) width)
+ (mh-xtruncwidth str width (+ start 1) rev)
+ (if (> (string-width (substring str 0 start)) width)
+ (if rev
+ (concat " " (substring str start))
+ (concat (substring str 0 (- start 1)) " "))
+ (if rev
+ (substring str start)
+ (substring str 0 start)))))
+ (let ((s (mh-xtruncwidth str from 0 t)))
+ (if to
+ (mh-xtruncwidth s (- to from) 1 nil)
+ s)))
+ (let* ((string (or string
+ (buffer-substring-no-properties (line-beginning-position)
+ (line-end-position))))
+ (address-start (+ mh-cmd-note mh-scan-field-from-start-offset))
+ (body-start (+ mh-cmd-note mh-scan-field-from-end-offset))
+ (first-string (mh-xsubstring string 0 address-start)))
+ (list first-string
+ (mh-xsubstring string address-start (- body-start 2))
+ (mh-xsubstring string body-start)
+ string)))))
+
+(provide 'mh-e-hack)
+
+;;; mh-e-hack.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment