From ebbaa5829bbf97ffeb98bf38989dc1589a3edf0f Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 28 Apr 2023 00:42:38 -0500 Subject: [PATCH 01/31] Add: (ement--byte-run--declare-function) And use in (ement-room-retro-callback). --- ement-lib.el | 24 ++++++++++++++++++++++++ ement-room.el | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ement-lib.el b/ement-lib.el index 06c98ab6..c573d2a7 100644 --- a/ement-lib.el +++ b/ement-lib.el @@ -62,6 +62,30 @@ (defvar ement-room-prism-minimum-contrast) (defvar ement-room-unread-only-counts-notifications) +;;;; Function declarations + +;; Instead of using top-level `declare-function' forms (which can easily become obsolete +;; if not kept with the code that needs them), this allows the use of `(declare (function +;; ...))' forms in each function definition, so that if a function is moved or removed, +;; the `declare-function' goes with it. + +;; TODO: Propose this upstream. + +(eval-and-compile + (defun ement--byte-run--declare-function (_name _args &rest values) + "Return a `declare-function' form with VALUES. +Allows the use of a form like: + + (declare (function FN FILE ...)) + +inside of a function definition, effectively keeping its +`declare-function' form inside the function definition, ensuring +that stray such forms don't remain if the function is removed." + `(declare-function ,@values)) + + (cl-pushnew '(function ement--byte-run--declare-function) defun-declarations-alist :test #'equal) + (cl-pushnew '(function ement--byte-run--declare-function) macro-declarations-alist :test #'equal)) + ;;;; Compatibility ;; These workarounds should be removed when they aren't needed. diff --git a/ement-room.el b/ement-room.el index 0808729a..554a69be 100644 --- a/ement-room.el +++ b/ement-room.el @@ -1906,8 +1906,6 @@ Uses action `ement-view-room-display-buffer-action', which see." (goto-char (ewoc-location node)) (error "Event not found in buffer: %S" (ement-event-id event)))) -(declare-function ement--make-event "ement.el") -(declare-function ement--put-event "ement.el") (cl-defun ement-room-retro-callback (room session data &key (set-prev-batch t)) "Push new DATA to ROOM on SESSION and add events to room buffer. @@ -1915,6 +1913,8 @@ If SET-PREV-BATCH is nil, don't set ROOM's prev-batch slot to the \"prev_batch\" token in response DATA (this should be set, e.g. when filling timeline gaps as opposed to retrieving messages before the earliest-seen message)." + (declare (function ement--make-event "ement.el") + (function ement--put-event "ement.el")) (pcase-let* (((cl-struct ement-room local) room) ((map _start end chunk state) data) ((map buffer) local) From 2bfb2bae5d6b5fd647b1d956c6388f746fe1597b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 28 Apr 2023 00:43:11 -0500 Subject: [PATCH 02/31] Tidy: Remove old declare-function form --- ement-room.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/ement-room.el b/ement-room.el index 554a69be..09ac63b5 100644 --- a/ement-room.el +++ b/ement-room.el @@ -1871,8 +1871,6 @@ reaction string, e.g. \"👍\"." ;;;; Functions -(declare-function magit-current-section "magit-section") - (defun ement-room-view (room session) "Switch to a buffer showing ROOM on SESSION. Uses action `ement-view-room-display-buffer-action', which see." From 8589774ba30397de3c06537a85eb6c292217580d Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 28 Apr 2023 00:44:27 -0500 Subject: [PATCH 03/31] Add/Change: (ement-room-view-hook), etc. * ement-room.el (ement-room-view-hook): New option. (ement-room-view): Call new hook. (ement-room-view-hook-room-list-auto-update): To be called from hook. --- README.org | 1 + ement-room.el | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 6e195684..45ad9392 100644 --- a/README.org +++ b/README.org @@ -300,6 +300,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time *Additions* + 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.) *Changes* diff --git a/ement-room.el b/ement-room.el index 09ac63b5..46b458ae 100644 --- a/ement-room.el +++ b/ement-room.el @@ -229,6 +229,12 @@ In that case, sender names are aligned to the margin edge.") (const :tag "Center" center) (const :tag "Right" right))) +(defcustom ement-room-view-hook + '(ement-room-view-hook-room-list-auto-update) + "Functions called when `ement-room-view' is called. +Called with two arguments, the room and the session." + :type 'hook) + ;;;;; Faces (defface ement-room-name @@ -1884,9 +1890,18 @@ Uses action `ement-view-room-display-buffer-action', which see." ;; FIXME: This doesn't seem to work as desired, e.g. when ;; `ement-view-room-display-buffer-action' is set to `display-buffer-no-window'; I ;; guess because `pop-to-buffer' selects a window. - (pop-to-buffer buffer ement-view-room-display-buffer-action))) + (pop-to-buffer buffer ement-view-room-display-buffer-action) + (run-hook-with-args 'ement-room-view-hook room session))) (defalias 'ement-view-room #'ement-room-view) +(defun ement-room-view-hook-room-list-auto-update (_room session) + "Call `ement-room-list-auto-update' with SESSION. +To be used in `ement-room-view-hook', which see." + ;; This function is necessary because the hook is called with the room argument, which + ;; `ement-room-list-auto-update' doesn't need. + (declare (function ement-room-list-auto-update "ement-room-list")) + (ement-room-list-auto-update session)) + (defun ement-room--buffer-name (room) "Return name for ROOM's buffer." (concat ement-room-buffer-name-prefix From 0693e2e71e3ad4e14b5823896bba38cb36f552bc Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 28 Apr 2023 00:46:10 -0500 Subject: [PATCH 04/31] Add/Change: (ement-room-list-define-mouse-command), etc. * ement-room-list.el (ement-room-list-define-mouse-command): New macro. (ement-room-list-mode-map): Use new macro. (ement-room-list-mouse-1): Remove old defun. --- ement-room-list.el | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ement-room-list.el b/ement-room-list.el index 39542c5d..17c1f84b 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -39,6 +39,23 @@ "Group Ement rooms with Taxy." :group 'ement) +;;;; Mouse commands + +;; Since mouse-activated commands must handle mouse events, we define a simple macro to +;; wrap a command into a mouse-event-accepting one. + +(defmacro ement-room-list-define-mouse-command (command) + "Define a command that calls COMMAND interactively with point at mouse event. +COMMAND should be a form that evaluates to a function symbol; if +a symbol, it should be unquoted.." + (let ((docstring (format "Call command `%s' interactively with point at EVENT." command)) + (name (intern (format "ement-room-list-mouse-%s" command)))) + `(defun ,name (event) + ,docstring + (interactive "e") + (mouse-set-point event) + (call-interactively #',command)))) + ;;;; Variables (declare-function ement-room-toggle-space "ement-room") @@ -48,7 +65,7 @@ (define-key map (kbd "RET") #'ement-room-list-RET) (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-mouse-1) + (define-key map [mouse-1] (ement-room-list-define-mouse-command ement-room-list-RET)) (define-key map (kbd "k") #'ement-room-list-kill-buffer) (define-key map (kbd "s") #'ement-room-toggle-space) map)) @@ -692,12 +709,6 @@ left." (kill-buffer buffer) (ement-room-list-revert)))) -(defun ement-room-list-mouse-1 (event) - "Call `ement-room-list-RET' at EVENT." - (interactive "e") - (mouse-set-point event) - (call-interactively #'ement-room-list-RET)) - (declare-function ement-view-room "ement-room") (defun ement-room-list-RET () "View room at point, or cycle section at point." From 11450ed3440741730581d97c82880cb51d9ff489 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 28 Apr 2023 00:49:10 -0500 Subject: [PATCH 05/31] Add/Change: (ement-room-list-button-map) * 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. --- README.org | 1 + ement-room-list.el | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 45ad9392..c6eec790 100644 --- a/README.org +++ b/README.org @@ -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* diff --git a/ement-room-list.el b/ement-room-list.el index 17c1f84b..516ac80b 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -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. @@ -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) From 242953b52a0eee5ea9d71004ed6bff2e2de715c5 Mon Sep 17 00:00:00 2001 From: Arto Jantunen Date: Mon, 27 Feb 2023 13:23:50 +0200 Subject: [PATCH 06/31] Add basic support for m.video events This is very similar to the m.file handler (which would mostly work for videos as well), and is also missing support for thumbnails (however the events I'm seeing don't contain those anyway). In comparison to ement-room--format-m.file this handler uses content.body as the caption instead of content.filename (which m.video doesn't contain, while m.file does have body). Also the video resolution is shown (x). --- ement-room.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ement-room.el b/ement-room.el index 46b458ae..359f4fe8 100644 --- a/ement-room.el +++ b/ement-room.el @@ -3396,6 +3396,7 @@ If FORMATTED-P, return the formatted body content, when available." ((or "m.text" "m.emote" "m.notice") nil) ("m.image" (ement-room--format-m.image event)) ("m.file" (ement-room--format-m.file event)) + ("m.video" (ement-room--format-m.video event)) (_ (if (or local-redacted-by unsigned-redacted-by) nil (format "[unsupported msgtype: %s]" msgtype )))))) @@ -4136,6 +4137,31 @@ Then invalidate EVENT's node to show the image." (propertize " " 'display '(space :relative-height 1.5))))) +(defun ement-room--format-m.video (event) + "Return \"m.video\" EVENT formatted as a string." + ;; TODO: Insert thumbnail images when enabled. + (pcase-let* (((cl-struct ement-event + (content (map body + ('info (map mimetype size w h)) + ('url mxc-url)))) + event) + (url (when mxc-url + (ement--mxc-to-url mxc-url ement-session))) + (human-size (file-size-human-readable size)) + (string (format "[video: %s (%s) (%sx%s) (%s)]" body mimetype w h human-size))) + (concat (propertize string + 'action #'browse-url + 'button t + 'button-data url + 'category t + 'face 'button + 'follow-link t + 'help-echo url + 'keymap button-map + 'mouse-face 'highlight) + (propertize " " + 'display '(space :relative-height 1.5))))) + ;;;;; Org format sending ;; Some of these declarations may need updating as Org changes. From 243e44410c842b1f9fb714288e9f706fe28b0674 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 28 Apr 2023 01:05:33 -0500 Subject: [PATCH 07/31] Docs: Update changelog --- README.org | 1 + 1 file changed, 1 insertion(+) diff --git a/README.org b/README.org index c6eec790..6032ef11 100644 --- a/README.org +++ b/README.org @@ -302,6 +302,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. ++ Basic support for video events. (Thanks to [[https://github.com/viiru-][Arto Jantunen]].) *Changes* From 6bd1091757bce5feedb337d01b88ab0aa3bc6124 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 12 May 2023 20:47:50 -0500 Subject: [PATCH 08/31] Fix: (-defevent "m.room.avatar") Warn for unreadable images If Emacs can't load a room's avatar image, `create-image' returns nil. This can happen if, e.g. the image is corrupt or an unreadable format (such as an ICO file). See . Fixes #147. Thanks to @jgarte for reporting. --- README.org | 1 + ement.el | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.org b/README.org index 6032ef11..c20f85d7 100644 --- a/README.org +++ b/README.org @@ -311,6 +311,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time *Fixes* + Recognition of certain MXID or displayname forms in outgoing messages when linkifying (aka "pilling") them. ++ Unreadable room avatar images no longer cause errors. (Fixes [[https://github.com/alphapapa/ement.el/issues/147][#147]]. Thanks to [[https://github.com/jgarte][@jgarte]] for reporting.) ** 0.8.3 diff --git a/ement.el b/ement.el index 0c5eded2..32ade698 100644 --- a/ement.el +++ b/ement.el @@ -874,16 +874,22 @@ and `session' to the session. Adds function to :ascent 'center :max-width ement-room-avatar-max-width :max-height ement-room-avatar-max-height))) - (when (fboundp 'imagemagick-types) - ;; Only do this when ImageMagick is supported. - ;; FIXME: When requiring Emacs 27+, remove this (I guess?). - (setf (image-property image :type) 'imagemagick)) - ;; We set the room-avatar slot to a propertized string that - ;; displays as the image. This seems the most convenient thing to - ;; do. We also unset the cached room-list-avatar so it can be - ;; remade. - (setf (ement-room-avatar room) (propertize " " 'display image) - (alist-get 'room-list-avatar (ement-room-local room)) nil)))))) + (if (not image) + (progn + (display-warning 'ement (format "Room avatar seems unreadable: ROOM-ID:%S AVATAR-URL:%S" + (ement-room-id room) (ement--mxc-to-url url session))) + (setf (ement-room-avatar room) nil + (alist-get 'room-list-avatar (ement-room-local room)) nil)) + (when (fboundp 'imagemagick-types) + ;; Only do this when ImageMagick is supported. + ;; FIXME: When requiring Emacs 27+, remove this (I guess?). + (setf (image-property image :type) 'imagemagick)) + ;; We set the room-avatar slot to a propertized string that + ;; displays as the image. This seems the most convenient thing to + ;; do. We also unset the cached room-list-avatar so it can be + ;; remade. + (setf (ement-room-avatar room) (propertize " " 'display image) + (alist-get 'room-list-avatar (ement-room-local room)) nil))))))) ;; Unset avatar. (setf (ement-room-avatar room) nil (alist-get 'room-list-avatar (ement-room-local room)) nil)))) From c0b922bcc5d3c11b60d283caf28356c251fe885b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 13 May 2023 23:19:39 -0500 Subject: [PATCH 09/31] Fix: (ement-room-list) When no rooms are joined Fixes #123. --- README.org | 1 + ement-room-list.el | 126 +++++++++++++++++++++++---------------------- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/README.org b/README.org index c20f85d7..6f1835c0 100644 --- a/README.org +++ b/README.org @@ -312,6 +312,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time + Recognition of certain MXID or displayname forms in outgoing messages when linkifying (aka "pilling") them. + Unreadable room avatar images no longer cause errors. (Fixes [[https://github.com/alphapapa/ement.el/issues/147][#147]]. Thanks to [[https://github.com/jgarte][@jgarte]] for reporting.) ++ Don't error in ~ement-room-list~ when no rooms are joined. (Fixes [[https://github.com/alphapapa/ement.el/issues/123][#123]]. Thanks to [[https://github.com/Kabouik][@Kabouik]] and [[https://github.com/oantolin][Omar Antolín Camarena]] for reporting.) ** 0.8.3 diff --git a/ement-room-list.el b/ement-room-list.el index 516ac80b..1b68e983 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -547,7 +547,7 @@ After showing it, its window is selected. The buffer is named BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (interactive) - (let (format-table column-sizes window-start) + (let (format-table column-sizes window-start room-session-vectors) (cl-labels (;; (heading-face ;; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth)))) (format-item (item) (gethash item format-table)) @@ -615,69 +615,71 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." ;; (kill-buffer buffer-name)) (unless ement-sessions (error "Ement: Not connected. Use `ement-connect' to connect")) + (setf room-session-vectors + (cl-loop for (_id . session) in ement-sessions + append (cl-loop for room in (ement-session-rooms session) + collect (vector room session)))) (with-current-buffer (get-buffer-create buffer-name) (ement-room-list-mode) - (let* ((room-session-vectors - (cl-loop for (_id . session) in ement-sessions - append (cl-loop for room in (ement-session-rooms session) - collect (vector room session)))) - (taxy (cl-macrolet ((first-item - (pred) `(lambda (taxy) - (when (taxy-items taxy) - (,pred (car (taxy-items taxy)))))) - (name= (name) `(lambda (taxy) - (equal ,name (taxy-name taxy))))) - (thread-last - (make-fn - :name "Ement Rooms" - :take (taxy-make-take-function keys ement-room-list-keys)) - (taxy-fill room-session-vectors) - (taxy-sort #'> #'item-latest-ts) - (taxy-sort #'tnil #'item-low-priority-p) - (taxy-sort #'tnil #'item-left-p) - (taxy-sort* #'string< #'taxy-name) - (taxy-sort* #'> #'taxy-latest-ts) - (taxy-sort* #'tnil (first-item item-space-p)) - (taxy-sort* #'t>nil (name= "Low-priority")) - (taxy-sort* #'t>nil (first-item item-left-p))))) - (taxy-magit-section-insert-indent-items nil) - (inhibit-read-only t) - (format-cons (taxy-magit-section-format-items - ement-room-list-columns ement-room-list-column-formatters taxy)) - (pos (point)) - (section-ident (when (magit-current-section) - (magit-section-ident (magit-current-section))))) - (setf format-table (car format-cons) - column-sizes (cdr format-cons) - header-line-format (taxy-magit-section-format-header - column-sizes ement-room-list-column-formatters) - window-start (if (get-buffer-window buffer-name) - (window-start (get-buffer-window buffer-name)) - 0)) - (when ement-room-list-visibility-cache - (setf magit-section-visibility-cache ement-room-list-visibility-cache)) - (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local) - (delete-all-overlays) - (erase-buffer) - (save-excursion - (taxy-magit-section-insert taxy :items 'first - ;; :blank-between-depth bufler-taxy-blank-between-depth - :initial-depth 0)) - (goto-char pos) - (when (and section-ident (magit-get-section section-ident)) - (goto-char (oref (magit-get-section section-ident) start))))) + (delete-all-overlays) + (erase-buffer) + (if (not room-session-vectors) + (insert "No joined rooms. Use command `ement-join-room' to join a room, or `ement-directory' or `ement-directory-search' to find rooms.") + (let* ((taxy (cl-macrolet ((first-item + (pred) `(lambda (taxy) + (when (taxy-items taxy) + (,pred (car (taxy-items taxy)))))) + (name= (name) `(lambda (taxy) + (equal ,name (taxy-name taxy))))) + (thread-last + (make-fn + :name "Ement Rooms" + :take (taxy-make-take-function keys ement-room-list-keys)) + (taxy-fill room-session-vectors) + (taxy-sort #'> #'item-latest-ts) + (taxy-sort #'tnil #'item-low-priority-p) + (taxy-sort #'tnil #'item-left-p) + (taxy-sort* #'string< #'taxy-name) + (taxy-sort* #'> #'taxy-latest-ts) + (taxy-sort* #'tnil (first-item item-space-p)) + (taxy-sort* #'t>nil (name= "Low-priority")) + (taxy-sort* #'t>nil (first-item item-left-p))))) + (taxy-magit-section-insert-indent-items nil) + (inhibit-read-only t) + (format-cons (taxy-magit-section-format-items + ement-room-list-columns ement-room-list-column-formatters taxy)) + (pos (point)) + (section-ident (when (magit-current-section) + (magit-section-ident (magit-current-section))))) + (setf format-table (car format-cons) + column-sizes (cdr format-cons) + header-line-format (taxy-magit-section-format-header + column-sizes ement-room-list-column-formatters) + window-start (if (get-buffer-window buffer-name) + (window-start (get-buffer-window buffer-name)) + 0)) + (when ement-room-list-visibility-cache + (setf magit-section-visibility-cache ement-room-list-visibility-cache)) + (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local) + (save-excursion + (taxy-magit-section-insert taxy :items 'first + ;; :blank-between-depth bufler-taxy-blank-between-depth + :initial-depth 0)) + (goto-char pos) + (when (and section-ident (magit-get-section section-ident)) + (goto-char (oref (magit-get-section section-ident) start)))))) (when display-buffer-action (when-let ((window (display-buffer buffer-name display-buffer-action))) (select-window window))) From 4d46aa0659e138073ff7db9e25b243630f92cb45 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 13 May 2023 23:44:11 -0500 Subject: [PATCH 10/31] Change: (ement-room--member-names-and-ids) Use timeline not EWOC There seems little reason to use the EWOC instead of the timeline, and using the timeline instead allows completion to work in compose buffers without having to pass the EWOC in. --- ement-room.el | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ement-room.el b/ement-room.el index 359f4fe8..0ce2923c 100644 --- a/ement-room.el +++ b/ement-room.el @@ -4316,10 +4316,6 @@ members list and return already-seen members instead. For use in (buffer-local-value 'ement-session (window-buffer (minibuffer-selected-window))) ement-session)) - (ewoc (if (minibufferp) - (buffer-local-value - 'ement-ewoc (window-buffer (minibuffer-selected-window))) - ement-ewoc)) ((cl-struct ement-room members) room) (members (if (alist-get 'fetched-members-p (ement-room-local room)) (hash-table-values members) @@ -4330,7 +4326,7 @@ members list and return already-seen members instead. For use in :then (lambda (_) (setf (alist-get 'getting-members-p (ement-room-local room)) nil)) :else (lambda (_) (setf (alist-get 'getting-members-p (ement-room-local room)) nil)))) (mapcar #'ement-event-sender - (ewoc-collect ewoc #'ement-event-p))))) + (ement-room-timeline ement-room))))) (delete-dups (cl-loop for member in members collect (ement-user-id member) From 1bad05695cb7d84a8789d75104f889e1b56dab1a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 13 May 2023 23:45:20 -0500 Subject: [PATCH 11/31] Change: Improve completion by looking for prefixes * ement-room.el (ement-room--complete-members-at-point): (ement-room--complete-rooms-at-point): Look for "@", "!", or "#" prefix. --- ement-room.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ement-room.el b/ement-room.el index 0ce2923c..5dbbbcd0 100644 --- a/ement-room.el +++ b/ement-room.el @@ -4272,8 +4272,8 @@ Web-compatible HTML output, using HTML like: Uses members in the current buffer's room. For use in `completion-at-point-functions'." (let ((beg (save-excursion - (re-search-backward (rx (or bol bos blank))) - (1+ (point)))) + (when (re-search-backward (rx (or bol bos blank) "@") nil t) + (point)))) (end (point)) (collection-fn (completion-table-dynamic ;; The manual seems to show the FUN ignoring any @@ -4281,14 +4281,15 @@ Uses members in the current buffer's room. For use in ;; seems to say that it should use the argument. (lambda (_ignore) (ement-room--member-names-and-ids))))) - (list beg end collection-fn :exclusive 'no))) + (when beg + (list beg end collection-fn :exclusive 'no)))) (defun ement-room--complete-rooms-at-point () "Complete room aliases and IDs at point. For use in `completion-at-point-functions'." (let ((beg (save-excursion - (re-search-backward (rx (or bol bos blank))) - (1+ (point)))) + (when (re-search-backward (rx (or bol bos blank) (or "!" "#")) nil t) + (point)))) (end (point)) (collection-fn (completion-table-dynamic ;; The manual seems to show the FUN ignoring any @@ -4296,7 +4297,8 @@ For use in `completion-at-point-functions'." ;; seems to say that it should use the argument. (lambda (_ignore) (ement-room--room-aliases-and-ids))))) - (list beg end collection-fn :exclusive 'no))) + (when beg + (list beg end collection-fn :exclusive 'no)))) ;; TODO: Use `cl-pushnew' in these two functions instead of `delete-dups'. From cb95f5e0e84c351758d757033257f21dd03f3b62 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 13 May 2023 23:46:12 -0500 Subject: [PATCH 12/31] Fix: (ement-room-init-compose-buffer) Enable member/room completion Fixes #115. Thanks to Justus Piater (@piater) and Caleb Chase (@chasecaleb) for reporting. --- README.org | 1 + ement-room.el | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.org b/README.org index 6f1835c0..cf1c4115 100644 --- a/README.org +++ b/README.org @@ -313,6 +313,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time + Recognition of certain MXID or displayname forms in outgoing messages when linkifying (aka "pilling") them. + Unreadable room avatar images no longer cause errors. (Fixes [[https://github.com/alphapapa/ement.el/issues/147][#147]]. Thanks to [[https://github.com/jgarte][@jgarte]] for reporting.) + Don't error in ~ement-room-list~ when no rooms are joined. (Fixes [[https://github.com/alphapapa/ement.el/issues/123][#123]]. Thanks to [[https://github.com/Kabouik][@Kabouik]] and [[https://github.com/oantolin][Omar Antolín Camarena]] for reporting.) ++ Enable member/room completion in compose buffers. (Fixes [[https://github.com/alphapapa/ement.el/issues/115][#115]]. Thanks to Thanks to [[https://github.com/piater][Justus Piater]] and [[https://github.com/chasecaleb][Caleb Chase]] for reporting.) ** 0.8.3 diff --git a/ement-room.el b/ement-room.el index 5dbbbcd0..2436167c 100644 --- a/ement-room.el +++ b/ement-room.el @@ -3660,6 +3660,9 @@ a copy of the local keymap, and sets `header-line-format'." (setq-local ement-room room) (setq-local ement-session session) (setf ement-room-compose-buffer t) + (setq-local completion-at-point-functions + (append '(ement-room--complete-members-at-point ement-room--complete-rooms-at-point) + completion-at-point-functions)) ;; FIXME: Compose with local map? (use-local-map (if (current-local-map) (copy-keymap (current-local-map)) From 726d17b082e1276e8ace5b2d75c95bc1405e5f44 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 13 May 2023 23:53:13 -0500 Subject: [PATCH 13/31] Docs: Explain mentions and completion Fixes #115. --- README.org | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index cf1c4115..20fe501a 100644 --- a/README.org +++ b/README.org @@ -184,7 +184,7 @@ These bindings are common to all of the following buffer types: + Send file: ~s f~ + Send image: ~s i~ + View event source: ~v~ -+ Complete members and rooms at point: ~C-M-i~ (standard ~completion-at-point~ command). ++ Complete members and rooms at point: ~C-M-i~ (standard ~completion-at-point~ command). (Type an ~@~ prefix for a member mention, a ~#~ prefix for a room alias, or a ~!~ prefix for a room ID.) *Images* @@ -254,6 +254,7 @@ These bindings are common to all of the following buffer types: + Starting in the room list buffer, by pressing ~SPC~ repeatedly, you can cycle through and read all rooms with unread buffers. (If a room doesn't have a buffer, it will not be included.) + Room buffers and the room-list buffer can be bookmarked in Emacs, i.e. using =C-x r m=. This is especially useful with [[https://github.com/alphapapa/burly.el][Burly]]: you can arrange an Emacs frame with several room buffers displayed at once, use =burly-bookmark-windows= to bookmark the layout, and then you can restore that layout and all of the room buffers by opening the bookmark, rather than having to manually arrange them every time you start Emacs or change the window configuration. + Images and other files can be uploaded to rooms using drag-and-drop. ++ Mention members by typing a ~@~ followed by their displayname or Matrix ID. (Members' names and rooms' aliases/IDs may be completed with ~completion-at-point~ commands.) + You can customize settings in the ~ement~ group. - *Note:* ~setq~ should not be used for certain options, because it will not call the associated setter function. Users who have an aversion to the customization system may experience problems. From cef206f780eec049ea3a5433edf717361d561f50 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:05:43 -0500 Subject: [PATCH 14/31] Meta: Update makem.sh --- makem.sh | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/makem.sh b/makem.sh index 3985ff7d..82a2db0d 100755 --- a/makem.sh +++ b/makem.sh @@ -198,24 +198,36 @@ function elisp-byte-compile-file { cat >"$file" < Date: Sun, 14 May 2023 01:05:47 -0500 Subject: [PATCH 15/31] Meta: (test.yml) Also run on Emacs 28.2 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4e6b95e..2d452d1f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,7 @@ jobs: emacs_version: - 26.3 - 27.1 + - 28.2 - snapshot steps: - uses: purcell/setup-emacs@master From 2351905eedee31b4067ea010ddc421e0ff7781da Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:06:20 -0500 Subject: [PATCH 16/31] Release: v0.9 --- README.org | 2 +- ement.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 20fe501a..29c1be14 100644 --- a/README.org +++ b/README.org @@ -296,7 +296,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: -** 0.9-pre +** 0.9 *Additions* diff --git a/ement.el b/ement.el index 32ade698..516ed1a9 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9-pre +;; Version: 0.9 ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From 97e0f87c4329f7cf3f933362b2752e9616d2a33a Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:27:14 -0500 Subject: [PATCH 17/31] Meta: v0.9.1-pre --- README.org | 4 ++++ ement.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 29c1be14..6959d021 100644 --- a/README.org +++ b/README.org @@ -296,6 +296,10 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: +** 0.9.1-pre + +Nothing new yet. + ** 0.9 *Additions* diff --git a/ement.el b/ement.el index 516ed1a9..f0ea2938 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9 +;; Version: 0.9.1-pre ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From a7ea47b197a0756d08d6af6634a476fdd18344bb Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:27:24 -0500 Subject: [PATCH 18/31] Fix: (ement-room-list) inhibit-read-only earlier Needed for when no rooms are yet joined (or have not yet been loaded). --- README.org | 3 ++- ement-room-list.el | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 6959d021..01d5edbe 100644 --- a/README.org +++ b/README.org @@ -298,7 +298,8 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time ** 0.9.1-pre -Nothing new yet. +*Fixes* ++ Error in ~ement-room-list~ command upon initial sync. ** 0.9 diff --git a/ement-room-list.el b/ement-room-list.el index 1b68e983..bbdbfa69 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -547,7 +547,8 @@ After showing it, its window is selected. The buffer is named BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (interactive) - (let (format-table column-sizes window-start room-session-vectors) + (let ((inhibit-read-only t) + format-table column-sizes window-start room-session-vectors) (cl-labels (;; (heading-face ;; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth)))) (format-item (item) (gethash item format-table)) @@ -657,7 +658,6 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (taxy-sort* #'t>nil (name= "Low-priority")) (taxy-sort* #'t>nil (first-item item-left-p))))) (taxy-magit-section-insert-indent-items nil) - (inhibit-read-only t) (format-cons (taxy-magit-section-format-items ement-room-list-columns ement-room-list-column-formatters taxy)) (pos (point)) From dc3514e5c69d061d9a6a4ba36257de3209f6b8fa Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:28:37 -0500 Subject: [PATCH 19/31] Release: v0.9.1 --- README.org | 2 +- ement.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 01d5edbe..c7c75ee7 100644 --- a/README.org +++ b/README.org @@ -296,7 +296,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: -** 0.9.1-pre +** 0.9.1 *Fixes* + Error in ~ement-room-list~ command upon initial sync. diff --git a/ement.el b/ement.el index f0ea2938..ae759448 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9.1-pre +;; Version: 0.9.1 ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From 50ce611da7ec1593aa59b0f28ceb37feb17d028b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:36:11 -0500 Subject: [PATCH 20/31] Meta: v0.10-pre --- README.org | 4 ++++ ement.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index c7c75ee7..3a61739e 100644 --- a/README.org +++ b/README.org @@ -296,6 +296,10 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: +** 0.10-pre + +Nothing new yet. + ** 0.9.1 *Fixes* diff --git a/ement.el b/ement.el index ae759448..aed01dfd 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9.1 +;; Version: 0.10-pre ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From 4d44ea274c9a799b1c8d371080cfdc0bcd7e7f9d Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 14 May 2023 01:36:52 -0500 Subject: [PATCH 21/31] Docs: Improve export settings --- README.org | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 3a61739e..5995436e 100644 --- a/README.org +++ b/README.org @@ -3,7 +3,7 @@ #+PROPERTY: LOGGING nil # Export options. -#+OPTIONS: broken-links:t *:t +#+OPTIONS: broken-links:t *:t num:1 toc:1 # Info export options. #+EXPORT_FILE_NAME: ement.texi @@ -298,7 +298,9 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time ** 0.10-pre -Nothing new yet. +*Changes* + ++ Improve readme export settings. ** 0.9.1 From 8027cdd09199d71513af94d26d1b7bf56613b39b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 15 May 2023 18:32:38 -0500 Subject: [PATCH 22/31] Meta: v0.9.2-pre --- README.org | 4 ++++ ement.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index c7c75ee7..2f607bcd 100644 --- a/README.org +++ b/README.org @@ -296,6 +296,10 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: +** 0.9.2-pre + +Nothing new yet. + ** 0.9.1 *Fixes* diff --git a/ement.el b/ement.el index ae759448..fa2c21d5 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9.1 +;; Version: 0.9.2-pre ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From 8b295133ff4729864329a13a11091c9b0c61a42d Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 15 May 2023 18:29:55 -0500 Subject: [PATCH 23/31] Fix: (ement-room-list) Restore point on refresh --- README.org | 3 ++- ement-room-list.el | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 2f607bcd..3e0d69c3 100644 --- a/README.org +++ b/README.org @@ -298,7 +298,8 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time ** 0.9.2-pre -Nothing new yet. +*Fixes* ++ Restore position in room list when refreshing. ** 0.9.1 diff --git a/ement-room-list.el b/ement-room-list.el index bbdbfa69..49a8d9dd 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -548,7 +548,7 @@ BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (interactive) (let ((inhibit-read-only t) - format-table column-sizes window-start room-session-vectors) + pos format-table column-sizes window-start room-session-vectors) (cl-labels (;; (heading-face ;; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth)))) (format-item (item) (gethash item format-table)) @@ -621,6 +621,7 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." append (cl-loop for room in (ement-session-rooms session) collect (vector room session)))) (with-current-buffer (get-buffer-create buffer-name) + (setf pos (point)) (ement-room-list-mode) (delete-all-overlays) (erase-buffer) @@ -660,7 +661,6 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (taxy-magit-section-insert-indent-items nil) (format-cons (taxy-magit-section-format-items ement-room-list-columns ement-room-list-column-formatters taxy)) - (pos (point)) (section-ident (when (magit-current-section) (magit-section-ident (magit-current-section))))) (setf format-table (car format-cons) From 896ad5311de5b999a95c26ddfc12cb2fadb085d0 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 16 May 2023 01:20:05 -0500 Subject: [PATCH 24/31] Fix: Completion in minibuffer I've no idea why adding one to the point is necessary in the minibuffer, and only in the minibuffer, but it seems to be. --- README.org | 1 + ement-room.el | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 3e0d69c3..93f518cb 100644 --- a/README.org +++ b/README.org @@ -300,6 +300,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time *Fixes* + Restore position in room list when refreshing. ++ Completion in minibuffer. ** 0.9.1 diff --git a/ement-room.el b/ement-room.el index 2436167c..c01190dd 100644 --- a/ement-room.el +++ b/ement-room.el @@ -4275,8 +4275,10 @@ Web-compatible HTML output, using HTML like: Uses members in the current buffer's room. For use in `completion-at-point-functions'." (let ((beg (save-excursion - (when (re-search-backward (rx (or bol bos blank) "@") nil t) - (point)))) + (when (re-search-backward (rx (or bol bos blank)) nil t) + (if (minibufferp) + (1+ (point)) + (point))))) (end (point)) (collection-fn (completion-table-dynamic ;; The manual seems to show the FUN ignoring any @@ -4292,7 +4294,9 @@ Uses members in the current buffer's room. For use in For use in `completion-at-point-functions'." (let ((beg (save-excursion (when (re-search-backward (rx (or bol bos blank) (or "!" "#")) nil t) - (point)))) + (if (minibufferp) + (1+ (point)) + (point))))) (end (point)) (collection-fn (completion-table-dynamic ;; The manual seems to show the FUN ignoring any From 7f39fa5694232fa3f0a32b2104187fe1e886c202 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 16 May 2023 01:21:23 -0500 Subject: [PATCH 25/31] Release: v0.9.2 --- README.org | 2 +- ement.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 93f518cb..9df95a9b 100644 --- a/README.org +++ b/README.org @@ -296,7 +296,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: -** 0.9.2-pre +** 0.9.2 *Fixes* + Restore position in room list when refreshing. diff --git a/ement.el b/ement.el index fa2c21d5..8a1983f8 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9.2-pre +;; Version: 0.9.2 ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From fbf59554c6fe8447cead8a5ff83bdd1f297530cf Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 17 May 2023 05:31:04 -0500 Subject: [PATCH 26/31] Meta: v0.9.3-pre --- README.org | 4 ++++ ement.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 9df95a9b..fe5b3e20 100644 --- a/README.org +++ b/README.org @@ -296,6 +296,10 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: +** 0.9.3-pre + +Nothing new yet. + ** 0.9.2 *Fixes* diff --git a/ement.el b/ement.el index 8a1983f8..1285f819 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9.2 +;; Version: 0.9.3-pre ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm From 6a12faa2c5a7b902a9de6a43609bf4e380a5b3f2 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 17 May 2023 05:33:10 -0500 Subject: [PATCH 27/31] Revert "Fix: (ement-room-list) Restore point on refresh" This reverts commit 8b295133ff4729864329a13a11091c9b0c61a42d. --- ement-room-list.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ement-room-list.el b/ement-room-list.el index 49a8d9dd..bbdbfa69 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -548,7 +548,7 @@ BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (interactive) (let ((inhibit-read-only t) - pos format-table column-sizes window-start room-session-vectors) + format-table column-sizes window-start room-session-vectors) (cl-labels (;; (heading-face ;; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth)))) (format-item (item) (gethash item format-table)) @@ -621,7 +621,6 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." append (cl-loop for room in (ement-session-rooms session) collect (vector room session)))) (with-current-buffer (get-buffer-create buffer-name) - (setf pos (point)) (ement-room-list-mode) (delete-all-overlays) (erase-buffer) @@ -661,6 +660,7 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (taxy-magit-section-insert-indent-items nil) (format-cons (taxy-magit-section-format-items ement-room-list-columns ement-room-list-column-formatters taxy)) + (pos (point)) (section-ident (when (magit-current-section) (magit-section-ident (magit-current-section))))) (setf format-table (car format-cons) From de82db64f1bc4c8c1b3f14506c0900afab21c2ba Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 17 May 2023 05:34:20 -0500 Subject: [PATCH 28/31] Revert "Fix: (ement-room-list) When no rooms are joined" This reverts commit c0b922bcc5d3c11b60d283caf28356c251fe885b. --- ement-room-list.el | 126 ++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/ement-room-list.el b/ement-room-list.el index bbdbfa69..516ac80b 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -547,8 +547,7 @@ After showing it, its window is selected. The buffer is named BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (interactive) - (let ((inhibit-read-only t) - format-table column-sizes window-start room-session-vectors) + (let (format-table column-sizes window-start) (cl-labels (;; (heading-face ;; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth)))) (format-item (item) (gethash item format-table)) @@ -616,70 +615,69 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." ;; (kill-buffer buffer-name)) (unless ement-sessions (error "Ement: Not connected. Use `ement-connect' to connect")) - (setf room-session-vectors - (cl-loop for (_id . session) in ement-sessions - append (cl-loop for room in (ement-session-rooms session) - collect (vector room session)))) (with-current-buffer (get-buffer-create buffer-name) (ement-room-list-mode) - (delete-all-overlays) - (erase-buffer) - (if (not room-session-vectors) - (insert "No joined rooms. Use command `ement-join-room' to join a room, or `ement-directory' or `ement-directory-search' to find rooms.") - (let* ((taxy (cl-macrolet ((first-item - (pred) `(lambda (taxy) - (when (taxy-items taxy) - (,pred (car (taxy-items taxy)))))) - (name= (name) `(lambda (taxy) - (equal ,name (taxy-name taxy))))) - (thread-last - (make-fn - :name "Ement Rooms" - :take (taxy-make-take-function keys ement-room-list-keys)) - (taxy-fill room-session-vectors) - (taxy-sort #'> #'item-latest-ts) - (taxy-sort #'tnil #'item-low-priority-p) - (taxy-sort #'tnil #'item-left-p) - (taxy-sort* #'string< #'taxy-name) - (taxy-sort* #'> #'taxy-latest-ts) - (taxy-sort* #'tnil (first-item item-space-p)) - (taxy-sort* #'t>nil (name= "Low-priority")) - (taxy-sort* #'t>nil (first-item item-left-p))))) - (taxy-magit-section-insert-indent-items nil) - (format-cons (taxy-magit-section-format-items - ement-room-list-columns ement-room-list-column-formatters taxy)) - (pos (point)) - (section-ident (when (magit-current-section) - (magit-section-ident (magit-current-section))))) - (setf format-table (car format-cons) - column-sizes (cdr format-cons) - header-line-format (taxy-magit-section-format-header - column-sizes ement-room-list-column-formatters) - window-start (if (get-buffer-window buffer-name) - (window-start (get-buffer-window buffer-name)) - 0)) - (when ement-room-list-visibility-cache - (setf magit-section-visibility-cache ement-room-list-visibility-cache)) - (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local) - (save-excursion - (taxy-magit-section-insert taxy :items 'first - ;; :blank-between-depth bufler-taxy-blank-between-depth - :initial-depth 0)) - (goto-char pos) - (when (and section-ident (magit-get-section section-ident)) - (goto-char (oref (magit-get-section section-ident) start)))))) + (let* ((room-session-vectors + (cl-loop for (_id . session) in ement-sessions + append (cl-loop for room in (ement-session-rooms session) + collect (vector room session)))) + (taxy (cl-macrolet ((first-item + (pred) `(lambda (taxy) + (when (taxy-items taxy) + (,pred (car (taxy-items taxy)))))) + (name= (name) `(lambda (taxy) + (equal ,name (taxy-name taxy))))) + (thread-last + (make-fn + :name "Ement Rooms" + :take (taxy-make-take-function keys ement-room-list-keys)) + (taxy-fill room-session-vectors) + (taxy-sort #'> #'item-latest-ts) + (taxy-sort #'tnil #'item-low-priority-p) + (taxy-sort #'tnil #'item-left-p) + (taxy-sort* #'string< #'taxy-name) + (taxy-sort* #'> #'taxy-latest-ts) + (taxy-sort* #'tnil (first-item item-space-p)) + (taxy-sort* #'t>nil (name= "Low-priority")) + (taxy-sort* #'t>nil (first-item item-left-p))))) + (taxy-magit-section-insert-indent-items nil) + (inhibit-read-only t) + (format-cons (taxy-magit-section-format-items + ement-room-list-columns ement-room-list-column-formatters taxy)) + (pos (point)) + (section-ident (when (magit-current-section) + (magit-section-ident (magit-current-section))))) + (setf format-table (car format-cons) + column-sizes (cdr format-cons) + header-line-format (taxy-magit-section-format-header + column-sizes ement-room-list-column-formatters) + window-start (if (get-buffer-window buffer-name) + (window-start (get-buffer-window buffer-name)) + 0)) + (when ement-room-list-visibility-cache + (setf magit-section-visibility-cache ement-room-list-visibility-cache)) + (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local) + (delete-all-overlays) + (erase-buffer) + (save-excursion + (taxy-magit-section-insert taxy :items 'first + ;; :blank-between-depth bufler-taxy-blank-between-depth + :initial-depth 0)) + (goto-char pos) + (when (and section-ident (magit-get-section section-ident)) + (goto-char (oref (magit-get-section section-ident) start))))) (when display-buffer-action (when-let ((window (display-buffer buffer-name display-buffer-action))) (select-window window))) From 588113092f759fbf262847b258037ca2fd9e457f Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 17 May 2023 06:19:16 -0500 Subject: [PATCH 29/31] Fix: (ement-room-list) Another attempt This seems to work most of the time, but not all of the time. See comment at bottom of function. This will have to be good enough for now. --- README.org | 3 +- ement-room-list.el | 160 +++++++++++++++++++++++++-------------------- 2 files changed, 90 insertions(+), 73 deletions(-) diff --git a/README.org b/README.org index fe5b3e20..a6882d9d 100644 --- a/README.org +++ b/README.org @@ -298,7 +298,8 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time ** 0.9.3-pre -Nothing new yet. +*Fixes* ++ Another attempt at restoring position in room list when refreshing. ** 0.9.2 diff --git a/ement-room-list.el b/ement-room-list.el index 516ac80b..076314e1 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -547,7 +547,8 @@ After showing it, its window is selected. The buffer is named BUFFER-NAME and is shown with DISPLAY-BUFFER-ACTION; or if DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." (interactive) - (let (format-table column-sizes window-start) + (let ((window-start 0) (window-point 0) + format-table column-sizes) (cl-labels (;; (heading-face ;; (depth) (list :inherit (list 'bufler-group (bufler-level-face depth)))) (format-item (item) (gethash item format-table)) @@ -615,77 +616,92 @@ DISPLAY-BUFFER-ACTION is nil, the buffer is not displayed." ;; (kill-buffer buffer-name)) (unless ement-sessions (error "Ement: Not connected. Use `ement-connect' to connect")) - (with-current-buffer (get-buffer-create buffer-name) - (ement-room-list-mode) - (let* ((room-session-vectors - (cl-loop for (_id . session) in ement-sessions - append (cl-loop for room in (ement-session-rooms session) - collect (vector room session)))) - (taxy (cl-macrolet ((first-item - (pred) `(lambda (taxy) - (when (taxy-items taxy) - (,pred (car (taxy-items taxy)))))) - (name= (name) `(lambda (taxy) - (equal ,name (taxy-name taxy))))) - (thread-last - (make-fn - :name "Ement Rooms" - :take (taxy-make-take-function keys ement-room-list-keys)) - (taxy-fill room-session-vectors) - (taxy-sort #'> #'item-latest-ts) - (taxy-sort #'tnil #'item-low-priority-p) - (taxy-sort #'tnil #'item-left-p) - (taxy-sort* #'string< #'taxy-name) - (taxy-sort* #'> #'taxy-latest-ts) - (taxy-sort* #'tnil (first-item item-space-p)) - (taxy-sort* #'t>nil (name= "Low-priority")) - (taxy-sort* #'t>nil (first-item item-left-p))))) - (taxy-magit-section-insert-indent-items nil) - (inhibit-read-only t) - (format-cons (taxy-magit-section-format-items - ement-room-list-columns ement-room-list-column-formatters taxy)) - (pos (point)) - (section-ident (when (magit-current-section) - (magit-section-ident (magit-current-section))))) - (setf format-table (car format-cons) - column-sizes (cdr format-cons) - header-line-format (taxy-magit-section-format-header - column-sizes ement-room-list-column-formatters) - window-start (if (get-buffer-window buffer-name) - (window-start (get-buffer-window buffer-name)) - 0)) - (when ement-room-list-visibility-cache - (setf magit-section-visibility-cache ement-room-list-visibility-cache)) - (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local) - (delete-all-overlays) - (erase-buffer) - (save-excursion - (taxy-magit-section-insert taxy :items 'first - ;; :blank-between-depth bufler-taxy-blank-between-depth - :initial-depth 0)) - (goto-char pos) - (when (and section-ident (magit-get-section section-ident)) - (goto-char (oref (magit-get-section section-ident) start))))) - (when display-buffer-action - (when-let ((window (display-buffer buffer-name display-buffer-action))) - (select-window window))) - (when (get-buffer-window buffer-name) - (set-window-start (get-buffer-window buffer-name) window-start)) - ;; NOTE: In order for `bookmark--jump-via' to work properly, the restored buffer - ;; must be set as the current buffer, so we have to do this explicitly here. - (set-buffer buffer-name)))) + (if (not (cl-loop for (_id . session) in ement-sessions + thereis (ement-session-rooms session))) + (ement-message "No rooms have been joined") + (with-current-buffer (get-buffer-create buffer-name) + (ement-room-list-mode) + (let* ((room-session-vectors + (cl-loop for (_id . session) in ement-sessions + append (cl-loop for room in (ement-session-rooms session) + collect (vector room session)))) + (taxy (cl-macrolet ((first-item + (pred) `(lambda (taxy) + (when (taxy-items taxy) + (,pred (car (taxy-items taxy)))))) + (name= (name) `(lambda (taxy) + (equal ,name (taxy-name taxy))))) + (thread-last + (make-fn + :name "Ement Rooms" + :take (taxy-make-take-function keys ement-room-list-keys)) + (taxy-fill room-session-vectors) + (taxy-sort #'> #'item-latest-ts) + (taxy-sort #'tnil #'item-low-priority-p) + (taxy-sort #'tnil #'item-left-p) + (taxy-sort* #'string< #'taxy-name) + (taxy-sort* #'> #'taxy-latest-ts) + (taxy-sort* #'tnil (first-item item-space-p)) + (taxy-sort* #'t>nil (name= "Low-priority")) + (taxy-sort* #'t>nil (first-item item-left-p))))) + (taxy-magit-section-insert-indent-items nil) + (inhibit-read-only t) + (format-cons (taxy-magit-section-format-items + ement-room-list-columns ement-room-list-column-formatters taxy)) + (pos (point)) + (section-ident (when (magit-current-section) + (magit-section-ident (magit-current-section))))) + (setf format-table (car format-cons) + column-sizes (cdr format-cons) + header-line-format (taxy-magit-section-format-header + column-sizes ement-room-list-column-formatters)) + (when-let ((window (get-buffer-window (current-buffer)))) + (setf window-point (window-point window) + window-start (window-start window))) + (when ement-room-list-visibility-cache + (setf magit-section-visibility-cache ement-room-list-visibility-cache)) + (add-hook 'kill-buffer-hook #'ement-room-list--cache-visibility nil 'local) + ;; Before this point, no changes have been made to the buffer's contents. + (delete-all-overlays) + (erase-buffer) + (save-excursion + (taxy-magit-section-insert taxy :items 'first + ;; :blank-between-depth bufler-taxy-blank-between-depth + :initial-depth 0)) + (if-let* ((section-ident) + (section (magit-get-section section-ident))) + (goto-char (oref section start)) + (goto-char pos)))) + (when display-buffer-action + (when-let ((window (display-buffer buffer-name display-buffer-action))) + (select-window window))) + (when-let ((window (get-buffer-window buffer-name))) + (set-window-start window window-start) + (set-window-point window window-point)) + ;; FIXME: Despite all this code to save and restore point and window point and + ;; window start, when I send a message from the minibuffer, or when I abort + ;; sending a message from the minibuffer, point is moved to the beginning of the + ;; buffer. While the minibuffer is open (and the typing messages are being sent + ;; to the server, causing it to repeatedly sync), the point stays in the correct + ;; place. I can't find any reason why this happens. It makes no sense. And + ;; while trying to debug the problem, somehow Emacs got put into an unbreakable, + ;; infinite loop twice; even C-g and SIGUSR2 didn't stop it. + + ;; NOTE: In order for `bookmark--jump-via' to work properly, the restored buffer + ;; must be set as the current buffer, so we have to do this explicitly here. + (set-buffer buffer-name))))) (cl-defun ement-room-list-side-window (&key (side 'left)) "Show room list in side window on SIDE. From 91590202d13623830491ada3bafb03f8b1eb3cc4 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 17 May 2023 06:24:37 -0500 Subject: [PATCH 30/31] Fix: (ement-room-list-next-unread) Was broken by 11450ed3440741730581d97c82880cb51d9ff489. Fixes #149. Thanks to @jeffbowman for reporting. --- README.org | 1 + ement-room-list.el | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.org b/README.org index a6882d9d..49aed6e9 100644 --- a/README.org +++ b/README.org @@ -300,6 +300,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time *Fixes* + Another attempt at restoring position in room list when refreshing. ++ Command ~ement-room-list-next-unread~. ** 0.9.2 diff --git a/ement-room-list.el b/ement-room-list.el index 076314e1..6dad2354 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -753,19 +753,17 @@ left." (defun ement-room-list-next-unread () "Show next unread room." (interactive) - (unless (button-at (point)) - (call-interactively #'forward-button)) + (when (eobp) + (goto-char (point-min))) (unless (cl-loop with starting-line = (line-number-at-pos) for value = (oref (magit-current-section) value) - for room = (elt value 0) - for session = (elt value 1) - if (ement--room-unread-p room session) + if (and (vectorp value) + (ement--room-unread-p (elt value 0) (elt value 1))) do (progn - (goto-char (button-end (button-at (point)))) - (push-button (1- (point))) + (ement-view-room (elt value 0) (elt value 1)) (ement-room-goto-fully-read-marker) (cl-return t)) - else do (call-interactively #'forward-button) + else do (forward-line 1) while (> (line-number-at-pos) starting-line)) ;; No more unread rooms. (message "No more unread rooms"))) From 16e05cf4d3f3cc8dcfa30a4c2426066dbef798ad Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 17 May 2023 06:25:30 -0500 Subject: [PATCH 31/31] Release: v0.9.3 --- README.org | 2 +- ement.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 49aed6e9..13443f8a 100644 --- a/README.org +++ b/README.org @@ -296,7 +296,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time :TOC: :depth 0 :END: -** 0.9.3-pre +** 0.9.3 *Fixes* + Another attempt at restoring position in room list when refreshing. diff --git a/ement.el b/ement.el index 1285f819..ac75ac8e 100644 --- a/ement.el +++ b/ement.el @@ -5,7 +5,7 @@ ;; Author: Adam Porter ;; Maintainer: Adam Porter ;; URL: https://github.com/alphapapa/ement.el -;; Version: 0.9.3-pre +;; Version: 0.9.3 ;; Package-Requires: ((emacs "27.1") (map "2.1") (persist "0.5") (plz "0.2") (taxy "0.10") (taxy-magit-section "0.12.1") (svg-lib "0.2.5") (transient "0.3.7")) ;; Keywords: comm