aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-09-01 17:42:37 +0200
committerStefan Monnier2010-09-01 17:42:37 +0200
commit765abcce0abdce0177ecc3330199f5921eccc84c (patch)
tree5c68ba95c2b915b4e569e01a64dbfcd5f21a8877
parent8f4e9110cad4aa7fbbfa4765221f4a6392ca7af3 (diff)
downloademacs-765abcce0abdce0177ecc3330199f5921eccc84c.tar.gz
emacs-765abcce0abdce0177ecc3330199f5921eccc84c.zip
Fix up some byte-compiler warnings.
* lisp/gnus/gnus.el (gnus-group-find-parameter, gnus-kill-save-kill-buffer): * lisp/gnus/gnus-cite.el (gnus-article-highlight-citation, gnus-dissect-cited-text) (gnus-article-fill-cited-article, gnus-article-hide-citation) (gnus-article-hide-citation-in-followups, gnus-cite-toggle): * lisp/gnus/gnus-group.el (gnus-group-set-mode-line, gnus-group-quit) (gnus-group-set-info, gnus-add-mark): Use with-current-buffer. (gnus-group-update-group): Use save-excursion and with-current-buffer.
-rw-r--r--lisp/gnus/ChangeLog11
-rw-r--r--lisp/gnus/gnus-cite.el140
-rw-r--r--lisp/gnus/gnus-group.el131
-rw-r--r--lisp/gnus/gnus.el6
4 files changed, 139 insertions, 149 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 16c90ac61e8..a1c33b09815 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,14 @@
12010-09-01 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 Fix up some byte-compiler warnings.
4 * gnus.el (gnus-group-find-parameter, gnus-kill-save-kill-buffer):
5 * gnus-cite.el (gnus-article-highlight-citation, gnus-dissect-cited-text)
6 (gnus-article-fill-cited-article, gnus-article-hide-citation)
7 (gnus-article-hide-citation-in-followups, gnus-cite-toggle):
8 * gnus-group.el (gnus-group-set-mode-line, gnus-group-quit)
9 (gnus-group-set-info, gnus-add-mark): Use with-current-buffer.
10 (gnus-group-update-group): Use save-excursion and with-current-buffer.
11
12010-09-01 Katsumi Yamaoka <yamaoka@jpl.org> 122010-09-01 Katsumi Yamaoka <yamaoka@jpl.org>
2 13
3 * gnus-html.el (gnus-article-html): Decode contents by charset. 14 * gnus-html.el (gnus-article-html): Decode contents by charset.
diff --git a/lisp/gnus/gnus-cite.el b/lisp/gnus/gnus-cite.el
index 9502bd819cc..ebc84b6e0b6 100644
--- a/lisp/gnus/gnus-cite.el
+++ b/lisp/gnus/gnus-cite.el
@@ -407,9 +407,7 @@ lines matches `message-cite-prefix-regexp' with the same prefix.
407Lines matching `gnus-cite-attribution-suffix' and perhaps 407Lines matching `gnus-cite-attribution-suffix' and perhaps
408`gnus-cite-attribution-prefix' are considered attribution lines." 408`gnus-cite-attribution-prefix' are considered attribution lines."
409 (interactive (list 'force)) 409 (interactive (list 'force))
410 (save-excursion 410 (with-current-buffer (if same-buffer (current-buffer) gnus-article-buffer)
411 (unless same-buffer
412 (set-buffer gnus-article-buffer))
413 (gnus-cite-parse-maybe force) 411 (gnus-cite-parse-maybe force)
414 (let ((buffer-read-only nil) 412 (let ((buffer-read-only nil)
415 (alist gnus-cite-prefix-alist) 413 (alist gnus-cite-prefix-alist)
@@ -462,8 +460,7 @@ Lines matching `gnus-cite-attribution-suffix' and perhaps
462 460
463(defun gnus-dissect-cited-text () 461(defun gnus-dissect-cited-text ()
464 "Dissect the article buffer looking for cited text." 462 "Dissect the article buffer looking for cited text."
465 (save-excursion 463 (with-current-buffer gnus-article-buffer
466 (set-buffer gnus-article-buffer)
467 (gnus-cite-parse-maybe nil t) 464 (gnus-cite-parse-maybe nil t)
468 (let ((alist gnus-cite-prefix-alist) 465 (let ((alist gnus-cite-prefix-alist)
469 prefix numbers number marks m) 466 prefix numbers number marks m)
@@ -523,8 +520,7 @@ Lines matching `gnus-cite-attribution-suffix' and perhaps
523 "Do word wrapping in the current article. 520 "Do word wrapping in the current article.
524If WIDTH (the numerical prefix), use that text width when filling." 521If WIDTH (the numerical prefix), use that text width when filling."
525 (interactive (list t current-prefix-arg)) 522 (interactive (list t current-prefix-arg))
526 (save-excursion 523 (with-current-buffer gnus-article-buffer
527 (set-buffer gnus-article-buffer)
528 (let ((buffer-read-only nil) 524 (let ((buffer-read-only nil)
529 (inhibit-point-motion-hooks t) 525 (inhibit-point-motion-hooks t)
530 (marks (gnus-dissect-cited-text)) 526 (marks (gnus-dissect-cited-text))
@@ -578,67 +574,66 @@ always hide."
578 (interactive (append (gnus-article-hidden-arg) (list 'force))) 574 (interactive (append (gnus-article-hidden-arg) (list 'force)))
579 (gnus-set-format 'cited-opened-text-button t) 575 (gnus-set-format 'cited-opened-text-button t)
580 (gnus-set-format 'cited-closed-text-button t) 576 (gnus-set-format 'cited-closed-text-button t)
581 (save-excursion 577 (with-current-buffer gnus-article-buffer
582 (set-buffer gnus-article-buffer) 578 (let ((buffer-read-only nil)
583 (let ((buffer-read-only nil) 579 marks
584 marks 580 (inhibit-point-motion-hooks t)
585 (inhibit-point-motion-hooks t) 581 (props (nconc (list 'article-type 'cite)
586 (props (nconc (list 'article-type 'cite) 582 gnus-hidden-properties))
587 gnus-hidden-properties)) 583 (point (point-min))
588 (point (point-min)) 584 found beg end start)
589 found beg end start) 585 (while (setq point
590 (while (setq point 586 (text-property-any point (point-max)
591 (text-property-any point (point-max) 587 'gnus-callback
592 'gnus-callback 588 'gnus-article-toggle-cited-text))
593 'gnus-article-toggle-cited-text)) 589 (setq found t)
594 (setq found t) 590 (goto-char point)
595 (goto-char point) 591 (gnus-article-toggle-cited-text
596 (gnus-article-toggle-cited-text 592 (get-text-property point 'gnus-data) arg)
597 (get-text-property point 'gnus-data) arg) 593 (forward-line 1)
598 (forward-line 1) 594 (setq point (point)))
599 (setq point (point))) 595 (unless found
600 (unless found 596 (setq marks (gnus-dissect-cited-text))
601 (setq marks (gnus-dissect-cited-text)) 597 (while marks
602 (while marks 598 (setq beg nil
603 (setq beg nil 599 end nil)
604 end nil) 600 (while (and marks (string= (cdar marks) ""))
605 (while (and marks (string= (cdar marks) "")) 601 (setq marks (cdr marks)))
606 (setq marks (cdr marks))) 602 (when marks
607 (when marks 603 (setq beg (caar marks)))
608 (setq beg (caar marks))) 604 (while (and marks (not (string= (cdar marks) "")))
609 (while (and marks (not (string= (cdar marks) ""))) 605 (setq marks (cdr marks)))
610 (setq marks (cdr marks))) 606 (when marks
611 (when marks
612 (setq end (caar marks))) 607 (setq end (caar marks)))
613 ;; Skip past lines we want to leave visible. 608 ;; Skip past lines we want to leave visible.
614 (when (and beg end gnus-cited-lines-visible) 609 (when (and beg end gnus-cited-lines-visible)
615 (goto-char beg) 610 (goto-char beg)
616 (forward-line (if (consp gnus-cited-lines-visible) 611 (forward-line (if (consp gnus-cited-lines-visible)
617 (car gnus-cited-lines-visible) 612 (car gnus-cited-lines-visible)
618 gnus-cited-lines-visible)) 613 gnus-cited-lines-visible))
619 (if (>= (point) end) 614 (if (>= (point) end)
620 (setq beg nil) 615 (setq beg nil)
621 (setq beg (point-marker)) 616 (setq beg (point-marker))
622 (when (consp gnus-cited-lines-visible) 617 (when (consp gnus-cited-lines-visible)
623 (goto-char end) 618 (goto-char end)
624 (forward-line (- (cdr gnus-cited-lines-visible))) 619 (forward-line (- (cdr gnus-cited-lines-visible)))
625 (if (<= (point) beg) 620 (if (<= (point) beg)
626 (setq beg nil) 621 (setq beg nil)
627 (setq end (point-marker)))))) 622 (setq end (point-marker))))))
628 (when (and beg end) 623 (when (and beg end)
629 (gnus-add-wash-type 'cite) 624 (gnus-add-wash-type 'cite)
630 ;; We use markers for the end-points to facilitate later 625 ;; We use markers for the end-points to facilitate later
631 ;; wrapping and mangling of text. 626 ;; wrapping and mangling of text.
632 (setq beg (set-marker (make-marker) beg) 627 (setq beg (set-marker (make-marker) beg)
633 end (set-marker (make-marker) end)) 628 end (set-marker (make-marker) end))
634 (gnus-add-text-properties-when 'article-type nil beg end props) 629 (gnus-add-text-properties-when 'article-type nil beg end props)
635 (goto-char beg) 630 (goto-char beg)
636 (when (and gnus-cite-blank-line-after-header 631 (when (and gnus-cite-blank-line-after-header
637 (not (save-excursion (search-backward "\n\n" nil t)))) 632 (not (save-excursion (search-backward "\n\n" nil t))))
638 (insert "\n")) 633 (insert "\n"))
639 (put-text-property 634 (put-text-property
640 (setq start (point-marker)) 635 (setq start (point-marker))
641 (progn 636 (progn
642 (gnus-article-add-button 637 (gnus-article-add-button
643 (point) 638 (point)
644 (progn (eval gnus-cited-closed-text-button-line-format-spec) 639 (progn (eval gnus-cited-closed-text-button-line-format-spec)
@@ -646,8 +641,8 @@ always hide."
646 `gnus-article-toggle-cited-text 641 `gnus-article-toggle-cited-text
647 (list (cons beg end) start)) 642 (list (cons beg end) start))
648 (point)) 643 (point))
649 'article-type 'annotation) 644 'article-type 'annotation)
650 (set-marker beg (point)))))))) 645 (set-marker beg (point))))))))
651 646
652(defun gnus-article-toggle-cited-text (args &optional arg) 647(defun gnus-article-toggle-cited-text (args &optional arg)
653 "Toggle hiding the text in REGION. 648 "Toggle hiding the text in REGION.
@@ -750,11 +745,9 @@ See also the documentation for `gnus-article-highlight-citation'."
750(defun gnus-article-hide-citation-in-followups () 745(defun gnus-article-hide-citation-in-followups ()
751 "Hide cited text in non-root articles." 746 "Hide cited text in non-root articles."
752 (interactive) 747 (interactive)
753 (save-excursion 748 (with-current-buffer gnus-article-buffer
754 (set-buffer gnus-article-buffer)
755 (let ((article (cdr gnus-article-current))) 749 (let ((article (cdr gnus-article-current)))
756 (unless (save-excursion 750 (unless (with-current-buffer gnus-summary-buffer
757 (set-buffer gnus-summary-buffer)
758 (gnus-article-displayed-root-p article)) 751 (gnus-article-displayed-root-p article))
759 (gnus-article-hide-citation))))) 752 (gnus-article-hide-citation)))))
760 753
@@ -1097,8 +1090,7 @@ See also the documentation for `gnus-article-highlight-citation'."
1097 (gnus-overlay-put overlay 'face face)))))) 1090 (gnus-overlay-put overlay 'face face))))))
1098 1091
1099(defun gnus-cite-toggle (prefix) 1092(defun gnus-cite-toggle (prefix)
1100 (save-excursion 1093 (with-current-buffer gnus-article-buffer
1101 (set-buffer gnus-article-buffer)
1102 (gnus-cite-parse-maybe nil t) 1094 (gnus-cite-parse-maybe nil t)
1103 (let ((buffer-read-only nil) 1095 (let ((buffer-read-only nil)
1104 (numbers (cdr (assoc prefix gnus-cite-prefix-alist))) 1096 (numbers (cdr (assoc prefix gnus-cite-prefix-alist)))
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index e4758fadb85..b12d76b4618 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -1691,72 +1691,66 @@ if it is a string, only list groups matching REGEXP."
1691 "Update all lines where GROUP appear. 1691 "Update all lines where GROUP appear.
1692If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't 1692If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1693already." 1693already."
1694 ;; Can't use `save-excursion' here, so we do it manually. 1694 (with-current-buffer gnus-group-buffer
1695 (let ((buf (current-buffer)) 1695 (save-excursion
1696 mark) 1696 ;; The buffer may be narrowed.
1697 (set-buffer gnus-group-buffer) 1697 (save-restriction
1698 (setq mark (point-marker)) 1698 (widen)
1699 ;; The buffer may be narrowed. 1699 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1700 (save-restriction 1700 (loc (point-min))
1701 (widen) 1701 found buffer-read-only)
1702 (let ((ident (gnus-intern-safe group gnus-active-hashtb)) 1702 ;; Enter the current status into the dribble buffer.
1703 (loc (point-min)) 1703 (let ((entry (gnus-group-entry group)))
1704 found buffer-read-only) 1704 (when (and entry
1705 ;; Enter the current status into the dribble buffer. 1705 (not (gnus-ephemeral-group-p group)))
1706 (let ((entry (gnus-group-entry group))) 1706 (gnus-dribble-enter
1707 (when (and entry 1707 (concat "(gnus-group-set-info '"
1708 (not (gnus-ephemeral-group-p group))) 1708 (gnus-prin1-to-string (nth 2 entry))
1709 (gnus-dribble-enter 1709 ")"))))
1710 (concat "(gnus-group-set-info '" 1710 ;; Find all group instances. If topics are in use, each group
1711 (gnus-prin1-to-string (nth 2 entry)) 1711 ;; may be listed in more than once.
1712 ")")))) 1712 (while (setq loc (text-property-any
1713 ;; Find all group instances. If topics are in use, each group 1713 loc (point-max) 'gnus-group ident))
1714 ;; may be listed in more than once. 1714 (setq found t)
1715 (while (setq loc (text-property-any 1715 (goto-char loc)
1716 loc (point-max) 'gnus-group ident)) 1716 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1717 (setq found t) 1717 (gnus-delete-line)
1718 (goto-char loc) 1718 (gnus-group-insert-group-line-info group)
1719 (let ((gnus-group-indentation (gnus-group-group-indentation))) 1719 (save-excursion
1720 (gnus-delete-line) 1720 (forward-line -1)
1721 (gnus-group-insert-group-line-info group) 1721 (gnus-run-hooks 'gnus-group-update-group-hook)))
1722 (save-excursion 1722 (setq loc (1+ loc)))
1723 (forward-line -1) 1723 (unless (or found visible-only)
1724 (gnus-run-hooks 'gnus-group-update-group-hook))) 1724 ;; No such line in the buffer, find out where it's supposed to
1725 (setq loc (1+ loc))) 1725 ;; go, and insert it there (or at the end of the buffer).
1726 (unless (or found visible-only) 1726 (if gnus-goto-missing-group-function
1727 ;; No such line in the buffer, find out where it's supposed to 1727 (funcall gnus-goto-missing-group-function group)
1728 ;; go, and insert it there (or at the end of the buffer). 1728 (let ((entry (cddr (gnus-group-entry group))))
1729 (if gnus-goto-missing-group-function 1729 (while (and entry (car entry)
1730 (funcall gnus-goto-missing-group-function group) 1730 (not
1731 (let ((entry (cddr (gnus-group-entry group)))) 1731 (gnus-goto-char
1732 (while (and entry (car entry) 1732 (text-property-any
1733 (not 1733 (point-min) (point-max)
1734 (gnus-goto-char 1734 'gnus-group (gnus-intern-safe
1735 (text-property-any 1735 (caar entry)
1736 (point-min) (point-max) 1736 gnus-active-hashtb)))))
1737 'gnus-group (gnus-intern-safe 1737 (setq entry (cdr entry)))
1738 (caar entry) gnus-active-hashtb))))) 1738 (or entry (goto-char (point-max)))))
1739 (setq entry (cdr entry))) 1739 ;; Finally insert the line.
1740 (or entry (goto-char (point-max))))) 1740 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1741 ;; Finally insert the line. 1741 (gnus-group-insert-group-line-info group)
1742 (let ((gnus-group-indentation (gnus-group-group-indentation))) 1742 (save-excursion
1743 (gnus-group-insert-group-line-info group) 1743 (forward-line -1)
1744 (save-excursion 1744 (gnus-run-hooks 'gnus-group-update-group-hook))))
1745 (forward-line -1) 1745 (when gnus-group-update-group-function
1746 (gnus-run-hooks 'gnus-group-update-group-hook)))) 1746 (funcall gnus-group-update-group-function group))
1747 (when gnus-group-update-group-function 1747 (gnus-group-set-mode-line))))))
1748 (funcall gnus-group-update-group-function group))
1749 (gnus-group-set-mode-line)))
1750 (goto-char mark)
1751 (set-marker mark nil)
1752 (set-buffer buf)))
1753 1748
1754(defun gnus-group-set-mode-line () 1749(defun gnus-group-set-mode-line ()
1755 "Update the mode line in the group buffer." 1750 "Update the mode line in the group buffer."
1756 (when (memq 'group gnus-updated-mode-lines) 1751 (when (memq 'group gnus-updated-mode-lines)
1757 ;; Yes, we want to keep this mode line updated. 1752 ;; Yes, we want to keep this mode line updated.
1758 (save-excursion 1753 (with-current-buffer gnus-group-buffer
1759 (set-buffer gnus-group-buffer)
1760 (let* ((gformat (or gnus-group-mode-line-format-spec 1754 (let* ((gformat (or gnus-group-mode-line-format-spec
1761 (gnus-set-format 'group-mode))) 1755 (gnus-set-format 'group-mode)))
1762 (gnus-tmp-news-server (cadr gnus-select-method)) 1756 (gnus-tmp-news-server (cadr gnus-select-method))
@@ -1769,8 +1763,7 @@ already."
1769 (and gnus-dribble-buffer 1763 (and gnus-dribble-buffer
1770 (buffer-name gnus-dribble-buffer) 1764 (buffer-name gnus-dribble-buffer)
1771 (buffer-modified-p gnus-dribble-buffer) 1765 (buffer-modified-p gnus-dribble-buffer)
1772 (save-excursion 1766 (with-current-buffer gnus-dribble-buffer
1773 (set-buffer gnus-dribble-buffer)
1774 (not (zerop (buffer-size)))))) 1767 (not (zerop (buffer-size))))))
1775 (mode-string (eval gformat))) 1768 (mode-string (eval gformat)))
1776 ;; Say whether the dribble buffer has been modified. 1769 ;; Say whether the dribble buffer has been modified.
@@ -4433,8 +4426,7 @@ The hook `gnus-exit-gnus-hook' is called before actually exiting."
4433 (gnus-run-hooks 'gnus-exit-gnus-hook) 4426 (gnus-run-hooks 'gnus-exit-gnus-hook)
4434 (gnus-configure-windows 'group t) 4427 (gnus-configure-windows 'group t)
4435 (when (and (gnus-buffer-live-p gnus-dribble-buffer) 4428 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4436 (not (zerop (save-excursion 4429 (not (zerop (with-current-buffer gnus-dribble-buffer
4437 (set-buffer gnus-dribble-buffer)
4438 (buffer-size))))) 4430 (buffer-size)))))
4439 (gnus-dribble-enter 4431 (gnus-dribble-enter
4440 ";;; Gnus was exited on purpose without saving the .newsrc files.")) 4432 ";;; Gnus was exited on purpose without saving the .newsrc files."))
@@ -4495,13 +4487,11 @@ and the second element is the address."
4495 (setcar (nthcdr (1- total) info) part-info))) 4487 (setcar (nthcdr (1- total) info) part-info)))
4496 (unless entry 4488 (unless entry
4497 ;; This is a new group, so we just create it. 4489 ;; This is a new group, so we just create it.
4498 (save-excursion 4490 (with-current-buffer gnus-group-buffer
4499 (set-buffer gnus-group-buffer)
4500 (setq method (gnus-info-method info)) 4491 (setq method (gnus-info-method info))
4501 (when (gnus-server-equal method "native") 4492 (when (gnus-server-equal method "native")
4502 (setq method nil)) 4493 (setq method nil))
4503 (save-excursion 4494 (with-current-buffer gnus-group-buffer
4504 (set-buffer gnus-group-buffer)
4505 (if method 4495 (if method
4506 ;; It's a foreign group... 4496 ;; It's a foreign group...
4507 (gnus-group-make-group 4497 (gnus-group-make-group
@@ -4565,8 +4555,7 @@ and the second element is the address."
4565 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not." 4555 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4566 (let ((buffer (gnus-summary-buffer-name group))) 4556 (let ((buffer (gnus-summary-buffer-name group)))
4567 (if (gnus-buffer-live-p buffer) 4557 (if (gnus-buffer-live-p buffer)
4568 (save-excursion 4558 (with-current-buffer (get-buffer buffer)
4569 (set-buffer (get-buffer buffer))
4570 (gnus-summary-add-mark article mark)) 4559 (gnus-summary-add-mark article mark))
4571 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists)) 4560 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4572 (list article))))) 4561 (list article)))))
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index dece8dccece..b3752506c8f 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -3937,8 +3937,7 @@ If SYMBOL, return the value of that symbol in the group parameters.
3937 3937
3938If you call this function inside a loop, consider using the faster 3938If you call this function inside a loop, consider using the faster
3939`gnus-group-fast-parameter' instead." 3939`gnus-group-fast-parameter' instead."
3940 (save-excursion 3940 (with-current-buffer gnus-group-buffer
3941 (set-buffer gnus-group-buffer)
3942 (if symbol 3941 (if symbol
3943 (gnus-group-fast-parameter group symbol allow-list) 3942 (gnus-group-fast-parameter group symbol allow-list)
3944 (nconc 3943 (nconc
@@ -4097,8 +4096,7 @@ Returns the number of articles marked as read."
4097(defun gnus-kill-save-kill-buffer () 4096(defun gnus-kill-save-kill-buffer ()
4098 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))) 4097 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
4099 (when (get-file-buffer file) 4098 (when (get-file-buffer file)
4100 (save-excursion 4099 (with-current-buffer (get-file-buffer file)
4101 (set-buffer (get-file-buffer file))
4102 (when (buffer-modified-p) 4100 (when (buffer-modified-p)
4103 (save-buffer)) 4101 (save-buffer))
4104 (kill-buffer (current-buffer)))))) 4102 (kill-buffer (current-buffer))))))