aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-discover.el12
-rw-r--r--lisp/mastodon-iso.el246
-rw-r--r--lisp/mastodon-notifications.el32
-rw-r--r--lisp/mastodon-profile.el28
-rw-r--r--lisp/mastodon-tl.el34
-rw-r--r--lisp/mastodon-toot.el43
-rw-r--r--lisp/mastodon.el26
7 files changed, 362 insertions, 59 deletions
diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el
index 5d1a86e..08df46e 100644
--- a/lisp/mastodon-discover.el
+++ b/lisp/mastodon-discover.el
@@ -57,8 +57,8 @@
("p" "Prev" mastodon-tl--goto-prev-toot)
("TAB" "Next link item" mastodon-tl--next-tab-item)
("S-TAB" "Prev link item" mastodon-tl--previous-tab-item)
- (when (require 'mpv nil :noerror)
- ("C-RET" "Play media" mastodon-tl--mpv-play-video-at-point))
+ ;; NB: (when (require 'mpv etc. calls don't work here
+ ("C-RET" "Play media" mastodon-tl--mpv-play-video-at-point)
("t" "New toot" mastodon-toot)
("r" "Reply" mastodon-toot--reply)
("C" "Copy toot URL" mastodon-toot--copy-toot-url)
@@ -66,8 +66,7 @@
("D" "Delete and redraft (your) toot" mastodon-toot--delete-toot)
("i" "Pin/Unpin (your) toot" mastodon-toot--pin-toot-toggle)
("P" "View user profile" mastodon-profile--show-user)
- (when (require 'lingva nil :noerror)
- "s" "Translate toot at point" mastodon-toot--translate-toot-text)
+ ("s" "Translate toot at point" mastodon-toot--translate-toot-text)
("T" "View thread" mastodon-tl--thread)
("v" "Vote on poll" mastodon-tl--poll-vote))
("Views"
@@ -76,7 +75,7 @@
("F" "Federated" mastodon-tl--get-federated-timeline)
("H" "Home" mastodon-tl--get-home-timeline)
("L" "Local" mastodon-tl--get-local-timeline)
- ("N" "Notifications" mastodon-notifications--get)
+ ("N" "Notifications" mastodon-notifications-get)
("u" "Update timeline" mastodon-tl--update)
("S" "Search" mastodon-search--search-query)
("O" "Jump to your profile" mastodon-profile--my-profile)
@@ -94,7 +93,8 @@
("B" "Block" mastodon-tl--block-user)
("C-S-B" "Unblock" mastodon-tl--unblock-user))
("Images"
- ("RET/i" "Load full image in browser" 'shr-browse-image)
+ ;; RET errors here also :/
+ ("<return>/i" "Load full image in browser" 'shr-browse-image)
("r" "rotate" 'image-rotate)
("+" "zoom in" 'image-increase-size)
("-" "zoom out" 'image-decrease-size)
diff --git a/lisp/mastodon-iso.el b/lisp/mastodon-iso.el
new file mode 100644
index 0000000..8baff3c
--- /dev/null
+++ b/lisp/mastodon-iso.el
@@ -0,0 +1,246 @@
+;;; mastodon-iso.el --- ISO language code lists for mastodon.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Marty Hiatt
+;; Author: Marty Hiatt <martianhiatus@riseup.net>
+;; Version: 1.0.0
+;; Package-Requires: ((emacs "27.1") (request "0.3.0"))
+;; Homepage: https://codeberg.org/martianh/mastodon.el
+
+;; This file is not part of GNU Emacs.
+
+;; This file is part of mastodon.el.
+
+;; mastodon.el is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; mastodon.el is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with mastodon.el. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+;; via
+;; https://github.com/VyrCossont/mastodon/blob/0836f4a656d5486784cadfd7d0cd717bb67ede4c/app/helpers/languages_helper.rb
+;; and
+;; https://github.com/Shinmera/language-codes/blob/master/data/iso-639-3.lisp
+
+(defvar mastodon-iso-639-1
+ '(("ab" "Abkhazian")
+ ("aa" "Afar")
+ ("af" "Afrikaans")
+ ("ak" "Akan")
+ ("sq" "Albanian")
+ ("am" "Amharic")
+ ("ar" "Arabic")
+ ("an" "Aragonese")
+ ("hy" "Armenian")
+ ("as" "Assamese")
+ ("av" "Avaric")
+ ("ae" "Avestan")
+ ("ay" "Aymara")
+ ("az" "Azerbaijani")
+ ("bm" "Bambara")
+ ("ba" "Bashkir")
+ ("eu" "Basque")
+ ("be" "Belarusian")
+ ("bn" "Bengali")
+ ("bh" "Bihari languages")
+ ("bi" "Bislama")
+ ("bs" "Bosnian")
+ ("br" "Breton")
+ ("bg" "Bulgarian")
+ ("my" "Burmese")
+ ("km" "Central Khmer")
+ ("ch" "Chamorro")
+ ("ce" "Chechen")
+ ("zh" "Chinese")
+ ("cv" "Chuvash")
+ ("kw" "Cornish")
+ ("co" "Corsican")
+ ("cr" "Cree")
+ ("hr" "Croatian")
+ ("cs" "Czech")
+ ("da" "Danish")
+ ("dz" "Dzongkha")
+ ("en" "English")
+ ("eo" "Esperanto")
+ ("et" "Estonian")
+ ("ee" "Ewe")
+ ("fo" "Faroese")
+ ("fj" "Fijian")
+ ("fi" "Finnish")
+ ("nl" "Dutch" "Flemish")
+ ("fr" "French")
+ ("ff" "Fulah")
+ ("gl" "Galician")
+ ("lg" "Ganda")
+ ("ka" "Georgian")
+ ("de" "German")
+ ("el" "Greek")
+ ("gn" "Guarani")
+ ("gu" "Gujarati")
+ ("ht" "Haitian" "Haitian Creole")
+ ("ha" "Hausa")
+ ("he" "Hebrew")
+ ("hz" "Herero")
+ ("hi" "Hindi")
+ ("ho" "Hiri Motu")
+ ("hu" "Hungarian")
+ ("is" "Icelandic")
+ ("io" "Ido")
+ ("ig" "Igbo")
+ ("id" "Indonesian")
+ ("ia" "Interlingua" "Interlingua (International Auxiliary Language Association)")
+ ("iu" "Inuktitut")
+ ("ik" "Inupiaq")
+ ("ga" "Irish")
+ ("it" "Italian")
+ ("ja" "Japanese")
+ ("jp" "Japanese")
+ ("jv" "Javanese")
+ ("kl" "Kalaallisut" "Greenlandic")
+ ("kn" "Kannada")
+ ("kr" "Kanuri")
+ ("ks" "Kashmiri")
+ ("kk" "Kazakh")
+ ("ki" "Kikuyu" "Gikuyu")
+ ("rw" "Kinyarwanda")
+ ("kv" "Komi")
+ ("kg" "Kongo")
+ ("ko" "Korean")
+ ("ku" "Kurdish")
+ ("kj" "Kuanyama" "Kwanyama")
+ ("ky" "Kirghiz" "Kyrgyz")
+ ("lo" "Lao")
+ ("la" "Latin")
+ ("lv" "Latvian")
+ ("li" "Limburgan" "Limburger" "Limburgish")
+ ("ln" "Lingala")
+ ("lt" "Lithuanian")
+ ("lu" "Luba-Katanga")
+ ("lb" "Luxembourgish" "Letzeburgesch")
+ ("mk" "Macedonian")
+ ("mg" "Malagasy")
+ ("ms" "Malay")
+ ("ml" "Malayalam")
+ ("dv" "Divehi" "Dhivehi" "Maldivian")
+ ("mt" "Maltese")
+ ("gv" "Manx")
+ ("mi" "Maori")
+ ("mr" "Marathi")
+ ("mh" "Marshallese")
+ ("mn" "Mongolian")
+ ("na" "Nauru")
+ ("nv" "Navajo" "Navaho")
+ ("ng" "Ndonga")
+ ("ne" "Nepali")
+ ("nd" "Ndebele, North" "North Ndebele")
+ ("se" "Northern Sami")
+ ("no" "Norwegian")
+ ("nb" "Bokmål, Norwegian" "Norwegian Bokmål")
+ ("ny" "Chichewa" "Chewa" "Nyanja")
+ ("nn" "Norwegian Nynorsk" "Nynorsk, Norwegian")
+ ("ie" "Interlingue" "Occidental")
+ ("oc" "Occitan")
+ ("oj" "Ojibwa")
+ ("cu" "Church Slavic" "Old Slavonic" "Church Slavonic" "Old Bulgarian" "Old Church Slavonic")
+ ("or" "Oriya")
+ ("om" "Oromo")
+ ("os" "Ossetian" "Ossetic")
+ ("pi" "Pali")
+ ("fa" "Persian")
+ ("pl" "Polish")
+ ("pt" "Portuguese")
+ ("pa" "Panjabi" "Punjabi")
+ ("ps" "Pushto" "Pashto")
+ ("qu" "Quechua")
+ ("ro" "Romanian" "Moldavian" "Moldovan")
+ ("rm" "Romansh")
+ ("rn" "Rundi")
+ ("ru" "Russian")
+ ("sm" "Samoan")
+ ("sg" "Sango")
+ ("sa" "Sanskrit")
+ ("sc" "Sardinian")
+ ("gd" "Gaelic" "Scottish Gaelic")
+ ("sr" "Serbian")
+ ("sn" "Shona")
+ ("ii" "Sichuan Yi" "Nuosu")
+ ("sd" "Sindhi")
+ ("si" "Sinhala" "Sinhalese")
+ ("sk" "Slovak")
+ ("sl" "Slovenian")
+ ("so" "Somali")
+ ("st" "Sotho, Southern")
+ ("nr" "Ndebele, South" "South Ndebele")
+ ("es" "Spanish" "Castilian")
+ ("su" "Sundanese")
+ ("sw" "Swahili")
+ ("ss" "Swati")
+ ("sv" "Swedish")
+ ("tl" "Tagalog")
+ ("ty" "Tahitian")
+ ("tg" "Tajik")
+ ("ta" "Tamil")
+ ("tt" "Tatar")
+ ("te" "Telugu")
+ ("th" "Thai")
+ ("bo" "Tibetan")
+ ("ti" "Tigrinya")
+ ("to" "Tonga (Tonga Islands)")
+ ("ts" "Tsonga")
+ ("tn" "Tswana")
+ ("tr" "Turkish")
+ ("tk" "Turkmen")
+ ("tw" "Twi")
+ ("uk" "Ukrainian")
+ ("ur" "Urdu")
+ ("ug" "Uighur" "Uyghur")
+ ("uz" "Uzbek")
+ ("ca" "Catalan" "Valencian")
+ ("ve" "Venda")
+ ("vi" "Vietnamese")
+ ("vo" "Volapük")
+ ("wa" "Walloon")
+ ("cy" "Welsh")
+ ("fy" "Western Frisian")
+ ("wo" "Wolof")
+ ("xh" "Xhosa")
+ ("yi" "Yiddish")
+ ("yo" "Yoruba")
+ ("za" "Zhuang" "Chuang")
+ ("zu" "Zulu")))
+
+;; web UI doesn't respect these for now
+(defvar mastodon-iso-639-regional
+ '(("es-AR" "Español (Argentina)")
+ ("es-MX" "Español (México)")
+ ("pt-BR" "Português (Brasil)")
+ ("pt-PT" "Português (Portugal)")
+ ("sr-Latn" "Srpski (latinica)")
+ ("zh-CN" "简体中文")
+ ("zh-HK" "繁體中文(香港)")
+ ("zh-TW" "繁體中文(臺灣)")))
+
+(defvar mastodon-iso-639-3
+ '(("ast" "Asturian" "Asturianu")
+ ("ckb" "Sorani (Kurdish)" "سۆرانی")
+ ("jbo" "Lojban" "la .lojban.")
+ ("kab" "Kabyle" "Taqbaylit")
+ ("kmr" "Kurmanji (Kurdish)" "Kurmancî")
+ ("ldn" "Láadan" "Láadan")
+ ("lfn" "Lingua Franca Nova" "lingua franca nova")
+ ("tok" "Toki Pona" "toki pona")
+ ("zba" "Balaibalan" "باليبلن")
+ ("zgh" "Standard Moroccan Tamazight" "ⵜⴰⵎⴰⵣⵉⵖⵜ")))
+
+(provide 'mastodon-iso)
+;;; mastodon-iso.el ends here
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index f9e2fe5..f5ddea3 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -51,6 +51,7 @@
(autoload 'mastodon-profile--view-follow-requests "mastodon-profile.el")
(autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl")
(autoload 'mastodon-tl--update "mastodon-tl")
+(autoload 'mastodon-notifications-get "mastodon")
(defvar mastodon-tl--buffer-spec)
(defvar mastodon-tl--display-media-p)
(defvar mastodon-mode-map)
@@ -124,7 +125,7 @@ follow-requests view."
(lambda ()
(if f-reqs-view-p
(mastodon-profile--view-follow-requests)
- (mastodon-notifications--get))
+ (mastodon-notifications-get))
(message "Follow request of %s (@%s) %s!"
name handle (if reject
"rejected"
@@ -276,51 +277,32 @@ of the toot responded to."
(mapc #'mastodon-notifications--by-type json)
(goto-char (point-min))))
-;;;###autoload
-(defun mastodon-notifications--get (&optional type buffer-name)
- "Display NOTIFICATIONS in buffer.
-Optionally only print notifications of type TYPE, a string.
-BUFFER-NAME is added to \"*mastodon-\" to create the buffer name."
- (interactive)
- (let ((buffer (or (concat "*mastodon-" buffer-name "*")
- "*mastodon-notifications*")))
- (if (get-buffer buffer)
- (progn (switch-to-buffer buffer)
- (mastodon-tl--update))
- (message "Loading your notifications...")
- (mastodon-tl--init-sync
- (or buffer-name "notifications")
- "notifications"
- 'mastodon-notifications--timeline
- type)
- (use-local-map mastodon-notifications--map))))
-
(defun mastodon-notifications--get-mentions ()
"Display mention notifications in buffer."
(interactive)
- (mastodon-notifications--get "mention" "mentions"))
+ (mastodon-notifications-get "mention" "mentions"))
(defun mastodon-notifications--get-favourites ()
"Display favourite notifications in buffer."
(interactive)
- (mastodon-notifications--get "favourite" "favourites"))
+ (mastodon-notifications-get "favourite" "favourites"))
(defun mastodon-notifications--get-boosts ()
"Display boost notifications in buffer."
(interactive)
- (mastodon-notifications--get "reblog" "boosts"))
+ (mastodon-notifications-get "reblog" "boosts"))
(defun mastodon-notifications--get-polls ()
"Display poll notifications in buffer."
(interactive)
- (mastodon-notifications--get "poll" "polls"))
+ (mastodon-notifications-get "poll" "polls"))
(defun mastodon-notifications--get-statuses ()
"Display status notifications in buffer.
Status notifications are created when you call
`mastodon-tl--enable-notify-user-posts'."
(interactive)
- (mastodon-notifications--get "status" "statuses"))
+ (mastodon-notifications-get "status" "statuses"))
(defun mastodon-notifications--filter-types-list (type)
"Return a list of notification types with TYPE removed."
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 975f7b7..69cd65d 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -70,6 +70,8 @@
(autoload 'mastodon-search--insert-users-propertized "mastodon-search")
(autoload 'mastodon-tl--get-endpoint "mastodon-tl.el")
(autoload 'mastodon-toot--get-max-toot-chars "mastodon-toot")
+(autoload 'mastodon-tl--add-account-to-list "mastodon-tl")
+
(defvar mastodon-instance-url)
(defvar mastodon-tl--buffer-spec)
(defvar mastodon-tl--update-point)
@@ -244,6 +246,15 @@ JSON is the data returned by the server."
(mastodon-search--insert-users-propertized json :note)))
;; (mastodon-profile--add-author-bylines json)))
+(defun mastodon-profile--add-account-to-list ()
+ "Add account of current profile buffer to a list."
+ (interactive)
+ (when mastodon-profile--account
+ (let* ((profile mastodon-profile--account)
+ (id (alist-get 'id profile))
+ (handle (alist-get 'acct profile)))
+ (mastodon-tl--add-account-to-list nil id handle))))
+
;;; ACCOUNT PREFERENCES
(defun mastodon-profile--get-json-value (val)
@@ -568,8 +579,7 @@ FIELDS means provide a fields vector fetched by other means."
(followsp (or (equal follows-you 't) (equal followed-by-you 't)))
(fields (mastodon-profile--fields-get account))
(pinned (mastodon-profile--get-statuses-pinned account))
- (joined-ts (ts-parse
- (mastodon-profile--account-field account 'created_at))))
+ (joined (mastodon-profile--account-field account 'created_at)))
(with-output-to-temp-buffer buffer
(switch-to-buffer buffer)
(mastodon-mode)
@@ -616,11 +626,7 @@ FIELDS means provide a fields vector fetched by other means."
"\n")
"")
(propertize
- (format "Joined %s"
- (format "%s" (concat (ts-month-name joined-ts)
- " "
- (number-to-string
- (ts-year joined-ts)))))
+ (mastodon-profile--format-joined-date-string joined)
'face 'success)
"\n\n")
'profile-json account)
@@ -657,6 +663,14 @@ FIELDS means provide a fields vector fetched by other means."
(funcall update-function json)))
(goto-char (point-min))))
+(defun mastodon-profile--format-joined-date-string (joined)
+ "Format a Joined timestamp."
+ (let ((joined-ts (ts-parse joined)))
+ (format "Joined %s" (concat (ts-month-name joined-ts)
+ " "
+ (number-to-string
+ (ts-year joined-ts))))))
+
(defun mastodon-profile--get-toot-author ()
"Open profile of author of toot under point.
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index e4f2dc9..46ec8fe 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -61,7 +61,7 @@
(autoload 'mastodon-profile--lookup-account-in-status "mastodon-profile")
(autoload 'mastodon-profile-mode "mastodon-profile")
;; make notifications--get available via M-x and outside our keymap:
-(autoload 'mastodon-notifications--get "mastodon-notifications"
+(autoload 'mastodon-notifications-get "mastodon-notifications"
"Display NOTIFICATIONS in buffer." t) ; interactive
(autoload 'mastodon-search--propertize-user "mastodon-search")
(autoload 'mastodon-search--insert-users-propertized "mastodon-search")
@@ -619,7 +619,8 @@ this just means displaying toot client."
(concat (when boosted
(mastodon-tl--format-faved-or-boosted-byline "B"))
(when faved
- (mastodon-tl--format-faved-or-boosted-byline "F"))
+ (mastodon-tl--format-faved-or-boosted-byline
+ (mastodon-tl--return-fave-char)))
(when bookmarked
(mastodon-tl--format-faved-or-boosted-byline bookmark-str)))
;; we remove avatars from the byline also, so that they also do not mess
@@ -693,6 +694,16 @@ this just means displaying toot client."
(mastodon-toot--get-toot-edits (alist-get 'id toot)))
'byline t))))
+(defun mastodon-tl--return-fave-char ()
+ ""
+ (cond
+ ((fontp (char-displayable-p #10r11088))
+ "⭐")
+ ((fontp (char-displayable-p #10r9733))
+ "★")
+ (t
+ "F")))
+
(defun mastodon-tl--format-edit-timestamp (timestamp)
"Convert edit TIMESTAMP into a descriptive string."
(let ((parsed (ts-human-duration
@@ -1481,7 +1492,7 @@ If ID is provided, use that list."
(interactive)
(let* ((list-names (unless id (mastodon-tl--get-lists-names)))
(name-old (if id
- (get-text-property (point) 'list-id)
+ (get-text-property (point) 'list-name)
(completing-read "Edit list: "
list-names)))
(id (or id (mastodon-tl--get-list-id name-old)))
@@ -1631,12 +1642,13 @@ a: add account to this list, r: remove account from this list"
(let ((id (get-text-property (point) 'list-id)))
(mastodon-tl--add-account-to-list id)))
-(defun mastodon-tl--add-account-to-list (&optional id)
+(defun mastodon-tl--add-account-to-list (&optional id account-id handle)
"Prompt for a list and for an account, add account to list.
-If ID is provided, use that list."
+If ID is provided, use that list.
+If ACCOUNT-ID and HANDLE are provided use them rather than prompting."
(interactive)
(let* ((list-name (if id
- (get-text-property (point) 'list-id)
+ (get-text-property (point) 'list-name)
(completing-read "Add account to list: "
(mastodon-tl--get-lists-names) nil t)))
(list-id (or id (mastodon-tl--get-list-id list-name)))
@@ -1645,9 +1657,9 @@ If ID is provided, use that list."
(cons (alist-get 'acct x)
(alist-get 'id x)))
followings))
- (account (completing-read "Account to add: "
- handles nil t))
- (account-id (alist-get account handles nil nil 'equal))
+ (account (or handle (completing-read "Account to add: "
+ handles nil t)))
+ (account-id (or account-id (alist-get account handles nil nil 'equal)))
(url (mastodon-http--api (format "lists/%s/accounts" list-id)))
(response (mastodon-http--post url
`(("account_ids[]" . ,account-id)))))
@@ -1666,7 +1678,7 @@ If ID is provided, use that list."
If ID is provided, use that list."
(interactive)
(let* ((list-name (if id
- (get-text-property (point) 'list-id)
+ (get-text-property (point) 'list-name)
(completing-read "Remove account from list: "
(mastodon-tl--get-lists-names) nil t)))
(list-id (or id (mastodon-tl--get-list-id list-name)))
@@ -2234,7 +2246,7 @@ For use after e.g. deleting a toot."
((equal (mastodon-tl--get-endpoint) "timelines/public?local=true")
(mastodon-tl--get-local-timeline))
((equal (mastodon-tl--get-endpoint) "notifications")
- (mastodon-notifications--get))
+ (mastodon-notifications-get))
((equal (mastodon-tl--buffer-name)
(concat "*mastodon-" (mastodon-auth--get-account-name) "-statuses*"))
(mastodon-profile--my-profile))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index c870092..4f9fb1b 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'.")
@@ -327,7 +333,9 @@ TYPE is a symbol, either 'favourite or 'boost."
(list 'boosted-p (not boosted))
(list 'favourited-p (not faved))))
(mastodon-toot--action-success
- (if boost-p "B" "F")
+ (if boost-p
+ "B"
+ (mastodon-tl--return-fave-char))
byline-region remove))
(message (format "%s #%s" (if boost-p msg action) id))))))
(message (format "Nothing to %s here?!?" action-string)))))
@@ -380,9 +388,12 @@ TYPE is a symbol, either 'favourite or 'boost."
(message (format "Nothing to %s here?!?" action)))))
(defun mastodon-toot--copy-toot-url ()
- "Copy URL of toot at point."
+ "Copy URL of toot at point.
+If the toot is a fave/boost notification, copy the URLof the
+base toot."
(interactive)
- (let* ((toot (mastodon-tl--property 'toot-json))
+ (let* ((toot (or (mastodon-tl--property 'base-toot)
+ (mastodon-tl--property 'toot-json)))
(url (if (mastodon-tl--field 'reblog toot)
(alist-get 'url (alist-get 'reblog toot))
(alist-get 'url toot))))
@@ -390,9 +401,12 @@ TYPE is a symbol, either 'favourite or 'boost."
(message "Toot URL copied to the clipboard.")))
(defun mastodon-toot--copy-toot-text ()
- "Copy text of toot at point."
+ "Copy text of toot at point.
+If the toot is a fave/boost notification, copy the text of the
+base toot."
(interactive)
- (let* ((toot (mastodon-tl--property 'toot-json)))
+ (let* ((toot (or (mastodon-tl--property 'base-toot)
+ (mastodon-tl--property 'toot-json))))
(kill-new (mastodon-tl--content toot))
(message "Toot content copied to the clipboard.")))
@@ -662,7 +676,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-params-alist
"media_ids[]"
@@ -1142,6 +1157,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 ()
@@ -1330,7 +1357,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."
@@ -1452,7 +1478,8 @@ a draft into the buffer."
(set (make-local-variable 'company-backends)
(add-to-list 'company-backends 'mastodon-toot-mentions))
(add-to-list 'company-backends 'mastodon-toot-tags))
- (company-mode-on))
+ (unless (bound-and-true-p corfu-mode) ; don't clash w corfu mode
+ (company-mode-on)))
(make-local-variable 'after-change-functions)
(push #'mastodon-toot--update-status-fields after-change-functions)
(mastodon-toot--refresh-attachments-display)
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 4097b27..921e3af 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -57,7 +57,6 @@
(autoload 'mastodon-tl--thread "mastodon-tl")
(autoload 'mastodon-tl--toggle-spoiler-text-in-toot "mastodon-tl")
(autoload 'mastodon-tl--update "mastodon-tl")
-(autoload 'mastodon-notifications--get "mastodon-notifications")
(autoload 'mastodon-profile--get-toot-author "mastodon-profile")
(autoload 'mastodon-profile--make-author-buffer "mastodon-profile")
(autoload 'mastodon-profile--show-user "mastodon-profile")
@@ -96,6 +95,10 @@
(autoload 'mastodon-tl--view-lists "mastodon-tl")
(autoload 'mastodon-toot--edit-toot-at-point "mastodon-toot")
(autoload 'mastodon-toot--view-toot-history "mastodon-tl")
+(autoload 'mastodon-tl--init-sync "mastodon-tl")
+(autoload 'mastodon-notifications--timeline "mastodon-notifications")
+
+(defvar mastodon-notifications--map)
(defgroup mastodon nil
"Interface with Mastodon."
@@ -160,7 +163,7 @@ Use. e.g. \"%c\" for your locale's date and time format."
(define-key map (kbd "F") #'mastodon-tl--get-federated-timeline)
(define-key map (kbd "H") #'mastodon-tl--get-home-timeline)
(define-key map (kbd "L") #'mastodon-tl--get-local-timeline)
- (define-key map (kbd "N") #'mastodon-notifications--get)
+ (define-key map (kbd "N") #'mastodon-notifications-get)
(define-key map (kbd "P") #'mastodon-profile--show-user)
(define-key map (kbd "T") #'mastodon-tl--thread)
;; navigation out of mastodon
@@ -268,6 +271,25 @@ If REPLY-JSON is the json of the toot being replied to."
(interactive)
(mastodon-toot--compose-buffer user reply-to-id reply-json))
+;;;###autoload
+(defun mastodon-notifications-get (&optional type buffer-name)
+ "Display NOTIFICATIONS in buffer.
+Optionally only print notifications of type TYPE, a string.
+BUFFER-NAME is added to \"*mastodon-\" to create the buffer name."
+ (interactive)
+ (let ((buffer (or (concat "*mastodon-" buffer-name "*")
+ "*mastodon-notifications*")))
+ (if (get-buffer buffer)
+ (progn (switch-to-buffer buffer)
+ (mastodon-tl--update))
+ (message "Loading your notifications...")
+ (mastodon-tl--init-sync
+ (or buffer-name "notifications")
+ "notifications"
+ 'mastodon-notifications--timeline
+ type)
+ (use-local-map mastodon-notifications--map))))
+
;; URL lookup: should be available even if `mastodon.el' not loaded:
;;;###autoload