[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 7c6d15a 1/5: Be smarter about displaying appended
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 7c6d15a 1/5: Be smarter about displaying appended records |
Date: |
Tue, 24 Apr 2018 16:26:59 -0400 (EDT) |
branch: externals/ebdb
commit 7c6d15abd51299b81ba5fe389cfd9e1682154080
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Be smarter about displaying appended records
* ebdb-com.el (ebdb-display-records): When records are appended to an
existing buffer, we almost certainly want point to end up on them.
Record the uuid of the first additional record, and try to move to
its marker after redisplay. Additionally, use `recenter' instead of
`set-window-start', as that's less likely to cause surprising
scrolling behavior.
---
ebdb-com.el | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 8945668..6f4941f 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -756,7 +756,12 @@ name based on the current major mode."
(setq fmt ebdb-default-multiline-formatter))
;; `ebdb-make-buffer-name' is a generic function that
;; dispatches on the current major mode.
- (let ((target-buffer (or buf (ebdb-make-buffer-name))))
+ (let ((target-buffer (or buf (ebdb-make-buffer-name)))
+ ;; When appending, we want point to end up on the first of the
+ ;; appended records. Save the uuid, and later point a marker
+ ;; at it. Mostly useful for `follow-related'.
+ (target-record-uuid (ebdb-record-uuid (car records)))
+ target-record-marker)
(with-current-buffer (get-buffer-create target-buffer)
;; If we are appending RECORDS to the ones already displayed,
@@ -772,7 +777,11 @@ name based on the current major mode."
(setq ebdb-records
(mapcar (lambda (r)
- (list r fmt (make-marker) nil))
+ (let ((m (make-marker)))
+ (when (string= target-record-uuid
+ (ebdb-record-uuid r))
+ (setq target-record-marker m))
+ (list r fmt m nil)))
records))
(ebdb-pop-up-window target-buffer select pop)
@@ -795,8 +804,10 @@ name based on the current major mode."
(message "Formatting EBDB...done."))
(set-buffer-modified-p nil)
- (goto-char (point-min))
- (set-window-start (get-buffer-window (current-buffer)) (point)))))
+ (goto-char (or target-record-marker (point-min)))
+ (when (window-live-p (get-buffer-window))
+ (with-selected-window (get-buffer-window)
+ (recenter))))))
(defun ebdb-undisplay-records (&optional buffer)
"Undisplay records in *EBDB* BUFFER, leaving the buffer empty.