aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-05-04 23:12:26 +0000
committerJuri Linkov2008-05-04 23:12:26 +0000
commitd844ef2fabbd6d6066ebd6d4e74ac52543a0858e (patch)
tree3287f92f2e2f6b21def65f7a8d1eb05d0e761a07
parentf67e15be8d94718b2e2ea7da68eb0b2dc94ce016 (diff)
downloademacs-d844ef2fabbd6d6066ebd6d4e74ac52543a0858e.tar.gz
emacs-d844ef2fabbd6d6066ebd6d4e74ac52543a0858e.zip
(mailcap-replace-in-string): New compatibility alias.
(mailcap-file-default-commands): Use mailcap-replace-in-string instead of replace-regexp-in-string, and mailcap-delete-duplicates instead of delete-dups. Use [ \t\n]* for whitespace in regexp.
-rw-r--r--lisp/gnus/ChangeLog7
-rw-r--r--lisp/gnus/mailcap.el40
2 files changed, 34 insertions, 13 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 3087e640c62..72c48e2e456 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,10 @@
12008-05-04 Juri Linkov <juri@jurta.org>
2
3 * mailcap.el (mailcap-replace-in-string): New compatibility alias.
4 (mailcap-file-default-commands): Use mailcap-replace-in-string
5 instead of replace-regexp-in-string, and mailcap-delete-duplicates
6 instead of delete-dups. Use [ \t\n]* for whitespace in regexp.
7
12008-05-03 Reiner Steib <reiner.steib@gmx.de> 82008-05-03 Reiner Steib <reiner.steib@gmx.de>
2 9
3 * gnus-sum.el (gnus-propagate-marks): Fix custom version. 10 * gnus-sum.el (gnus-propagate-marks): Fix custom version.
diff --git a/lisp/gnus/mailcap.el b/lisp/gnus/mailcap.el
index 7abb97eadf5..cc7c9a3a7ab 100644
--- a/lisp/gnus/mailcap.el
+++ b/lisp/gnus/mailcap.el
@@ -42,6 +42,19 @@
42 (autoload 'mm-delete-duplicates "mm-util") 42 (autoload 'mm-delete-duplicates "mm-util")
43 'mm-delete-duplicates)) 43 'mm-delete-duplicates))
44 44
45;; `mailcap-replace-in-string' is an alias like `gnus-replace-in-string'.
46(eval-and-compile
47 (cond
48 ((fboundp 'replace-regexp-in-string)
49 (defun mailcap-replace-in-string (string regexp newtext &optional literal)
50 "Replace all matches for REGEXP with NEWTEXT in STRING.
51If LITERAL is non-nil, insert NEWTEXT literally. Return a new
52string containing the replacements.
53This is a compatibility function for different Emacsen."
54 (replace-regexp-in-string regexp newtext string nil literal)))
55 ((fboundp 'replace-in-string)
56 (defalias 'mailcap-replace-in-string 'replace-in-string))))
57
45(defgroup mailcap nil 58(defgroup mailcap nil
46 "Definition of viewers for MIME types." 59 "Definition of viewers for MIME types."
47 :version "21.1" 60 :version "21.1"
@@ -1017,15 +1030,17 @@ If FORCE, re-parse even if already parsed."
1017 (mailcap-parse-mimetypes) 1030 (mailcap-parse-mimetypes)
1018 (let* ((all-mime-type 1031 (let* ((all-mime-type
1019 ;; All unique MIME types from file extensions 1032 ;; All unique MIME types from file extensions
1020 (delete-dups (mapcar (lambda (file) 1033 (mailcap-delete-duplicates
1021 (mailcap-extension-to-mime 1034 (mapcar (lambda (file)
1022 (file-name-extension file t))) 1035 (mailcap-extension-to-mime
1023 files))) 1036 (file-name-extension file t)))
1037 files)))
1024 (all-mime-info 1038 (all-mime-info
1025 ;; All MIME info lists 1039 ;; All MIME info lists
1026 (delete-dups (mapcar (lambda (mime-type) 1040 (mailcap-delete-duplicates
1027 (mailcap-mime-info mime-type 'all)) 1041 (mapcar (lambda (mime-type)
1028 all-mime-type))) 1042 (mailcap-mime-info mime-type 'all))
1043 all-mime-type)))
1029 (common-mime-info 1044 (common-mime-info
1030 ;; Intersection of mime-infos from different mime-types; 1045 ;; Intersection of mime-infos from different mime-types;
1031 ;; or just the first MIME info for a single MIME type 1046 ;; or just the first MIME info for a single MIME type
@@ -1040,18 +1055,17 @@ If FORCE, re-parse even if already parsed."
1040 (car all-mime-info))) 1055 (car all-mime-info)))
1041 (commands 1056 (commands
1042 ;; Command strings from `viewer' field of the MIME info 1057 ;; Command strings from `viewer' field of the MIME info
1043 (delete-dups 1058 (mailcap-delete-duplicates
1044 (delq nil (mapcar (lambda (mime-info) 1059 (delq nil (mapcar (lambda (mime-info)
1045 (let ((command (cdr (assoc 'viewer mime-info)))) 1060 (let ((command (cdr (assoc 'viewer mime-info))))
1046 (if (stringp command) 1061 (if (stringp command)
1047 (replace-regexp-in-string 1062 (mailcap-replace-in-string
1048 ;; Replace mailcap's `%s' placeholder 1063 ;; Replace mailcap's `%s' placeholder
1049 ;; with dired's `?' placeholder 1064 ;; with dired's `?' placeholder
1050 "%s" "?" 1065 (mailcap-replace-in-string
1051 (replace-regexp-in-string
1052 ;; Remove the final filename placeholder 1066 ;; Remove the final filename placeholder
1053 "\s*\\('\\)?%s\\1?\s*\\'" "" command nil t) 1067 command "[ \t\n]*\\('\\)?%s\\1?[ \t\n]*\\'" "" t)
1054 nil t)))) 1068 "%s" "?" t))))
1055 common-mime-info))))) 1069 common-mime-info)))))
1056 commands)) 1070 commands))
1057 1071