*** empty log message ***
[gnus] / lisp / gnus-salt.el
index 14c15ab..3cbbf14 100644 (file)
@@ -43,6 +43,9 @@
 (defvar gnus-mark-unpicked-articles-as-read nil
   "*If non-nil, mark all unpicked articles as read.")
 
+(defvar gnus-pick-elegant-flow t
+  "If non-nil, gnus-pick-start-reading will run gnus-summary-next-group when no articles have been picked.")
+
 (defvar gnus-summary-pick-line-format
   "%-5P %U\%R\%z\%I\%(%[%4L: %-20,20n%]%) %s\n"
   "*The format specification of the lines in pick buffers.
@@ -70,7 +73,8 @@ It accepts the same format specs that `gnus-summary-line-format' does.")
    "b" gnus-uu-mark-buffer
    "B" gnus-uu-unmark-buffer
    "." gnus-pick-article
-   gnus-mouse-2 gnus-mouse-pick-article
+   gnus-down-mouse-2 gnus-pick-mouse-pick-region
+   ;;gnus-mouse-2 gnus-pick-mouse-pick
    "\r" gnus-pick-start-reading))
 
 (defun gnus-pick-make-menu-bar ()
@@ -99,19 +103,17 @@ It accepts the same format specs that `gnus-summary-line-format' does.")
 \\{gnus-pick-mode-map}"
   (interactive "P")
   (when (eq major-mode 'gnus-summary-mode)
-    (make-local-variable 'gnus-pick-mode)
-    (setq gnus-pick-mode 
-         (if (null arg) (not gnus-pick-mode)
-           (> (prefix-numeric-value arg) 0)))
-    (when gnus-pick-mode
+    (when (set (make-local-variable 'gnus-pick-mode)
+              (if (null arg) (not gnus-pick-mode)
+                (> (prefix-numeric-value arg) 0)))
       ;; Make sure that we don't select any articles upon group entry.
-      (make-local-variable 'gnus-auto-select-first)
-      (setq gnus-auto-select-first nil)
+      (set (make-local-variable 'gnus-auto-select-first) nil)
       ;; Change line format.
       (setq gnus-summary-line-format gnus-summary-pick-line-format)
       (setq gnus-summary-line-format-spec nil)
       (gnus-update-format-specifications nil 'summary)
       (gnus-update-summary-mark-positions)
+      (set (make-local-variable 'gnus-summary-goto-unread) 'never)
       ;; Set up the menu.
       (when (and menu-bar-mode
                 (gnus-visual-p 'pick-menu 'menu))
@@ -134,13 +136,17 @@ It accepts the same format specs that `gnus-summary-line-format' does.")
   "Start reading the picked articles.
 If given a prefix, mark all unpicked articles as read."
   (interactive "P")
-  (unless gnus-newsgroup-processable
-    (error "No articles have been picked"))
-  (gnus-summary-limit-to-articles nil)
-  (when (or catch-up gnus-mark-unpicked-articles-as-read)
-    (gnus-summary-limit-mark-excluded-as-read))
-  (gnus-summary-first-unread-article)
-  (gnus-configure-windows (if gnus-pick-display-summary 'article 'pick) t))
+  (if gnus-newsgroup-processable
+      (progn
+        (gnus-summary-limit-to-articles nil)
+        (when (or catch-up gnus-mark-unpicked-articles-as-read)
+         (gnus-summary-limit-mark-excluded-as-read))
+        (gnus-summary-first-unread-article)
+        (gnus-configure-windows 
+        (if gnus-pick-display-summary 'article 'pick) t))
+    (if gnus-pick-elegant-flow
+        (gnus-summary-next-group)
+      (error "No articles have been picked"))))
 
 (defun gnus-pick-article (&optional arg)
   "Pick the article on the current line.
@@ -157,25 +163,116 @@ If ARG, pick the article on that line instead."
        (goto-char pos))))
   (gnus-summary-mark-as-processable 1))
 
-(defun gnus-mouse-pick-article (e)
+(defun gnus-pick-mouse-pick (e)
   (interactive "e")
   (mouse-set-point e)
   (save-excursion
     (gnus-summary-mark-as-processable 1)))
 
+(defun gnus-pick-mouse-pick-region (start-event)
+  "Pick articles that the mouse is dragged over.
+This must be bound to a button-down mouse event."
+  (interactive "e")
+  (mouse-minibuffer-check start-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-window (posn-window start-posn))
+        (start-frame (window-frame start-window))
+        (bounds (window-edges start-window))
+        (top (nth 1 bounds))
+        (bottom (if (window-minibuffer-p start-window)
+                    (nth 3 bounds)
+                  ;; Don't count the mode line.
+                  (1- (nth 3 bounds))))
+        (click-count (1- (event-click-count start-event))))
+    (setq mouse-selection-click-count click-count)
+    (setq mouse-selection-click-count-buffer (current-buffer))
+    (mouse-set-point start-event)
+    ;; In case the down click is in the middle of some intangible text,
+    ;; use the end of that text, and put it in START-POINT.
+    (if (< (point) start-point)
+       (goto-char start-point))
+    (gnus-pick-article)
+    (setq start-point (point))
+    ;; end-of-range is used only in the single-click case.
+    ;; It is the place where the drag has reached so far
+    ;; (but not outside the window where the drag started).
+    (let (event end end-point last-end-point (end-of-range (point)))
+      (track-mouse
+       (while (progn
+                (setq event (read-event))
+                (or (mouse-movement-p event)
+                    (eq (car-safe event) 'switch-frame)))
+         (if (eq (car-safe event) 'switch-frame)
+             nil
+           (setq end (event-end event)
+                 end-point (posn-point end))
+           (if end-point
+               (setq last-end-point end-point))
+
+           (cond
+            ;; 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,
+             ;; 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)))
+                     (min-line (min this-line start-line))
+                     (max-line (max this-line start-line)))
+                (while (< min-line max-line)
+                  (goto-line min-line)
+                  (gnus-pick-article)
+                  (setq min-line (1+ min-line)))
+                (setq start-line this-line))
+             (if (zerop (% click-count 3))
+                 (setq end-of-range (point))))
+             (t
+             (let ((mouse-row (cdr (cdr (mouse-position)))))
+               (cond
+                ((null mouse-row))
+                ((< mouse-row top)
+                 (mouse-scroll-subr start-window (- mouse-row top)))
+                ((>= mouse-row bottom)
+                 (mouse-scroll-subr start-window
+                                     (1+ (- mouse-row bottom)))))))))))
+      (if (consp event)
+         (let ((fun (key-binding (vector (car event)))))
+           ;; Run the binding of the terminating up-event, if possible.
+           ;; In the case of a multiple click, it gives the wrong results,
+           ;; because it would fail to set up a region.
+           (if nil ;; (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
+               ;; In this case, we can just let the up-event execute normally.
+               (let ((end (event-end event)))
+                 ;; Set the position in the event before we replay it,
+                 ;; because otherwise it may have a position in the wrong
+                 ;; buffer.
+                 (setcar (cdr end) end-of-range)
+                 ;; Delete the overlay before calling the function,
+                 ;; because delete-overlay increases buffer-modified-tick.
+                 (setq unread-command-events
+                       (cons event unread-command-events)))))))))
+
 (defun gnus-pick-next-page ()
   "Go to the next page.  If at the end of the buffer, start reading articles."
   (interactive)
-  (condition-case ()
+  (condition-case nil
       (scroll-up)
-    (gnus-pick-start-reading)))
+    (end-of-buffer (gnus-pick-start-reading))))
 
 ;;;
 ;;; gnus-binary-mode
 ;;;
 
 (defvar gnus-binary-mode nil
-  "Minor mode for provind a binary group interface in Gnus summary buffers.")
+  "Minor mode for providing a binary group interface in Gnus summary buffers.")
 
 (defvar gnus-binary-mode-hook nil
   "Hook run in summary binary mode buffers.")
@@ -253,7 +350,7 @@ lines.")
   "Brackets used in tree nodes.")
 
 (defvar gnus-tree-parent-child-edges '(?- ?\\ ?|)
-  "Charaters used to connect parents with children.")
+  "Characters used to connect parents with children.")
 
 (defvar gnus-tree-mode-line-format "Gnus: %%b %S %Z"
   "*The format specification for the tree mode line.")
@@ -656,7 +753,7 @@ Two predefined functions are available:
   (gnus-get-tree-buffer))
 
 (defun gnus-tree-close (group)
-  ;(gnus-kill-buffer gnus-tree-buffer)
+                                       ;(gnus-kill-buffer gnus-tree-buffer)
   )
 
 (defun gnus-highlight-selected-tree (article)