From 4372c24df308a9495ba17378b7e8e003cf3576e8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 30 Oct 2024 14:57:51 +0100 Subject: byte-compile --- lisp/mastodon-toot.el | 2 +- lisp/mastodon-transient.el | 2 +- lisp/mastodon-widget.el | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 4e116fa..82ebc90 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1429,7 +1429,7 @@ MAX is the maximum number set by their instance." "Prompt for new poll options and return as a list." (interactive) (if mastodon-toot-poll-use-transient - (mastodon-create-poll) + (call-interactively #'mastodon-create-poll) (mastodon-toot--read-poll))) (defun mastodon-toot--read-poll () diff --git a/lisp/mastodon-transient.el b/lisp/mastodon-transient.el index bbfbfc9..c96e1d5 100644 --- a/lisp/mastodon-transient.el +++ b/lisp/mastodon-transient.el @@ -332,7 +332,7 @@ Do not add more than the server's maximum setting." (not (y-or-n-p "Need more than one option. Proceed? "))) (and (> opts-count (mastodon-transient-max-poll-opts)) (not (y-or-n-p "More options than server max. Proceed? ")))) - (mastodon-create-poll) + (call-interactively #'mastodon-create-poll) ;; if we are called with no poll data, do not set: (unless (not vals) (setq tp-transient-settings diff --git a/lisp/mastodon-widget.el b/lisp/mastodon-widget.el index a326800..a576672 100644 --- a/lisp/mastodon-widget.el +++ b/lisp/mastodon-widget.el @@ -45,7 +45,8 @@ Note that such modes will need to require wid-edit.") (defface mastodon-widget-face '((t :inherit font-lock-function-name-face :weight bold :underline t)) - "Face for widgets.") + "Face for widgets." + :group 'mastodon) (defun mastodon-widget--return-item-widgets (list) "Return a list of item widgets for each item, a string, in LIST." -- cgit v1.2.3 From 1e18934c705514dc3aad6170a50cd5875dab86bf Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 31 Oct 2024 08:36:05 +0100 Subject: bump tp version, bump version --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 119a045..ea4a4e2 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -6,8 +6,8 @@ ;; Author: Johnson Denen ;; Marty Hiatt ;; Maintainer: Marty Hiatt -;; Version: 1.1.3 -;; Package-Requires: ((emacs "28.1") (request "0.3.0") (persist "0.4") (tp "0.5")) +;; Version: 1.1.4 +;; Package-Requires: ((emacs "28.1") (request "0.3.0") (persist "0.4") (tp "0.6")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From 2bb6ad95f777f5f206ad203482e74f6eec0a64c1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 31 Oct 2024 10:20:03 +0100 Subject: toot.el cask build cleanups --- lisp/mastodon-toot.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 82ebc90..fa5a955 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -36,14 +36,18 @@ (require 'emojify nil :noerror) (declare-function emojify-insert-emoji "emojify") (declare-function emojify-set-emoji-data "emojify") +(declare-function emojify-mode "emojify") +(declare-function emojify-emojis-each "emojify") (defvar emojify-emojis-dir) (defvar emojify-user-emojis) +(defvar emojify-emoji-styles) (require 'cl-lib) (require 'persist) (require 'mastodon-iso) (require 'facemenu) (require 'text-property-search) +(require 'ht) (eval-when-compile (require 'mastodon-tl)) -- cgit v1.2.3 From babb3a1adf7dbc2c458c65d841e758aafaabd298 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 1 Nov 2024 15:05:15 +0100 Subject: fold-toot - respect CW state --- lisp/mastodon-tl.el | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 5178a25..b655bec 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1772,15 +1772,18 @@ title, and context." (mastodon-tl--filter-by-context context filters-no-context))) (defun mastodon-tl--toot (toot &optional detailed-p thread domain - unfolded no-byline) + unfolded no-byline no-cw) "Format TOOT and insert it into the buffer. DETAILED-P means display more detailed info. For now this just means displaying toot client. THREAD means the status will be displayed in a thread view. When DOMAIN, force inclusion of user's domain in their handle. UNFOLDED is a boolean meaning whether to unfold or fold item if foldable. -NO-BYLINE means just insert toot body, used for folding." - (let* ((filtered (mastodon-tl--field 'filtered toot)) +NO-BYLINE means just insert toot body, used for folding. +NO-CW means treat content warnings as unfolded." + (let* ((mastodon-tl--expand-content-warnings + (or no-cw mastodon-tl--expand-content-warnings)) + (filtered (mastodon-tl--field 'filtered toot)) (filters (when filtered (mastodon-tl--current-filters filtered))) (spoiler-or-content (if-let ((match (assoc "warn" filters))) @@ -1826,9 +1829,14 @@ When DOMAIN, force inclusion of user's domain in their handle." (defun mastodon-tl--fold-body (body) "Fold toot BODY if it is very long. Folding decided by `mastodon-tl--fold-toots-at-length'." - (let* ((heading (mastodon-search--format-heading - (mastodon-tl--make-link "READ MORE" 'read-more) - nil :no-newline)) + (let* ((invis (get-text-property (1- (length body)) 'invisible body)) + (spoiler (get-text-property (1- (length body)) + 'mastodon-content-warning-body body)) + (heading (propertize (mastodon-search--format-heading + (mastodon-tl--make-link "READ MORE" 'read-more) + nil :no-newline) + 'mastodon-content-warning-body spoiler + 'invisible invis)) (display (concat (substring body 0 mastodon-tl--fold-toots-at-length) heading))) @@ -1848,6 +1856,10 @@ FOLD means to fold it instead." (let* ((inhibit-read-only t) (body-range (mastodon-tl--find-property-range 'toot-body (point) :backward)) + (cw-range (mastodon-tl--find-property-range + 'mastodon-content-warning-body + (point) :backward)) + (cw-invis (get-text-property (car cw-range) 'invisible)) (toot (mastodon-tl--property 'item-json :no-move)) ;; `replace-region-contents' is much too slow, our hack from ;; fedi.el is much simpler and much faster: @@ -1863,7 +1875,8 @@ FOLD means to fold it instead." (delete-region beg end) (delete-char 1) ;; prevent newlines accumulating ;; insert toot body: - (mastodon-tl--toot toot nil nil nil (not fold) :no-byline) + (mastodon-tl--toot toot nil nil nil (not fold) :no-byline + (unless cw-invis :no-cw)) ;; respect CW state ;; set toot-folded prop on entire toot (not just body): (let ((toot-range ;; post fold action range: (mastodon-tl--find-property-range 'item-json -- cgit v1.2.3 From 1ba949586efbbcd50be9f341cfc3f8b9c591fb3b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 1 Nov 2024 15:05:44 +0100 Subject: tl: improve ctrl flow in --spoiler + --toot. FIX #579 --- lisp/mastodon-tl.el | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b655bec..595f0cf 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1275,25 +1275,22 @@ FILTER is a string to use as a filter warning spoiler instead." (cw (mastodon-tl--set-face message 'mastodon-cw-face))) (concat cw - (propertize (mastodon-tl--content toot) - 'invisible - (if filter - t - (let ((cust mastodon-tl--expand-content-warnings)) - (cond ((eq t cust) - nil) - ((eq nil cust) - t) - ((eq 'server cust) - (unless (eq t - ;; If something goes wrong reading prefs, - ;; just return nil so CWs show by default. - (condition-case nil - (mastodon-profile--get-preferences-pref - 'reading:expand:spoilers) - (error nil))) - t))))) - 'mastodon-content-warning-body t)))) + (propertize + (mastodon-tl--content toot) + 'invisible + (or filter ;; filters = invis + (let ((cust mastodon-tl--expand-content-warnings)) + (if (not (eq 'server cust)) + (not cust) ;; opp to setting + ;; respect server setting: + (not + ;; If something goes wrong reading prefs, + ;; just return nil so CWs show by default. + (condition-case nil + (mastodon-profile--get-preferences-pref + 'reading:expand:spoilers) + (error nil)))))) + 'mastodon-content-warning-body t)))) ;;; MEDIA @@ -1793,8 +1790,7 @@ NO-CW means treat content warnings as unfolded." (mastodon-tl--content toot))))) ;; If any filters are "hide", then we hide, ;; even though item may also have a "warn" filter: - (if (and filtered (assoc "hide" filters)) - nil ;; no insert + (unless (and filtered (assoc "hide" filters)) ;; no insert (mastodon-tl--insert-status toot (mastodon-tl--clean-tabs-and-nl spoiler-or-content) -- cgit v1.2.3 From b05de5f9075813d9e56317fd011dcd809da905bc Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 1 Nov 2024 15:48:32 +0100 Subject: some ifs become whens --- lisp/mastodon-tl.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 595f0cf..2db7f34 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -3037,7 +3037,7 @@ MAX-ID is the pagination parameter, a string." (alist-get 'hashtags response)) ((string= "accounts" type) (alist-get 'accounts response)))))) - (headers (if headers (cdr response) nil)) + (headers (when headers (cdr response))) (link-header (mastodon-tl--get-link-header-from-response headers))) (goto-char (point-max)) @@ -3309,7 +3309,7 @@ JSON and http headers, without it just the JSON." ((eq (caar json) 'error) (user-error "Looks like the server bugged out: \"%s\"" (cdar json))) (t - (let* ((headers (if headers (cdr response) nil)) + (let* ((headers (when headers (cdr response))) (link-header (mastodon-tl--get-link-header-from-response headers))) (with-mastodon-buffer buffer #'mastodon-mode nil -- cgit v1.2.3