diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-notifications.el | 39 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 16 | ||||
-rw-r--r-- | lisp/mastodon.el | 7 |
3 files changed, 45 insertions, 17 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 2c61cd4..f7276d6 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -171,6 +171,18 @@ Status notifications are given when "Format for an `edit' NOTE." (mastodon-notifications--format-note note 'edit)) +(defun mastodon-notifications--comment-note-text (str) + "Add comment face to all text in STR with `shr-text' face only." + (with-temp-buffer + (switch-to-buffer (current-buffer)) + (insert str) + (goto-char (point-min)) + (while (setq prop (text-property-search-forward 'face 'shr-text t)) + (add-text-properties (prop-match-beginning prop) + (prop-match-end prop) + '(face (font-lock-comment-face shr-text)))) + (buffer-string))) + (defun mastodon-notifications--format-note (note type) "Format for a NOTE of TYPE." (let ((id (alist-get 'id note)) @@ -191,17 +203,22 @@ Status notifications are given when (t status)) ;; body - (if (or (equal type 'follow) - (equal type 'follow-request)) - (propertize (if (equal type 'follow) - "Congratulations, you have a new follower!" - (format "You have a follow request from... %s" - follower)) - 'face 'default) - (mastodon-tl--clean-tabs-and-nl - (if (mastodon-tl--has-spoiler status) - (mastodon-tl--spoiler status) - (mastodon-tl--content status)))) + (let ((body (mastodon-tl--clean-tabs-and-nl + (if (mastodon-tl--has-spoiler status) + (mastodon-tl--spoiler status) + (mastodon-tl--content status))))) + (cond ((or (eq type 'follow) + (eq type 'follow-request)) + (propertize (if (equal type 'follow) + "Congratulations, you have a new follower!" + (format "You have a follow request from... %s" + follower)) + 'face 'default)) + ((or (eq type 'favourite) + (eq type 'boost)) + (mastodon-notifications--comment-note-text + body)) + (t body))) ;; author-byline (if (or (equal type 'follow) (equal type 'follow-request) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 366a000..82ad03b 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -155,7 +155,8 @@ If the original toot visibility is different we use the more restricted one." :type 'boolean) (defcustom mastodon-toot--emojify-in-compose-buffer t - "Whether to enable `emojify' in the compose buffer." + "Whether to enable `emojify-mode' in the compose buffer. +We only attempt to enable it if its bound." :type 'boolean) (defcustom mastodon-toot--proportional-fonts-compose nil @@ -1035,8 +1036,10 @@ Federated user: `username@host.co`." (defun mastodon-toot--fetch-emojify-candidates () "Get the candidates to be used for emojis completion. The candidates are calculated according to currently active -`emojify-emoji-styles'. Hacked off `emojify--get-completing-read-candidates'." - (let ((styles (mapcar #'symbol-name emojify-emoji-styles))) +`emojify-emoji-styles'. Hacked off +`emojify--get-completing-read-candidates'." + (let ((styles ;'("ascii" "unicode" "github") + (mapcar #'symbol-name emojify-emoji-styles))) (let ((emojis '())) (emojify-emojis-each (lambda (key value) (when (seq-position styles (ht-get value "style")) @@ -1061,7 +1064,8 @@ TYPE is the candidate type, it may be :tags, :handles, or :emoji." collect (cons (concat "#" (car tag)) (cdr tag))))) ((eq type :emoji) - (mastodon-toot--fetch-emojify-candidates)) + (when (bound-and-true-p emojify-mode) + (mastodon-toot--fetch-emojify-candidates))) (t (mastodon-search--search-accounts-query (buffer-substring-no-properties start end)))))) @@ -1902,7 +1906,9 @@ EDIT means we are editing an existing toot, not composing a new one." (setq mastodon-toot-previous-window-config previous-window-config) (when mastodon-toot--proportional-fonts-compose (facemenu-set-face 'variable-pitch)) - (when mastodon-toot--emojify-in-compose-buffer + (when (and mastodon-toot--emojify-in-compose-buffer + ;; emojify loaded but poss not enabled in our buffer: + (boundp 'emojify-mode)) (emojify-mode)) (when (and initial-text (not reply-json)) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 7a04c87..4928bf1 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -463,7 +463,12 @@ Calls `mastodon-tl--get-buffer-type', which see." (mastodon-toot--enable-custom-emoji))) (mastodon-profile--fetch-server-account-settings) (when mastodon-tl--highlight-current-toot - (cursor-face-highlight-mode))) ; 29.1 + (cursor-face-highlight-mode)) ; 29.1 + ;; make `thing-at-point' functions work: + (setq-local thing-at-point-provider-alist + (append thing-at-point-provider-alist + '((url . eww--url-at-point))))) + ;;;###autoload (add-hook 'mastodon-mode-hook #'mastodon-mode-hook-fun) |