[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 7c6d15a 1/5: Be smarter about displaying appended
[elpa] externals/ebdb 7c6d15a 1/5: Be smarter about displaying appended records
Tue, 24 Apr 2018 16:26:59 -0400 (EDT)
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
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
@@ -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)))
(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."
(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)))
(ebdb-pop-up-window target-buffer select pop)
@@ -795,8 +804,10 @@ name based on the current major mode."
(message "Formatting EBDB...done."))
- (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)
(defun ebdb-undisplay-records (&optional buffer)
"Undisplay records in *EBDB* BUFFER, leaving the buffer empty.