aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/.dir-locals.el6
-rw-r--r--lisp/mastodon-discover.el1
-rw-r--r--lisp/mastodon-profile.el8
-rw-r--r--lisp/mastodon-search.el2
-rw-r--r--lisp/mastodon-tl.el19
-rw-r--r--lisp/mastodon-toot.el29
-rw-r--r--lisp/mastodon-views.el8
-rw-r--r--lisp/mastodon.el2
8 files changed, 59 insertions, 16 deletions
diff --git a/lisp/.dir-locals.el b/lisp/.dir-locals.el
index 44e84e5..bcb8ba5 100644
--- a/lisp/.dir-locals.el
+++ b/lisp/.dir-locals.el
@@ -1,5 +1,7 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
-;; setting this makes package-lint look in the main file for deps:
-((emacs-lisp-mode . ((package-lint-main-file . "mastodon.el"))))
+;; Preferred indentation style:
+((nil . ((indent-tabs-mode . nil)))
+ ;; setting this makes package-lint look in the main file for deps:
+ (emacs-lisp-mode . ((package-lint-main-file . "mastodon.el"))))
diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el
index 715954f..c34d85f 100644
--- a/lisp/mastodon-discover.el
+++ b/lisp/mastodon-discover.el
@@ -65,6 +65,7 @@
("t" "New toot" mastodon-toot)
("r" "Reply" mastodon-toot--reply)
("C" "Copy toot URL" mastodon-toot--copy-toot-url)
+ ("o" "Open toot URL" mastodon-toot--open-toot-url)
("d" "Delete (your) toot" mastodon-toot--delete-toot)
("D" "Delete and redraft (your) toot" mastodon-toot--delete-toot)
("e" "Edit (your) toot" mastodon-toot--edit-toot-at-point)
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 22dd586..fc90cf7 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -777,13 +777,13 @@ If the handle does not match a search return then retun NIL."
(let* ((handle (if (string= "@" (substring handle 0 1))
(substring handle 1 (length handle))
handle))
- (args `(("q" . ,handle)))
+ (args `(("q" . ,handle)
+ ("type" . "accounts")))
+ (result (mastodon-http--get-json (mastodon-http--api-search) args))
(matching-account (seq-remove
(lambda (x)
(not (string= (alist-get 'acct x) handle)))
- (mastodon-http--get-json
- (mastodon-http--api "accounts/search")
- args))))
+ (alist-get 'accounts result))))
(when (equal 1 (length matching-account))
(elt matching-account 0))))
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index ac32efb..d73bf9f 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -234,7 +234,7 @@ BUFFER, PARAMS, and UPDATE-FUN are for `mastodon-tl--buffer-spec'."
((equal type "statuses")
(mastodon-search--query query "hashtags")))))
-(defun mastodon-serach--query-accounts-followed (query)
+(defun mastodon-search--query-accounts-followed (query)
"Run an accounts search QUERY, limited to your followers."
(interactive "sSearch mastodon for: ")
(mastodon-search--query query "accounts" :following))
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index d4f3d04..d21edaf 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -190,6 +190,11 @@ re-load mastodon.el, or restart Emacs."
:type '(choice (const :tag "true" t)
(const :tag "false" nil)
(const :tag "follow server setting" server)))
+
+(defcustom mastodon-tl--tag-timeline-tags nil
+ "A list of up to four tags for use with `mastodon-tl--followed-tags-timeline'."
+ :type '(repeat string))
+
;;; VARIABLES
@@ -2144,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
@@ -2206,13 +2214,14 @@ PREFIX is sent to `mastodon-tl--get-tag-timeline', which see."
(mastodon-tl--get-tag-timeline prefix tag))))
(defun mastodon-tl--followed-tags-timeline (&optional prefix)
- "Open a timeline of all your followed tags.
+ "Open a timeline of multiple tags.
PREFIX is sent to `mastodon-tl--show-tag-timeline', which see.
-Note that the number of tags supported is undocumented, and from
-manual testing appears to be limited to a total of four tags."
+If `mastodon-tl--tag-timeline-tags' is set, use its tags, else
+fetch followed tags and load the first four of them."
(interactive "p")
(let* ((followed-tags-json (mastodon-tl--followed-tags))
- (tags (mastodon-tl--map-alist 'name followed-tags-json)))
+ (tags (or mastodon-tl--tag-timeline-tags
+ (mastodon-tl--map-alist 'name followed-tags-json))))
(mastodon-tl--show-tag-timeline prefix tags)))
(defun mastodon-tl--some-followed-tags-timeline (&optional prefix)
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 51990fd..462f925 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -517,6 +517,11 @@ base toot."
(kill-new url)
(message "Toot URL copied to the clipboard.")))
+(defun mastodon-toot--open-toot-url ()
+ "Open URL of toot at point."
+ (interactive)
+ (browse-url (mastodon-toot--toot-url)))
+
(defun mastodon-toot--toot-url ()
"Return the URL of the base toot at point."
(let* ((toot (or (mastodon-tl--property 'base-toot)
@@ -1225,6 +1230,30 @@ File is actually attached to the toot upon posting."
(mastodon-toot--upload-attached-media
(car (last mastodon-toot--media-attachments)))))
+(defun mastodon-toot--attachment-descriptions ()
+ "Return a list of image descriptions for current attachments."
+ (mapcar (lambda (a)
+ (alist-get :description a))
+ mastodon-toot--media-attachments))
+
+(defun mastodon-toot--attachment-from-desc (desc)
+ "Return an attachment based on its description DESC."
+ (car
+ (cl-member-if (lambda (x)
+ (rassoc desc x))
+ mastodon-toot--media-attachments)))
+
+(defun mastodon-toot--edit-media-description ()
+ "Prompt for an attachment, and update its description."
+ (interactive)
+ (let* ((descs (mastodon-toot--attachment-descriptions))
+ (choice (completing-read "Attachment: " descs nil :match))
+ (attachment (mastodon-toot--attachment-from-desc choice))
+ (desc-new (read-string "Description: " choice)))
+ (setf (alist-get :description attachment)
+ desc-new)
+ (mastodon-toot--refresh-attachments-display)))
+
(defun mastodon-toot--upload-attached-media (attachment)
"Upload a single ATTACHMENT using `mastodon-http--post-media-attachment'.
The item's id is added to `mastodon-toot--media-attachment-ids',
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 28f7c7c..8e04434 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -572,14 +572,14 @@ NO-CONFIRM means there is no ask or message, there is only do."
(let* ((toot (mastodon-tl--property 'scheduled-json :no-move))
(scheduled (alist-get 'scheduled_at toot)))
(let-alist (alist-get 'params toot)
+ ;; TODO: preserve polls
;; (poll (alist-get 'poll params))
- ;; (media (alist-get 'media_attachments toot)))
- (mastodon-toot--compose-buffer)
+ (mastodon-toot--compose-buffer nil .in_reply_to_id nil .text :edit)
(goto-char (point-max))
- (insert .text)
;; adopt properties from scheduled toot:
(mastodon-toot--set-toot-properties
- .in_reply_to_id .visibility .spoiler_text .language scheduled id))))))
+ .in_reply_to_id .visibility .spoiler_text .language
+ scheduled id (alist-get 'media_attachments toot)))))))
;;; FILTERS
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 93e802e..142eced 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -184,6 +184,7 @@ Use. e.g. \"%c\" for your locale's date and time format."
(define-key map (kbd "k") #'mastodon-toot--toggle-bookmark)
(define-key map (kbd "r") #'mastodon-toot--reply)
(define-key map (kbd "C") #'mastodon-toot--copy-toot-url)
+ (define-key map (kbd "o") #'mastodon-toot--open-toot-url)
(define-key map (kbd "v") #'mastodon-tl--poll-vote)
(define-key map (kbd "E") #'mastodon-toot--view-toot-edits)
(define-key map (kbd "T") #'mastodon-tl--thread)
@@ -225,6 +226,7 @@ Use. e.g. \"%c\" for your locale's date and time format."
(define-key map (kbd "G") #'mastodon-views--view-follow-suggestions)
(define-key map (kbd "X") #'mastodon-views--view-lists)
(define-key map (kbd "SPC") #'mastodon-tl--scroll-up-command)
+ (define-key map (kbd "z") #'bury-buffer)
map)
"Keymap for `mastodon-mode'.")