Subject: Re: bug#10407: Random point jumps

From: Leo <[email-masked]>
Date: Fri, 30 Dec 2011 15:13:51 +0800

The following patch against emacs-24 fixes the bug. Could someone review
and fix it in Emacs-24 too? Thanks.

=== modified file 'lisp/gnus/gnus-topic.el'
--- lisp/gnus/gnus-topic.el	2011-11-25 07:14:48 +0000
+++ lisp/gnus/gnus-topic.el	2011-12-30 07:09:11 +0000
@@ -969,12 +969,15 @@
   (if (not group)
       (if (not (memq 'gnus-topic props))
 	  (goto-char (point-max))
-	(gnus-topic-goto-topic (symbol-name (cadr (memq 'gnus-topic props)))))
+	(let ((topic (symbol-name (cadr (memq 'gnus-topic props)))))
+	  (or (gnus-topic-goto-topic topic)
+	      (gnus-topic-goto-topic (gnus-topic-next-topic topic)))))
     (if (gnus-group-goto-group group)
 	t
       ;; The group is no longer visible.
       (let* ((list (assoc (gnus-group-topic group) gnus-topic-alist))
-	     (after (cdr (member group (cdr list)))))
+	     (topic-visible (save-excursion (gnus-topic-goto-topic (car list))))
+	     (after (and topic-visible (cdr (member group (cdr list))))))
 	;; First try to put point on a group after the current one.
 	(while (and after
 		    (not (gnus-group-goto-group (car after))))
@@ -989,7 +992,9 @@
 	(if (not (car list))
 	    (goto-char (point-min))
 	  (unless after
-	    (gnus-topic-goto-topic (car list))
+	    (if topic-visible
+		(gnus-goto-char topic-visible)
+	      (gnus-topic-goto-topic (gnus-topic-next-topic (car list))))
 	    (setq after nil)))
 	t))))