comparison lisp/mh-e/mh-utils.el @ 68096:57c4e7929f99

* 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.
author Bill Wohler <wohler@newt.com>
date Mon, 09 Jan 2006 06:28:49 +0000
parents bbc0e52abce5
children 5772368fe15e
comparison
equal deleted inserted replaced
68095:0a239e9952a6 68096:57c4e7929f99
31 31
32 ;;; Change Log: 32 ;;; Change Log:
33 33
34 ;;; Code: 34 ;;; Code:
35 35
36 (defvar recursive-load-depth-limit)
37 (eval-and-compile 36 (eval-and-compile
37 (defvar recursive-load-depth-limit)
38 (if (and (boundp 'recursive-load-depth-limit) 38 (if (and (boundp 'recursive-load-depth-limit)
39 (integerp recursive-load-depth-limit) 39 (integerp recursive-load-depth-limit)
40 (> 50 recursive-load-depth-limit)) 40 (< recursive-load-depth-limit 50))
41 (setq recursive-load-depth-limit 50))) 41 (setq recursive-load-depth-limit 50)))
42 42
43 (eval-when-compile (require 'mh-acros)) 43 (eval-when-compile (require 'mh-acros))
44 (mh-require-cl) 44 (mh-require-cl)
45
46 (require 'font-lock)
45 (require 'gnus-util) 47 (require 'gnus-util)
46 (require 'font-lock)
47 (require 'mouse)
48 (load "tool-bar" t t)
49 (require 'mh-loaddefs)
50 (require 'mh-customize) 48 (require 'mh-customize)
51 (require 'mh-inc) 49 (require 'mh-inc)
52 50 (require 'mouse)
53 (load "mm-decode" t t) ; Non-fatal dependency 51 (require 'sendmail)
54 (load "mm-view" t t) ; Non-fatal dependency 52
55 (load "vcard" t t) ; Non-fatal dependency 53 ;; Non-fatal dependencies
56 (load "hl-line" t t) ; Non-fatal dependency 54 (load "hl-line" t t)
57 (load "executable" t t) ; Non-fatal dependency on 55 (load "mm-decode" t t)
58 ; executable-find 56 (load "mm-view" t t)
59 57 (load "tool-bar" t t)
60 ;; Shush the byte-compiler 58 (load "vcard" t t)
61 (defvar font-lock-auto-fontify)
62 (defvar font-lock-defaults)
63 (defvar mark-active)
64 59
65 60
66 61
67 ;;; Autoloads 62 ;;; Autoloads
68 63
69 (autoload 'gnus-article-highlight-citation "gnus-cite") 64 (autoload 'gnus-article-highlight-citation "gnus-cite")
70 (autoload 'message-fetch-field "message") 65 (autoload 'message-fetch-field "message")
71 (autoload 'message-tokenize-header "message") 66 (autoload 'message-tokenize-header "message")
72 (require 'sendmail)
73 (unless (fboundp 'make-hash-table) 67 (unless (fboundp 'make-hash-table)
74 (autoload 'make-hash-table "cl")) 68 (autoload 'make-hash-table "cl"))
75 69
76 70
77 71
469 (t 463 (t
470 nil)))) 464 nil))))
471 465
472 ;; Needed to help shush the byte-compiler. 466 ;; Needed to help shush the byte-compiler.
473 (if mh-xemacs-flag 467 (if mh-xemacs-flag
474 (progn 468 (eval-and-compile
475 (eval-and-compile 469 (require 'gnus)
476 (require 'gnus) 470 (require 'gnus-art)
477 (require 'gnus-art) 471 (require 'gnus-cite)))
478 (require 'gnus-cite))))
479 472
480 (defun mh-gnus-article-highlight-citation () 473 (defun mh-gnus-article-highlight-citation ()
481 "Highlight cited text in current buffer using Gnus." 474 "Highlight cited text in current buffer using Gnus."
482 (interactive) 475 (interactive)
483 ;; Requiring gnus-cite should have been sufficient. However for Emacs21.1, 476 ;; Requiring gnus-cite should have been sufficient. However for Emacs21.1,
748 (file-name-nondirectory buffer-file-name))) 741 (file-name-nondirectory buffer-file-name)))
749 (error "Flushing changes not confirmed")) 742 (error "Flushing changes not confirmed"))
750 (clear-visited-file-modtime) 743 (clear-visited-file-modtime)
751 (unlock-buffer) 744 (unlock-buffer)
752 (setq buffer-file-name nil)) 745 (setq buffer-file-name nil))
753
754 746
755 (defun mh-get-msg-num (error-if-no-message) 747 (defun mh-get-msg-num (error-if-no-message)
756 "Return the message number of the displayed message. 748 "Return the message number of the displayed message.
757 If the argument ERROR-IF-NO-MESSAGE is non-nil, then complain if 749 If the argument ERROR-IF-NO-MESSAGE is non-nil, then complain if
758 the cursor is not pointing to a message." 750 the cursor is not pointing to a message."
1136 1128
1137 1129
1138 ;; Ensure new buffers won't get this mode if default-major-mode is nil. 1130 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
1139 (put 'mh-show-mode 'mode-class 'special) 1131 (put 'mh-show-mode 'mode-class 'special)
1140 1132
1141 ;; Avoid compiler warnings in XEmacs and Emacs 20 1133 ;; Shush compiler.
1142 (eval-when-compile 1134 (eval-when-compile
1143 (defvar tool-bar-mode) 1135 (defvar font-lock-auto-fontify)
1136 (defvar font-lock-defaults)
1144 (defvar tool-bar-map)) 1137 (defvar tool-bar-map))
1145 1138
1146 (define-derived-mode mh-show-mode text-mode "MH-Show" 1139 (define-derived-mode mh-show-mode text-mode "MH-Show"
1147 "Major mode for showing messages in MH-E.\\<mh-show-mode-map> 1140 "Major mode for showing messages in MH-E.\\<mh-show-mode-map>
1148 1141
1875 expression specifying the lines to display. INVISIBLE-HEADERS is 1868 expression specifying the lines to display. INVISIBLE-HEADERS is
1876 ignored if VISIBLE-HEADERS is non-nil." 1869 ignored if VISIBLE-HEADERS is non-nil."
1877 ;; XXX Note that MH-E no longer supports the `mh-visible-headers' 1870 ;; XXX Note that MH-E no longer supports the `mh-visible-headers'
1878 ;; variable, so this function could be trimmed of this feature too." 1871 ;; variable, so this function could be trimmed of this feature too."
1879 (let ((case-fold-search t) 1872 (let ((case-fold-search t)
1880 (buffer-read-only nil) 1873 (buffer-read-only nil))
1881 (after-change-functions nil)) ;Work around emacs-20 font-lock bug
1882 ;causing an endless loop.
1883 (save-restriction 1874 (save-restriction
1884 (goto-char start) 1875 (goto-char start)
1885 (if (search-forward "\n\n" nil 'move) 1876 (if (search-forward "\n\n" nil 'move)
1886 (backward-char 1)) 1877 (backward-char 1))
1887 (narrow-to-region start (point)) 1878 (narrow-to-region start (point))
2348 (return-from ancestor-found) 2339 (return-from ancestor-found)
2349 (setq one-ancestor-found t)))) 2340 (setq one-ancestor-found t))))
2350 (remhash nil mh-sub-folders-cache)))) 2341 (remhash nil mh-sub-folders-cache))))
2351 2342
2352 (defvar mh-folder-hist nil) 2343 (defvar mh-folder-hist nil)
2353 (defvar mh-speed-folder-map) 2344
2354 (defvar mh-speed-flists-cache) 2345 ;; Shush compiler.
2346 (eval-when-compile
2347 (defvar mh-speed-folder-map)
2348 (defvar mh-speed-flists-cache))
2355 2349
2356 (defvar mh-allow-root-folder-flag nil 2350 (defvar mh-allow-root-folder-flag nil
2357 "Non-nil means \"+\" is an acceptable folder name. 2351 "Non-nil means \"+\" is an acceptable folder name.
2358 This variable is used to communicate with 2352 This variable is used to communicate with
2359 `mh-folder-completion-function'. That function can have exactly 2353 `mh-folder-completion-function'. That function can have exactly
2610 "Return COMPONENT value from mhparam, or nil if unset." 2604 "Return COMPONENT value from mhparam, or nil if unset."
2611 (save-excursion 2605 (save-excursion
2612 (mh-exec-cmd-quiet nil "mhparam" "-components" component) 2606 (mh-exec-cmd-quiet nil "mhparam" "-components" component)
2613 (mh-get-profile-field (concat component ":")))) 2607 (mh-get-profile-field (concat component ":"))))
2614 2608
2609 (eval-when-compile (defvar mark-active)) ;shush compiler
2610
2615 (defun mh-exchange-point-and-mark-preserving-active-mark () 2611 (defun mh-exchange-point-and-mark-preserving-active-mark ()
2616 "Put the mark where point is now, and point where the mark is now. 2612 "Put the mark where point is now, and point where the mark is now.
2617 This command works even when the mark is not active, and 2613 This command works even when the mark is not active, and
2618 preserves whether the mark is active or not." 2614 preserves whether the mark is active or not."
2619 (interactive nil) 2615 (interactive nil)
2687 (t (error "Bad element in `mh-list-to-string': %s" (car l)))) 2683 (t (error "Bad element in `mh-list-to-string': %s" (car l))))
2688 (setq l (cdr l))) 2684 (setq l (cdr l)))
2689 new-list)) 2685 new-list))
2690 2686
2691 (defun mh-replace-string (old new) 2687 (defun mh-replace-string (old new)
2692 "Replace all occurrences of OLD with NEW in the current buffer." 2688 "Replace all occurrences of OLD with NEW in the current buffer.
2689 Ignores case when searching for OLD."
2693 (goto-char (point-min)) 2690 (goto-char (point-min))
2694 (let ((case-fold-search t)) 2691 (let ((case-fold-search t))
2695 (while (search-forward old nil t) 2692 (while (search-forward old nil t)
2696 (replace-match new t t)))) 2693 (replace-match new t t))))
2697 2694
2698 (defun mh-replace-in-string (regexp newtext string)
2699 "Replace REGEXP with NEWTEXT everywhere in STRING and return result.
2700 NEWTEXT is taken literally---no \\DIGIT escapes will be recognized.
2701
2702 The function body was copied from `dired-replace-in-string' in
2703 dired.el.
2704 Emacs21 has `replace-regexp-in-string' while XEmacs has
2705 `replace-in-string'.
2706 Neither is present in Emacs20. The file gnus-util.el in Gnus 5.10.1
2707 and above has `gnus-replace-in-string'. We should use that when we
2708 decide to not support older versions of Gnus."
2709 (let ((result "") (start 0) mb me)
2710 (while (string-match regexp string start)
2711 (setq mb (match-beginning 0)
2712 me (match-end 0)
2713 result (concat result (substring string start mb) newtext)
2714 start me))
2715 (concat result (substring string start))))
2716
2717 (provide 'mh-utils) 2695 (provide 'mh-utils)
2718 2696
2719 ;; Local Variables: 2697 ;; Local Variables:
2720 ;; indent-tabs-mode: nil 2698 ;; indent-tabs-mode: nil
2721 ;; sentence-end-double-space: nil 2699 ;; sentence-end-double-space: nil