ement.el/README.org

304 lines
15 KiB
Org Mode
Raw Normal View History

2021-08-24 03:21:46 -05:00
#+TITLE: Ement.el
#+PROPERTY: LOGGING nil
# Note: This readme works with the org-make-toc <https://github.com/alphapapa/org-make-toc> package, which automatically updates the table of contents.
#+HTML: <img src="images/logo-128px.png" align="right">
2021-08-13 10:47:17 -05:00
# [[https://melpa.org/#/package-name][file:https://melpa.org/packages/package-name-badge.svg]] [[https://stable.melpa.org/#/package-name][file:https://stable.melpa.org/packages/package-name-badge.svg]]
2021-09-16 00:28:32 +00:00
Ement.el is a new Matrix client for Emacs. It aims to be simple, fast, featureful, and reliable.
2021-09-16 00:28:32 +00:00
Feel free to join us in the chat room: [[https://matrix.to/#/#ement.el:matrix.org][https://img.shields.io/matrix/ement.el:matrix.org.svg?label=%23ement.el:matrix.org]]
2021-08-18 09:51:24 -05:00
* Contents :noexport:
:PROPERTIES:
:TOC: :include siblings
:END:
:CONTENTS:
2021-08-12 15:10:47 -05:00
- [[#screenshots][Screenshots]]
2020-12-01 16:08:51 -06:00
- [[#installation][Installation]]
- [[#usage][Usage]]
- [[#bindings][Bindings]]
2021-07-29 04:17:46 -05:00
- [[#tips][Tips]]
2021-08-12 04:25:27 -05:00
- [[#encrypted-room-support-through-pantalaimon][Encrypted room support through Pantalaimon]]
2021-07-29 04:17:46 -05:00
- [[#rationale][Rationale]]
2020-12-01 16:08:51 -06:00
- [[#changelog][Changelog]]
2021-09-24 04:33:06 -05:00
- [[#development][Development]]
:END:
2021-08-12 15:10:47 -05:00
* Screenshots
2021-08-13 09:14:14 -05:00
:PROPERTIES:
:ID: d818f690-5f22-4eb0-83e1-4d8ce16c9e5b
:END:
2021-08-12 15:10:47 -05:00
The default formatting style resembles IRC clients, with each message being prefixed by the username (which enables powerful Emacs features, like using Occur to show all messages from or mentioning a user). Alternative, built-in styles include an Element-like one with usernames above groups of messages, as well as a classic, no-margins IRC style. Messages may be optionally displayed with unique colors for each user (with customizeable contrast), making it easier to follow conversations. Timestamp headers are optionally displayed where a certain amount of time passes between events, as well as where the date changes.
2021-08-13 09:14:14 -05:00
[[images/ement-for-twim.png]]
/Two rooms shown in side-by-side buffers, showing inline images, reactions, date/time headings, room avatars, and messages colored by user (using the modus-vivendi Emacs theme)./
2021-08-12 15:10:47 -05:00
[[images/emacs-with-fully-read-line.png]]
/#emacs:libera.chat showing colored text from IRC users, replies with quoted parts, messages colored by user, addressed usernames colored by their user color, highlighted mentions, and the fully-read marker line (using the modus-vivendi Emacs theme)./
[[images/screenshot5.png]]
/Four rooms shown at once, with messages colored by user, in the default Emacs theme./
[[images/screenshot2.png]]
/A room at the top in the "Elemental" display style, with sender names displayed over groups of messages, and only self-messages in an alternate color. The lower window shows an earlier version of the rooms list./
[[images/reactions.png]]
/Reactions displayed as color emojis (may need [[#displaying-symbols-and-emojis][proper Emacs configuration]])./
* Installation
:PROPERTIES:
:TOC: :depth 0
:END:
# ** MELPA
#
# If you installed from MELPA, you're done. Just run one of the commands below.
** Quelpa
The recommended way to install is with [[https://github.com/quelpa/quelpa-use-package][quelpa-use-package]], like this:
#+BEGIN_SRC elisp
;; Install and load `quelpa-use-package'.
(package-install 'quelpa-use-package)
(require 'quelpa-use-package)
;; Install Ement.
(use-package ement
:quelpa (ement :fetcher github :repo "alphapapa/ement.el"))
#+END_SRC
** Manual
If you want to install it manually, it's simple enough, but you should know what you're doing, and you're on your own.
* Usage
:PROPERTIES:
2021-08-12 04:25:27 -05:00
:TOC: :include descendants :depth 1
:END:
:CONTENTS:
- [[#bindings][Bindings]]
- [[#tips][Tips]]
- [[#encrypted-room-support-through-pantalaimon][Encrypted room support through Pantalaimon]]
:END:
2021-08-05 01:05:34 -05:00
1. Call command ~ement-connect~ to connect. Multiple sessions are supported, so you may call the command again to connect to another account.
2. Wait for initial sync to complete (which can take a few moments--initial sync JSON requests can be large).
2020-12-03 22:08:48 -06:00
3. Use these commands:
- ~ement-list-rooms~ to view the list of joined rooms.
2021-07-27 22:04:25 -05:00
- ~ement-view-room~ to view a room's buffer, selected with completion.
- ~ement-create-room~ to create a new room.
- ~ement-invite-user~ to invite a user to a room.
2021-07-27 22:04:25 -05:00
- ~ement-join-room~ to join a room.
- ~ement-leave-room~ to leave a room.
2022-03-24 17:22:46 -05:00
- ~ement-forget-room~ to forget a room.
2022-04-09 16:55:41 -05:00
- ~ement-tag-room~ to add (or with interactive prefix, remove) a tag on a room (including favorite/low-priority status).
- ~ement-list-members~ to list members in a room.
2022-03-25 23:01:52 -05:00
- ~ement-send-direct-message~ to send a direct message to a user (in an existing direct room, or creating a new one automatically).
2021-07-29 05:16:35 -05:00
- ~ement-room-edit-message~ to edit a message at point.
- ~ement-room-send-file~ to send a file.
- ~ement-room-send-image~ to send an image.
2021-08-03 04:31:57 -05:00
- ~ement-room-set-topic~ to set a room's topic.
2022-04-29 16:00:40 -05:00
- ~ement-room-occur~ to search in a room's known events.
2022-04-12 09:35:51 -05:00
- ~ement-ignore-user~ to ignore a user (or with interactive prefix, un-ignore).
2021-08-10 06:31:15 -05:00
- ~ement-room-set-message-format~ to set a room's message format buffer-locally.
4. Use these special buffers to see events from multiple rooms (you can also reply to messages from these buffers!):
- See all new events that mention you in the =*Ement Mentions*= buffer.
- See all new events in rooms that have open buffers in the =*Ement Notifications*= buffer.
** Bindings
These bindings are common to all of the following buffer types:
+ Switch to a room buffer: ~M-g M-r~
+ Switch to the room list buffer: ~M-g M-l~
+ Switch to the mentions buffer: ~M-g M-m~
+ Switch to the notifications buffer: ~M-g M-n~
*** Room buffers
2022-05-06 20:42:53 -05:00
+ Show command menu: ~?~
[[images/transient.png]]
*Movement*
+ Next event: ~TAB~
+ Previous event: ~<backtab>~
+ Scroll up and mark read: ~SPC~
+ Scroll down: ~S-SPC~
+ Jump to fully-read marker: ~M-SPC~
+ Load older messages: at top of buffer, scroll contents up (i.e. ~S-SPC~, ~M-v~ or ~mwheel-scroll~)
*Switching*
+ List rooms: ~M-g M-l~
+ Switch to other room: ~M-g M-r~
+ Switch to mentions buffer: ~M-g M-m~
+ Switch to notifications buffer: ~M-g M-n~
+ Quit window: ~q~
*Messages*
+ Write message: ~RET~
+ Write reply to event at point (when region is active, only quote marked text) : ~S-RET~
+ Compose message in buffer: ~M-RET~ (while writing in minibuffer: ~C-c ')~ (Use command ~ement-room-compose-org~ to activate Org mode in the compose buffer.)
+ Edit message: ~<insert>~
+ Delete message: ~C-k~
+ Send reaction to event at point, or send same reaction at point: ~s r~
+ Send emote: ~s e~
+ 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).
*Images*
+ Toggle scale of image (between fit-to-window and thumbnail): ~mouse-1~
+ Show image in new buffer at full size: ~double-mouse-1~
*Users*
+ Send direct message: ~u RET~
+ Invite user: ~u i~
+ Ignore user: ~u I~
*Room*
+ Occur search in room: ~M-s o~
+ List members: ~r m~
+ Set topic: ~r t~
+ Set message format: ~r f~
+ Tag/untag room: ~r T~
*Room membership*
+ Create room: ~R c~
+ Join room: ~R j~
+ Leave room: ~R l~
+ Forget room: ~R F~
*Other*
+ Sync new messages (not necessary if auto sync is enabled; with prefix to force new sync): ~g~
*** Room list buffer
+ Show buffer of room at point: ~RET~
+ Show buffer of next unread room: ~SPC~
+ Move between room names: ~TAB~ / ~<backtab>~
*** Mentions/notifications buffers
+ Move between events: ~TAB~ / ~<backtab>~
+ Go to event at point in its room buffer: ~RET~
+ Write reply to event at point (shows the event in its room while writing) : ~S-RET~
** Tips
# TODO: Show sending messages in Org format.
+ Desktop notifications are enabled by default for events that mention the local user. They can also be shown for all events in rooms with open buffers.
+ Send messages in Org mode format by customizing the option ~ement-room-send-message-filter~ (which enables Org format by default), or by calling ~ement-room-compose-org~ in a compose buffer (which enables it for a single message). Then Org-formatted messages are automatically converted and sent as HTML-formatted messages (with the Org syntax as the plain-text fallback). You can send syntax such as:
- Bold, italic, underline, strikethrough
- Links
- Tables
- Source blocks (including results with ~:exports both~)
- Footnotes (okay, that might be pushing it, but you can!)
- And, generally, anything that Org can export to HTML
+ 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.)
2021-07-29 04:17:46 -05:00
+ 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.
+ 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.
Merge: Add: Show reactions Squashed commit of the following: commit 1f393d7dde91acf315d5e218e9d52e69b1a5aa28 Author: Adam Porter <adam@alphapapa.net> Date: Thu Jul 22 10:48:19 2021 -0500 Comment: TODOs commit 7e039a7b4f2b8c05d1a3a8e5e763344f783dfdbe Author: Adam Porter <adam@alphapapa.net> Date: Thu Jul 22 10:48:08 2021 -0500 WIP: Docstring for handler lambdas commit 441c23113cf52b53773e6a9cb3cb66870da87c24 Author: Adam Porter <adam@alphapapa.net> Date: Thu Jul 22 10:40:58 2021 -0500 WIP: Don't insert reaction events as nodes This seems to work well. However, the event-processing needs some refactoring, because the logic is now spread across a few places. commit 4fdf0ddf37399eb2b8c75639c7f8ff40897e45b6 Author: Adam Porter <adam@alphapapa.net> Date: Thu Jul 22 10:30:28 2021 -0500 WIP: Key face, and fix help-echo Remaining issue is that reactions still insert empty events in the buffer. commit 5f700ccc16276b9ce8bb1682e2446e14b6c6873a Author: Adam Porter <adam@alphapapa.net> Date: Thu Jul 22 09:30:18 2021 -0500 WIP: Fix: Use pushnew to avoid duplicating reactions commit a40a6e6bc1f97d6ada7291d0b216cff0d9ab8074 Author: Adam Porter <adam@alphapapa.net> Date: Wed Jul 21 20:17:32 2021 -0500 WIP: And in -retro-callback A bug now is that, every time a room's buffer is created anew, the reactions are duplicated. commit dbfec18e45f1371cf1f45ae301445055ce670960 Author: Adam Porter <adam@alphapapa.net> Date: Wed Jul 21 19:49:47 2021 -0500 WIP: Call -room---process-events in -room--buffer This almost seems to work, in that reactions from old timeline events are displayed when the buffer is made...or not? It seems to work in some cases, but not in others, like when retro-loading... The big issue now is that the reaction events cause blank events to be inserted into the buffer. Fixing that will require conditionally inserting events, which probably means moving message event handling into the defevent macro, which will require some more refactoring... commit 81757536f27d14c868cee42b70a6cd806020d148 Author: Adam Porter <adam@alphapapa.net> Date: Wed Jul 21 17:02:29 2021 -0500 WIP: Add: Reactions It works for newly received reactions, but after initial sync, reactions that happened in the past are not displayed. I think it's because the related events aren't found in the room's timeline, but I tried to fix that, and it still doesn't work. I'm guessing there are some assumptions that I'm making wrongly, or something that I don't understand about how the server sends events. We may have to save a list of certain types of events and process them after all other events have been processed. Ugh. The good news is that EWOC makes it pretty easy and reliable to update messages in the buffer.
2021-07-22 10:48:41 -05:00
*** Displaying symbols and emojis
Emacs may not display certain symbols and emojis well by default. Based on [[https://emacs.stackexchange.com/questions/62049/override-the-default-font-for-emoji-characters][this question and answer]], you may find that the simplest way to fix this is to install an appropriate font, like [[https://www.google.com/get/noto/#emoji-zsye][Noto Emoji]], and then use this Elisp code:
#+BEGIN_SRC elisp
(setf use-default-font-for-symbols nil)
(set-fontset-font t 'unicode "Noto Emoji" nil 'append)
#+END_SRC
2021-08-12 04:25:27 -05:00
** Encrypted room support through Pantalaimon
Ement.el doesn't support encrypted rooms natively, but it can be used transparently with the E2EE-aware reverse proxy daemon [[https://github.com/matrix-org/pantalaimon/][Pantalaimon]]. After configuring it according to its documentation, call ~ement-connect~ with the appropriate hostname and port, like:
#+BEGIN_SRC elisp
(ement-connect :uri-prefix "http://localhost:8009")
2021-08-12 04:25:27 -05:00
#+END_SRC
2021-07-29 04:17:46 -05:00
* Rationale
Why write a new Emacs Matrix client when there is already [[https://github.com/alphapapa/matrix-client.el][matrix-client.el]], by the same author, no less? A few reasons:
- ~matrix-client~ uses an older version of the Matrix spec, r0.3.0, with a few elements of r0.4.0 grafted in. Bringing it up to date with the current version of the spec, r0.6.1, would be more work than to begin with the current version. Ement.el targets r0.6.1 from the beginning.
- ~matrix-client~ does not use Matrix's lazy-loading feature (which was added to the specification later), so initial sync requests can take a long time for the server to process and can be large (sometimes tens of megabytes of JSON for the client to process!). Ement.el uses lazy-loading, which significantly improves performance.
- ~matrix-client~ automatically makes buffers for every room a user has joined, even if the user doesn't currently want to watch a room. Ement.el opens room buffers on-demand, improving performance by not having to insert events into buffers for rooms the user isn't watching.
- ~matrix-client~ was developed without the intention of publishing it to, e.g. MELPA or ELPA. It has several dependencies, and its code does not always install or compile cleanly due to macro-expansion issues (apparently depending on the user's Emacs config). Ement.el is designed to have minimal dependencies outside of Emacs (currently only one, ~plz~, which could be imported into the project), and every file is linted and compiles cleanly using [[https://github.com/alphapapa/makem.sh][makem.sh]].
- ~matrix-client~ uses EIEIO, probably unnecessarily, since few, if any, of the benefits of EIEIO are realized in it. Ement.el uses structs instead.
- ~matrix-client~ uses bespoke code for inserting messages into buffers, which works pretty well, but has a few minor bugs which are difficult to track down. Ement.el uses Emacs's built-in (and perhaps little-known) ~ewoc~ library, which makes it much simpler and more reliable to insert and update messages in buffers, and enables the development of advanced UI features more easily.
- ~matrix-client~ was, to a certain extent, designed to imitate other messaging apps. The result is, at least when used with the ~matrix-client-frame~ command, fairly pleasing to use, but isn't especially "Emacsy." Ement.el is intended to better fit into Emacs's paradigms.
- ~matrix-client~'s long name makes for long symbol names, which makes for tedious, verbose code. ~ement~ is easy to type and makes for concise, readable code.
- The author has learned much since writing ~matrix-client~ and hopes to write simpler, more readable, more maintainable code in Ement.el. It's hoped that this will enable others to contribute more easily.
However, note that ~matrix-client~ is a more mature client and is very reliable in the author's experience. While Ement.el is intended to reach feature parity with it and eventually surpass it, that will take some time, so ~matrix-client~ remains a good choice.
* Changelog
:PROPERTIES:
:TOC: :depth 0
:END:
** 0.1-pre
Yet to be released.
* COMMENT Credits
* Development
2022-03-20 17:33:28 -05:00
:PROPERTIES:
:TOC: :include this :ignore descendants
:END:
2021-09-24 04:33:06 -05:00
Bug reports, feature requests, suggestions — /oh my/!
** Copyright Assignment
2021-07-29 04:17:46 -05:00
:PROPERTIES:
:TOC: :ignore (this)
:END:
2021-09-24 04:33:06 -05:00
While Ement.el is not yet available in GNU ELPA and is not part of Emacs, it would be good to keep that option available. In that case, cumulative contributions of more than 15 lines of code would require that the author assign copyright of such contributions to the FSF. Therefore, please note that this project may require such assignment before accepting contributions. Authors who are interested in doing so may contact [[mailto:assign@gnu.org][assign@gnu.org]] to request the appropriate form.
2021-09-24 04:43:19 -05:00
** Matrix spec in Org format
:PROPERTIES:
:TOC: :ignore (this)
:END:
An Org-formatted version of the Matrix spec is available in the [[https://github.com/alphapapa/ement.el/tree/meta/spec][meta/spec]] branch.
* License
2021-07-29 04:17:46 -05:00
:PROPERTIES:
:TOC: :ignore (this)
:END:
GPLv3
# Local Variables:
# eval: (require 'org-make-toc)
# before-save-hook: org-make-toc
# org-export-with-properties: ()
# org-export-with-title: t
# End: