aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-22 16:49:55 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-22 16:49:55 +0100
commitcbc27cfbcf2840eda619e425cc986c8198deea26 (patch)
treead3de4a25733eb9a7b2a1c3c1a3b1d81ef9df2b9 /lisp/mastodon-toot.el
parent9d1d2fc3746a87cf9e841da58a5c7641599650a0 (diff)
parent77b8a2ea379e10ed8df316c116a72c476bb9af50 (diff)
Merge branch 'toot-langs' into develop
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el22
1 files changed, 20 insertions, 2 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 5a735dc..18dba06 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -47,6 +47,8 @@
(declare-function company-grab-symbol "company")
(defvar company-backends))
+(require 'mastodon-iso)
+
(defvar mastodon-instance-url)
(defvar mastodon-tl--buffer-spec)
(defvar mastodon-tl--enable-proportional-fonts)
@@ -169,6 +171,9 @@ change the setting on the server, see
(defvar-local mastodon-toot-poll nil
"A list of poll options for the toot being composed.")
+(defvar-local mastodon-toot--language nil
+ "The language of the toot being composed, in ISO 639 (two-letter).")
+
(defvar-local mastodon-toot--reply-to-id nil
"Buffer-local variable to hold the id of the toot being replied to.")
@@ -211,6 +216,7 @@ send.")
(define-key map (kbd "C-c C-a") #'mastodon-toot--attach-media)
(define-key map (kbd "C-c !") #'mastodon-toot--clear-all-attachments)
(define-key map (kbd "C-c C-p") #'mastodon-toot--create-poll)
+ (define-key map (kbd "C-c C-l") #'mastodon-toot--set-toot-lang)
map)
"Keymap for `mastodon-toot'.")
@@ -661,7 +667,8 @@ instance to edit a toot."
("visibility" . ,mastodon-toot--visibility)
("sensitive" . ,(when mastodon-toot--content-nsfw
(symbol-name t)))
- ("spoiler_text" . ,spoiler)))
+ ("spoiler_text" . ,spoiler)
+ ("language" . ,mastodon-toot--language)))
(args-media (when mastodon-toot--media-attachments
(mastodon-http--build-array-args-alist
"media_ids[]"
@@ -1141,6 +1148,18 @@ LENGTH is the maximum character length allowed for a poll option."
("14 days" . ,(number-to-string (* 60 60 24 14)))
("30 days" . ,(number-to-string (* 60 60 24 30)))))
+(defun mastodon-toot--set-toot-lang ()
+ "Prompt for a language and return its two letter ISO 639 1 code."
+ (interactive)
+ (let* ((langs (mapcar (lambda (x)
+ (cons (cadr x)
+ (car x)))
+ mastodon-iso-639-1))
+ (choice (completing-read "Language for this toot: "
+ langs)))
+ (setq mastodon-toot--language
+ (alist-get choice langs nil nil 'equal))))
+
;; we'll need to revisit this if the binds get
;; more diverse than two-chord bindings
(defun mastodon-toot--get-mode-kbinds ()
@@ -1329,7 +1348,6 @@ This is how mastodon does it."
(replace-match (match-string 2))) ; replace with handle only
(length (buffer-substring (point-min) (point-max)))))
-
(defun mastodon-toot--save-toot-text (&rest _args)
"Save the current toot text in `mastodon-toot-current-toot-text'.
Added to `after-change-functions' in new toot buffers."