Skip to content

Commit

Permalink
Fixes and enhancements
Browse files Browse the repository at this point in the history
- [upd] README.md update TDLib version

- [enh] For documentation, extract TDLib version and branch from
  etc/Dockerfile, fixes #501

- [fix] Handle `avatar' palette context ignorance while reandering
  telega cat eyers, fixes

- [enh] Use sender of message at point as default member for
  `telega-completing-read-chat-member', fixes #504

Version -> 0.8.391
  • Loading branch information
zevlg committed Nov 9, 2024
1 parent e24b789 commit 0368bae
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![CI test](https://github.com/zevlg/telega.el/workflows/CI/badge.svg)](https://github.com/zevlg/telega.el/actions) [![DOCKER image build](https://github.com/zevlg/telega.el/workflows/DOCKER/badge.svg)](https://github.com/zevlg/telega.el/actions) [![Telegram chat](https://img.shields.io/badge/chat-%40emacs__telega-%2335ADE1?logo=telegram)](https://t.me/emacs_telega) [![TDLib](https://img.shields.io/badge/TDLib-v1.8.29-%2335ADE1)](https://github.com/tdlib/td) [![MELPA](https://melpa.org/packages/telega-badge.svg)](https://melpa.org/#/telega) [![MELPA Stable](http://stable.melpa.org/packages/telega-badge.svg)](http://stable.melpa.org/#/telega) [![GNU Guix](https://repology.org/badge/version-for-repo/gnuguix/emacs:telega.svg?header=GNU%20Guix)](https://packages.guix.gnu.org/packages/emacs-telega/) [![Open Collective](https://img.shields.io/opencollective/backers/telega?logo=opencollective)](https://opencollective.com/telega)
[![CI test](https://github.com/zevlg/telega.el/workflows/CI/badge.svg)](https://github.com/zevlg/telega.el/actions) [![DOCKER image build](https://github.com/zevlg/telega.el/workflows/DOCKER/badge.svg)](https://github.com/zevlg/telega.el/actions) [![Telegram chat](https://img.shields.io/badge/chat-%40emacs__telega-%2335ADE1?logo=telegram)](https://t.me/emacs_telega) [![TDLib](https://img.shields.io/badge/TDLib-v1.8.39_(056963e48)-%2335ADE1)](https://github.com/tdlib/td) [![MELPA](https://melpa.org/packages/telega-badge.svg)](https://melpa.org/#/telega) [![MELPA Stable](http://stable.melpa.org/packages/telega-badge.svg)](http://stable.melpa.org/#/telega) [![GNU Guix](https://repology.org/badge/version-for-repo/gnuguix/emacs:telega.svg?header=GNU%20Guix)](https://packages.guix.gnu.org/packages/emacs-telega/) [![Open Collective](https://img.shields.io/opencollective/backers/telega?logo=opencollective)](https://opencollective.com/telega)

[![Backers](https://opencollective.com/telega/backers.svg?avatarHeight=32&width=600)](https://opencollective.com/telega)

Expand Down
26 changes: 13 additions & 13 deletions docs/index.html

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

2 changes: 1 addition & 1 deletion docs/telega-ellit.org
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Thanks to [[https://t.me/ritsch_master][=@ritsch_master=]]

[[https://core.telegram.org/tdlib][TDLib]] is the library for building Telegram clients. It requires a
large amount of memory to be built. Make sure you are using TDLib
version greater or equal to {{{eval(telega-tdlib-min-version, t)}}}.
version equal to {{{eval((telega-dockrefile-tdlib-version), t)}}}.

On MacOS you can install a pre-built =TDLib= package using homebrew
from [[https://brew.sh][brew.sh]]. Just run:
Expand Down
4 changes: 2 additions & 2 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.390)
#+title: Telega Manual (v0.8.391)
#+author: Zajcev Evgeny
#+startup: showall

Expand Down Expand Up @@ -244,7 +244,7 @@ Thanks to [[https://t.me/ritsch_master][=@ritsch_master=]]

[[https://core.telegram.org/tdlib][TDLib]] is the library for building Telegram clients. It requires a
large amount of memory to be built. Make sure you are using TDLib
version greater or equal to 1.8.39.
version equal to v1.8.39-056963e48.

On MacOS you can install a pre-built =TDLib= package using homebrew
from [[https://brew.sh][brew.sh]]. Just run:
Expand Down
12 changes: 9 additions & 3 deletions telega-chat.el
Original file line number Diff line number Diff line change
Expand Up @@ -6745,7 +6745,9 @@ by some chat member, member name is queried."
(interactive "sSearch Query: \nP")
(let ((by-sender (when by-sender-p
(telega-completing-read-chat-member
"Sent by: " telega-chatbuf--chat))))
"Sent by: " telega-chatbuf--chat
(when-let ((msg (telega-msg-at (point))))
(telega-msg-sender msg))))))
(telega-chatbuf-filter
(list :title (format "search \"%s\"" query)
:tdlib-msg-filter '(:@type "searchMessagesFilterEmpty")
Expand Down Expand Up @@ -6960,7 +6962,9 @@ bindings."
(interactive "sTelega-search (backward): \nP")
(let ((by-sender (when by-sender-p
(telega-completing-read-chat-member
"Sent by: " telega-chatbuf--chat))))
"Sent by: " telega-chatbuf--chat
(when-let ((msg (telega-msg-at (point))))
(telega-msg-sender msg))))))
(telega-chatbuf-inplace-search
(list :title (format "query \"%s\"" query)
:query query
Expand Down Expand Up @@ -6990,7 +6994,9 @@ containing QUERY sent by specified sender."
(defun telega-chatbuf-inplace-search-by-sender (sender &optional forward-p)
"Search inplace by SENDER."
(interactive (list (telega-completing-read-chat-member
"Sent by: " telega-chatbuf--chat)))
"Sent by: " telega-chatbuf--chat
(when-let ((msg (telega-msg-at (point))))
(telega-msg-sender msg)))))
(telega-chatbuf-inplace-search
(list :title (telega-ins--as-string
(telega-ins "sent by ")
Expand Down
7 changes: 0 additions & 7 deletions telega-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,6 @@ cell of endings for the button with LABEL."
:value-type (repeat (list string)))
:group 'telega)

(defcustom telega-palette-light-saturation-alist
'((:background (light 0.8 0.1) (dark 0.2 0.1))
(:outline (light 0.9 0.1) (dark 0.1 0.1)))
"Ligthness and saturation specification for."
:type 'alist
)

(defcustom telega-palette-context-ignore-list '(msg-header)
"List of `telega-palette-context' values to ignore."
:type '(list symbol)
Expand Down
5 changes: 3 additions & 2 deletions telega-modes.el
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,9 @@ Return patron info, or nil if SENDER is not a telega patron."
(telega-palette-context 'avatar)
(svg-color
(telega-color-name-as-hex-2digits
(telega-palette-attr
(telega-msg-sender-palette sender) :foreground))))
(or (telega-palette-attr
(telega-msg-sender-palette sender) :foreground)
(face-foreground 'default)))))
(telega-svg-telega-logo
svg ear-w
:transform (format "scale(-1, 1) translate(-%f, %f)"
Expand Down
55 changes: 38 additions & 17 deletions telega-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -1759,18 +1759,21 @@ SORT-CRITERIA is a chat sort criteria to apply. (NOT YET)"
"Results from last `telega--searchChatMembers'.
To be used `telega-completing-read-chat-member' to get user.")

(defun telega-completing--chat-members-collection (chat prefix &rest _ignored)
"Function used for programmed completing CHAT members.
Works only with `fido-mode' completion."
(when prefix
(setq telega-completing--chat-member-alist
(mapcar (lambda (user)
(cons (propertize
(telega-msg-sender-title-for-completion user)
:user user)
user))
(telega--searchChatMembers chat prefix)))
(mapcar #'car telega-completing--chat-member-alist)))
(cl-defun telega-completing--chat-member-choices (chat &key (prefix "")
default-member)
"Return completions list of CHAT members."
(declare (indent 1))
(setq telega-completing--chat-member-alist
(mapcar (lambda (sender)
(cons (propertize
(telega-msg-sender-title-for-completion sender)
:sender sender)
sender))
(let ((members (telega--searchChatMembers chat prefix)))
(if default-member
(cons default-member (delq default-member members))
members))))
(mapcar #'car telega-completing--chat-member-alist))

(defun telega-completing-read (prompt collection &optional predicate
require-match initial-input hist def
Expand Down Expand Up @@ -1804,8 +1807,9 @@ Works only with `fido-mode' completion."
(local-set-key (kbd "C-c C-e") #'telega-custom-emoji-choose))
(apply #'read-string prompt args))))

(defun telega-completing-read-chat-member (prompt chat)
(defun telega-completing-read-chat-member (prompt chat &optional default-member)
"Interactively read member of CHAT.
DEFAULT-MEMBER specifies default member to complete.
Return a user."
(let* ((telega-completing--chat-member-alist nil)
(name
Expand All @@ -1814,13 +1818,19 @@ Return a user."
;; Works ok only in `fido-mode'
(completing-read
prompt
(apply-partially
#'telega-completing--chat-members-collection chat))
(lambda (prefix &rest _ignored)
(telega-completing--chat-member-choices chat
:prefix prefix
:default-member (when (or (not prefix)
(string-empty-p prefix))
default-member)))
nil 'require-match)

;; Static completion, can complete only 50 chat members
(telega-completing-read
prompt
(telega-completing--chat-members-collection chat "")
(telega-completing--chat-member-choices chat
:default-member default-member)
nil t))))
(cdr (assoc name telega-completing--chat-member-alist))))

Expand Down Expand Up @@ -2101,7 +2111,7 @@ Do not trap errors if `debug-on-error' is enabled."
(telega-debug "--------\n")

(telega-ins "---[telega bug]\n")
(telega-ins-fmt "PP-ERROR: (%S %S) ==>\n" pp-fun arg)
(telega-ins-fmt "PP-ERROR: %S ==>\n" pp-fun)
(telega-ins-fmt " %S\n" pp-err)
(telega-ins "------\n"))))))

Expand Down Expand Up @@ -3299,6 +3309,17 @@ Return nil if there is no tags for the SM-TOPIC-ID or new tag is choosen."
(line-pixel-height))
(line-pixel-height)))

(defun telega-dockrefile-tdlib-version (&optional dockerfile)
"Extract TDLib version from DOCKERFILE."
(with-temp-buffer
(insert-file-contents (or dockerfile (telega-etc-file "Dockerfile")))
(goto-char (point-min))
(let ((version (when (re-search-forward "^ARG tdlib_version=\\(.*\\)$")
(match-string 1)))
(branch (when (re-search-forward "^ARG tdlib_branch=\\(.*\\)$")
(match-string 1))))
(concat version "-" branch))))


;;; Transients
(transient-define-suffix telega-saved-messages-tag-filter ()
Expand Down
4 changes: 2 additions & 2 deletions telega.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
;; Keywords: comm
;; Package-Requires: ((emacs "27.1") (visual-fill-column "1.9") (transient "0.3.0"))
;; URL: https://github.com/zevlg/telega.el
;; Version: 0.8.390
(defconst telega-version "0.8.390")
;; Version: 0.8.391
(defconst telega-version "0.8.391")
(defconst telega-server-min-version "0.7.7")
(defconst telega-tdlib-min-version "1.8.39")
(defconst telega-tdlib-max-version nil)
Expand Down

0 comments on commit 0368bae

Please sign in to comment.