- (let (final-target-pos)
- (mapc
- (lambda (section)
- (let ((point-before (point))
- (result (if (functionp section)
- (funcall section)
- (apply (car section) (cdr section)))))
- (if (and (not final-target-pos) (integer-or-marker-p result))
- (setq final-target-pos result))
- ;; don't insert a newline when the previous section didn't show
- ;; anything.
- (unless (eq (point) point-before)
- (widget-insert "\n"))))
- notmuch-hello-sections)
- (widget-setup)
-
- (when final-target-pos
- (goto-char final-target-pos)
- (unless (widget-at)
- (widget-forward 1)))
-
- (unless (widget-at)
- (when notmuch-hello-search-pos
- (goto-char notmuch-hello-search-pos)))))
+ (mapc
+ (lambda (section)
+ (let ((point-before (point)))
+ (if (functionp section)
+ (funcall section)
+ (apply (car section) (cdr section)))
+ ;; don't insert a newline when the previous section didn't
+ ;; show anything.
+ (unless (eq (point) point-before)
+ (widget-insert "\n"))))
+ notmuch-hello-sections)
+ (widget-setup)
+
+ ;; Move point back to where it was before refresh. Use line and
+ ;; column instead of point directly to be insensitive to additions
+ ;; and removals of text within earlier lines.
+ (goto-char (point-min))
+ (forward-line (1- target-line))
+ (move-to-column target-column))