alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
488 stars 44 forks source link

Improve behavior of calling reply command when point is on username using "Elemental" message format #194

Open rgri opened 1 year ago

rgri commented 1 year ago

To reproduce:

  1. Open the room list
  2. Enter a room
  3. Attempt to use S-RET or M-x ement-room-write-reply to reply to a message point

This fails with the following trace:

Debugger entered--Lisp error: (cl-assertion-failed ((ement-event-p (ewoc-data (ewoc-locate ement-ewoc))) nil))
  cl--assertion-failed((ement-event-p (ewoc-data (ewoc-locate ement-ewoc))))
  ement-room-write-reply()
  #<subr funcall-interactively>(ement-room-write-reply)
  apply(#<subr funcall-interactively> ement-room-write-reply)
  funcall-interactively(ement-room-write-reply)
  #<subr call-interactively>(ement-room-write-reply nil nil)
  apply(#<subr call-interactively> (ement-room-write-reply nil nil))
  explain-pause--wrap-call-interactively(#<subr call-interactively> ement-room-write-reply nil nil)
  apply(explain-pause--wrap-call-interactively #<subr call-interactively> (ement-room-write-reply nil nil))
  call-interactively(ement-room-write-reply nil nil)
  command-execute(ement-room-write-reply)

Specifically, I am using Nix's emacs29-pgtk package.

alphapapa commented 1 year ago

The backtrace would seem to indicate that you called the command to write a reply when point was not on a message event.

rgri commented 1 year ago

Yes, I must have thought that the username associated with a message is included in the region defined as the message. I'll close this now.

Though is it perhaps worthwhile to add a catch for such an error? So far nothing else while using ement has spit such an ugly message at me.

alphapapa commented 1 year ago

Yes, I must have thought that the username associated with a message is included in the region defined as the message. I'll close this now.

The default message display format puts the usernames and timestamps in the margins; the point can't move into the margins. Point can be in the message body, reactions, etc.

Though is it perhaps worthwhile to add a catch for such an error? So far nothing else while using ement has spit such an ugly message at me.

What you saw was the catch, the assertion. I don't understand how you could have tried to call that command thinking point was on a username shown in a margin, though.

Maybe it should be improved, but this is the first I've heard of this problem, and at least a few hundred people are using Ement now, so we'll see.

rgri commented 1 year ago

I maybe should have clarified: the issue only appears while in the "Elemental" room format: with ement-room-message-format-spec set to "%B%r%R%t".

alphapapa commented 1 year ago

Ok, that makes sense, yes. Probably point was on the username rather than the message below it. I'll repurpose this issue to improve that behavior. Thanks.