[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb dda2a56 2/4: Use with-silent-modifications around
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb dda2a56 2/4: Use with-silent-modifications around record redisplay |
Date: |
Fri, 17 Apr 2020 14:08:01 -0400 (EDT) |
branch: externals/ebdb
commit dda2a5681d9381dd06e04283aab9a7caa4f88c26
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Use with-silent-modifications around record redisplay
* ebdb-com.el (ebdb-redisplay-records): Now that we're no longer
overriding the buffer-modified mechanism, we need to handle this.
---
ebdb-com.el | 95 +++++++++++++++++++++++++++++++------------------------------
1 file changed, 48 insertions(+), 47 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 5d9dfd1..4e2c38b 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -1023,53 +1023,54 @@ displayed records."
records)))
(dolist (b bufs)
(with-current-buffer b
- (let ((inhibit-read-only t)
- renumber)
- (dolist (r records)
- (catch 'bail
- ;; Find the location of record in this buffer. The
- ;; majority of the time this function will be working on
- ;; the single record under point, so short-circuit that
- ;; case. Check if record is present, or if its uuid has
- ;; been left behind by some previous redisplay. If
- ;; record isn't in this buffer, then bail.
- (setq local-record (cond ((equal r (ignore-errors
(ebdb-current-record)))
- (ebdb-current-record t))
- ((assoc r ebdb-records))
- ((assoc (ebdb-record-uuid r)
ebdb-records))
- (t (throw 'bail nil)))
- marker (nth 2 local-record)
- end-marker (nth 2 (car (cdr (memq local-record
ebdb-records)))))
- (unless renumber-index
- (setq renumber-index (cl-position local-record ebdb-records)))
- ;; If point is inside record, put it at the beginning of the
record.
- (when (and (<= marker (point))
- (< (point) (or end-marker (point-max))))
- (goto-char marker))
- (save-excursion
- (goto-char marker)
- (setq record-number (get-text-property (point)
'ebdb-record-number))
- ;; First insert the reformatted record, then delete the old one,
- ;; so that the marker of this record cannot collapse with the
- ;; marker of the subsequent record
- (setq ret (ebdb-redisplay-record r action local-record))
- (put-text-property marker (point) 'ebdb-record-number
record-number)
- (when (eq ret 'removed)
- (setq renumber t))
- (when (memq ret '(removed replaced))
- (delete-region (point) (or end-marker (point-max)))))))
- (when renumber
- ;; If we deleted a record we need to update the subsequent
- ;; record numbers.
- (let* ((markers (append (mapcar (lambda (x) (nth 2 x))
- (cl-subseq ebdb-records
renumber-index))
- (list (point-max))))
- (start (pop markers)))
- (dolist (end markers)
- (put-text-property start end
- 'ebdb-record-number record-number)
- (setq start end
- record-number (1+ record-number))))))
+ (with-silent-modifications
+ (let ((inhibit-read-only t)
+ renumber)
+ (dolist (r records)
+ (catch 'bail
+ ;; Find the location of record in this buffer. The
+ ;; majority of the time this function will be working on
+ ;; the single record under point, so short-circuit that
+ ;; case. Check if record is present, or if its uuid has
+ ;; been left behind by some previous redisplay. If
+ ;; record isn't in this buffer, then bail.
+ (setq local-record (cond ((equal r (ignore-errors
(ebdb-current-record)))
+ (ebdb-current-record t))
+ ((assoc r ebdb-records))
+ ((assoc (ebdb-record-uuid r)
ebdb-records))
+ (t (throw 'bail nil)))
+ marker (nth 2 local-record)
+ end-marker (nth 2 (car (cdr (memq local-record
ebdb-records)))))
+ (unless renumber-index
+ (setq renumber-index (cl-position local-record ebdb-records)))
+ ;; If point is inside record, put it at the beginning of the
record.
+ (when (and (<= marker (point))
+ (< (point) (or end-marker (point-max))))
+ (goto-char marker))
+ (save-excursion
+ (goto-char marker)
+ (setq record-number (get-text-property (point)
'ebdb-record-number))
+ ;; First insert the reformatted record, then delete the old
one,
+ ;; so that the marker of this record cannot collapse with the
+ ;; marker of the subsequent record
+ (setq ret (ebdb-redisplay-record r action local-record))
+ (put-text-property marker (point) 'ebdb-record-number
record-number)
+ (when (eq ret 'removed)
+ (setq renumber t))
+ (when (memq ret '(removed replaced))
+ (delete-region (point) (or end-marker (point-max)))))))
+ (when renumber
+ ;; If we deleted a record we need to update the subsequent
+ ;; record numbers.
+ (let* ((markers (append (mapcar (lambda (x) (nth 2 x))
+ (cl-subseq ebdb-records
renumber-index))
+ (list (point-max))))
+ (start (pop markers)))
+ (dolist (end markers)
+ (put-text-property start end
+ 'ebdb-record-number record-number)
+ (setq start end
+ record-number (1+ record-number)))))))
(run-hooks 'ebdb-display-hook)))))
(easy-menu-define