alphapapa / ement.el

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

[Feature]: jump to prev/next image #206

Open progfolio opened 10 months ago

progfolio commented 10 months ago

An idea I had while looking for an image in a room:

(defun +ement--find-image (backp)
  "Move point to image.
If BACKP is non-nil, search backward."
  (or
   (funcall (if backp #'text-property-search-backward
              #'text-property-search-forward)
            'display 'image
            (lambda (val here) (eq val (car-safe here)))
            'not-current)
   (user-error "No more images")))

(defun +ement-next-image (n)
  "Move point to Nth next image."
  (interactive "p")
  (unless ement-room (user-error "Not in ement room"))
  (dotimes (_ (abs n)) (+ement--find-image (when (< n 0) 'previous))))

(defun +ement-prev-image (n)
  "Move point to Nth previous image."
  (interactive "p")
  (unless ement-room (user-error "Not in ement room"))
  (dotimes (_ (abs n)) (+ement--find-image (when (> n 0) 'previous))))
alphapapa commented 10 months ago

Thanks. This could be useful. Possibly a better overall solution would be to offer the ability to list media events in a room in a separate buffer, similarly to how Element has a tab for that.

progfolio commented 10 months ago

Adam Porter @.***> writes:

Thanks. This could be useful. Possibly a better overall solution would be to offer the ability to list media events in a room in a separate buffer, similarly to how Element has a tab for that.

Good idea!