changeset 68137:ec4727559827

* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Move here from mh-gnus.el. * mh-gnus.el: Require mh-acros. (mh-defmacro-compat, mh-defun-compat): Move to mh-acros.el. * mh-utils.el (url-unreserved-chars, url-hexify-string): Define if not defined. Copied from url-util.el in Emacs22 for Emacs 21.
author Bill Wohler <wohler@newt.com>
date Wed, 11 Jan 2006 21:02:35 +0000
parents 98275190ec04
children d47ecb3cad92
files lisp/mh-e/ChangeLog lisp/mh-e/mh-acros.el lisp/mh-e/mh-gnus.el lisp/mh-e/mh-utils.el
diffstat 4 files changed, 68 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mh-e/ChangeLog	Wed Jan 11 20:15:38 2006 +0000
+++ b/lisp/mh-e/ChangeLog	Wed Jan 11 21:02:35 2006 +0000
@@ -1,5 +1,19 @@
 2006-01-11  Bill Wohler  <wohler@newt.com>
 
+	* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Move here
+	from mh-gnus.el.
+
+	* mh-gnus.el: Require mh-acros.
+	(mh-defmacro-compat, mh-defun-compat): Move to mh-acros.el.
+
+	* mh-utils.el (mh-x-image-url-cache-canonicalize): Use
+	url-hexify-string to remove special characters from filenames
+	(closes SF #1396499). Note that this invalidates the existing
+	names in your cache so you might as well remove
+	~/Mail/.mhe-x-image-cache/* now.
+	(url-unreserved-chars, url-hexify-string): Define if not defined.
+	Copied from url-util.el in Emacs22 for Emacs 21.
+
 	* mh-buffers.el: New file. Contains constants and code from
 	mh-index.el and mh-utils.el.
 
@@ -27,12 +41,6 @@
 	* mh-comp.el (mh-forward): Cosmetics on prompt when draft exists.
 	(mh-send-letter): Add -msgid to mh-send-args (closes SF #725425).
 
-	* mh-utils.el (mh-x-image-url-cache-canonicalize): Use
-	url-hexify-string to remove special characters from filenames
-	(closes SF #1396499). Note that this invalidates the existing
-	names in your cache so you might as well remove
-	~/Mail/.mhe-x-image-cache/* now.
-	
 2006-01-10  Bill Wohler  <wohler@newt.com>
 
 	* mh-comp.el (mh-insert-letter): If you choose a different folder,
--- a/lisp/mh-e/mh-acros.el	Wed Jan 11 20:15:38 2006 +0000
+++ b/lisp/mh-e/mh-acros.el	Wed Jan 11 21:02:35 2006 +0000
@@ -1,6 +1,6 @@
 ;;; mh-acros.el --- Macros used in MH-E
 
-;; Copyright (C) 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2006 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -74,6 +74,26 @@
     `(when (fboundp ',function)
        (funcall ',function ,@args))))
 
+(defmacro mh-defun-compat (function arg-list &rest body)
+  "This is a macro to define functions which are not defined.
+It is used for functions which were added to Emacs recently.
+If FUNCTION is not defined then it is defined to have argument
+list, ARG-LIST and body, BODY."
+  (let ((defined-p (fboundp function)))
+    (unless defined-p
+      `(defun ,function ,arg-list ,@body))))
+(put 'mh-defun-compat 'lisp-indent-function 'defun)
+
+(defmacro mh-defmacro-compat (function arg-list &rest body)
+  "This is a macro to define functions which are not defined.
+It is used for macros which were added to Emacs recently.
+If FUNCTION is not defined then it is defined to have argument
+list, ARG-LIST and body, BODY."
+  (let ((defined-p (fboundp function)))
+    (unless defined-p
+      `(defmacro ,function ,arg-list ,@body))))
+(put 'mh-defmacro-compat 'lisp-indent-function 'defun)
+
 (defmacro mh-make-local-hook (hook)
   "Make HOOK local if needed.
 XEmacs and versions of GNU Emacs before 21.1 require
--- a/lisp/mh-e/mh-gnus.el	Wed Jan 11 20:15:38 2006 +0000
+++ b/lisp/mh-e/mh-gnus.el	Wed Jan 11 21:02:35 2006 +0000
@@ -1,6 +1,6 @@
 ;;; mh-gnus.el --- Make MH-E compatible with installed version of Gnus.
 
-;; Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -30,6 +30,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'mh-acros))
+
 ;; Load libraries in a non-fatal way in order to see if certain functions are
 ;; pre-defined.
 (load "mailabbrev" t t)
@@ -39,34 +41,14 @@
 (load "mml" t t)
 (load "smiley" t t)
 
-(defmacro mh-defun-compat (function arg-list &rest body)
-  "This is a macro to define functions which are not defined.
-It is used for Gnus utility functions which were added recently.
-If FUNCTION is not defined then it is defined to have argument
-list, ARG-LIST and body, BODY."
-  (let ((defined-p (fboundp function)))
-    (unless defined-p
-      `(defun ,function ,arg-list ,@body))))
-(put 'mh-defun-compat 'lisp-indent-function 'defun)
-
-(defmacro mh-defmacro-compat (function arg-list &rest body)
-  "This is a macro to define functions which are not defined.
-It is used for Gnus utility functions which were added recently.
-If FUNCTION is not defined then it is defined to have argument
-list, ARG-LIST and body, BODY."
-  (let ((defined-p (fboundp function)))
-    (unless defined-p
-      `(defmacro ,function ,arg-list ,@body))))
-(put 'mh-defmacro-compat 'lisp-indent-function 'defun)
-
-;; Copy of original function from gnus-util.el.
+;; Copy of function from gnus-util.el.
 (mh-defun-compat gnus-local-map-property (map)
   "Return a list suitable for a text property list specifying keymap MAP."
   (cond (mh-xemacs-flag (list 'keymap map))
         ((>= emacs-major-version 21) (list 'keymap map))
         (t (list 'local-map map))))
 
-;; Copy of original function from mm-decode.el.
+;; Copy of function from mm-decode.el.
 (mh-defun-compat mm-merge-handles (handles1 handles2)
   (append (if (listp (car handles1)) handles1 (list handles1))
           (if (listp (car handles2)) handles2 (list handles2))))
@@ -96,11 +78,11 @@
 (mh-defun-compat mm-possibly-verify-or-decrypt (parts ctl)
   nil)
 
-;; Copy of original macro is in mm-decode.el.
+;; Copy of macro in mm-decode.el.
 (mh-defmacro-compat mm-handle-multipart-ctl-parameter (handle parameter)
   `(get-text-property 0 ,parameter (car ,handle)))
 
-;; Copy of original function in mm-decode.el.
+;; Copy of function in mm-decode.el.
 (mh-defun-compat mm-readable-p (handle)
   "Say whether the content of HANDLE is readable."
   (and (< (with-current-buffer (mm-handle-buffer handle)
@@ -110,7 +92,7 @@
          (and (eq (mm-body-7-or-8) '7bit)
               (not (mm-long-lines-p 76))))))
 
-;; Copy of original function in mm-bodies.el.
+;; Copy of function in mm-bodies.el.
 (mh-defun-compat mm-long-lines-p (length)
   "Say whether any of the lines in the buffer is longer than LENGTH."
   (save-excursion
@@ -132,7 +114,7 @@
   "Older versions of Emacs don't have this function."
   nil)
 
-;; Copy of original function in mml.el.
+;; Copy of function in mml.el.
 (mh-defun-compat mml-minibuffer-read-disposition (type &optional default)
   (unless default (setq default
                         (if (and (string-match "\\`text/" type)
--- a/lisp/mh-e/mh-utils.el	Wed Jan 11 20:15:38 2006 +0000
+++ b/lisp/mh-e/mh-utils.el	Wed Jan 11 21:02:35 2006 +0000
@@ -1466,6 +1466,30 @@
   "Scale image in INPUT file and write to OUTPUT file using ImageMagick."
   (call-process "convert" nil nil nil "-geometry" "96x48" input output))
 
+;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21.
+(if (not (boundp 'url-unreserved-chars))
+    (defconst url-unreserved-chars
+      '(
+        ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z
+        ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z
+        ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
+        ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\))
+      "A list of characters that are _NOT_ reserved in the URL spec.
+This is taken from RFC 2396."))
+
+;; Copy of function from url-util.el in Emacs 22; needed by Emacs 21.
+(mh-defun-compat url-hexify-string (str)
+  "Escape characters in a string."
+  (mapconcat
+   (lambda (char)
+     ;; Fixme: use a char table instead.
+     (if (not (memq char url-unreserved-chars))
+	 (if (> char 255)
+	       (error "Hexifying multibyte character %s" str)
+	   (format "%%%02X" char))
+       (char-to-string char)))
+   str ""))
+
 (defun mh-x-image-url-cache-canonicalize (url)
   "Canonicalize URL.
 Replace the ?/ character with a ?! character and append .png.