diff --git a/telega-chat.el b/telega-chat.el index 5a25420..2c24cd7 100644 --- a/telega-chat.el +++ b/telega-chat.el @@ -2407,7 +2407,7 @@ Global chat bindings: ;; Enable filling by default to resemble old style telega formatting ;; We give a little bit extra space for filling column ot accomodate ;; inaccuracies in message header width calculation - (setq visual-fill-column-extra-text-width '(0 . 2)) + (setq visual-fill-column-extra-text-width '(0 . 1)) (visual-fill-column-mode 1) (cursor-sensor-mode 1) diff --git a/telega-core.el b/telega-core.el index 0d6c333..e9f512a 100644 --- a/telega-core.el +++ b/telega-core.el @@ -125,6 +125,9 @@ ("RUB" . "₽")) "Alist of currency symbols.") +(defvar telega--column-offset 0 + "Additional offset for the `telega-currency-column'.") + (defconst telega-symbol-nbsp "\u00a0" "Non-breakable space.") @@ -1734,7 +1737,6 @@ Return what BODY returns." (defmacro telega-ins--line-wrap-prefix (prefix &rest body) "Execute BODY adding `line-prefix' and `wrap-prefix' properties. -PREFIX evaluates *after* BODY. `line-prefix' and `wrap-prefix' are contatenated on subsequent calls to `telega-ins--line-wrap-prefix'." (declare (indent 1)) @@ -1743,14 +1745,15 @@ PREFIX evaluates *after* BODY. (start-sym (gensym "start")) (region-sym (gensym "region"))) `(let* ((,start-sym (point)) - ,lwprefix-sym ,lwprefix-props-sym ,region-sym) + (,lwprefix-sym ,prefix) + (,lwprefix-props-sym (list :telega-lwprefix ,lwprefix-sym + 'line-prefix ,lwprefix-sym + 'wrap-prefix ,lwprefix-sym)) + (telega--column-offset (+ telega--column-offset + (string-width ,lwprefix-sym))) + ,region-sym) (prog1 (progn ,@body) - (setq ,lwprefix-sym ,prefix - ,lwprefix-props-sym (list :telega-lwprefix ,lwprefix-sym - 'line-prefix ,lwprefix-sym - 'wrap-prefix ,lwprefix-sym)) - (while (setq ,region-sym (telega--region-by-text-prop ,start-sym 'line-prefix (point))) (add-text-properties ,start-sym (car ,region-sym) diff --git a/telega-customize.el b/telega-customize.el index cc78682..f0879da 100644 --- a/telega-customize.el +++ b/telega-customize.el @@ -2222,10 +2222,9 @@ If nil, then user's online status is not displayed." (vector #b11111111) nil nil '(top periodic))) (defcustom telega-symbol-mark - (if (fboundp 'define-fringe-bitmap) - (propertize "*" 'display '(left-fringe telega-mark error)) - (propertize "*" 'face 'error)) + (propertize " " 'face 'custom-invalid) "*Symbol used to denote marked messages/chats." + :package-version '(telega . "0.8.213") :type 'string :group 'telega-symbol) @@ -2261,12 +2260,9 @@ If nil, then user's online status is not displayed." ))) (defcustom telega-symbol-mention-mark - (if (fboundp 'define-fringe-bitmap) - (propertize "\u200B" 'display - '(left-fringe telega-mention telega-mention-count)) - (propertize "\u200B" 'face 'telega-mention-count)) + (propertize "@" 'face 'telega-mention-count) "*Symbol used to denote massages which contains unread mention." - :package-version '(telega . "0.6.30") + :package-version '(telega . "0.8.213") :type 'string :group 'telega-symbol) diff --git a/telega-ins.el b/telega-ins.el index 937e052..711578d 100644 --- a/telega-ins.el +++ b/telega-ins.el @@ -2661,7 +2661,7 @@ ADDON-HEADER-INSERTER is passed directly to `telega-ins--message-header'." ;; inside `telega--entity-to-properties' (telega-msg-contains-unread-mention (plist-get msg :contains_unread_mention)) - ccol) + content-prefix) (if (and no-header (zerop (plist-get msg :edit_date)) (zerop (plist-get msg :via_bot_user_id))) @@ -2681,16 +2681,29 @@ ADDON-HEADER-INSERTER is passed directly to `telega-ins--message-header'." (telega-ins--image avatar 1 :no-display-if (not telega-chat-show-avatars)))) - (setq ccol (telega-current-column)) + ;; NOTE: we use `current-column' because line/wrap prefix could + ;; be already in use by marked message for example + (setq content-prefix (make-string (current-column) ?\s)) (telega-ins--fwd-info-inline fwd-info) ;; NOTE: Three lines avatars in "Replies" chat (when msg-for-replies-p (telega-ins--image avatar 2 :no-display-if (not telega-chat-show-avatars))) - (telega-ins--line-wrap-prefix (make-string ccol ?\s) - (telega-ins--msg-reply-inline msg) - + ;; NOTE: `line-prefix' applies only if inserting at the + ;; beginning of the line, inline reply can be inserted in two + ;; different ways: + ;; 1. Following the avatar (no fwd info) + ;; 2. At the beginning of the line + ;; + ;; We need `telega-current-column' to return correct values in + ;; both cases + (if (bolp) + (telega-ins--line-wrap-prefix content-prefix + (telega-ins--msg-reply-inline msg)) + (telega-ins--msg-reply-inline msg)) + + (telega-ins--line-wrap-prefix content-prefix (telega-ins--content msg) (telega-ins-prefix "\n" @@ -2735,15 +2748,14 @@ ADDON-HEADER-INSERTER is passed directly to `telega-ins--message-header'." "Inserter for the message MSG. Pass all ARGS directly to `telega-ins--message0'." (declare (indent 1)) - (if (telega-msg-marked-p msg) - (telega-ins--line-wrap-prefix telega-symbol-mark - (apply #'telega-ins--message0 msg args)) - - (when (plist-get msg :contains_unread_mention) - (telega-ins telega-symbol-mention-mark)) - (when (telega-msg-match-p msg 'unread-reactions) - (telega-ins telega-symbol-reaction-mark)) - (apply #'telega-ins--message0 msg args))) + (telega-ins--line-wrap-prefix + (concat (when (telega-msg-marked-p msg) + telega-symbol-mark) + (when (plist-get msg :contains_unread_mention) + telega-symbol-mention-mark)) + (when (telega-msg-match-p msg 'unread-reactions) + (telega-ins telega-symbol-reaction-mark)) + (apply #'telega-ins--message0 msg args))) (defun telega-ins--message-no-header (msg) "Insert message MSG without header." diff --git a/telega-util.el b/telega-util.el index 81aba83..27bee91 100644 --- a/telega-util.el +++ b/telega-util.el @@ -206,6 +206,7 @@ Also take into account `:align-to' display property, used by (string-width (buffer-substring dpoint spoint))))))) (+ (or ccolumn (current-column)) + telega--column-offset (or (when-let ((lwprefix (or (get-text-property bol-point 'line-prefix) (get-text-property bol-point 'wrap-prefix)))) (string-width lwprefix)) @@ -1173,16 +1174,18 @@ Return nil if STR does not specify an org mode link." "Split TEXT by `:tl-entity-type'. Return list of list where first element is markup function, second is substring and rest are additional arguments to markup function." - ;; NOTE: if markup is applied, then ignore all tl entity types - ;; except for custom emojis and mentions, so you can cut&paste text - ;; already having entity-type and apply new markup to it (let ((result nil) (tomarkup-ss nil)) (seq-doseq (ss (telega--split-by-text-prop text :tl-entity-type)) (let ((ent-type (get-text-property 0 :tl-entity-type ss))) - (if (and ent-type - (memq (telega--tl-type ent-type) - '(textEntityTypeCustomEmoji textEntityTypeMentionName))) + ;; NOTE: if markup is applied, then ignore all tl entity types + ;; except for custom emojis and mentions, so you can cut&paste + ;; text already having entity-type and apply new markup to it + (if (or (eq default-markup-func #'telega-markup-as-is-fmt) + (and ent-type + (memq (telega--tl-type ent-type) + '(textEntityTypeCustomEmoji + textEntityTypeMentionName)))) (progn (when tomarkup-ss (push (list default-markup-func tomarkup-ss) result) diff --git a/telega.el b/telega.el index ab69bbc..afd04b9 100644 --- a/telega.el +++ b/telega.el @@ -8,8 +8,8 @@ ;; Keywords: comm ;; Package-Requires: ((emacs "27.1") (visual-fill-column "1.9") (rainbow-identifiers "0.2.2")) ;; URL: https://github.com/zevlg/telega.el -;; Version: 0.8.212 -(defconst telega-version "0.8.212") +;; Version: 0.8.213 +(defconst telega-version "0.8.213") (defconst telega-server-min-version "0.7.7") (defconst telega-tdlib-min-version "1.8.21") (defconst telega-tdlib-max-version nil)