1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-06 11:50:51 -08:00

* lisp/simple.el (next-line-completion): Improve (bug#59486).

Handle the case when lines with completion candidates are
interspersed with lines that contain group headings.
This commit is contained in:
Juri Linkov 2023-11-06 19:43:06 +02:00
parent dfffb91a70
commit a1abb6a85e

View file

@ -10017,7 +10017,7 @@ With prefix argument N, move N lines forward (negative N means move backward).
Also see the `completion-auto-wrap' variable." Also see the `completion-auto-wrap' variable."
(interactive "p") (interactive "p")
(let (line column pos) (let (line column pos found)
(when (and (bobp) (when (and (bobp)
(> n 0) (> n 0)
(get-text-property (point) 'mouse-face) (get-text-property (point) 'mouse-face)
@ -10044,12 +10044,14 @@ Also see the `completion-auto-wrap' variable."
((< n 0) (first-completion))))) ((< n 0) (first-completion)))))
(while (> n 0) (while (> n 0)
(setq pos nil column (current-column) line (line-number-at-pos)) (setq found nil pos nil column (current-column) line (line-number-at-pos))
(when (and (or (not (eq (forward-line 1) 0)) (while (and (not found)
(eobp) (eq (forward-line 1) 0)
(not (eq (move-to-column column) column)) (not (eobp))
(not (get-text-property (point) 'mouse-face))) (eq (move-to-column column) column))
completion-auto-wrap) (when (get-text-property (point) 'mouse-face)
(setq found t)))
(when (and (not found) completion-auto-wrap)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(when (and (eq (move-to-column column) column) (when (and (eq (move-to-column column) column)
@ -10064,11 +10066,13 @@ Also see the `completion-auto-wrap' variable."
(setq n (1- n))) (setq n (1- n)))
(while (< n 0) (while (< n 0)
(setq pos nil column (current-column) line (line-number-at-pos)) (setq found nil pos nil column (current-column) line (line-number-at-pos))
(when (and (or (not (eq (forward-line -1) 0)) (while (and (not found)
(not (eq (move-to-column column) column)) (eq (forward-line -1) 0)
(not (get-text-property (point) 'mouse-face))) (eq (move-to-column column) column))
completion-auto-wrap) (when (get-text-property (point) 'mouse-face)
(setq found t)))
(when (and (not found) completion-auto-wrap)
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (point-max))
(when (and (eq (move-to-column column) column) (when (and (eq (move-to-column column) column)