From 4e19f18a1a6d5bd60673013751b4332be0ea445c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 12 Mar 2024 17:48:49 +0100 Subject: apply not cl-reduce to find longest item for padding --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 82ad03b..7d2e467 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1374,7 +1374,7 @@ LENGTH is the maximum character length allowed for a poll option." collect (read-string (format "Poll option [%s/%s] [max %s chars]: " x count length)))) - (longest (cl-reduce #'max (mapcar #'length choices)))) + (longest (apply #'max (mapcar #'length choices)))) (if (> longest length) (progn (message "looks like you went over the max length. Try again.") -- cgit v1.2.3 From 3711c59984ab369fb5fc575e8a55fb26b2a2be51 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 15 Mar 2024 10:43:21 +0100 Subject: toot-compose: only call mode funs if not buffer-exists this avoids wiping prev set buf-local vars --- lisp/mastodon-toot.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7d2e467..a332706 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1851,8 +1851,11 @@ EDIT means we are editing an existing toot, not composing a new one." (previous-window-config (list (current-window-configuration) (point-marker)))) (switch-to-buffer-other-window buffer) - (text-mode) - (mastodon-toot-mode t) + ;; if a user hits reply while a compose buffer is already open, + ;; we really ought to wipe it all and start over. + (unless buffer-exists ; don't nuke buffer-local vars + (text-mode) + (mastodon-toot-mode t)) (setq mastodon-toot--visibility (or (plist-get mastodon-profile-account-settings 'privacy) ;; use toot visibility setting from the server: -- cgit v1.2.3 From a55db10550fbf4163f380648616e63a574dea838 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 15 Mar 2024 11:15:00 +0100 Subject: reply when replying: prompt to either nuke existing or abort --- lisp/mastodon-toot.el | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index a332706..47bda3f 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1843,7 +1843,15 @@ a draft into the buffer. EDIT means we are editing an existing toot, not composing a new one." (let* ((buffer-name (if edit "*edit toot*" "*new toot*")) (buffer-exists (get-buffer buffer-name)) - (buffer (or buffer-exists (get-buffer-create buffer-name))) + (buffer (if (not buffer-exists) + (get-buffer-create buffer-name) + ;; if a user hits reply while a compose buffer is already + ;; open, we really ought to wipe it all and start over. + (switch-to-buffer-other-window buffer-exists) + (if (not (y-or-n-p "Overwrite existing compose buffer?")) + (user-error "Aborting") + (kill-buffer-and-window) + (get-buffer-create buffer-name)))) (inhibit-read-only t) (reply-text (alist-get 'content (or (alist-get 'reblog reply-json) @@ -1851,29 +1859,25 @@ EDIT means we are editing an existing toot, not composing a new one." (previous-window-config (list (current-window-configuration) (point-marker)))) (switch-to-buffer-other-window buffer) - ;; if a user hits reply while a compose buffer is already open, - ;; we really ought to wipe it all and start over. - (unless buffer-exists ; don't nuke buffer-local vars - (text-mode) - (mastodon-toot-mode t)) + (text-mode) + (mastodon-toot-mode t) (setq mastodon-toot--visibility (or (plist-get mastodon-profile-account-settings 'privacy) ;; use toot visibility setting from the server: (mastodon-profile--get-source-pref 'privacy) "public")) ; fallback - (unless buffer-exists - (if mastodon-toot-display-orig-in-reply-buffer - (progn - (mastodon-toot--display-docs-and-status-fields reply-text) - (mastodon-toot--fill-reply-in-compose)) - (mastodon-toot--display-docs-and-status-fields)) - ;; `reply-to-user' (alone) is also used by `mastodon-tl--dm-user', so - ;; perhaps we should not always call --setup-as-reply, or make its - ;; workings conditional on reply-to-id. currently it only checks for - ;; reply-to-user. - (mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json - ;; only initial-text if reply (not edit): - (when reply-json initial-text))) + (if mastodon-toot-display-orig-in-reply-buffer + (progn + (mastodon-toot--display-docs-and-status-fields reply-text) + (mastodon-toot--fill-reply-in-compose)) + (mastodon-toot--display-docs-and-status-fields)) + ;; `reply-to-user' (alone) is also used by `mastodon-tl--dm-user', so + ;; perhaps we should not always call --setup-as-reply, or make its + ;; workings conditional on reply-to-id. currently it only checks for + ;; reply-to-user. + (mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json + ;; only initial-text if reply (not edit): + (when reply-json initial-text)) (unless mastodon-toot--max-toot-chars ;; no need to fetch from `mastodon-profile-account-settings' as ;; `mastodon-toot--max-toot-chars' is set when we set it -- cgit v1.2.3 From 7df610ba70be4349db418c901af33fdf126997bb Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 17 Mar 2024 14:06:58 +0100 Subject: condition case for lingva translations --- lisp/mastodon-toot.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 47bda3f..062eaf0 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -549,16 +549,18 @@ base toot." "Translate text of toot at point. Uses `lingva.el'." (interactive) - (if (not (require 'lingva nil :no-error)) - (message "Looks like you need to install lingva.el first.") - (if mastodon-tl--buffer-spec - (if-let ((toot (mastodon-tl--property 'item-json))) - (lingva-translate nil - (mastodon-tl--content toot) - (when mastodon-tl--enable-proportional-fonts - t)) - (message "No toot to translate?")) - (message "No mastodon buffer?")))) + (if mastodon-tl--buffer-spec + (if-let ((toot (mastodon-tl--property 'item-json))) + (condition-case x + (lingva-translate nil + (mastodon-tl--content toot) + (when mastodon-tl--enable-proportional-fonts + t)) + (void-function + (message "Looks like you need to install lingva.el. Error: %s" + (error-message-string x)))) + (message "No toot to translate?")) + (message "No mastodon buffer?"))) (defun mastodon-toot--own-toot-p (toot) "Check if TOOT is user's own, for deleting, editing, or pinning it." -- cgit v1.2.3 From 1454c2253d507adf9be1d413172e0b11b853c661 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 27 Mar 2024 14:52:14 +0100 Subject: docstrings - reduce explicit refs to Mastodon itself. --- lisp/mastodon-profile.el | 4 ++-- lisp/mastodon-tl.el | 2 +- lisp/mastodon-toot.el | 6 +++--- lisp/mastodon.el | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 55041c9..7b5a700 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -131,7 +131,7 @@ is updated on entering mastodon mode and on toggle any setting it contains") (define-minor-mode mastodon-profile-update-mode - "Minor mode to update Mastodon user profile." + "Minor mode to update user profile." :group 'mastodon-profile :keymap mastodon-profile-update-mode-map :global nil) @@ -790,7 +790,7 @@ If the handle does not match a search return then retun NIL." (elt matching-account 0)))) (defun mastodon-profile--account-from-id (user-id) - "Request an account object relating to a USER-ID from Mastodon." + "Request an account object relating to a USER-ID." (mastodon-http--get-json (mastodon-http--api (format "accounts/%s" user-id)))) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index a35ae5e..4c0375d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -216,7 +216,7 @@ respects the user's `browse-url' settings." ;;; VARIABLES (defvar-local mastodon-tl--buffer-spec nil - "A unique identifier and functions for each Mastodon buffer.") + "A unique identifier and functions for each mastodon buffer.") (defvar-local mastodon-tl--update-point nil "When updating a mastodon buffer this is where new toots will be inserted. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 062eaf0..a48d5d9 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -699,7 +699,7 @@ CANCEL means the toot was not sent, so we save the toot text as a draft." (mastodon-toot--restore-previous-window-config prev-window-config))) (defun mastodon-toot--cancel () - "Kill new-toot buffer/window. Does not POST content to Mastodon. + "Kill new-toot buffer/window. Does not POST content. If toot is not empty, prompt to save text as a draft." (interactive) (if (mastodon-toot--empty-p) @@ -840,7 +840,7 @@ to `emojify-user-emojis', and the emoji data is updated." ;;; SEND TOOT FUNCTION (defun mastodon-toot--send () - "POST contents of new-toot buffer to Mastodon instance and kill buffer. + "POST contents of new-toot buffer to fediverse instance and kill buffer. If media items have been attached and uploaded with `mastodon-toot--attach-media', they are attached to the toot. If `mastodon-toot--edit-item-id' is non-nil, PUT contents to @@ -1953,7 +1953,7 @@ Only text that is not one of these faces will be spell-checked." (define-minor-mode mastodon-toot-mode - "Minor mode to capture Mastodon toots." + "Minor mode for composing toots." :keymap mastodon-toot-mode-map :global nil) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 4667450..70ab73c 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -110,8 +110,8 @@ :group 'external) (defcustom mastodon-instance-url "https://mastodon.social" - "Base URL for the Mastodon instance you want to be active. -For example, if your mastodon username is + "Base URL for the fediverse instance you want to be active. +For example, if your username is \"example_user@social.instance.org\", and you want this account to be active, the value of this variable should be \"https://social.instance.org\". @@ -125,7 +125,7 @@ changes to take effect." (defcustom mastodon-active-user nil "Username of the active user. -For example, if your mastodon username is +For example, if your username is \"example_user@social.instance.org\", and you want this account to be active, the value of this variable should be \"example_user\". @@ -275,7 +275,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") ;;;###autoload (defun mastodon () - "Connect Mastodon client to `mastodon-instance-url' instance." + "Connect client to `mastodon-instance-url' instance." (interactive) (let* ((tls (list "home" "local" @@ -295,7 +295,7 @@ See `mastodon-toot-display-orig-in-reply-buffer'.") (if buffer (pop-to-buffer buffer '(display-buffer-same-window)) (mastodon-tl--get-home-timeline) - (message "Loading Mastodon account %s on %s..." + (message "Loading fediverse account %s on %s..." (mastodon-auth--user-acct) mastodon-instance-url)))) @@ -477,7 +477,7 @@ Calls `mastodon-tl--get-buffer-type', which see." (add-hook 'mastodon-mode-hook #'mastodon-mode-hook-fun) (define-derived-mode mastodon-mode special-mode "Mastodon" - "Major mode for Mastodon, the federated microblogging network." + "Major mode for fediverse services using the Mastodon API." (read-only-mode 1)) (provide 'mastodon) -- cgit v1.2.3