Fix inconsistent point movement in the Gnus group buffer

* lisp/gnus/gnus-group.el (gnus-group-goto-group): If we can't
find the group we're looking for, then don't move point at all
(bug#23021).
This commit is contained in:
Lars Ingebrigtsen 2018-04-16 23:10:03 +02:00
parent 36e5673753
commit c8be645598

View file

@ -2565,51 +2565,53 @@ If PROMPT (the prefix) is a number, use the prompt specified in
If FAR, it is likely that the group is not on the current line.
If TEST-MARKED, the line must be marked."
(when group
(beginning-of-line)
(cond
;; It's quite likely that we are on the right line, so
;; we check the current line first.
((and (not far)
(eq (get-text-property (point) 'gnus-group)
(gnus-intern-safe group gnus-active-hashtb))
(or (not test-marked) (gnus-group-mark-line-p)))
(point))
;; Previous and next line are also likely, so we check them as well.
((and (not far)
(save-excursion
(forward-line -1)
(and (eq (get-text-property (point) 'gnus-group)
(gnus-intern-safe group gnus-active-hashtb))
(or (not test-marked) (gnus-group-mark-line-p)))))
(forward-line -1)
(point))
((and (not far)
(save-excursion
(forward-line 1)
(and (eq (get-text-property (point) 'gnus-group)
(gnus-intern-safe group gnus-active-hashtb))
(or (not test-marked) (gnus-group-mark-line-p)))))
(forward-line 1)
(point))
(test-marked
(goto-char (point-min))
(let (found)
(while (and (not found)
(gnus-goto-char
(text-property-any
(point) (point-max)
'gnus-group
(gnus-intern-safe group gnus-active-hashtb))))
(if (gnus-group-mark-line-p)
(setq found t)
(forward-line 1)))
found))
(t
;; Search through the entire buffer.
(gnus-goto-char
(text-property-any
(point-min) (point-max)
'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
(let ((start (point)))
(beginning-of-line)
(cond
;; It's quite likely that we are on the right line, so
;; we check the current line first.
((and (not far)
(eq (get-text-property (point) 'gnus-group)
(gnus-intern-safe group gnus-active-hashtb))
(or (not test-marked) (gnus-group-mark-line-p)))
(point))
;; Previous and next line are also likely, so we check them as well.
((and (not far)
(save-excursion
(forward-line -1)
(and (eq (get-text-property (point) 'gnus-group)
(gnus-intern-safe group gnus-active-hashtb))
(or (not test-marked) (gnus-group-mark-line-p)))))
(forward-line -1)
(point))
((and (not far)
(save-excursion
(forward-line 1)
(and (eq (get-text-property (point) 'gnus-group)
(gnus-intern-safe group gnus-active-hashtb))
(or (not test-marked) (gnus-group-mark-line-p)))))
(forward-line 1)
(point))
(test-marked
(goto-char (point-min))
(let (found)
(while (and (not found)
(gnus-goto-char
(text-property-any
(point) (point-max)
'gnus-group
(gnus-intern-safe group gnus-active-hashtb))))
(if (gnus-group-mark-line-p)
(setq found t)
(forward-line 1)))
found))
(t
;; Search through the entire buffer.
(unless (gnus-goto-char
(text-property-any
(point-min) (point-max)
'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
(goto-char start)))))))
(defun gnus-group-next-group (n &optional silent)
"Go to next N'th newsgroup.