mu4e-headers: mu4e~headers-move: consider folded headers

Ensure going backwards over folded headers works.
This commit is contained in:
Dirk-Jan C. Binnema 2023-04-30 12:38:16 +03:00
parent 9544473e35
commit f02f1c282c
1 changed files with 33 additions and 40 deletions

View File

@ -1424,52 +1424,45 @@ and there is a live message view.
This variable is for let-binding when scripting.") This variable is for let-binding when scripting.")
(defun mu4e~headers-move (lines) (defun mu4e~headers-move (lines)
"Move point LINES lines. "Move point LINES lines.
Move foward if LINES is positive or backwards if LINES is Move forward if LINES is positive or backwards if LINES is
negative. If this succeeds, return the new docid. Otherwise, negative. If this succeeds, return the new docid. Otherwise,
return nil. return nil.
If pointing at a message after the move and there is a If pointing at a message after the move and there is a
view-window, open the message unless view-window, open the message unless
`mu4e-headers-open-after-move' is non-nil." `mu4e-headers-open-after-move' is non-nil."
(unless (eq major-mode 'mu4e-headers-mode) (cl-assert (eq major-mode 'mu4e-headers-mode))
(mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (when (ignore-errors
(cl-flet ((goto-next-line (let (line-move-visual)
(arg) (line-move lines)
(condition-case _err t))
(prog1 (let* ((docid (mu4e~headers-docid-at-point))
(let (line-move-visual) (folded (and docid (mu4e-thread-message-folded-p))))
(and (line-move arg) 0)) (if folded
;; Skip invisible text at BOL possibly hidden by (mu4e~headers-move (if (< lines 0) -1 1)) ;; skip folded
;; the end of another invisible overlay covering (when docid
;; previous EOL. ;; Skip invisible text at BOL possibly hidden by
(move-to-column 2)) ;; the end of another invisible overlay covering
((beginning-of-buffer end-of-buffer) ;; previous EOL.
1)))) (move-to-column 2)
(let* ((succeeded (zerop (goto-next-line lines))) ;; update all windows showing the headers buffer
(docid (mu4e~headers-docid-at-point))) (walk-windows
;; move point, even if this function is called when this window is not (lambda (win)
;; visible (when (eq (window-buffer win)
(when docid (mu4e-get-headers-buffer (buffer-name)))
;; update all windows showing the headers buffer (set-window-point win (point))))
(walk-windows nil t)
(lambda (win) ;; If the assigned (and buffer-local) `mu4e~headers-view-win'
(when (eq (window-buffer win) ;; is not live then that is indicates the user does not want
(mu4e-get-headers-buffer (buffer-name))) ;; to pop up the view when they navigate in the headers
(set-window-point win (point)))) ;; buffer.
nil t) (when (and mu4e-headers-open-after-move
;; If the assigned (and buffer-local) `mu4e~headers-view-win' (window-live-p mu4e~headers-view-win))
;; is not live then that is indicates the user does not want (mu4e-headers-view-message))
;; to pop up the view when they navigate in the headers ;; attempt to highlight the new line, display the message
;; buffer. (mu4e~headers-highlight docid)
(when (and mu4e-headers-open-after-move docid)))))
(window-live-p mu4e~headers-view-win))
(mu4e-headers-view-message))
;; attempt to highlight the new line, display the message
(mu4e~headers-highlight docid)
(if succeeded
docid
nil)))))
(defun mu4e-headers-next (&optional n) (defun mu4e-headers-next (&optional n)
"Move point to the next message header. "Move point to the next message header.