Merge from gnus--rel--5.10
[gnus] / lisp / gnus-salt.el
index b0329d1..6ecb7b4 100644 (file)
@@ -1,7 +1,7 @@
 ;;; gnus-salt.el --- alternate summary mode interfaces for Gnus
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2001
-;;        Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -10,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -20,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -128,18 +128,16 @@ It accepts the same format specs that `gnus-summary-line-format' does."
       ;; Set up the menu.
       (when (gnus-visual-p 'pick-menu 'menu)
        (gnus-pick-make-menu-bar))
-      (add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map
-                          nil 'gnus-pick-mode)
+      (add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map)
       (gnus-run-hooks 'gnus-pick-mode-hook))))
 
 (defun gnus-pick-setup-message ()
   "Make Message do the right thing on exit."
   (when (and (gnus-buffer-live-p gnus-summary-buffer)
-            (save-excursion
-              (set-buffer gnus-summary-buffer)
+            (with-current-buffer gnus-summary-buffer
               gnus-pick-mode))
     (message-add-action
-     '(gnus-configure-windows ,gnus-current-window-configuration t)
+     `(gnus-configure-windows ,gnus-current-window-configuration t)
      'send 'exit 'postpone 'kill)))
 
 (defvar gnus-pick-line-number 1)
@@ -230,7 +228,7 @@ This must be bound to a button-down mouse event."
   (let* ((echo-keystrokes 0)
         (start-posn (event-start start-event))
         (start-point (posn-point start-posn))
-        (start-line (1+ (count-lines 1 start-point)))
+         (start-line (1+ (count-lines (point-min) start-point)))
         (start-window (posn-window start-posn))
         (bounds (gnus-window-edges start-window))
         (top (nth 1 bounds))
@@ -266,17 +264,18 @@ This must be bound to a button-down mouse event."
             ;; Are we moving within the original window?
             ((and (eq (posn-window end) start-window)
                   (integer-or-marker-p end-point))
-       ;; Go to START-POINT first, so that when we move to END-POINT,
+             ;; Go to START-POINT first, so that when we move to END-POINT,
              ;; if it's in the middle of intangible text,
              ;; point jumps in the direction away from START-POINT.
              (goto-char start-point)
              (goto-char end-point)
              (gnus-pick-article)
              ;; In case the user moved his mouse really fast, pick
-           ;; articles on the line between this one and the last one.
-             (let* ((this-line (1+ (count-lines 1 end-point)))
+             ;; articles on the line between this one and the last one.
+             (let* ((this-line (1+ (count-lines (point-min) end-point)))
                     (min-line (min this-line start-line))
                     (max-line (max this-line start-line)))
+               ;; Why not use `forward-line'?  --Stef
                (while (< min-line max-line)
                  (goto-line min-line)
                  (gnus-pick-article)
@@ -361,8 +360,7 @@ This must be bound to a button-down mouse event."
       ;; Set up the menu.
       (when (gnus-visual-p 'binary-menu 'menu)
        (gnus-binary-make-menu-bar))
-      (add-minor-mode 'gnus-binary-mode " Binary"
-                          gnus-binary-mode-map nil 'gnus-binary-mode)
+      (add-minor-mode 'gnus-binary-mode " Binary" gnus-binary-mode-map)
       (gnus-run-hooks 'gnus-binary-mode-hook))))
 
 (defun gnus-binary-display-article (article &optional all-header)
@@ -495,7 +493,7 @@ Two predefined functions are available:
     (gnus-set-work-buffer)
     (gnus-tree-node-insert (make-mail-header "") nil)
     (setq gnus-tree-node-length (1- (point))))
-  (gnus-run-hooks 'gnus-tree-mode-hook))
+  (gnus-run-mode-hooks 'gnus-tree-mode-hook))
 
 (defun gnus-tree-read-summary-keys (&optional arg)
   "Read a summary buffer key sequence and execute it."
@@ -525,8 +523,7 @@ Two predefined functions are available:
   (interactive (list (gnus-tree-article-number)))
   (let ((buf (current-buffer)))
     (when article
-      (save-excursion
-       (set-buffer gnus-summary-buffer)
+      (with-current-buffer gnus-summary-buffer
        (gnus-summary-goto-article article))
       (select-window (get-buffer-window buf)))))
 
@@ -577,8 +574,7 @@ Two predefined functions are available:
 
 (defun gnus-get-tree-buffer ()
   "Return the tree buffer properly initialized."
-  (save-excursion
-    (set-buffer (gnus-get-buffer-create gnus-tree-buffer))
+  (with-current-buffer (gnus-get-buffer-create gnus-tree-buffer)
     (unless (eq major-mode 'gnus-tree-mode)
       (gnus-tree-mode))
     (current-buffer)))
@@ -663,8 +659,7 @@ Two predefined functions are available:
   "Highlight current line according to `gnus-summary-highlight'."
   (let ((list gnus-summary-highlight)
        face)
-    (save-excursion
-      (set-buffer gnus-summary-buffer)
+    (with-current-buffer gnus-summary-buffer
       (let* ((score (or (cdr (assq article gnus-newsgroup-scored))
                        gnus-summary-default-score 0))
             (default gnus-summary-default-score)
@@ -691,8 +686,7 @@ Two predefined functions are available:
 
 (defun gnus-generate-tree (thread)
   "Generate a thread tree for THREAD."
-  (save-excursion
-    (set-buffer (gnus-get-tree-buffer))
+  (with-current-buffer (gnus-get-tree-buffer)
     (let ((buffer-read-only nil)
          (gnus-tmp-indent 0))
       (erase-buffer)
@@ -787,7 +781,7 @@ Two predefined functions are available:
          (setq beg (point))
          (forward-char -1)
          ;; Draw "-" lines leftwards.
-         (while (and (> (point) 1)
+         (while (and (not (bobp))
                      (eq (char-after (1- (point))) ? ))
            (delete-char -1)
            (insert (car gnus-tree-parent-child-edges))
@@ -815,14 +809,12 @@ Two predefined functions are available:
 
 (defun gnus-possibly-generate-tree (article &optional force)
   "Generate the thread tree for ARTICLE if it isn't displayed already."
-  (when (save-excursion
-         (set-buffer gnus-summary-buffer)
+  (when (with-current-buffer gnus-summary-buffer
          (and gnus-use-trees
               gnus-show-threads
               (vectorp (gnus-summary-article-header article))))
     (save-excursion
-      (let ((top (save-excursion
-                  (set-buffer gnus-summary-buffer)
+      (let ((top (with-current-buffer gnus-summary-buffer
                   (gnus-cut-thread
                    (gnus-remove-thread
                     (mail-header-id
@@ -844,8 +836,7 @@ Two predefined functions are available:
 (defun gnus-tree-perhaps-minimize ()
   (when (and gnus-tree-minimize-window
             (get-buffer gnus-tree-buffer))
-    (save-excursion
-      (set-buffer gnus-tree-buffer)
+    (with-current-buffer gnus-tree-buffer
       (gnus-tree-minimize))))
 
 (defun gnus-highlight-selected-tree (article)
@@ -858,7 +849,8 @@ Two predefined functions are available:
                (gnus-extent-detached-p gnus-selected-tree-overlay))
        ;; Create a new overlay.
        (gnus-overlay-put
-        (setq gnus-selected-tree-overlay (gnus-make-overlay 1 2))
+        (setq gnus-selected-tree-overlay
+              (gnus-make-overlay (point-min) (1+ (point-min))))
         'face gnus-selected-tree-face))
       ;; Move the overlay to the article.
       (gnus-move-overlay
@@ -871,14 +863,12 @@ Two predefined functions are available:
          (gnus-horizontal-recenter)
          (select-window selected))))
 ;; If we remove this save-excursion, it updates the wrong mode lines?!?
-    (save-excursion
-      (set-buffer gnus-tree-buffer)
+    (with-current-buffer gnus-tree-buffer
       (gnus-set-mode-line 'tree))
     (set-buffer buf)))
 
 (defun gnus-tree-highlight-article (article face)
-  (save-excursion
-    (set-buffer (gnus-get-tree-buffer))
+  (with-current-buffer (gnus-get-tree-buffer)
     (let (region)
       (when (setq region (gnus-tree-article-region article))
        (gnus-put-text-property (car region) (cdr region) 'face face)
@@ -1007,14 +997,13 @@ The following commands are available:
   (buffer-disable-undo)
   (setq buffer-read-only t)
   (make-local-variable 'gnus-carpal-attached-buffer)
-  (gnus-run-hooks 'gnus-carpal-mode-hook))
+  (gnus-run-mode-hooks 'gnus-carpal-mode-hook))
 
 (defun gnus-carpal-setup-buffer (type)
   (let ((buffer (symbol-value (intern (format "gnus-carpal-%s-buffer" type)))))
     (if (get-buffer buffer)
        ()
-      (save-excursion
-       (set-buffer (gnus-get-buffer-create buffer))
+      (with-current-buffer (gnus-get-buffer-create buffer)
        (gnus-carpal-mode)
        (setq gnus-carpal-attached-buffer
              (intern (format "gnus-%s-buffer" type)))
@@ -1062,5 +1051,5 @@ The following commands are available:
 
 (provide 'gnus-salt)
 
-;;; arch-tag: 35449164-77b3-4398-bcbd-a2e3e998f810
+;; arch-tag: 35449164-77b3-4398-bcbd-a2e3e998f810
 ;;; gnus-salt.el ends here