+2006-01-08 Bill Wohler <wohler@newt.com>
+
+ Removed code that was marked as Emacs 20 compatible that was
+ easily found showing how important it is to document such
+ things (closes SF #1359240). Feel free to nuke any other Emacs 20
+ peculiarities that you find. Wrapped code for shushing compiler
+ with (eval-when-compile), sometimes moving the defvars closer to
+ where they were used.
+
+ * mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
+ instead of mh-replace-in-string as mh-replace-in-string was
+ replaced by a more appropriate defsubst in mh-xemacs.el.
+
+ * mh-comp.el: Require cleanup, wrap compiler-shushing defvars with
+ eval-when-compile.
+ (mh-file-is-vcard-p): Removed redundant test.
+
+ * mh-customize.el: Require cleanup, wrap compiler-shushing defvars
+ with eval-when-compile.
+ (mh-adaptive-cmd-note-flag, mh-invisible-header-fields)
+ (mh-invisible-header-fields-default): Add forward definitions.
+ (mh-invisible-header-fields-default): Alphabetize.
+
+ * mh-e.el: Require cleanup, wrap compiler-shushing defvars with
+ eval-when-compile.
+ (mh-thread-scan-line-map-stack, tool-bar-mode): Delete unused
+ variables.
+ (mh-colors-available-p): Just call display-color-cells. It's on
+ all supported Emacsen (and defaliased on XEmacs).
+
+ * mh-funcs.el:
+ * mh-inc.el:
+ * mh-init.el: Wrap compiler-shushing defvars with
+ eval-when-compile.
+
+ * mh-identity.el: Don't need (mh-require-cl).
+
+ * mh-index.el: Don't need to load executable any more.
+
+ * mh-mime.el: Wrap compiler-shushing defvars with
+ eval-when-compile.
+ (mh-have-file-command): Initialize variable to 'undefined. Add
+ docstring. Update function of same name accordingly. Also don't
+ need to load executable any more.
+ (mh-mime-content-types): Delete.
+ (mh-minibuffer-read-type): Prompt user for type if
+ mh-file-mime-type returns application/octet-stream. Assume we have
+ mailcap-mime-types.
+ (mh-mime-display): Update error message.
+
+ * mh-seq.el: Require cleanup, and wrap compiler-shushing defvars
+ with eval-when-compile.
+
+ * mh-utils.el: Require cleanup, and wrap compiler-shushing defvars
+ with eval-when-compile.
+ (mh-clean-msg-header): Don't set after-change-functions to nil.
+ (mh-replace-in-string): Remove. Create defsubst in mh-xemacs.el
+ instead.
+
2006-01-07 Bill Wohler <wohler@newt.com>
* mh-customize.el: Updated Faces documentation in header.
(setq res (match-string 1 res)))
;; Replace "&" with capitalized username
(if (string-match "&" res)
- (setq res (mh-replace-in-string "&" (capitalize username) res)))
+ (setq res (replace-regexp-in-string "&" (capitalize username) res)))
;; Remove " character
(if (string-match "\"" res)
- (setq res (mh-replace-in-string "\"" "" res)))
+ (setq res (replace-regexp-in-string "\"" "" res)))
;; If empty string, use username instead
(if (string-equal "" res)
(setq res username))
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
-(require 'mh-e)
-(require 'gnus-util)
+
(require 'easymenu)
+(require 'gnus-util)
+(require 'mh-e)
(require 'mh-gnus)
+
(eval-when (compile load eval)
(ignore-errors (require 'mailabbrev)))
-;; Shush the byte-compiler
-(defvar adaptive-fill-first-line-regexp)
-(defvar font-lock-defaults)
-(defvar mark-active)
-(defvar sendmail-coding-system)
-(defvar mh-identity-list)
-(defvar mh-identity-default)
-(defvar mh-mml-mode-default)
-(defvar mh-identity-menu)
-
\f
+
;;; Autoloads
(autoload 'mail-mode-fill-paragraph "sendmail")
(mail-mode-fill-paragraph arg)
(fill-paragraph arg))))
-;; Avoid compiler warnings in XEmacs and Emacs 20
+;; Shush compiler.
(eval-when-compile
- (defvar tool-bar-mode)
- (defvar tool-bar-map))
+ (defvar adaptive-fill-first-line-regexp)
+ (defvar tool-bar-map)
+ (defvar font-lock-defaults)
+)
(defvar mh-letter-buttons-init-flag nil)
(file-exists-p file)
(or (and (not (mh-have-file-command))
(not (null (string-match "\.vcf$" file))))
- (and (mh-have-file-command)
- (string-equal "text/x-vcard" (mh-file-mime-type file)))))))
+ (string-equal "text/x-vcard" (mh-file-mime-type file))))))
;;;###mh-autoload
(defun mh-insert-signature (&optional file)
unless (eq charset 'ascii) return nil
finally return t))
+(eval-when-compile (defvar sendmail-coding-system)) ;shush compiler
+
;;;###mh-autoload
(defun mh-send-letter (&optional arg)
"Save draft and send message.
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
-(require 'mh-loaddefs)
(eval-and-compile
(defvar mh-xemacs-flag (featurep 'xemacs)
- "Non-nil means the current Emacs is XEmacs."))
+ "Non-nil means the current Emacs is XEmacs.")
+ (when mh-xemacs-flag
+ (require 'mh-xemacs)))
-(when mh-xemacs-flag
- (require 'mh-xemacs))
-
-;; XXX: Functions autoloaded from the following files are used to initialize
-;; customizable variables. They are require'd here, since otherwise the
-;; corresponding .elc would be loaded at compile time.
-(eval-when-compile
+(eval-and-compile
+ (require 'mh-identity)
(require 'mh-init)
- (require 'mh-identity))
+ (require 'mh-loaddefs))
;; For compiler warnings...
(eval-when-compile
;;; Scan Line Formats (:group 'mh-scan-line-formats)
-;; Forward definition to avoid compiler and runtime error.
-(defvar mh-scan-format-file t)
+(defvar mh-scan-format-file t) ;forward definition
(defun mh-adaptive-cmd-note-flag-check (symbol value)
"Check if desired setting is legal.
"is set to \"Use MH-E scan Format\"")
(set-default symbol value)))
+(defvar mh-adaptive-cmd-note-flag) ;forward definition
+
(defun mh-scan-format-file-check (symbol value)
"Check if desired setting is legal.
Throw an error if user tries to set `mh-scan-format-file' to
hidden that you wish to display, and add extra entries to hide in
`mh-invisible-header-fields'.")
+;; Forward definition.
+(defvar mh-invisible-header-fields)
+(defvar mh-invisible-header-fields-default nil)
+
(defun mh-invisible-headers ()
"Make or remake the variable `mh-invisible-header-fields-compiled'.
Done using `mh-invisible-header-fields-internal' as input, from
(regexp-opt fields t))))
(setq mh-invisible-header-fields-compiled nil))))
-(defcustom mh-invisible-header-fields-default nil
- "*List of hidden header fields.
-
-The header fields listed in this option are hidden, although you
-can check off any field that you would like to see.
-
-Header fields that you would like to hide that aren't listed can
-be added to the option `mh-invisible-header-fields'.
-
-See also `mh-clean-message-header-flag'."
- :type `(set ,@(mapcar (lambda (x) `(const ,x))
- mh-invisible-header-fields-internal))
- :set (lambda (symbol value)
- (set-default symbol value)
- (mh-invisible-headers))
- :group 'mh-show)
-
(defcustom mh-invisible-header-fields nil
"*Additional header fields to hide.
(mh-invisible-headers))
:group 'mh-show)
+(defcustom mh-invisible-header-fields-default nil
+ "*List of hidden header fields.
+
+The header fields listed in this option are hidden, although you
+can check off any field that you would like to see.
+
+Header fields that you would like to hide that aren't listed can
+be added to the option `mh-invisible-header-fields'.
+
+See also `mh-clean-message-header-flag'."
+ :type `(set ,@(mapcar (lambda (x) `(const ,x))
+ mh-invisible-header-fields-internal))
+ :set (lambda (symbol value)
+ (set-default symbol value)
+ (mh-invisible-headers))
+ :group 'mh-show)
+
(defcustom mh-lpr-command-format "lpr -J '%s'"
"*Command used to print\\<mh-folder-mode-map>.
;; MH-E is an Emacs interface to the MH mail system.
-;; MH-E is supported in GNU Emacs 20 and 21, with MH 6.8.4 and nmh 1.0.4.
+;; MH-E is supported in GNU Emacs 21 and 22 as well as XEmacs 21
+;; (except for versions 21.5.9-21.5.16), with MH 6.8.4 on, nmh 1.0.4
+;; on, and GNU mailutils 0.4 on.
;; Mailing Lists:
;; mh-e-users@lists.sourceforge.net
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
-(require 'mh-utils)
-(require 'mh-init)
-(require 'mh-inc)
-(require 'mh-seq)
-(require 'gnus-util)
-(require 'easymenu)
-;; Shush the byte-compiler
-(eval-when-compile
- (defvar font-lock-auto-fontify)
- (defvar font-lock-defaults))
+(require 'easymenu)
+(require 'gnus-util)
+(require 'mh-seq)
+(require 'mh-utils)
(defconst mh-version "7.85+cvs" "Version number of MH-E.")
(when (consp part-index) (setq part-index (car part-index)))
(mh-folder-mime-action part-index #'mh-mime-save-part nil))
-(defvar mh-thread-scan-line-map-stack)
-
(defun mh-reset-threads-and-narrowing ()
"Reset all variables pertaining to threads and narrowing.
Also removes all content from the folder buffer."
''write-file-functions ;Emacs 21.4
''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
-;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
-(eval-when-compile
- (defvar tool-bar-mode)
- (defvar tool-bar-map)
- (defvar desktop-save-buffer)) ;Emacs 21.4
-
;; Register mh-folder-mode as supporting which-function-mode...
(load "which-func" t t)
(when (and (boundp 'which-func-modes)
(not (member 'mh-folder-mode which-func-modes)))
(push 'mh-folder-mode which-func-modes))
+;; Shush compiler in non-bleeding edge versions of Emacs.
+(eval-when-compile
+ (defvar desktop-save-buffer) ;Emacs 21.4
+ (defvar font-lock-auto-fontify)
+ (defvar font-lock-defaults)
+ (defvar tool-bar-map))
+
(defvar mh-folder-buttons-init-flag nil)
;; Autoload cookie needed by desktop.el
(defun mh-colors-available-p ()
"Check if colors are available in the Emacs being used."
(or mh-xemacs-flag
- (let ((color-cells
- (or (ignore-errors (mh-funcall-if-exists display-color-cells))
- (ignore-errors (mh-funcall-if-exists
- x-display-color-cells)))))
+ (let ((color-cells (display-color-cells)))
(and (numberp color-cells) (>= color-cells 8)))))
(defun mh-colors-in-use-p ()
(re-search-forward "^rmf: " (point-max) t))
(display-buffer mh-temp-buffer)))
-;; Avoid compiler warning...
-(defvar view-exit-action)
+(eval-when-compile (defvar view-exit-action)) ;shush compile
;;;###mh-autoload
(defun mh-list-folders ()
;;; Code:
(eval-when-compile (require 'mh-acros))
-(mh-require-cl)
+
(require 'mh-comp)
(autoload 'mml-insert-tag "mml")
;;; mh-inc.el --- MH-E "inc" and separate mail spool handling
;;
-;; Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
;; Author: Peter S. Galbraith <psg@debian.org>
;; Maintainer: Bill Wohler <wohler@newt.com>
(char-to-string key)
"] inc " folder " folder\n"))))
-;; Avoid compiler warning
-(defvar mh-inc-spool-list)
+(eval-when-compile (defvar mh-inc-spool-list)) ;shush compiler
(defun mh-inc-spool-make ()
"Make all commands and defines keys for contents of `mh-inc-spool-list'."
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
+
(require 'mh-e)
(require 'mh-mime)
(require 'mh-pick)
(autoload 'gnus-local-map-property "gnus-util")
(autoload 'gnus-eval-format "gnus-spec")
(autoload 'widget-convert-button "wid-edit")
-(autoload 'executable-find "executable")
;; Support different indexing programs
(defvar mh-indexer-choices
(mh-require-cl)
(require 'mh-utils)
-;; Avoid compiler warnings.
-(eval-when-compile (defvar image-load-path))
-
;; Set for local environment:
;; mh-progs and mh-lib used to be set in paths.el, which tried to
;; figure out at build time which of several possible directories MH
\f
+(eval-when-compile (defvar image-load-path)) ;shush compiler
+
(defvar mh-image-load-path-called-flag nil)
;;;###mh-autoload
\f
+;;; Support routines for mh-customize.el
+
(defvar mh-min-colors-defined-flag (and (not mh-xemacs-flag)
(>= emacs-major-version 22))
"Non-nil means defface supports min-colors display requirement.")
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
-(require 'mh-comp)
+
(require 'gnus-util)
+(require 'mh-comp)
(require 'mh-gnus)
(autoload 'article-emphasize "gnus-art")
"/[-.+a-zA-Z0-9]+")
"Regexp matching valid media types used in MIME attachment compositions.")
-;; Just defvar the variable to avoid compiler warning... This doesn't bind
-;; the variable, so things should work exactly as before.
-(defvar mh-have-file-command)
+(defvar mh-have-file-command 'undefined
+ "Cached value of `mh-have-file-command'.
+Do not reference this variable directly as it might not have been
+initialized. Always use the command `mh-have-file-command'.")
;;;###mh-autoload
(defun mh-have-file-command ()
"Return t if 'file' command is on the system.
'file -i' is used to get MIME type of composition insertion."
- (when (not (boundp 'mh-have-file-command))
- (load "executable" t t) ; executable-find not autoloaded in emacs20
+ (when (eq mh-have-file-command 'undefined)
(setq mh-have-file-command
(and (fboundp 'executable-find)
(executable-find "file") ; file command exists
Returns nil if file command not on system."
(cond
((not (mh-have-file-command))
- nil) ;No file command, exit now.
- ((not (and (file-exists-p filename)(file-readable-p filename)))
- nil)
+ nil) ;no file command, exit now
+ ((not (and (file-exists-p filename)
+ (file-readable-p filename)))
+ nil) ;no file or not readable, ditto
(t
(save-excursion
(let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
(mh-file-mime-type-substitute (match-string 0) filename)))
(kill-buffer tmp-buffer)))))))
-(defvar mh-mime-content-types
- '(("application/mac-binhex40") ("application/msword")
- ("application/octet-stream") ("application/pdf") ("application/pgp-keys")
- ("application/pgp-signature") ("application/pkcs7-signature")
- ("application/postscript") ("application/rtf")
- ("application/vnd.ms-excel") ("application/vnd.ms-powerpoint")
- ("application/vnd.ms-project") ("application/vnd.ms-tnef")
- ("application/wordperfect5.1") ("application/wordperfect6.0")
- ("application/zip")
-
- ("audio/basic") ("audio/mpeg")
-
- ("image/gif") ("image/jpeg") ("image/png")
-
- ("message/delivery-status")
- ("message/external-body") ("message/partial") ("message/rfc822")
-
- ("text/enriched") ("text/html") ("text/plain") ("text/rfc822-headers")
- ("text/richtext") ("text/x-vcard") ("text/xml")
-
- ("video/mpeg") ("video/quicktime"))
- "Valid MIME content types for Emacs 20.
-Obsolete; use `mailcap-mime-types'.
-
-See also \\[mh-mh-to-mime].")
-
-;; Delete mh-minibuffer-read-type and mh-mime-content-types and use
-;; mml-minibuffer-read-type when Emacs20 is no longer supported unless we
-;; think (mh-file-mime-type) is better than (mm-default-file-encoding).
-
(defun mh-minibuffer-read-type (filename &optional default)
"Return the content type associated with the given FILENAME.
If the \"file\" command exists and recognizes the given file,
(let* ((default (or default
(mm-default-file-encoding filename)
"application/octet-stream"))
- (type (or (mh-file-mime-type filename)
+ (probed-type (mh-file-mime-type filename))
+ (type (or (and (not (equal probed-type "application/octet-stream"))
+ probed-type)
(completing-read
(format "Content type (default %s): " default)
- (if (fboundp 'mailcap-mime-types)
- (mapcar 'list (mailcap-mime-types))
- mh-mime-content-types)))))
+ (mapcar 'list (mailcap-mime-types))))))
(if (not (equal type ""))
type
default)))
(mml-insert-empty-tag 'part 'type type 'filename file
'disposition dispos 'description description)))
-(defvar mh-identity-pgg-default-user-id)
+(eval-when-compile (defvar mh-identity-pgg-default-user-id)) ;shush compiler
(defun mh-secure-message (method mode &optional identity)
"Add tag to encrypt or sign message.
(mh-mime-display-part handles))
(t (mh-signature-highlight))))
(error
- (message "Please report this error:\n %s"
- (error-message-string err))
+ (message "Could not display body: %s" (error-message-string err))
(delete-region (point-min) (point-max))
(insert raw-message-data))))))
;; These variables should already be initialized in mm-decode.el if we have a
;; recent enough Gnus. The defvars are here to avoid compiler warnings.
-(defvar mm-verify-function-alist nil)
-(defvar mm-decrypt-function-alist nil)
+(eval-when-compile
+ (defvar mm-verify-function-alist nil)
+ (defvar mm-decrypt-function-alist nil))
(defvar pressed-details)
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
-(require 'mh-e)
-;; Shush the byte-compiler
-(defvar tool-bar-mode)
+(require 'mh-e)
\f
(when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
(apply #'mh-speed-flists t folders-changed))))
-;; Avoid compiler warnings
-(defvar view-exit-action)
+(eval-when-compile (defvar view-exit-action)) ;shush compiler
;;;###mh-autoload
(defun mh-list-sequences ()
(mh-list-to-string (mh-seq-containing-msg message t))
" "))))
-;; Avoid compiler warning
-(defvar tool-bar-map)
+;; Shush compiler
+(eval-when-compile
+ (defvar tool-bar-map)
+ (defvar tool-bar-mode))
(make-variable-buffer-local 'mh-non-seq-mode-line-annotation)
;;; Code:
-(defvar recursive-load-depth-limit)
(eval-and-compile
+ (defvar recursive-load-depth-limit)
(if (and (boundp 'recursive-load-depth-limit)
(integerp recursive-load-depth-limit)
- (> 50 recursive-load-depth-limit))
+ (< recursive-load-depth-limit 50))
(setq recursive-load-depth-limit 50)))
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
-(require 'gnus-util)
+
(require 'font-lock)
-(require 'mouse)
-(load "tool-bar" t t)
-(require 'mh-loaddefs)
+(require 'gnus-util)
(require 'mh-customize)
(require 'mh-inc)
+(require 'mouse)
+(require 'sendmail)
-(load "mm-decode" t t) ; Non-fatal dependency
-(load "mm-view" t t) ; Non-fatal dependency
-(load "vcard" t t) ; Non-fatal dependency
-(load "hl-line" t t) ; Non-fatal dependency
-(load "executable" t t) ; Non-fatal dependency on
- ; executable-find
-
-;; Shush the byte-compiler
-(defvar font-lock-auto-fontify)
-(defvar font-lock-defaults)
-(defvar mark-active)
+;; Non-fatal dependencies
+(load "hl-line" t t)
+(load "mm-decode" t t)
+(load "mm-view" t t)
+(load "tool-bar" t t)
+(load "vcard" t t)
\f
(autoload 'gnus-article-highlight-citation "gnus-cite")
(autoload 'message-fetch-field "message")
(autoload 'message-tokenize-header "message")
-(require 'sendmail)
(unless (fboundp 'make-hash-table)
(autoload 'make-hash-table "cl"))
;; Needed to help shush the byte-compiler.
(if mh-xemacs-flag
- (progn
- (eval-and-compile
- (require 'gnus)
- (require 'gnus-art)
- (require 'gnus-cite))))
+ (eval-and-compile
+ (require 'gnus)
+ (require 'gnus-art)
+ (require 'gnus-cite)))
(defun mh-gnus-article-highlight-citation ()
"Highlight cited text in current buffer using Gnus."
(unlock-buffer)
(setq buffer-file-name nil))
-
(defun mh-get-msg-num (error-if-no-message)
"Return the message number of the displayed message.
If the argument ERROR-IF-NO-MESSAGE is non-nil, then complain if
;; Ensure new buffers won't get this mode if default-major-mode is nil.
(put 'mh-show-mode 'mode-class 'special)
-;; Avoid compiler warnings in XEmacs and Emacs 20
+;; Shush compiler.
(eval-when-compile
- (defvar tool-bar-mode)
+ (defvar font-lock-auto-fontify)
+ (defvar font-lock-defaults)
(defvar tool-bar-map))
(define-derived-mode mh-show-mode text-mode "MH-Show"
;; XXX Note that MH-E no longer supports the `mh-visible-headers'
;; variable, so this function could be trimmed of this feature too."
(let ((case-fold-search t)
- (buffer-read-only nil)
- (after-change-functions nil)) ;Work around emacs-20 font-lock bug
- ;causing an endless loop.
+ (buffer-read-only nil))
(save-restriction
(goto-char start)
(if (search-forward "\n\n" nil 'move)
(remhash nil mh-sub-folders-cache))))
(defvar mh-folder-hist nil)
-(defvar mh-speed-folder-map)
-(defvar mh-speed-flists-cache)
+
+;; Shush compiler.
+(eval-when-compile
+ (defvar mh-speed-folder-map)
+ (defvar mh-speed-flists-cache))
(defvar mh-allow-root-folder-flag nil
"Non-nil means \"+\" is an acceptable folder name.
(mh-exec-cmd-quiet nil "mhparam" "-components" component)
(mh-get-profile-field (concat component ":"))))
+(eval-when-compile (defvar mark-active)) ;shush compiler
+
(defun mh-exchange-point-and-mark-preserving-active-mark ()
"Put the mark where point is now, and point where the mark is now.
This command works even when the mark is not active, and
new-list))
(defun mh-replace-string (old new)
- "Replace all occurrences of OLD with NEW in the current buffer."
+ "Replace all occurrences of OLD with NEW in the current buffer.
+Ignores case when searching for OLD."
(goto-char (point-min))
(let ((case-fold-search t))
(while (search-forward old nil t)
(replace-match new t t))))
-(defun mh-replace-in-string (regexp newtext string)
- "Replace REGEXP with NEWTEXT everywhere in STRING and return result.
-NEWTEXT is taken literally---no \\DIGIT escapes will be recognized.
-
-The function body was copied from `dired-replace-in-string' in
-dired.el.
-Emacs21 has `replace-regexp-in-string' while XEmacs has
-`replace-in-string'.
-Neither is present in Emacs20. The file gnus-util.el in Gnus 5.10.1
-and above has `gnus-replace-in-string'. We should use that when we
-decide to not support older versions of Gnus."
- (let ((result "") (start 0) mb me)
- (while (string-match regexp string start)
- (setq mb (match-beginning 0)
- me (match-end 0)
- result (concat result (substring string start mb) newtext)
- start me))
- (concat result (substring string start))))
-
(provide 'mh-utils)
;; Local Variables: