Skip to content

Commit

Permalink
Merge: Set filter-buffer-substring-function in room buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapapa committed Sep 9, 2024
2 parents caf7ca9 + d29bccb commit a47de8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ Ement.el doesn't support encrypted rooms natively, but it can be used transparen
+ Option ~ement-room-coalesce-events~ may now be set to (and defaults to) a maximum number of events to coalesce together. (This avoids potential performance problems in rare cases. See [[https://github.com/alphapapa/ement.el/issues/247][#247]]. Thanks to [[https://github.com/viiru-][Arto Jantunen]] for reporting and [[https://github.com/sergiodj][Sergio Durigan Junior]] for testing.)

*Fixes*
+ Replies to edited messages are correctly sent to the original event (whereas previously they were sent to the edit, which caused reactions to not be shown). ([[https://github.com/alphapapa/ement.el/issues/230][#230]], [[https://github.com/alphapapa/ement.el/issues/277][#277]]. Thanks to [[https://github.com/phil-s][Phil Sainty]] for suggesting, and to [[https://github.com/dionisos2][dionisos]] for reporting.)
+ Replies to edited messages are correctly sent to the original event (whereas previously they were sent to the edit, which caused reactions to not be shown). ([[https://github.com/alphapapa/ement.el/issues/230][#230]], [[https://github.com/alphapapa/ement.el/issues/277][#277]]. Thanks to [[https://github.com/phil-s][Phil Sainty]] for suggesting, and to [[https://github.com/dionisos2][dionisos]] for reporting.)
+ Set ~filter-buffer-substring-function~ in room buffers to prevent undesired text properties from being included in copied text. ([[https://github.com/alphapapa/ement.el/pull/278][#278]]. Thanks to [[https://github.com/phil-s][Phil Sainty]].)

** 0.15.1

Expand Down
14 changes: 14 additions & 0 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,8 @@ and erases the buffer.
imenu-create-index-function #'ement-room--imenu-create-index-function
;; TODO: Use EWOC header/footer for, e.g. typing messages.
ement-ewoc (ewoc-create #'ement-room--pp-thing))
;; Prevent line/wrap-prefix formatting properties being included in copied text.
(setq-local filter-buffer-substring-function #'ement-room--buffer-substring-filter)
;; Set the URL handler. Note that `browse-url-handlers' was added in 28.1;
;; prior to that `browse-url-browser-function' served double-duty.
;; TODO: Remove compat code when requiring Emacs >=28.
Expand Down Expand Up @@ -2801,6 +2803,18 @@ data slot."
Needed to display things in the header line."
(replace-regexp-in-string (rx "%") "%%" string t t))

(defun ement-room--buffer-substring-filter (beg end &optional delete)
"Value for `filter-buffer-substring-function' in Ement rooms.

Strips the `line-prefix' and `wrap-prefix' text properties which
are used when formatting certain Matrix events, but which should
not be copied into other buffers."
(let ((string (funcall (default-value 'filter-buffer-substring-function)
beg end delete)))
(remove-list-of-text-properties
0 (length string) '(line-prefix wrap-prefix) string)
string))

;;;;; Imenu

(defconst ement-room-timestamp-header-imenu-format "%Y-%m-%d (%A) %H:%M"
Expand Down

0 comments on commit a47de8a

Please sign in to comment.