Skip to content

Commit

Permalink
Add/Change: (ement-room-list-button-map)
Browse files Browse the repository at this point in the history
* ement-room-list.el
(ement-room-list-mouse-ement-room-list-kill-buffer): New command.
(ement-room-list-mode-map): Bind new command.
(ement-room-list-button-map): New keymap variable.
(column "Name"): Apply new keymap to buttons.
  • Loading branch information
alphapapa committed Apr 28, 2023
1 parent 0693e2e commit 11450ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time

+ Option ~ement-room-timestamp-header-align~ controls how timestamp headers are aligned in room buffers.
+ Option ~ement-room-view-hook~ runs functions when ~ement-room-view~ is called. (By default, it refreshes the room list buffer.)
+ In the room list, middle-clicking a room which has a buffer closes its buffer.

*Changes*

Expand Down
20 changes: 17 additions & 3 deletions ement-room-list.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,22 @@ a symbol, it should be unquoted.."
(define-key map (kbd "SPC") #'ement-room-list-next-unread)
(define-key map [tab] #'ement-room-list-section-toggle)
(define-key map [mouse-1] (ement-room-list-define-mouse-command ement-room-list-RET))
(define-key map [mouse-2] (ement-room-list-define-mouse-command ement-room-list-kill-buffer))
(define-key map (kbd "k") #'ement-room-list-kill-buffer)
(define-key map (kbd "s") #'ement-room-toggle-space)
map))
map)
"Keymap for `ement-room-list' buffers.
See also `ement-room-list-button-map'.")

(defvar ement-room-list-button-map
;; This map is needed because some columns are propertized as buttons, which override
;; the main keymap.
;; TODO: Is it possible to adjust the button properties to obviate this map?
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] (ement-room-list-define-mouse-command ement-room-list-RET))
(define-key map [mouse-2] (ement-room-list-define-mouse-command ement-room-list-kill-buffer))
map)
"Keymap for buttonized text in `ement-room-list' buffers.")

(defvar ement-room-list-timestamp-colors nil
"List of colors used for timestamps.
Expand Down Expand Up @@ -386,9 +399,10 @@ from recent to non-recent for rooms updated in the past hour.")
(push 'ement-room-list-invited (map-elt face :inherit)))
('leave
(push 'ement-room-list-left (map-elt face :inherit))))
(propertize (ement--button-buttonize display-name #'ement-room-list-mouse-1)
(propertize display-name
'face face
'mouse-face 'highlight))
'mouse-face 'highlight
'keymap ement-room-list-button-map))
"")))

(ement-room-list-define-column #("Unread" 0 6 (help-echo "Unread events (Notifications:Highlights)")) (:align 'right)
Expand Down

0 comments on commit 11450ed

Please sign in to comment.