emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multi-article Isearch in Gnus (was: Conflict about M-s)


From: Juri Linkov
Subject: Multi-article Isearch in Gnus (was: Conflict about M-s)
Date: Mon, 29 Dec 2008 01:55:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

[Cc'd address@hidden

> 1. Gnus binds `M-s' to `gnus-summary-search-article-forward'.

In order to compensate the need to change the key binding `M-s' in Gnus that
now conflicts with the global prefix key `M-s' in Emacs 23, I implemented
support for multi-article Isearch.  This means that after installing the
following small patch, typing `C-s' in the *Article* buffer will switch
to the next article with more search hits when Isearch finds no more
search results in the current article.  This works like the current
non-incremental command `M-s', but like `C-s' it searches incrementally.
Another way to run it is to type `s' in the *Summary* buffer that
will start Isearch in the *Article* buffer with multi-article support.
It has no effect on versions other than Emacs 23.

Index: lisp/gnus/gnus-art.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/gnus/gnus-art.el,v
retrieving revision 1.172
diff -u -r1.172 gnus-art.el
--- lisp/gnus/gnus-art.el       4 Dec 2008 10:53:19 -0000       1.172
+++ lisp/gnus/gnus-art.el       28 Dec 2008 23:55:05 -0000
@@ -4366,6 +4366,9 @@
   ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
   ;; face.
   (set (make-local-variable 'nobreak-char-display) nil)
+  ;; For multi-article Isearch in Emacs 23.
+  (set (make-local-variable 'multi-isearch-next-buffer-function)
+       'gnus-article-isearch-next-buffer)
   (setq cursor-in-non-selected-windows nil)
   (setq truncate-lines gnus-article-truncate-lines)
   (gnus-set-default-directory)
@@ -6758,6 +6761,48 @@
                            (point))
          (set-buffer buf))))))
 
+
+(defun gnus-article-isearch-next-buffer (&optional buffer wrap)
+  "Find and return the next article buffer for multi-article Isearch.
+`gnus-select-article-hook' is not called during the search."
+  ;; We have to require this here to make sure that the following
+  ;; dynamic binding isn't shadowed by autoloading.
+  (require 'gnus-async)
+  (require 'gnus-art)
+  (let ((gnus-select-article-hook nil) ;Disable hook.
+       (gnus-article-prepare-hook nil)
+       (gnus-mark-article-hook nil)    ;Inhibit marking as read.
+       (gnus-use-article-prefetch nil)
+       (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
+       (gnus-use-trees nil)            ;Inhibit updating tree buffer.
+       (gnus-visual nil)
+       (gnus-keep-backlog nil)
+       (gnus-break-pages nil)
+       (gnus-summary-display-arrow nil)
+       (gnus-updated-mode-lines nil)
+       (gnus-auto-center-summary nil)
+       (gnus-display-mime-function nil)
+       (found 'not))
+    (with-current-buffer gnus-summary-buffer
+      (if wrap
+         (goto-char (if isearch-forward (point-min) (point-max)))
+       (while (eq found 'not)
+         (if (not (if isearch-forward
+                      (gnus-summary-find-next)
+                    (gnus-summary-find-prev)))
+             ;; No more articles.
+             (setq found nil)
+           ;; Select the next article and adjust point.
+           (unless (gnus-summary-article-sparse-p
+                    (gnus-summary-article-number))
+             (setq found t)))))
+      (gnus-summary-select-article)
+      (pop-to-buffer gnus-article-buffer)
+      (widen)
+      ;; Return nil when no more articles.
+      (and found (current-buffer)))))
+
+
 ;;;
 ;;; Article editing
 ;;;

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]