Skip to content

Commit

Permalink
Change: (ement-room-mode) Set `filter-buffer-substring-function'
Browse files Browse the repository at this point in the history
Strip 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.
  • Loading branch information
Phil Sainty committed Apr 20, 2024
1 parent dc314a1 commit 694fb28
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,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 @@ -2786,6 +2788,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 694fb28

Please sign in to comment.