Skip to content

Commit

Permalink
M-g * to goto previous favorite message, not next
Browse files Browse the repository at this point in the history
So you can use series of `M-g *` commands to navigate across favorite
messages in the chatbuf
  • Loading branch information
zevlg committed Dec 15, 2024
1 parent 3f6f452 commit 80f5d49
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
31 changes: 16 additions & 15 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions docs/telega-ellit.org
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,9 @@ messages are labeled with:
To toggle message at point being favorite, press
{{{where-is(telega-msg-favorite-toggle,telega-msg-button-map)}}}.

To jump to next favorite message in the chat buffer press
{{{where-is(telega-chatbuf-next-favorite,telega-chat-mode-map)}}}.
To jump to a favorite message before message at point in the chat
buffer, press
{{{where-is(telega-chatbuf-prev-favorite,telega-chat-mode-map)}}}.

To view all favorite messages in all chats, enable "Favorite Messages"
Root View, by pressing
Expand Down
11 changes: 6 additions & 5 deletions docs/telega-manual.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#+options: timestamp:nil \n:t num:nil ellit-cid:t
#+title: Telega Manual (v0.8.391)
#+title: Telega Manual (v0.8.393)
#+author: Zajcev Evgeny
#+startup: showall

Expand Down Expand Up @@ -1912,8 +1912,8 @@ messages:
- @@html:<kbd>@@M-g x@@html:</kbd>@@ (~telega-chatbuf-goto-pop-message~) ::
Pop message from ~telega-chatbuf--messages-pop-ring~ and goto it.

- @@html:<kbd>@@M-g *@@html:</kbd>@@ (~telega-chatbuf-next-favorite~) ::
Goto next favorite message.
- @@html:<kbd>@@M-g *@@html:</kbd>@@ (~telega-chatbuf-prev-favorite~) ::
Goto previous favorite message.
See [[#favorite-messages][Favorite Messages]] for details.

- @@html:<kbd>@@M-g v@@html:</kbd>@@ (~telega-chatbuf-goto-video-chat~) ::
Expand Down Expand Up @@ -2620,8 +2620,9 @@ messages are labeled with:
To toggle message at point being favorite, press
@@html:<kbd>@@*@@html:</kbd>@@, @@html:<kbd>@@<down-mouse-3> <rm-favorite>@@html:</kbd>@@, @@html:<kbd>@@<down-mouse-3> <add-favorite>@@html:</kbd>@@ (~telega-msg-favorite-toggle~).

To jump to next favorite message in the chat buffer press
@@html:<kbd>@@M-g *@@html:</kbd>@@ (~telega-chatbuf-next-favorite~).
To jump to a favorite message before message at point in the chat
buffer, press
@@html:<kbd>@@M-g *@@html:</kbd>@@ (~telega-chatbuf-prev-favorite~).

To view all favorite messages in all chats, enable "Favorite Messages"
Root View, by pressing
Expand Down
17 changes: 9 additions & 8 deletions telega-chat.el
Original file line number Diff line number Diff line change
Expand Up @@ -1626,10 +1626,10 @@ new Chat buffers.")
;; {{{fundoc(telega-chatbuf-goto-pop-message, 2)}}}
(define-key map (kbd "x") 'telega-chatbuf-goto-pop-message)
;;; ellit-org: chatbuf-fastnav-bindings
;; - {{{where-is(telega-chatbuf-next-favorite,telega-chat-mode-map)}}} ::
;; {{{fundoc(telega-chatbuf-next-favorite, 2)}}}
;; - {{{where-is(telega-chatbuf-prev-favorite,telega-chat-mode-map)}}} ::
;; {{{fundoc(telega-chatbuf-prev-favorite, 2)}}}
;; See [[#favorite-messages][Favorite Messages]] for details.
(define-key map (kbd "*") 'telega-chatbuf-next-favorite)
(define-key map (kbd "*") 'telega-chatbuf-prev-favorite)
;;; ellit-org: chatbuf-fastnav-bindings
;; - {{{where-is(telega-chatbuf-goto-video-chat,telega-chat-mode-map)}}} ::
;; {{{fundoc(telega-chatbuf-goto-video-chat, 2)}}}
Expand Down Expand Up @@ -4970,18 +4970,19 @@ from message at point."
(cl-remove (plist-get chat :id) telega--favorite-messages
:test-not 'eq :key (telega--tl-prop :chat_id)))

(defun telega-chatbuf-next-favorite ()
"Goto next favorite message."
(defun telega-chatbuf-prev-favorite ()
"Goto previous favorite message."
(interactive)
(let* ((fav-ids
;; NOTE: Sort favorite messages ids by id decreasing order
;; NOTE: Sort favorite messages ids by id in decreasing order
(sort (mapcar (telega--tl-prop :id)
(telega-chat-favorite-messages telega-chatbuf--chat))
#'>))
(next-fav-id
(or (cl-find (or (plist-get (telega-msg-at (point)) :id) -1)
fav-ids :test #'<)
;; wrap to first one
fav-ids :test #'>)
;; wrap to the most recent favorite message in the
;; chatbuf
(car fav-ids))))
(unless next-fav-id
(user-error "No favorite messages in the chat"))
Expand Down

0 comments on commit 80f5d49

Please sign in to comment.