[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ement 20f6982182 2/4: Fix: (ement-notifications-log-to-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ement 20f6982182 2/4: Fix: (ement-notifications-log-to-buffer) Use save-mark-and-excursion |
Date: |
Thu, 14 Sep 2023 12:58:08 -0400 (EDT) |
branch: externals/ement
commit 20f6982182f341d4eaa330fd2621ca6651aef56d
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Fix: (ement-notifications-log-to-buffer) Use save-mark-and-excursion
Fixes #218.
Reported-by: Phil Sainty <phil@catalyst.net.nz>
---
ement-notifications.el | 67 +++++++++++++++++++++++++-------------------------
1 file changed, 34 insertions(+), 33 deletions(-)
diff --git a/ement-notifications.el b/ement-notifications.el
index 9be6a82969..40cf7e5bb2 100644
--- a/ement-notifications.el
+++ b/ement-notifications.el
@@ -185,39 +185,40 @@ to `ement-api', which see."
;; Select the buffer's window to avoid EWOC bug. (See #191.)
(select-window buffer-window))
;; TODO: Use the :readp slot to mark unread events.
- (pcase-let* (((cl-struct ement-notification room-id event)
notification)
- (ement-session session)
- (ement-room (or (cl-find room-id (ement-session-rooms
session)
- :key #'ement-room-id :test
#'equal)
- (error
"ement-notifications-log-to-buffer: Can't find room <%s>; discarding
notification" room-id)))
- (ement-room-sender-in-left-margin nil)
- (ement-room-message-format-spec "%o%O »%W %S> %B%R%t")
- (new-node (ement-room--insert-event event))
- (inhibit-read-only t)
- (start) (end))
- (ewoc-goto-node ement-ewoc new-node)
- (setf start (point))
- (if-let (next-node (ewoc-next ement-ewoc new-node))
- (ewoc-goto-node ement-ewoc next-node)
- (goto-char (point-max)))
- (setf end (- (point) 2))
- (add-text-properties start end
- (list 'button '(t)
- 'category 'default-button
- 'action #'ement-notify-button-action
- 'session session
- 'room ement-room
- 'event event))
- ;; Remove button face property.
- (alter-text-property start end 'face
- (lambda (face)
- (pcase face
- ('button nil)
- ((pred listp) (remq 'button face))
- (_ face))))
- (when ement-notify-prism-background
- (add-face-text-property start end (list :background
(ement-notifications--room-background-color ement-room)
- :extend t))))))))
+ (save-mark-and-excursion
+ (pcase-let* (((cl-struct ement-notification room-id event)
notification)
+ (ement-session session)
+ (ement-room (or (cl-find room-id (ement-session-rooms
session)
+ :key #'ement-room-id :test
#'equal)
+ (error
"ement-notifications-log-to-buffer: Can't find room <%s>; discarding
notification" room-id)))
+ (ement-room-sender-in-left-margin nil)
+ (ement-room-message-format-spec "%o%O »%W %S> %B%R%t")
+ (new-node (ement-room--insert-event event))
+ (inhibit-read-only t)
+ (start) (end))
+ (ewoc-goto-node ement-ewoc new-node)
+ (setf start (point))
+ (if-let (next-node (ewoc-next ement-ewoc new-node))
+ (ewoc-goto-node ement-ewoc next-node)
+ (goto-char (point-max)))
+ (setf end (- (point) 2))
+ (add-text-properties start end
+ (list 'button '(t)
+ 'category 'default-button
+ 'action #'ement-notify-button-action
+ 'session session
+ 'room ement-room
+ 'event event))
+ ;; Remove button face property.
+ (alter-text-property start end 'face
+ (lambda (face)
+ (pcase face
+ ('button nil)
+ ((pred listp) (remq 'button face))
+ (_ face))))
+ (when ement-notify-prism-background
+ (add-face-text-property start end (list :background
(ement-notifications--room-background-color ement-room)
+ :extend t)))))))))
(defun ement-notifications--room-background-color (room)
"Return a background color on which to display ROOM's messages."