From 4a8a102b3b4f8483af5b688e7ea480ff6b8dc2ed Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Fri, 5 Jan 2024 22:09:27 +0100 Subject: Count characters directly from string --- lisp/mastodon-toot.el | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index f60f314..51990fd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1669,20 +1669,13 @@ REPLY-REGION is a string to be injected into the buffer." URLs always = 23, and domain names of handles are not counted. This is how mastodon does it. CW is the content warning, which contributes to the character count." - (with-temp-buffer - (switch-to-buffer (current-buffer)) - (insert toot-string) - (goto-char (point-min)) - ;; handle URLs - (while (search-forward-regexp mastodon-toot-url-regex nil t) - ; "\\w+://[^ \n]*" old regex - (replace-match "xxxxxxxxxxxxxxxxxxxxxxx")) ; 23 x's - ;; handle @handles - (goto-char (point-min)) - (while (search-forward-regexp mastodon-toot-handle-regex nil t) - (replace-match (match-string 2))) ; replace with handle only + (let* ((url-replacement (make-string 23 ?x)) + (count-str (replace-regexp-in-string ; handle @handles + mastodon-toot-handle-regex "\2" + (replace-regexp-in-string ; handle URLs + mastodon-toot-url-regex url-replacement toot-string)))) (+ (length cw) - (length (buffer-substring (point-min) (point-max)))))) + (length count-str)))) ;;; DRAFTS -- cgit v1.2.3 From 445d176b2a593a87afd3f6bca717feba639dfbdc Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sat, 6 Jan 2024 12:32:57 +0100 Subject: Replace 'switch-to-buffer' with 'display-buffer' or 'pop-to-buffer' This allows user to customize how buffers get shown using 'display-buffer-alist'. Also refactors mastodon-auth--show-notice. --- lisp/mastodon-auth.el | 31 +++++++++++++------------------ lisp/mastodon-http.el | 1 - lisp/mastodon-tl.el | 4 ++-- lisp/mastodon.el | 4 ++-- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 279377b..9f9d128 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -105,30 +105,25 @@ code. Copy this code and paste it in the minibuffer prompt." (defun mastodon-auth--show-notice (notice buffer-name &optional ask) "Display NOTICE to user. -NOTICE is displayed in vertical split occupying 50% of total +By default NOTICE is displayed in vertical split occupying 50% of total width. The buffer name of the buffer being displayed in the window is BUFFER-NAME. When optional argument ASK is given which should be a string, use ASK as the minibuffer prompt. Return whatever user types in response to the prompt. When ASK is absent return nil." - (let ((buffer (get-buffer-create buffer-name)) - (inhibit-read-only t) - ask-value window) - (set-buffer buffer) - (erase-buffer) - (insert notice) - (fill-region (point-min) (point-max)) - (read-only-mode) - (setq window (select-window - (split-window (frame-root-window) nil 'left) - t)) - (switch-to-buffer buffer t) - (when ask - (setq ask-value (read-string ask)) - (kill-buffer buffer) - (delete-window window)) - ask-value)) + (if ask + (read-string ask) + (let ((buffer (get-buffer-create buffer-name)) + (inhibit-read-only t)) + (set-buffer buffer) + (erase-buffer) + (insert notice) + (fill-region (point-min) (point-max)) + (read-only-mode) + (prog1 nil + (pop-to-buffer buffer '(display-buffer-in-side-window + (side . left) (window-width . 0.5))))))) (defun mastodon-auth--request-authorization-code () "Ask authorization code and return it." diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index a357672..541c92e 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -240,7 +240,6 @@ Callback to `mastodon-http--get-response-async', usually (defun mastodon-http--process-headers () "Return an alist of http response headers." - (switch-to-buffer (current-buffer)) (goto-char (point-min)) (let* ((head-str (buffer-substring-no-properties (point-min) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 561087e..d4f3d04 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -287,7 +287,7 @@ It is active where point is placed by `mastodon-tl--goto-next-item.'") "Evaluate BODY in a new or existing buffer called BUFFER. MODE-FUN is called to set the major mode. OTHER-WINDOW means call `switch-to-buffer-other-window' rather -than `switch-to-buffer'." +than `pop-to-buffer'." (declare (debug t) (indent 3)) `(with-current-buffer (get-buffer-create ,buffer) @@ -296,7 +296,7 @@ than `switch-to-buffer'." (funcall ,mode-fun) (if ,other-window (switch-to-buffer-other-window ,buffer) - (switch-to-buffer ,buffer)) + (pop-to-buffer ,buffer '(display-buffer-same-window))) ,@body))) (defmacro mastodon-tl--do-if-item (&rest body) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index bac4d67..c9c3b64 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -289,7 +289,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (buffer-list))))) ; catch any other masto buffer (mastodon-return-credential-account :force) (if buffer - (switch-to-buffer buffer) + (display-buffer buffer) (mastodon-tl--get-home-timeline) (message "Loading Mastodon account %s on %s..." (mastodon-auth--user-acct) @@ -335,7 +335,7 @@ from the server and load anew." "*mastodon-notifications*"))) (if (and (not force) (get-buffer buffer)) - (progn (switch-to-buffer buffer) + (progn (display-buffer buffer) (mastodon-tl--update)) (message "Loading your notifications...") (mastodon-tl--init-sync (or buffer-name "notifications") -- cgit v1.2.3 From 6a5152b6cbbf69c46720732a847ca47504bf213f Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sat, 6 Jan 2024 12:54:27 +0100 Subject: Use 'read-buffer' to choose a buffer --- lisp/mastodon.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index c9c3b64..2ab3bc3 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -433,10 +433,12 @@ Calls `mastodon-tl--get-buffer-type', which see." (defun mastodon-switch-to-buffer () "Switch to a live mastodon buffer." (interactive) - (let* ((bufs (mastodon-live-buffers)) - (buf-names (mapcar #'buffer-name bufs)) - (choice (completing-read "Switch to mastodon buffer: " - buf-names))) + (let ((choice (read-buffer + "Switch to mastodon buffer: " nil t + (lambda (cand) + (with-current-buffer + (if (stringp cand) cand (car cand)) + (mastodon-tl--get-buffer-type)))))) (switch-to-buffer choice))) (defun mastodon-mode-hook-fun () -- cgit v1.2.3 From 3d558edff6ae59e487b2bfe189ff4445841c5604 Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sun, 7 Jan 2024 09:17:55 +0100 Subject: Tweak display actions to better preserve defaults --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 2ab3bc3..20b252f 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -289,7 +289,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (buffer-list))))) ; catch any other masto buffer (mastodon-return-credential-account :force) (if buffer - (display-buffer buffer) + (display-buffer buffer '(display-buffer-same-window)) (mastodon-tl--get-home-timeline) (message "Loading Mastodon account %s on %s..." (mastodon-auth--user-acct) @@ -335,7 +335,7 @@ from the server and load anew." "*mastodon-notifications*"))) (if (and (not force) (get-buffer buffer)) - (progn (display-buffer buffer) + (progn (display-buffer buffer '(display-buffer-same-window)) (mastodon-tl--update)) (message "Loading your notifications...") (mastodon-tl--init-sync (or buffer-name "notifications") -- cgit v1.2.3 From 2e6bcd41a9bb5953b20758ada8cec2b4ff8e9b4f Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Mon, 8 Jan 2024 20:34:59 +0100 Subject: Use pop-to-buffer so that new window is selected --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 20b252f..93e802e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -289,7 +289,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (buffer-list))))) ; catch any other masto buffer (mastodon-return-credential-account :force) (if buffer - (display-buffer buffer '(display-buffer-same-window)) + (pop-to-buffer buffer '(display-buffer-same-window)) (mastodon-tl--get-home-timeline) (message "Loading Mastodon account %s on %s..." (mastodon-auth--user-acct) @@ -335,7 +335,7 @@ from the server and load anew." "*mastodon-notifications*"))) (if (and (not force) (get-buffer buffer)) - (progn (display-buffer buffer '(display-buffer-same-window)) + (progn (pop-to-buffer buffer '(display-buffer-same-window)) (mastodon-tl--update)) (message "Loading your notifications...") (mastodon-tl--init-sync (or buffer-name "notifications") -- cgit v1.2.3 From d749a78feb16362886d94209b1051adba107a146 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 1 Feb 2024 16:00:22 +0100 Subject: cmd index --- mastodon-index.org | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mastodon-index.org b/mastodon-index.org index d0918e3..90e7bf7 100644 --- a/mastodon-index.org +++ b/mastodon-index.org @@ -52,6 +52,7 @@ | | mastodon-async-mode | Async Mastodon. | | | mastodon-discover | Plug Mastodon functionality into `discover'. | | C-M-q | mastodon-kill-all-buffers | Kill any and all open mastodon buffers, hopefully. | +| Q | mastodon-kill-window | Quit window and delete helper. | | | mastodon-mode | Major mode for Mastodon, the federated microblogging network. | | | mastodon-notifications--clear-all | Clear all notifications. | | C-k | mastodon-notifications--clear-current | Dismiss the notification at point. | @@ -76,6 +77,7 @@ | | mastodon-profile--open-followers | Open a profile buffer showing the accounts following the current profile. | | | mastodon-profile--open-following | Open a profile buffer showing the accounts that current profile follows. | | | mastodon-profile--open-statuses-no-reblogs | Open a profile buffer showing statuses without reblogs. | +| | mastodon-profile--open-statuses-no-replies | Open a profile buffer showing statuses including replies. | | | mastodon-profile--remove-from-followers-at-point | Prompt for a user in the item at point and remove from followers. | | | mastodon-profile--remove-from-followers-list | Select a user from your followers and remove from followers. | | | mastodon-profile--remove-user-from-followers | Remove a user from your followers. | @@ -93,13 +95,14 @@ | | mastodon-profile-mode | Toggle mastodon profile minor mode. | | | mastodon-profile-update-mode | Minor mode to update Mastodon user profile. | | s | mastodon-search--query | Prompt for a search QUERY and return accounts, statuses, and hashtags. | +| | mastodon-search--query-accounts-followed | Run an accounts search QUERY, limited to your followers. | | | mastodon-search--query-cycle | Cycle through search types: accounts, hashtags, and statuses. | | | mastodon-search--trending-statuses | Display a list of statuses trending on your instance. | | | mastodon-search--trending-tags | Display a list of tags trending on your instance. | | | mastodon-search-mode | Toggle mastodon search minor mode. | -| | mastodon-serach--query-accounts-followed | Run an accounts search QUERY, limited to your followers. | | B | mastodon-tl--block-user | Query for USER-HANDLE from current status and block that user. | | | mastodon-tl--click-image-or-video | Click to play video with `mpv.el'. | +| | mastodon-tl--copy-image-caption | Copy the caption of the image at point. | | | mastodon-tl--disable-notify-user-posts | Query for USER-HANDLE and disable notifications when they post. | | m | mastodon-tl--dm-user | Query for USER-HANDLE from current status and compose a message to that user. | | | mastodon-tl--do-link-action | Do the action of the link at point. | @@ -110,7 +113,7 @@ | W | mastodon-tl--follow-user | Query for USER-HANDLE from current status and follow that user. | | | mastodon-tl--follow-user-disable-boosts | Prompt for a USER-HANDLE, and disable display of boosts in home timeline. | | | mastodon-tl--follow-user-enable-boosts | Prompt for a USER-HANDLE, and enable display of boosts in home timeline. | -| ' | mastodon-tl--followed-tags-timeline | Open a timeline of all your followed tags. | +| ' | mastodon-tl--followed-tags-timeline | Open a timeline of multiple tags. | | F | mastodon-tl--get-federated-timeline | Open federated timeline. | | H | mastodon-tl--get-home-timeline | Open home timeline. | | L | mastodon-tl--get-local-timeline | Open local timeline. | @@ -131,7 +134,7 @@ | SPC | mastodon-tl--scroll-up-command | Call `scroll-up-command', loading more toots if necessary. | | | mastodon-tl--single-toot | View toot at point in separate buffer. | | | mastodon-tl--some-followed-tags-timeline | Prompt for some tags, and open a timeline for them. | -| T | mastodon-tl--thread | Open thread buffer for toot at point or with ID. | +| RET, T | mastodon-tl--thread | Open thread buffer for toot at point or with ID. | | c | mastodon-tl--toggle-spoiler-text-in-toot | Toggle the visibility of the spoiler text in the current toot. | | C-S-b | mastodon-tl--unblock-user | Query for USER-HANDLE from list of blocked users and unblock that user. | | | mastodon-tl--unfollow-tag | Prompt for a followed tag, and unfollow it. | @@ -153,12 +156,14 @@ | | mastodon-toot--delete-draft-toot | Prompt for a draft toot and delete it. | | d | mastodon-toot--delete-toot | Delete user's toot at point synchronously. | | | mastodon-toot--download-custom-emoji | Download `mastodon-instance-url's custom emoji. | +| | mastodon-toot--edit-media-description | Prompt for an attachment, and update its description. | | e | mastodon-toot--edit-toot-at-point | Edit the user's toot at point. | | | mastodon-toot--enable-custom-emoji | Add `mastodon-instance-url's custom emoji to `emojify'. | | C-c C-e | mastodon-toot--insert-emoji | Prompt to insert an emoji. | | . | mastodon-toot--list-toot-boosters | List the boosters of toot at point. | | , | mastodon-toot--list-toot-favouriters | List the favouriters of toot at point. | | | mastodon-toot--open-draft-toot | Prompt for a draft and compose a toot with it. | +| o | mastodon-toot--open-toot-url | Open URL of toot at point. | | i | mastodon-toot--pin-toot-toggle | Pin or unpin user's toot at point. | | r | mastodon-toot--reply | Reply to toot at `point'. | | | mastodon-toot--save-draft | Save the current compose toot text as a draft. | @@ -176,6 +181,7 @@ | | mastodon-toot-mode | Minor mode to capture Mastodon toots. | | | mastodon-turn-on-discover | Turns on discover support | | | mastodon-url-lookup | If a URL resembles a mastodon link, try to load in `mastodon.el'. | +| | mastodon-url-lookup-force | Call `mastodon-url-lookup' without checking if URL is fedi-like. | | | mastodon-views--add-account-to-list | Prompt for a list and for an account, add account to list. | | | mastodon-views--add-account-to-list-at-point | Prompt for account and add to list at point. | | | mastodon-views--add-toot-account-at-point-to-list | Prompt for a list, and add the account of the toot at point to it. | -- cgit v1.2.3 From a01eec0d57ed64f8a83784cd48e44fc2961e0d64 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 7 Feb 2024 21:02:53 +0100 Subject: message appropriately for foll req --- lisp/mastodon-tl.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3d8e8dd..d462918 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2149,7 +2149,10 @@ ARGS is an alist of any parameters to send with the request." (mapconcat #'cdr args " "))) ((and (eq notify nil) (eq reblogs nil)) - (message "User %s (@%s) %sed!" name user-handle action)))))))) + (if (and (equal action "follow") + (eq t (alist-get 'requested json))) + (message "Follow requested for user %s (@%s)!" name user-handle) + (message "User %s (@%s) %sed!" name user-handle action))))))))) ;; FOLLOW TAGS -- cgit v1.2.3 From 11be568c1ed4bf903f2da09f1cc7353b7f5941e2 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 10 Feb 2024 16:48:27 +0100 Subject: my-profile: load by id, rather than server search --- lisp/mastodon-profile.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index fc90cf7..5929f1c 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -745,7 +745,9 @@ IMG-TYPE is the JSON key from the account data." "Show the profile of the currently signed in user." (interactive) (message "Loading your profile...") - (mastodon-profile--show-user (mastodon-auth--get-account-name))) + (let ((account (mastodon-profile--account-from-id + (mastodon-auth--get-account-id)))) + (mastodon-profile--make-author-buffer account))) (defun mastodon-profile--format-user (tootv) "Convert TOOTV into author-bylines and insert. -- cgit v1.2.3 From 9caa0b58ea67d807d65e48a7f7e8599644351eb7 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 15 Feb 2024 18:11:37 +0100 Subject: docstrings --- lisp/mastodon-tl.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d21edaf..7d6243f 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2215,7 +2215,8 @@ PREFIX is sent to `mastodon-tl--get-tag-timeline', which see." (defun mastodon-tl--followed-tags-timeline (&optional prefix) "Open a timeline of multiple tags. -PREFIX is sent to `mastodon-tl--show-tag-timeline', which see. +With a single PREFIX arg, only show posts with media. +With a double PREFIX arg, limit results to your own instance. If `mastodon-tl--tag-timeline-tags' is set, use its tags, else fetch followed tags and load the first four of them." (interactive "p") @@ -2748,7 +2749,7 @@ JSON and http headers, without it just the JSON." "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. UPDATE-FUNCTION is used to receive more toots. Runs synchronously. -Optional arg NOTE-TYPE means only get that type of note. +Optional arg NOTE-TYPE means only get that type of notification. PARAMS is an alist of any params to include in the request. HEADERS are any headers to send in the request. VIEW-NAME is a string, to be used as a heading for the view. -- cgit v1.2.3 From 1fa432d27cad87f873de656bd4d6b257198314d9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 19 Feb 2024 15:49:08 +0100 Subject: toot.el: use all emoji for : capf, and get text annotation --- lisp/mastodon-toot.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 462f925..9c6c1ef 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1027,6 +1027,21 @@ Federated user: `username@host.co`." (cons (match-beginning 2) (match-end 2)))))) +(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))) + (let ((emojis '())) + (emojify-emojis-each (lambda (key value) + (when (seq-position styles (ht-get value "style")) + (push (cons key + (format "%s (%s)" + (ht-get value "name") + (ht-get value "style"))) + emojis)))) + emojis))) + (defun mastodon-toot--fetch-completion-candidates (start end &optional type) "Search for a completion prefix from buffer positions START to END. Return a list of candidates. @@ -1041,8 +1056,7 @@ TYPE is the candidate type, it may be :tags, :handles, or :emoji." collect (cons (concat "#" (car tag)) (cdr tag))))) ((eq type :emoji) - (cl-loop for e in emojify-user-emojis - collect (car e))) + (mastodon-toot--fetch-emojify-candidates)) (t (mastodon-search--search-accounts-query (buffer-substring-no-properties start end)))))) @@ -1100,10 +1114,10 @@ arg, a candidate." ;; or make it an alist and use cdr (cadr (assoc candidate mastodon-toot-completions))) -(defun mastodon-toot--emoji-annotation-fun (_candidate) +(defun mastodon-toot--emoji-annotation-fun (candidate) "." ;; TODO: emoji image as annot - ) + (cdr (assoc candidate mastodon-toot-completions))) ;;; REPLY -- cgit v1.2.3 From 379e1edc278ba9a2179dafdfb1ca4e7d237db10b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 19 Feb 2024 15:56:17 +0100 Subject: read me, var index --- README.org | 2 +- mastodon-index.org | 72 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/README.org b/README.org index cfbe03e..747b29a 100644 --- a/README.org +++ b/README.org @@ -250,7 +250,7 @@ value of that hook is as follows: | =C-c C-l= | Set toot language | |---------+----------------------------------| -**** Autocompletion of mentions and tags +**** Autocompletion of mentions, tags, and emoji Autocompletion of mentions and tags is provided by =completion-at-point-functions= (capf) backends. diff --git a/mastodon-index.org b/mastodon-index.org index 90e7bf7..35fa77a 100644 --- a/mastodon-index.org +++ b/mastodon-index.org @@ -232,37 +232,41 @@ #+end_src #+RESULTS: -| Custom variable | Description | -|----------------------------------------------------+------------------------------------------------------------------------------| -| mastodon-active-user | Username of the active user. | -| mastodon-client--token-file | File path where Mastodon access tokens are stored. | -| mastodon-instance-url | Base URL for the Mastodon instance you want to be active. | -| mastodon-media--avatar-height | Height of the user avatar images (if shown). | -| mastodon-media--enable-image-caching | Whether images should be cached. | -| mastodon-media--preview-max-height | Max height of any media attachment preview to be shown in timelines. | -| mastodon-mode-hook | Hook run when entering Mastodon mode. | -| mastodon-profile-mode-hook | Hook run after entering or leaving `mastodon-profile-mode'. | -| mastodon-profile-update-mode-hook | Hook run after entering or leaving `mastodon-profile-update-mode'. | -| mastodon-tl--display-caption-not-url-when-no-media | Display an image's caption rather than URL. | -| mastodon-tl--enable-proportional-fonts | Nonnil to enable using proportional fonts when rendering HTML. | -| mastodon-tl--enable-relative-timestamps | Whether to show relative (to the current time) timestamps. | -| mastodon-tl--expand-content-warnings | Whether to expand content warnings by default. | -| mastodon-tl--hide-replies | Whether to hide replies from the timelines. | -| mastodon-tl--highlight-current-toot | Whether to highlight the toot at point. Uses `cursor-face' special property. | -| mastodon-tl--show-avatars | Whether to enable display of user avatars in timelines. | -| mastodon-tl--show-stats | Whether to show toot stats (faves, boosts, replies counts). | -| mastodon-tl--symbols | A set of symbols (and fallback strings) to be used in timeline. | -| mastodon-tl--timeline-posts-count | Number of posts to display when loading a timeline. | -| mastodon-tl-position-after-update | Defines where `point' should be located after a timeline update. | -| mastodon-toot--attachment-height | Height of the attached images preview in the toot draft buffer. | -| mastodon-toot--completion-style-for-mentions | The company completion style to use for mentions. | -| mastodon-toot--default-media-directory | The default directory when prompting for a media file to upload. | -| mastodon-toot--default-reply-visibility | Default visibility settings when replying. | -| mastodon-toot--enable-completion | Whether to enable completion of mentions and hashtags. | -| mastodon-toot--enable-custom-instance-emoji | Whether to enable your instance's custom emoji by default. | -| mastodon-toot--proportional-fonts-compose | Nonnil to enable using proportional fonts in the compose buffer. | -| mastodon-toot--use-company-for-completion | Whether to enable company for completion. | -| mastodon-toot-display-orig-in-reply-buffer | Display a copy of the toot replied to in the compose buffer. | -| mastodon-toot-mode-hook | Hook run after entering or leaving `mastodon-toot-mode'. | -| mastodon-toot-orig-in-reply-length | Length to crop toot replied to in the compose buffer to. | -| mastodon-toot-timestamp-format | Format to use for timestamps. | +| Custom variable | Description | +|----------------------------------------------------+-------------------------------------------------------------------------------| +| mastodon-active-user | Username of the active user. | +| mastodon-client--token-file | File path where Mastodon access tokens are stored. | +| mastodon-instance-url | Base URL for the Mastodon instance you want to be active. | +| mastodon-media--avatar-height | Height of the user avatar images (if shown). | +| mastodon-media--enable-image-caching | Whether images should be cached. | +| mastodon-media--preview-max-height | Max height of any media attachment preview to be shown in timelines. | +| mastodon-mode-hook | Hook run when entering Mastodon mode. | +| mastodon-profile-mode-hook | Hook run after entering or leaving `mastodon-profile-mode'. | +| mastodon-profile-update-mode-hook | Hook run after entering or leaving `mastodon-profile-update-mode'. | +| mastodon-search-mode-hook | Hook run after entering or leaving `mastodon-search-mode'. | +| mastodon-tl--display-caption-not-url-when-no-media | Display an image's caption rather than URL. | +| mastodon-tl--display-media-p | A boolean value stating whether to show media in timelines. | +| mastodon-tl--enable-proportional-fonts | Nonnil to enable using proportional fonts when rendering HTML. | +| mastodon-tl--enable-relative-timestamps | Whether to show relative (to the current time) timestamps. | +| mastodon-tl--expand-content-warnings | Whether to expand content warnings by default. | +| mastodon-tl--hide-replies | Whether to hide replies from the timelines. | +| mastodon-tl--highlight-current-toot | Whether to highlight the toot at point. Uses `cursor-face' special property. | +| mastodon-tl--show-avatars | Whether to enable display of user avatars in timelines. | +| mastodon-tl--show-stats | Whether to show toot stats (faves, boosts, replies counts). | +| mastodon-tl--symbols | A set of symbols (and fallback strings) to be used in timeline. | +| mastodon-tl--tag-timeline-tags | A list of up to four tags for use with `mastodon-tl--followed-tags-timeline'. | +| mastodon-tl--timeline-posts-count | Number of posts to display when loading a timeline. | +| mastodon-tl-position-after-update | Defines where `point' should be located after a timeline update. | +| mastodon-toot--attachment-height | Height of the attached images preview in the toot draft buffer. | +| mastodon-toot--completion-style-for-mentions | The company completion style to use for mentions. | +| mastodon-toot--default-media-directory | The default directory when prompting for a media file to upload. | +| mastodon-toot--default-reply-visibility | Default visibility settings when replying. | +| mastodon-toot--emojify-in-compose-buffer | Whether to enable `emojify' in the compose buffer. | +| mastodon-toot--enable-completion | Whether to enable completion of mentions and hashtags. | +| mastodon-toot--enable-custom-instance-emoji | Whether to enable your instance's custom emoji by default. | +| mastodon-toot--proportional-fonts-compose | Nonnil to enable using proportional fonts in the compose buffer. | +| mastodon-toot--use-company-for-completion | Whether to enable company for completion. | +| mastodon-toot-display-orig-in-reply-buffer | Display a copy of the toot replied to in the compose buffer. | +| mastodon-toot-mode-hook | Hook run after entering or leaving `mastodon-toot-mode'. | +| mastodon-toot-orig-in-reply-length | Length to crop toot replied to in the compose buffer to. | +| mastodon-toot-timestamp-format | Format to use for timestamps. | -- cgit v1.2.3 From 87b0b347b5cb43a571dbccae3fdb2adca6ed8cad Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 19 Feb 2024 17:06:12 +0100 Subject: readme completion --- README.org | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 747b29a..5c663e6 100644 --- a/README.org +++ b/README.org @@ -252,7 +252,8 @@ value of that hook is as follows: **** Autocompletion of mentions, tags, and emoji -Autocompletion of mentions and tags is provided by +Autocompletion of mentions, tags, and emoji is triggered =@=, =#=, and =:= +respectively, plus a few letters. It is provided by =completion-at-point-functions= (capf) backends. =mastodon-toot--enable-completion= is enabled by default. If you want to enable =company-mode= in the toot compose buffer, set -- cgit v1.2.3 From af029656fae2b54ea26467423dab7090d170d0a5 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 09:51:05 +0100 Subject: comment re return-creds-acc --- lisp/mastodon.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 142eced..ffeee82 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -299,6 +299,11 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (defvar mastodon-profile-credential-account nil) +;; TODO: the get request in mastodon-http--get-response often returns nil +;; after waking pc from sleep, not sure how to fix, or if just my pc +;; interestingly it only happens with this function tho. +;;we have to use :force to update the credential-account object in case things +;; have been changed via another client. (defun mastodon-return-credential-account (&optional force) "Return the CredentialAccount entity. Either from `mastodon-profile-credential-account' or from the -- cgit v1.2.3 From 5e31b1b484736b771b58a5d153b7e6e8f22cb364 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 09:52:02 +0100 Subject: http: some hack error handling in get-response --- lisp/mastodon-http.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 541c92e..a345324 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -179,8 +179,14 @@ PARAMS is an alist of any extra parameters to send with the request. SILENT means don't message. NO-HEADERS means don't collect http response headers. VECTOR means return json arrays as vectors." - (with-current-buffer (mastodon-http--get url params silent) - (mastodon-http--process-response no-headers vector))) + (let ((buf (mastodon-http--get url params silent))) + ;; (if (not buf) + ;; (error "Request returned nada") + (condition-case x + (with-current-buffer buf + (mastodon-http--process-response no-headers vector)) + (wrong-type-argument + (error "Request returned nada"))))) (defun mastodon-http--get-json (url &optional params silent vector) "Return only JSON data from URL request. -- cgit v1.2.3 From aa4e01e5cd2484eb51ed917410acd2b15f5fdd27 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 09:52:24 +0100 Subject: toot: defcustom emojify in compose --- lisp/mastodon-toot.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 9c6c1ef..97949cd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -154,6 +154,9 @@ If the original toot visibility is different we use the more restricted one." "Whether to enable your instance's custom emoji by default." :type 'boolean) +(defcustom mastodon-toot--emojify-in-compose-buffer nil + "Whether to enable `emojify' in the compose buffer.") + (defcustom mastodon-toot--proportional-fonts-compose nil "Nonnil to enable using proportional fonts in the compose buffer. By default fixed width fonts are used." -- cgit v1.2.3 From 58ec54b6663c82da6ec87c6f3d1016db4442d3dc Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 19:41:41 +0100 Subject: update: skip scheduled-statuses view --- lisp/mastodon-tl.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7d6243f..29dce60 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2683,6 +2683,7 @@ This location is defined by a non-nil value of (mastodon-tl--buffer-type-eq 'follow-suggestions) (mastodon-tl--buffer-type-eq 'lists) (mastodon-tl--buffer-type-eq 'filters) + (mastodon-tl--buffer-type-eq 'scheduled-statuses) (mastodon-tl--search-buffer-p)) (message "update not available in this view.") ;; FIXME: handle update for search and trending buffers -- cgit v1.2.3 From 63120440fa0e7c981c22d687a778b5143fc18639 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 19:42:17 +0100 Subject: string-trim-left on remove-docs --- lisp/mastodon-toot.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 97949cd..7ff3c34 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -812,7 +812,8 @@ to `emojify-user-emojis', and the emoji data is updated." "Get the body of a toot from the current compose buffer." (let ((header-region (mastodon-tl--find-property-range 'toot-post-header (point-min)))) - (buffer-substring (cdr header-region) (point-max)))) + (string-trim-left + (buffer-substring (cdr header-region) (point-max))))) (defun mastodon-toot--build-poll-params () "Return an alist of parameters for POSTing a poll status." -- cgit v1.2.3 From 52b7775cb7ce96fb023078ed5048f8bd5c080bc9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 20 Feb 2024 19:43:45 +0100 Subject: views: ensure things have item-type prop, and string-trim scheduleds --- lisp/mastodon-views.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el index 8e04434..d0f310b 100644 --- a/lisp/mastodon-views.el +++ b/lisp/mastodon-views.el @@ -509,11 +509,11 @@ JSON is the data returned by the server." "Insert scheduled TOOT into the buffer." (let-alist toot (insert - (propertize (concat .params.text + (propertize (concat (string-trim .params.text) " | " (mastodon-toot--iso-to-human .scheduled_at)) 'byline t ; so we nav here - 'item-id "0" ; so we nav here + 'item-type 'scheduled ; so we nav here 'face 'font-lock-comment-face 'keymap mastodon-views--scheduled-map 'scheduled-json toot @@ -619,6 +619,7 @@ JSON is the filters data." (insert (propertize filter-string 'item-id id ;for goto-next-filter compat + 'item-type 'filter 'phrase phrase 'byline t) ;for goto-next-filter compat "\n\n"))) -- cgit v1.2.3 From 5977495b8a7d2782b36723289e805f018375275b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 21 Feb 2024 10:26:53 +0100 Subject: move condition case from http get-response to credential-account --- lisp/mastodon-http.el | 9 ++------- lisp/mastodon.el | 7 ++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index a345324..aef8975 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -180,13 +180,8 @@ SILENT means don't message. NO-HEADERS means don't collect http response headers. VECTOR means return json arrays as vectors." (let ((buf (mastodon-http--get url params silent))) - ;; (if (not buf) - ;; (error "Request returned nada") - (condition-case x - (with-current-buffer buf - (mastodon-http--process-response no-headers vector)) - (wrong-type-argument - (error "Request returned nada"))))) + (with-current-buffer buf + (mastodon-http--process-response no-headers vector)))) (defun mastodon-http--get-json (url &optional params silent vector) "Return only JSON data from URL request. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index ffeee82..abc7787 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -315,7 +315,12 @@ FORCE means to fetch from the server and update nil :silent))) (if force (setq mastodon-profile-credential-account - (eval req)) + ;; TODO: we should also signal a quit condition after like 5 + ;; secs here + (condition-case x + (eval req) + (t ; req fails, return old value + mastodon-profile-credential-account))) (or mastodon-profile-credential-account (setq mastodon-profile-credential-account (eval req)))))) -- cgit v1.2.3 From 45e59eab514c11c69e5d0e619de967442ce1fddc Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 22 Feb 2024 10:31:25 +0100 Subject: make byte-compiler happier --- lisp/mastodon-toot.el | 3 ++- lisp/mastodon.el | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7ff3c34..e414552 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 nil - "Whether to enable `emojify' in the compose buffer.") + "Whether to enable `emojify' in the compose buffer." + :type 'boolean) (defcustom mastodon-toot--proportional-fonts-compose nil "Nonnil to enable using proportional fonts in the compose buffer. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index abc7787..7a04c87 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -97,6 +97,8 @@ (autoload 'mastodon-views--view-instance-description "mastodon-views") (autoload 'mastodon-views--view-lists "mastodon-views") (autoload 'mastodon-views--view-scheduled-toots "mastodon-views") +(autoload 'mastodon-tl--dm-user "mastodon-tl") +(autoload 'mastodon-tl--scroll-up-command "mastodon-tl") (autoload 'special-mode "simple") (defvar mastodon-tl--highlight-current-toot) @@ -317,7 +319,7 @@ FORCE means to fetch from the server and update (setq mastodon-profile-credential-account ;; TODO: we should also signal a quit condition after like 5 ;; secs here - (condition-case x + (condition-case nil (eval req) (t ; req fails, return old value mastodon-profile-credential-account))) -- cgit v1.2.3 From 96866e176e469811642b66b971f3125f040de5de Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 22 Feb 2024 12:36:20 +0100 Subject: remove stray or clauses in tl--goto-item-pos --- lisp/mastodon-tl.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 29dce60..856325e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -368,21 +368,22 @@ text, i.e. hidden spoiler text." "Search for item with function FIND-POS. If search returns nil, execute REFRESH function. Optionally start from POS." - (let* ((npos (or ; toot/user items have byline: - (funcall find-pos - (or pos (point)) - ;; 'item-type ; breaks nav to last item in a view? - 'byline - (current-buffer))))) + (let* ((npos ; toot/user items have byline: + (funcall find-pos + (or pos (point)) + ;; FIXME: we need to fix item-type? + ;; 'item-type ; breaks nav to last item in a view? + 'byline + (current-buffer)))) (if npos - (if (not (or - ;; (get-text-property npos 'item-id) ; toots, users, not tags - (get-text-property npos 'item-type))) ; generic + (if (not + ;; (get-text-property npos 'item-id) ; toots, users, not tags + (get-text-property npos 'item-type)) ; generic (mastodon-tl--goto-item-pos find-pos refresh npos) (goto-char npos) ;; force display of help-echo on moving to a toot byline: (mastodon-tl--message-help-echo)) - ;; FIXME: this doesn't really work, as the funcall doesn't return if we + ;; FIXME: this doesn't work, as the funcall doesn't return if we ;; run into an endless refresh loop (condition-case nil (funcall refresh) -- cgit v1.2.3