zevlg / telega.el

GNU Emacs telegram client (unofficial)
https://zevlg.github.io/telega.el/
GNU General Public License v3.0
1.09k stars 85 forks source link

telega-chatbuf-filter-search with regexp #414

Closed welandx closed 1 year ago

welandx commented 1 year ago

Current Behavior

I found that the function telega-chatbuf-filter-search cannot search for Chinese words within the sentence. For example, msg list:

  1. "内容为主,搜索、推荐、引流"
  2. "推荐一些内容"

If I want to search "推荐", I can get the first sentence, but I cannot search for the second one.

Possible Solution

I try to match some words with telega-msg-match-p:

(defun my/match-at-point-msg ()
  (interactive)
  (let ((regex (read-string "Type: ")))
    (when (telega-msg-match-p (telega-msg-at) `(contains ,regex))
      (message "yes!"))))

But I don't know how to get as many messages as possible and display the matching messages just like filter. Is it possible to implement a telega-chatbuf-filter-search using regex or some other way to achieve better searching of Chinese characters? Sorry, I have limited knowledge of Emacs Lisp.

zevlg commented 1 year ago

Searching is done by Telegram server, not by telega.el and Telegram server does not support regexps as I know. Use https://bugs.telegram.org/ to report this searching issue

JFYI: You can search messages inplace, using C-c C-r binding in the chatbuf

welandx commented 1 year ago

Searching is done by Telegram server, not by telega.el and Telegram server does not support regexps as I know. Use https://bugs.telegram.org/ to report this searching issue

Thank you for your suggestion. I found this: https://bugs.telegram.org/c/724. So I'm looking for a temporary alternative method.

JFYI: You can search messages inplace, using C-c C-r binding in the chatbuf

Is there any difference with this search? I found that it behaves the same as telega-chatbuf-filter-search.

My current idea is to use telega-button-backward and apply the logic similar to my/match-at-point-msg to each message. Store each matched message, then telega-msg-goto. Is this approach feasible? If you could provide some advice, I would greatly appreciate it.

zevlg commented 1 year ago

Searching is done by Telegram server, not by telega.el and Telegram server does not support regexps as I know. Use https://bugs.telegram.org/ to report this searching issue

Thank you for your suggestion. I found this: https://bugs.telegram.org/c/724. So I'm looking for a temporary alternative method.

JFYI: You can search messages inplace, using C-c C-r binding in the chatbuf

Is there any difference with this search? I found that it behaves the same as telega-chatbuf-filter-search.

telega-chatbuf-filter-search filters messages, i.e. shows only messages matching search query. Inplace searching searches for the query without filtering messages, so you can see context surrounding the message matching your query.

My current idea is to use telega-button-backward and apply the logic similar to my/match-at-point-msg to each message. Store each matched message, then telega-msg-goto. Is this approach feasible? If you could provide some advice, I would greatly appreciate it.

This could be done, however, in a general way this will be very slow and will give inconsistent results.

What you can do is to match newly incoming messages for some keyword of your interest and then display messages list. Something similar to custom value for telega-notifications-msg-temex and M-x telega-notifications-history RET command to display messages matching telega-notifications-msg-temex

welandx commented 1 year ago

telega-chatbuf-filter-search filters messages, i.e. shows only messages matching search query. Inplace searching searches for the query without filtering messages, so you can see context surrounding the message matching your query.

I see.

This could be done, however, in a general way this will be very slow and will give inconsistent results.

Thanks, but this feature is quite important to me personally, so I will implement it temporarily to solve the problem.

What you can do is to match newly incoming messages for some keyword of your interest and then display messages list. Something similar to custom value for telega-notifications-msg-temex and M-x telega-notifications-history RET command to display messages matching telega-notifications-msg-temex

This is also helpful.