Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into doc-e2ee
Browse files Browse the repository at this point in the history
  • Loading branch information
telenieko committed Nov 1, 2023
2 parents b87dbf1 + 8e6e9cd commit 3813c4d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ Please read the [[file:e2ee.org][dedicated E2EE document]] suplied with Ement.el
+ Customization group ~ement-room-list~.
+ Option ~ement-room-list-space-prefix~ is applied to space names in the room list (e.g. set to empty string for cleaner appearance).

*Changes*

+ Bind ~TAB~ / ~BACKTAB~ to move between links in room and like buffers. ([[https://github.com/alphapapa/ement.el/issues/113][#113]]. Thanks to [[https://github.com/ericsfraga][Eric S. Fraga]] for suggesting.)

** 0.13

*Additions*
Expand Down
47 changes: 36 additions & 11 deletions ement-notifications.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,35 @@ is passed through `ement--make-event'."
(declare-function ement-room-list "ement-room-list")
(defvar ement-notifications-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<return>") #'ement-notifications-jump)
(define-key map [mouse-1] #'ement-notifications-jump-mouse)
(define-key map [mouse-2] #'ement-notifications-jump-mouse)
(define-key map (kbd "S-<return>") #'ement-notify-reply)
(define-key map (kbd "M-g M-l") #'ement-room-list)
(define-key map (kbd "M-g M-m") #'ement-notify-switch-to-mentions-buffer)
(define-key map (kbd "M-g M-n") #'ement-notify-switch-to-notifications-buffer)
(define-key map [remap scroll-down-command] #'ement-notifications-scroll-down-command)
(define-key map [remap mwheel-scroll] #'ement-notifications-mwheel-scroll)
(make-composed-keymap (list map button-buffer-map) 'view-mode-map))
(make-composed-keymap (list map) 'view-mode-map))
"Map for Ement notification buffers.")

(cl-defun ement-notifications-jump (&optional (pos (point)))
"Jump to Matrix event at POS."
(interactive)
(let ((session (get-text-property pos 'session))
(room (get-text-property pos 'room))
(event (get-text-property pos 'event)))
(ement-view-room room session)
(ement-room-goto-event event)))

(defun ement-notifications-jump-mouse (event)
"Jump to Matrix event at EVENT."
(interactive "e")
(let ((pos (posn-point (event-start event))))
(if (button-at pos)
(push-button pos)
(ement-notifications-jump pos))))

(defvar ement-notifications-hook '(ement-notifications-log-to-buffer)
"Functions called for `ement-notifications' notifications.
Each function is called with two arguments, the session and the
Expand Down Expand Up @@ -197,19 +217,24 @@ to `ement-api', which see."
(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))
;; Apply the button properties only to the room and sender names,
;; allowing buttons in the rest of the message to remain separate.
(setf start (point)
end (save-excursion
(re-search-forward (rx "> "))))
(add-text-properties start end '( button (t)
category default-button
action ement-notify-button-action))
;; Apply the session, room, and event properties to the whole event.
(setf end (save-excursion
(if-let ((next-node (ewoc-next ement-ewoc new-node)))
(ewoc-location next-node)
(point-max))))
(add-text-properties start end
(list 'button '(t)
'category 'default-button
'action #'ement-notify-button-action
'session session
(list 'session session
'room ement-room
'event event))
;; Remove button face property.
;; Remove button face property from the whole event.
(alter-text-property start end 'face
(lambda (face)
(pcase face
Expand Down
2 changes: 2 additions & 0 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Used to, e.g. call `ement-room-compose-org'.")
(define-key map (kbd "m") #'ement-room-mark-read)
(define-key map [remap scroll-down-command] #'ement-room-scroll-down-command)
(define-key map [remap mwheel-scroll] #'ement-room-mwheel-scroll)
(define-key map (kbd "<tab>") #'forward-button)
(define-key map (kbd "<backtab>") #'backward-button)

;; Switching
(define-key map (kbd "M-g M-l") #'ement-room-list)
Expand Down

0 comments on commit 3813c4d

Please sign in to comment.