Sync with semi-1_14 branch.
[elisp/semi.git] / mime-view.el
index 2955e63..1f53690 100644 (file)
@@ -631,6 +631,19 @@ Each elements are regexp of field-name.")
 (define-calist-field-match-method
   'body #'mime-calist::field-match-method-as-default-rule)
 
+(defun mime-calist::field-match-method-ignore-case (calist
+                                                   field-type field-value)
+  (let ((s-field (assoc field-type calist)))
+    (cond ((null s-field)
+          (cons (cons field-type field-value) calist))
+         ((eq field-value t)
+          calist)
+         ((string= (downcase (cdr s-field)) (downcase field-value))
+          calist))))
+
+(define-calist-field-match-method
+  'access-type #'mime-calist::field-match-method-ignore-case)
+
 
 (defvar mime-preview-condition nil
   "Condition-tree about how to display entity.")
@@ -978,20 +991,22 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t.  t means default."
            (kill-all-local-variables)
            (mime-view-insert-text-content entity situation)
            (require 'font-lock)
-           ;; Inhibit font-lock this time (*-mode-hook might run
-           ;; `turn-on-font-lock') so that jit-lock may not turn off
-           ;; font-lock immediately after this.
-           (let ((font-lock-mode t))
+           (let ((font-lock-maximum-size nil)
+                 ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
+                 (font-lock-mode-hook nil)
+                 (font-lock-support-mode nil)
+                 ;; I find font-lock a bit too verbose.
+                 (font-lock-verbose nil))
              (cond (mode
                     (funcall mode))
                    ((setq filename (mime-entity-filename entity))
                     (let ((buffer-file-name
                            (expand-file-name (file-name-nondirectory filename)
                                              temporary-file-directory)))
-                      (set-auto-mode)))))
-           (let ((font-lock-verbose nil))
-             ;; I find font-lock a bit too verbose.
-             (font-lock-fontify-buffer))
+                      (set-auto-mode))))
+             ;; The mode function might have already turned on font-lock.
+             (unless (symbol-value 'font-lock-mode)
+               (font-lock-fontify-buffer)))
            ;; By default, XEmacs font-lock uses non-duplicable text
            ;; properties.  This code forces all the text properties
            ;; to be copied along with the text.