aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShengHuo ZHU2001-11-25 15:17:24 +0000
committerShengHuo ZHU2001-11-25 15:17:24 +0000
commit47b63dfa47e9fae9cacbc7e9a35a49d6e75ac8d5 (patch)
treeb7a5d220696ff544a3f43e8e03c40a98ca0c0b6c
parentfefed09d4223b272d3aa061dbdf6d7a0b2bb6047 (diff)
downloademacs-47b63dfa47e9fae9cacbc7e9a35a49d6e75ac8d5.tar.gz
emacs-47b63dfa47e9fae9cacbc7e9a35a49d6e75ac8d5.zip
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
* gnus-util.el (gnus-directory-sep-char-regexp): New. * gnus-score.el (gnus-score-find-bnews): Sync with Gnus CVS. * mm-util.el: Sync. * gnus-sum.el (gnus-summary-limit-to-subject): An exclusion version. (gnus-summary-limit-to-author): Ditto. (gnus-summary-limit-to-extra): Ditto. (gnus-summary-find-matching): Support not-matching argument. * message.el (message-wash-subject): Use `insert' rather than `insert-string', which is deprecated. From Kai Gro,A_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
-rw-r--r--lisp/gnus/ChangeLog15
-rw-r--r--lisp/gnus/gnus-score.el12
-rw-r--r--lisp/gnus/gnus-sum.el70
-rw-r--r--lisp/gnus/gnus-util.el5
-rw-r--r--lisp/gnus/message.el2
-rw-r--r--lisp/gnus/mm-util.el141
6 files changed, 183 insertions, 62 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 0f395c58658..7f66f92eef5 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,18 @@
12001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
2
3 * gnus-util.el (gnus-directory-sep-char-regexp): New.
4 * gnus-score.el (gnus-score-find-bnews): Sync with Gnus CVS.
5 * mm-util.el: Sync.
6
7 * gnus-sum.el (gnus-summary-limit-to-subject): An exclusion version.
8 (gnus-summary-limit-to-author): Ditto.
9 (gnus-summary-limit-to-extra): Ditto.
10 (gnus-summary-find-matching): Support not-matching argument.
11
12 * message.el (message-wash-subject): Use `insert' rather than
13 `insert-string', which is deprecated.
14 From Kai Gro,A_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
15
12001-11-14 Sam Steingold <sds@gnu.org> 162001-11-14 Sam Steingold <sds@gnu.org>
2 17
3 * gnus-score.el: Fixed some doc strings to properly quote symbols. 18 * gnus-score.el: Fixed some doc strings to properly quote symbols.
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 14ac43b4fe3..1de3b48e5f5 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -2560,8 +2560,10 @@ GROUP using BNews sys file syntax."
2560 ;; too much. 2560 ;; too much.
2561 (delete-char (min (1- (point-max)) klen)) 2561 (delete-char (min (1- (point-max)) klen))
2562 (goto-char (point-max)) 2562 (goto-char (point-max))
2563 (search-backward (string directory-sep-char)) 2563 (if (re-search-backward gnus-directory-sep-char-regexp nil t)
2564 (delete-region (1+ (point)) (point-min))) 2564 (delete-region (1+ (point)) (point-min))
2565 (gnus-message 1 "Can't find directory separator in %s"
2566 (car sfiles))))
2565 ;; If short file names were used, we have to translate slashes. 2567 ;; If short file names were used, we have to translate slashes.
2566 (goto-char (point-min)) 2568 (goto-char (point-min))
2567 (let ((regexp (concat 2569 (let ((regexp (concat
@@ -2595,10 +2597,10 @@ GROUP using BNews sys file syntax."
2595 ;; we add this score file to the list of score files 2597 ;; we add this score file to the list of score files
2596 ;; applicable to this group. 2598 ;; applicable to this group.
2597 (when (or (and not-match 2599 (when (or (and not-match
2598 (ignore-errors 2600 (ignore-errors
2599 (not (string-match regexp group-trans)))) 2601 (not (string-match regexp group-trans))))
2600 (and (not not-match) 2602 (and (not not-match)
2601 (ignore-errors (string-match regexp group-trans)))) 2603 (ignore-errors (string-match regexp group-trans))))
2602 (push (car sfiles) ofiles))) 2604 (push (car sfiles) ofiles)))
2603 (setq sfiles (cdr sfiles))) 2605 (setq sfiles (cdr sfiles)))
2604 (kill-buffer (current-buffer)) 2606 (kill-buffer (current-buffer))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 36fff90ef88..470c7a9aa88 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -6393,23 +6393,34 @@ If given a prefix, remove all limits."
6393 (gnus-summary-limit nil 'pop) 6393 (gnus-summary-limit nil 'pop)
6394 (gnus-summary-position-point))) 6394 (gnus-summary-position-point)))
6395 6395
6396(defun gnus-summary-limit-to-subject (subject &optional header) 6396(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6397 "Limit the summary buffer to articles that have subjects that match a regexp." 6397 "Limit the summary buffer to articles that have subjects that match a regexp.
6398 (interactive "sLimit to subject (regexp): ") 6398If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6399 (interactive
6400 (list (read-string (if current-prefix-arg
6401 "Exclude subject (regexp): "
6402 "Limit to subject (regexp): "))
6403 nil current-prefix-arg))
6399 (unless header 6404 (unless header
6400 (setq header "subject")) 6405 (setq header "subject"))
6401 (when (not (equal "" subject)) 6406 (when (not (equal "" subject))
6402 (prog1 6407 (prog1
6403 (let ((articles (gnus-summary-find-matching 6408 (let ((articles (gnus-summary-find-matching
6404 (or header "subject") subject 'all))) 6409 (or header "subject") subject 'all nil nil
6410 not-matching)))
6405 (unless articles 6411 (unless articles
6406 (error "Found no matches for \"%s\"" subject)) 6412 (error "Found no matches for \"%s\"" subject))
6407 (gnus-summary-limit articles)) 6413 (gnus-summary-limit articles))
6408 (gnus-summary-position-point)))) 6414 (gnus-summary-position-point))))
6409 6415
6410(defun gnus-summary-limit-to-author (from) 6416(defun gnus-summary-limit-to-author (from)
6411 "Limit the summary buffer to articles that have authors that match a regexp." 6417 "Limit the summary buffer to articles that have authors that match a regexp.
6412 (interactive "sLimit to author (regexp): ") 6418If NOT-MATCHING, excluding articles that have authors that match a regexp."
6419 (interactive
6420 (list (read-string (if current-prefix-arg
6421 "Exclude author (regexp): "
6422 "Limit to author (regexp): "))
6423 nil current-prefix-arg))
6413 (gnus-summary-limit-to-subject from "from")) 6424 (gnus-summary-limit-to-subject from "from"))
6414 6425
6415(defun gnus-summary-limit-to-age (age &optional younger-p) 6426(defun gnus-summary-limit-to-age (age &optional younger-p)
@@ -6450,25 +6461,31 @@ articles that are younger than AGE days."
6450 (gnus-summary-limit (nreverse articles))) 6461 (gnus-summary-limit (nreverse articles)))
6451 (gnus-summary-position-point))) 6462 (gnus-summary-position-point)))
6452 6463
6453(defun gnus-summary-limit-to-extra (header regexp) 6464(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
6454 "Limit the summary buffer to articles that match an 'extra' header." 6465 "Limit the summary buffer to articles that match an 'extra' header."
6455 (interactive 6466 (interactive
6456 (let ((header 6467 (let ((header
6457 (intern 6468 (intern
6458 (gnus-completing-read 6469 (gnus-completing-read
6459 (symbol-name (car gnus-extra-headers)) 6470 (symbol-name (car gnus-extra-headers))
6460 "Limit extra header:" 6471 (if current-prefix-arg
6472 "Exclude extra header:"
6473 "Limit extra header:")
6461 (mapcar (lambda (x) 6474 (mapcar (lambda (x)
6462 (cons (symbol-name x) x)) 6475 (cons (symbol-name x) x))
6463 gnus-extra-headers) 6476 gnus-extra-headers)
6464 nil 6477 nil
6465 t)))) 6478 t))))
6466 (list header 6479 (list header
6467 (read-string (format "Limit to header %s (regexp): " header))))) 6480 (read-string (format "%s header %s (regexp): "
6481 (if current-prefix-arg "Exclude" "Limit to")
6482 header))
6483 current-prefix-arg)))
6468 (when (not (equal "" regexp)) 6484 (when (not (equal "" regexp))
6469 (prog1 6485 (prog1
6470 (let ((articles (gnus-summary-find-matching 6486 (let ((articles (gnus-summary-find-matching
6471 (cons 'extra header) regexp 'all))) 6487 (cons 'extra header) regexp 'all nil nil
6488 not-matching)))
6472 (unless articles 6489 (unless articles
6473 (error "Found no matches for \"%s\"" regexp)) 6490 (error "Found no matches for \"%s\"" regexp))
6474 (gnus-summary-limit articles)) 6491 (gnus-summary-limit articles))
@@ -7215,17 +7232,15 @@ Optional argument BACKWARD means do search for backward.
7215 t))) 7232 t)))
7216 7233
7217(defun gnus-summary-find-matching (header regexp &optional backward unread 7234(defun gnus-summary-find-matching (header regexp &optional backward unread
7218 not-case-fold) 7235 not-case-fold not-matching)
7219 "Return a list of all articles that match REGEXP on HEADER. 7236 "Return a list of all articles that match REGEXP on HEADER.
7220The search stars on the current article and goes forwards unless 7237The search stars on the current article and goes forwards unless
7221BACKWARD is non-nil. If BACKWARD is `all', do all articles. 7238BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7222If UNREAD is non-nil, only unread articles will 7239If UNREAD is non-nil, only unread articles will
7223be taken into consideration. If NOT-CASE-FOLD, case won't be folded 7240be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7224in the comparisons." 7241in the comparisons. If NOT-MATCHING, return a list of all articles that
7225 (let ((data (if (eq backward 'all) gnus-newsgroup-data 7242not match REGEXP on HEADER."
7226 (gnus-data-find-list 7243 (let ((case-fold-search (not not-case-fold))
7227 (gnus-summary-article-number) (gnus-data-list backward))))
7228 (case-fold-search (not not-case-fold))
7229 articles d func) 7244 articles d func)
7230 (if (consp header) 7245 (if (consp header)
7231 (if (eq (car header) 'extra) 7246 (if (eq (car header) 'extra)
@@ -7237,14 +7252,21 @@ in the comparisons."
7237 (unless (fboundp (intern (concat "mail-header-" header))) 7252 (unless (fboundp (intern (concat "mail-header-" header)))
7238 (error "%s is not a valid header" header)) 7253 (error "%s is not a valid header" header))
7239 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))) 7254 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7240 (while data 7255 (dolist (d (if (eq backward 'all)
7241 (setq d (car data)) 7256 gnus-newsgroup-data
7242 (and (or (not unread) ; We want all articles... 7257 (gnus-data-find-list
7243 (gnus-data-unread-p d)) ; Or just unreads. 7258 (gnus-summary-article-number)
7244 (vectorp (gnus-data-header d)) ; It's not a pseudo. 7259 (gnus-data-list backward))))
7245 (string-match regexp (funcall func (gnus-data-header d))) ; Match. 7260 (when (and (or (not unread) ; We want all articles...
7246 (push (gnus-data-number d) articles)) ; Success! 7261 (gnus-data-unread-p d)) ; Or just unreads.
7247 (setq data (cdr data))) 7262 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7263 (if not-matching
7264 (not (string-match
7265 regexp
7266 (funcall func (gnus-data-header d))))
7267 (string-match regexp
7268 (funcall func (gnus-data-header d)))))
7269 (push (gnus-data-number d) articles))) ; Success!
7248 (nreverse articles))) 7270 (nreverse articles)))
7249 7271
7250(defun gnus-summary-execute-command (header regexp command &optional backward) 7272(defun gnus-summary-execute-command (header regexp command &optional backward)
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 7417543278c..329d81a2a33 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1003,6 +1003,11 @@ Entries without port tokens default to DEFAULTPORT."
1003 (remove-text-properties start end properties object)) 1003 (remove-text-properties start end properties object))
1004 t)) 1004 t))
1005 1005
1006(defvar gnus-directory-sep-char-regexp "/"
1007 "The regexp of directory separator character.
1008If you find some problem with the directory separator character, try
1009\"[/\\\\\]\" for some systems.")
1010
1006(provide 'gnus-util) 1011(provide 'gnus-util)
1007 1012
1008;;; gnus-util.el ends here 1013;;; gnus-util.el ends here
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index dcc265dcf0b..1280fdaf9f5 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -4116,7 +4116,7 @@ header line with the old Message-ID."
4116 "Remove junk like \"Re:\", \"(fwd)\", etc. added to subject string SUBJECT. 4116 "Remove junk like \"Re:\", \"(fwd)\", etc. added to subject string SUBJECT.
4117Previous forwarders, replyers, etc. may add it." 4117Previous forwarders, replyers, etc. may add it."
4118 (with-temp-buffer 4118 (with-temp-buffer
4119 (insert-string subject) 4119 (insert subject)
4120 (goto-char (point-min)) 4120 (goto-char (point-min))
4121 ;; strip Re/Fwd stuff off the beginning 4121 ;; strip Re/Fwd stuff off the beginning
4122 (while (re-search-forward 4122 (while (re-search-forward
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 35229591c7d..afe9f6cdbec 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -163,7 +163,7 @@
163 "Coding system of auto save file.") 163 "Coding system of auto save file.")
164 164
165(defvar mm-universal-coding-system mm-auto-save-coding-system 165(defvar mm-universal-coding-system mm-auto-save-coding-system
166 "The universal Coding system.") 166 "The universal coding system.")
167 167
168;; Fixme: some of the cars here aren't valid MIME charsets. That 168;; Fixme: some of the cars here aren't valid MIME charsets. That
169;; should only matter with XEmacs, though. 169;; should only matter with XEmacs, though.
@@ -238,6 +238,49 @@
238 (coding-system-get cs 'safe-charsets)))))) 238 (coding-system-get cs 'safe-charsets))))))
239 (sort-coding-systems (coding-system-list 'base-only)))))) 239 (sort-coding-systems (coding-system-list 'base-only))))))
240 240
241(defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2)
242 "A list of special charsets.
243Valid elements include:
244`iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists.
245`iso-2022-jp-2' convert ISO-2022-jp to ISO-2022-jp-2 if ISO-2022-jp-2 exists."
246)
247
248(defvar mm-iso-8859-15-compatible
249 '((iso-8859-1 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE")
250 (iso-8859-9 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xD0\xDD\xDE\xF0\xFD\xFE"))
251 "ISO-8859-15 exchangeable coding systems and inconvertible characters.")
252
253(defvar mm-iso-8859-x-to-15-table
254 (and (fboundp 'coding-system-p)
255 (mm-coding-system-p 'iso-8859-15)
256 (mapcar
257 (lambda (cs)
258 (if (mm-coding-system-p (car cs))
259 (let ((c (string-to-char
260 (decode-coding-string "\341" (car cs)))))
261 (cons (char-charset c)
262 (cons
263 (- (string-to-char
264 (decode-coding-string "\341" 'iso-8859-15)) c)
265 (string-to-list (decode-coding-string (car (cdr cs))
266 (car cs))))))
267 '(gnus-charset 0)))
268 mm-iso-8859-15-compatible))
269 "A table of the difference character between ISO-8859-X and ISO-8859-15.")
270
271(defvar mm-coding-system-priorities nil
272 "Preferred coding systems for encoding outgoing mails.
273
274More than one suitable coding systems may be found for some texts. By
275default, a coding system with the highest priority is used to encode
276outgoing mails (see `sort-coding-systems'). If this variable is set,
277it overrides the default priority. For example, Japanese users may
278prefer iso-2022-jp to japanese-shift-jis:
279
280\(setq mm-coding-system-priorities
281 '(iso-2022-jp iso-2022-jp-2 japanese-shift-jis utf-8))
282")
283
241;;; Internal variables: 284;;; Internal variables:
242 285
243;;; Functions: 286;;; Functions:
@@ -270,6 +313,8 @@ used as the line break code type of the coding system."
270 (when lbt 313 (when lbt
271 (setq charset (intern (format "%s-%s" charset lbt)))) 314 (setq charset (intern (format "%s-%s" charset lbt))))
272 (cond 315 (cond
316 ((null charset)
317 charset)
273 ;; Running in a non-MULE environment. 318 ;; Running in a non-MULE environment.
274 ((null (mm-get-coding-system-list)) 319 ((null (mm-get-coding-system-list))
275 charset) 320 charset)
@@ -348,8 +393,8 @@ Only used in Emacs Mule 4."
348 393
349(defun mm-preferred-coding-system (charset) 394(defun mm-preferred-coding-system (charset)
350 ;; A typo in some Emacs versions. 395 ;; A typo in some Emacs versions.
351 (or (get-charset-property charset 'prefered-coding-system) 396 (or (get-charset-property charset 'preferred-coding-system)
352 (get-charset-property charset 'preferred-coding-system))) 397 (get-charset-property charset 'prefered-coding-system)))
353 398
354(defun mm-charset-after (&optional pos) 399(defun mm-charset-after (&optional pos)
355 "Return charset of a character in current buffer at position POS. 400 "Return charset of a character in current buffer at position POS.
@@ -420,38 +465,70 @@ If the charset is `composition', return the actual one."
420 enable-multibyte-characters 465 enable-multibyte-characters
421 (featurep 'mule))) 466 (featurep 'mule)))
422 467
423(defun mm-find-mime-charset-region (b e) 468(defun mm-iso-8859-x-to-15-region (&optional b e)
469 (if (fboundp 'char-charset)
470 (let (charset item c inconvertible)
471 (save-restriction
472 (if e (narrow-to-region b e))
473 (goto-char (point-min))
474 (skip-chars-forward "\0-\177")
475 (while (not (eobp))
476 (cond
477 ((not (setq item (assq (char-charset (setq c (char-after)))
478 mm-iso-8859-x-to-15-table)))
479 (forward-char))
480 ((memq c (cdr (cdr item)))
481 (setq inconvertible t)
482 (forward-char))
483 (t
484 (insert (prog1 (+ c (car (cdr item))) (delete-char 1))))
485 (skip-chars-forward "\0-\177"))))
486 (not inconvertible))))
487
488(defun mm-sort-coding-systems-predicate (a b)
489 (> (length (memq a mm-coding-system-priorities))
490 (length (memq b mm-coding-system-priorities))))
491
492(defun mm-find-mime-charset-region (b e &optional hack-charsets)
424 "Return the MIME charsets needed to encode the region between B and E. 493 "Return the MIME charsets needed to encode the region between B and E.
425Nil means ASCII, a single-element list represents an appropriate MIME 494Nil means ASCII, a single-element list represents an appropriate MIME
426charset, and a longer list means no appropriate charset." 495charset, and a longer list means no appropriate charset."
427 ;; The return possibilities of this function are a mess... 496 (let (charsets)
428 (or (and 497 ;; The return possibilities of this function are a mess...
429 (mm-multibyte-p) 498 (or (and (mm-multibyte-p)
430 (fboundp 'find-coding-systems-region) 499 (fboundp 'find-coding-systems-region)
431 ;; Find the mime-charset of the most preferred coding 500 ;; Find the mime-charset of the most preferred coding
432 ;; system that has one. 501 ;; system that has one.
433 (let ((systems (find-coding-systems-region b e)) 502 (let ((systems (find-coding-systems-region b e)))
434 result) 503 (when mm-coding-system-priorities
435 ;; Fixme: The `mime-charset' (`x-ctext') of `compound-text' 504 (setq systems
436 ;; is not in the IANA list. 505 (sort systems 'mm-sort-coding-systems-predicate)))
437 (setq systems (delq 'compound-text systems)) 506 ;; Fixme: The `mime-charset' (`x-ctext') of `compound-text'
438 (unless (equal systems '(undecided)) 507 ;; is not in the IANA list.
439 (while systems 508 (setq systems (delq 'compound-text systems))
440 (let ((cs (coding-system-get (pop systems) 'mime-charset))) 509 (unless (equal systems '(undecided))
441 (if cs 510 (while systems
442 (setq systems nil 511 (let ((cs (coding-system-get (pop systems) 'mime-charset)))
443 result (list cs)))))) 512 (if cs
444 result)) 513 (setq systems nil
445 ;; Otherwise we're not multibyte, XEmacs or a single coding 514 charsets (list cs))))))
446 ;; system won't cover it. 515 charsets))
447 (let ((charsets 516 ;; Otherwise we're not multibyte, XEmacs or a single coding
448 (mm-delete-duplicates 517 ;; system won't cover it.
449 (mapcar 'mm-mime-charset 518 (setq charsets
450 (delq 'ascii 519 (mm-delete-duplicates
451 (mm-find-charset-region b e)))))) 520 (mapcar 'mm-mime-charset
452 (if (memq 'iso-2022-jp-2 charsets) 521 (delq 'ascii
453 (delq 'iso-2022-jp charsets) 522 (mm-find-charset-region b e))))))
454 charsets)))) 523 (if (and (memq 'iso-8859-15 charsets)
524 (memq 'iso-8859-15 hack-charsets)
525 (save-excursion (mm-iso-8859-x-to-15-region b e)))
526 (mapcar (lambda (x) (setq charsets (delq (car x) charsets)))
527 mm-iso-8859-15-compatible))
528 (if (and (memq 'iso-2022-jp-2 charsets)
529 (memq 'iso-2022-jp-2 hack-charsets))
530 (setq charsets (delq 'iso-2022-jp charsets)))
531 charsets))
455 532
456(defmacro mm-with-unibyte-buffer (&rest forms) 533(defmacro mm-with-unibyte-buffer (&rest forms)
457 "Create a temporary buffer, and evaluate FORMS there like `progn'. 534 "Create a temporary buffer, and evaluate FORMS there like `progn'.