[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tabulated list recenter issue
From: |
Eli Zaretskii |
Subject: |
Re: Tabulated list recenter issue |
Date: |
Wed, 12 Apr 2017 13:19:42 +0300 |
> From: Ian Dunn <address@hidden>
> Date: Tue, 11 Apr 2017 20:56:31 -0400
>
> diff --git a/lisp/emacs-lisp/tabulated-list.el
> b/lisp/emacs-lisp/tabulated-list.el
> index b6b49b1bfa..57dca910a8 100644
> --- a/lisp/emacs-lisp/tabulated-list.el
> +++ b/lisp/emacs-lisp/tabulated-list.el
> @@ -395,10 +395,21 @@ changing `tabulated-list-sort-key'."
> (set-buffer-modified-p nil)
> ;; If REMEMBER-POS was specified, move to the "old" location.
> (if saved-pt
> - (progn (goto-char saved-pt)
> - (move-to-column saved-col)
> - (when window-line
> - (recenter window-line)))
> + (let* ((lines (window-screen-lines))
> + (id (tabulated-list-get-id saved-pt))
> + (entries (if (functionp tabulated-list-entries)
> + (funcall tabulated-list-entries)
> + tabulated-list-entries))
> + (position (seq-position (map-keys entries) id))
> + (num-entries (length entries))
> + (remaining-entries (- num-entries position)))
> + (goto-char saved-pt)
> + (move-to-column saved-col)
> + ;; Only recenter if there are enough lines so that there's no empty
> + ;; space below the end of the text
> + (when (and window-line
> + (> remaining-entries lines))
> + (recenter window-line)))
> (goto-char (point-min)))))
>
> (defun tabulated-list-print-entry (id cols)
Regardless of whether this will be installed by default or as an
option, this code might behave unexpectedly when the entries are not
all of the same height, because AFAIU it counts the entries
disregarding their height. Also, window-screen-lines might return a
fractional value, and I wonder whether the behavior will be correct
when the number of entries differs from the window height by less than
a whole line.
- Re: Tabulated list recenter issue, (continued)
- Re: Tabulated list recenter issue, Clément Pit-Claudel, 2017/04/12
- Re: Tabulated list recenter issue, Eli Zaretskii, 2017/04/12
- Re: Tabulated list recenter issue, Clément Pit-Claudel, 2017/04/12
- Re: Tabulated list recenter issue, Eli Zaretskii, 2017/04/12
- Re: Tabulated list recenter issue, Clément Pit-Claudel, 2017/04/12
- Re: Tabulated list recenter issue, Eli Zaretskii, 2017/04/12
- Re: Tabulated list recenter issue, Clément Pit-Claudel, 2017/04/12
- Re: Tabulated list recenter issue, Ian Dunn, 2017/04/12
- Re: Tabulated list recenter issue, Eli Zaretskii, 2017/04/13
- Re: Tabulated list recenter issue, Ian Dunn, 2017/04/15
Re: Tabulated list recenter issue,
Eli Zaretskii <=