From fcdf2ca8451c21e373d1d484ee4883b9ec26c6e1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 31 Aug 2022 14:20:34 +0200 Subject: respect toot visibility setting from the server --- lisp/mastodon-toot.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 23abb84..3ecca20 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -71,6 +71,7 @@ (autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl") (autoload 'mastodon-tl--toot-id "mastodon-tl") (autoload 'mastodon-toot "mastodon") +(autoload 'mastodon-profile--get-source-pref "mastodon-profile") ;; for mastodon-toot--translate-toot-text (autoload 'mastodon-tl--content "mastodon-tl") @@ -141,7 +142,9 @@ This is only used if company mode is installed." "A string indicating the visibility of the toot being composed. Valid values are \"direct\", \"private\" (followers-only), -\"unlisted\", and \"public\".") +\"unlisted\", and \"public\". + +This may be set by the account setting on the server.") (defvar-local mastodon-toot--media-attachments nil "A list of the media attachments of the toot being composed.") @@ -1030,11 +1033,15 @@ REPLY-JSON is the full JSON of the toot being replied to." (switch-to-buffer-other-window buffer) (text-mode) (mastodon-toot-mode t) + ;; use toot visibility setting from the server: + (setq mastodon-toot--visibility + (mastodon-profile--get-source-pref 'privacy)) (unless buffer-exists (mastodon-toot--display-docs-and-status-fields) (mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json)) (unless mastodon-toot--max-toot-chars (mastodon-toot--get-max-toot-chars)) + ;; set up company backends: (when (require 'company nil :noerror) (when mastodon-toot--enable-completion (set (make-local-variable 'company-backends) -- cgit v1.2.3 From 284b4d583f4c78c815739dc4ec9bbcf39595117b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 31 Aug 2022 14:26:47 +0200 Subject: remove default-visibility defcustom --- lisp/mastodon-toot.el | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 3ecca20..253fb5d 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -83,18 +83,6 @@ :prefix "mastodon-toot-" :group 'mastodon) -(defcustom mastodon-toot--default-visibility "public" - "The default visibility for new toots. - -Must be one of \"public\", \"unlisted\", \"private\" (for -followers-only), or \"direct\"." - :group 'mastodon-toot - :type '(choice - (const :tag "public" "public") - (const :tag "unlisted" "unlisted") - (const :tag "followers only" "private") - (const :tag "direct" "direct"))) - (defcustom mastodon-toot--default-media-directory "~/" "The default directory when prompting for a media file to upload." :group 'mastodon-toot -- cgit v1.2.3 From 81bc0978fd36a17d2e0fba4123754ccc2af9035d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 31 Aug 2022 15:10:52 +0200 Subject: set default visibility fun --- lisp/mastodon-profile.el | 9 +++++++++ lisp/mastodon-toot.el | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 6fe3e14..0c91556 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -70,6 +70,7 @@ (defvar mastodon-tl--buffer-spec) (defvar mastodon-tl--update-point) (defvar mastodon-mode-map) +(defvar mastodon-toot-visibility-list) (defvar-local mastodon-profile--account nil "The data for the account being described in the current profile buffer.") @@ -263,6 +264,14 @@ SOURCE means that the preference is in the 'source' part of the account json." (lambda () (message "Account setting %s updated!" pref))))) +(defun mastodon-profile-set-default-toot-visibility () + "Set the default visibility for toots." + (interactive) + (let ((vis (completing-read "Set default visibility to:" + mastodon-toot-visibility-list + nil t))) + (mastodon-profile--update-preference "privacy" vis :source))) + (defun mastodon-profile-view-preferences () "View user preferences in another window." (interactive) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 253fb5d..8d8b9f3 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -126,6 +126,10 @@ This is only used if company mode is installed." (defvar-local mastodon-toot--content-nsfw nil "A flag indicating whether the toot should be marked as NSFW.") +(defvar mastodon-toot-visibility-list + '(direct private unlisted public) + "A list of the available toot visibility settings.") + (defvar-local mastodon-toot--visibility "public" "A string indicating the visibility of the toot being composed. -- cgit v1.2.3 From f6a2a14066cae107deab1805b8e5ff99d28c5125 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 1 Sep 2022 14:13:34 +0200 Subject: move set-default-toot-visibility to -toot.el --- lisp/mastodon-profile.el | 9 --------- lisp/mastodon-toot.el | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 116af5d..25edfba 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -70,7 +70,6 @@ (defvar mastodon-tl--buffer-spec) (defvar mastodon-tl--update-point) (defvar mastodon-mode-map) -(defvar mastodon-toot-visibility-list) (defvar-local mastodon-profile--account nil "The data for the account being described in the current profile buffer.") @@ -304,14 +303,6 @@ Discoverable means the account is listed in the server directory." (interactive) (mastodon-profile--edit-account-string 'display_name)) -(defun mastodon-profile-set-default-toot-visibility () - "Set the default visibility for toots." - (interactive) - (let ((vis (completing-read "Set default visibility to:" - mastodon-toot-visibility-list - nil t))) - (mastodon-profile--update-preference "privacy" vis :source))) - (defun mastodon-profile-view-preferences () "View user preferences in another window." (interactive) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 8d8b9f3..d7efd44 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -72,6 +72,7 @@ (autoload 'mastodon-tl--toot-id "mastodon-tl") (autoload 'mastodon-toot "mastodon") (autoload 'mastodon-profile--get-source-pref "mastodon-profile") +(autoload 'mastodon-profile--update-preference "mastodon-profile") ;; for mastodon-toot--translate-toot-text (autoload 'mastodon-tl--content "mastodon-tl") @@ -164,6 +165,14 @@ This may be set by the account setting on the server.") map) "Keymap for `mastodon-toot'.") +(defun mastodon-toot-set-default-visibility () + "Set the default visibility for toots on the server." + (interactive) + (let ((vis (completing-read "Set default visibility to:" + mastodon-toot-visibility-list + nil t))) + (mastodon-profile--update-preference "privacy" vis :source))) + (defun mastodon-toot--get-max-toot-chars () "Fetch max_toot_chars from `mastodon-instance-url' asynchronously." (mastodon-http--get-json-async -- cgit v1.2.3 From a93ef40dd8700659e84ca48571c24f98e56cfb91 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 1 Sep 2022 18:48:35 +0200 Subject: silence flycheck about 'backend-name' --- 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 d7efd44..7f867fe 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -661,7 +661,7 @@ The query is matched against a tag search on the server." 'mastodon-toot--tags-company-make-candidate)) (defun mastodon-toot--make-company-backend - (command backend-name str-prefix candidates-fun annot-fun meta-fun + (command _backend-name str-prefix candidates-fun annot-fun meta-fun &optional arg &rest ignored) "Make a company backend for `mastodon-toot-mode'. -- cgit v1.2.3