From e9e09b44cf2e194f317073f7db192e6eb79759e7 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Tue, 28 Dec 2021 20:21:49 +0530 Subject: update README update the README to inform about the new changes. --- README.org | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 88e8c41..22b2531 100644 --- a/README.org +++ b/README.org @@ -75,10 +75,6 @@ This repo also incorporates fixes for two bugs that were never merged into the u - https://github.com/jdenen/mastodon.el/issues/227 (and https://github.com/jdenen/mastodon.el/issues/234) - https://github.com/jdenen/mastodon.el/issues/228 -** 2FA - -It looks like 2-factor auth was never completed in the original repo. It's not a priority for me, auth ain't my thing. If you want to hack on it, its on the develop branch in the original repo. - ** contributing Contributions are welcome. Registration is disabled by default on the gitea instance, but if you are interested, get in touch with me on mastodon: @@ -147,21 +143,31 @@ Or, with =use-package=: #+END_SRC ** Usage -*** 2 Factor Auth -2FA is not supported yet. It is in the [[https://github.com/jdenen/mastodon.el/milestone/2][plans]] for the =1.0.0= release. - -If you have 2FA enabled and try to use mastodon.el, your Emacs client will hang until you `C-g` your way out. *** Instance -Set =mastodon-instance-url= in your =.emacs= or =customize=. Defaults to the [[https://mastodon.social][flagship]]. +You need to set 2 variables in your init file to get started: + +1. mastodon-instance-url +2. mastodon-active-user + +(see their doc strings for details). For example If you want to post +toots as "example_user@social.instance.org", then put this in your init +file: #+BEGIN_SRC emacs-lisp - (setq mastodon-instance-url "https://my.instance.url") + (setq mastodon-instance-url "https://social.instance.org" + mastodon-active-user "example_user") #+END_SRC -There is an option to have your user credentials (email address and password) saved to disk so you don't have to re-enter them on every restart. -The default is not to do this because if not properly configured it would save these unencrypted which is not a good default to have. -Customize the variable =mastodon-auth-source-file= if you want to enable this feature. +Then *restart* Emacs and run =M-x mastodon=. Make sure you are connected +to internet before you do this. If you have multiple mastodon accounts +you can activate one at a time by changing those two variables and +restarting Emacs. + +If you have been using mastodon.el before this change and the above +steps do not work it's advisable that you delete the old file specified +by =mastodon-client--token-file= and restart Emacs and follow the steps +again. *** Timelines -- cgit v1.2.3 From 51378f17d14ff877dfea29e496be64383b65da93 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 13:03:47 +0100 Subject: buffer local keymap, error handling, make filters nicer - separate goto-next/prev-filter commands - we use properties toot-id and byline so the navigation works, calqued on - goto-prev/next-toot - error handle no word or context supplied - reload filters view on create or delete --- README.org | 3 +- lisp/mastodon-tl.el | 115 ++++++++++++++++++++++++++++++++++++---------------- lisp/mastodon.el | 2 + 3 files changed, 83 insertions(+), 37 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index a2ed08f..fff0b09 100644 --- a/README.org +++ b/README.org @@ -29,12 +29,13 @@ It adds the following features: | =D= | delete and redraft toot at point, preserving reply/CW/visibility | | =W=, =M=, =B= | (un)follow, (un)mute, (un)block author of toot at point | | =k=, =K= | toggle bookmark of toot at point, view bookmarked toots | +| =L= | view, create, and delete filters | | | display polls and vote on them | | | images are links to the full image, can be zoomed/rotated/saved (see image keymap) | | | images scale properly | | | toot visibility (direct, followers only) icon appears in toot bylines | | | display toot's number of favorites, boosts and replies | -| | play gifs and videos (requires =mpv= to be installed) | +| | play gifs and videos (requires =mpv= to be installed) | | | customize option to cache images | | Toots: | | | | mention booster in replies by default | diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d69cb1a..0423e2e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -64,6 +64,8 @@ "Display NOTIFICATIONS in buffer." t) ; interactive (autoload 'mastodon-search--insert-users-propertized "mastodon-search") (autoload 'mastodon-search--get-user-info "mastodon-search") +(autoload 'mastodon-http--delete "mastodon-http") + (when (require 'mpv nil :no-error) (declare-function mpv-start "mpv")) (defvar mastodon-instance-url) @@ -171,6 +173,14 @@ types of mastodon links and not just shr.el-generated ones.") (defvar mastodon-tl--view-filters-keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "d") 'mastodon-tl--delete-filter) + (define-key map (kbd "c") 'mastodon-tl--create-filter) + (define-key map (kbd "n") 'mastodon-tl--goto-next-filter) + (define-key map (kbd "p") 'mastodon-tl--goto-prev-filter) + (define-key map (kbd "TAB") 'mastodon-tl--goto-next-filter) + (define-key map (kbd "g") 'mastodon-tl--view-filters) + (define-key map (kbd "t") 'mastodon-toot) + (define-key map (kbd "q") 'kill-current-buffer) + (define-key map (kbd "Q") 'kill-buffer-and-window) (keymap-canonicalize map)) "Keymap for viewing filters.") @@ -1102,18 +1112,25 @@ Prompt for a context, must be a list containting at least one of \"home\", (interactive) (let* ((url (mastodon-http--api "filters")) (word (read-string - (format "Word to filter (%s): " (current-word)) - nil nil (current-word))) - (contexts (completing-read-multiple - "Contexts to filter [TAB for options]:" - '("home" "notifications" "public" "thread"))) + (format "Word(s) to filter (%s): " (or (current-word) "")) + nil nil (or (current-word) ""))) + (contexts + (if (equal "" word) + (error "You must select at least one word for a filter") + (completing-read-multiple + "Contexts to filter [TAB for options]:" + '("home" "notifications" "public" "thread") + nil ; no predicate + t))) ; require-match, as context is mandatory (contexts-processed - (mapcar (lambda (x) - (cons "context[]" x)) - contexts)) + (if (equal nil contexts) + (error "You must select at least one context for a filter") + (mapcar (lambda (x) + (cons "context[]" x)) + contexts))) (response (mastodon-http--post url (push - `("phrase" . ,word) - contexts-processed) + `("phrase" . ,word) + contexts-processed) nil))) (mastodon-http--triage response (lambda () @@ -1123,28 +1140,39 @@ Prompt for a context, must be a list containting at least one of \"home\", (mastodon-tl--view-filters)))))) (defun mastodon-tl--view-filters () - "" + "View the user's filters in a new buffer." (interactive) - (let ((url (mastodon-http--api "filters"))) - (mastodon-tl--init-sync "*mastodon-filters*" - "filters" - 'mastodon-tl--insert-filters) - (mastodon-tl--goto-next-toot))) + (mastodon-tl--init-sync "filters" + "filters" + 'mastodon-tl--insert-filters) + (use-local-map mastodon-tl--view-filters-keymap) + (mastodon-tl--goto-next-filter)) (defun mastodon-tl--insert-filters (json) - "" + "Insert the user's current filters. +JSON is what is returned by by the server." (insert (mastodon-tl--set-face (concat "\n ------------\n" " CURRENT FILTERS\n" " ------------\n\n") - 'success)) - (mapc (lambda (x) - (mastodon-tl--insert-filter-string x) - (insert "\n\n")) - json)) + 'success) + (mastodon-tl--set-face + "[c - create filter\n d - delete filter at point\n n/p - go to next/prev filter]\n\n" + 'font-lock-comment-face)) + (if (not (equal json '[])) + (progn + (mapc (lambda (x) + (mastodon-tl--insert-filter-string x) + (insert "\n\n")) + json)) + (insert (propertize + "Looks like you have no filters for now." + 'face font-lock-comment-face + 'byline t + 'toot-id "0")))) ; so point can move here when no filters (defun mastodon-tl--insert-filter-string (filter) - "" + "Insert a single FILTER." (let* ((phrase (alist-get 'phrase filter)) (contexts (alist-get 'context filter)) (id (alist-get 'id filter)) @@ -1152,23 +1180,38 @@ Prompt for a context, must be a list containting at least one of \"home\", (mapconcat #'identity contexts ", ")))) (insert (propertize filter-string - 'toot-id id ;for goto-next-toot compat + 'toot-id id ;for goto-next-filter compat 'phrase phrase - 'help-echo "d to delete filter at point, n/p to go to next/prev filter." - 'keymap mastodon-tl--view-filters-keymap - 'byline t)))) ;for goto-next-toot compat + ;'help-echo "n/p to go to next/prev filter, c to create new filter, d to delete filter at point." + ;'keymap mastodon-tl--view-filters-keymap + 'byline t)))) ;for goto-next-filter compat (defun mastodon-tl--delete-filter () - "" + "Delete filter at point." (interactive) - (let* ((filter-id (mastodon-tl--property 'toot-id)) - (phrase (mastodon-tl--property 'phrase)) - (url (mastodon-http--api - (format "filters/%s" filter-id))) - (response (mastodon-http--delete url))) - (mastodon-http--triage response (lambda () - (message "Filter for \"%s\" deleted!" phrase) - (mastodon-tl--view-filters))))) + (let* ((filter-id (get-text-property (point) 'toot-id)) + (phrase (get-text-property (point) 'phrase)) + (url (mastodon-http--api + (format "filters/%s" filter-id)))) + (if (equal nil filter-id) + (error "No filter at point?") + (when (y-or-n-p (format "Delete this filter? "))) + (let ((response (mastodon-http--delete url))) + (mastodon-http--triage response (lambda () + (mastodon-tl--view-filters) + (message "Filter for \"%s\" deleted!" phrase))))))) + +(defun mastodon-tl--goto-next-filter () + "Jump to next filter." + (interactive) + (mastodon-tl--goto-toot-pos 'next-single-property-change + 'next-line)) + +(defun mastodon-tl--goto-prev-filter () + "Jump to previous filter." + (interactive) + (mastodon-tl--goto-toot-pos 'previous-single-property-change + 'previous-line)) (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a52bf41..180674e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -85,6 +85,7 @@ (autoload 'mastodon-tl--poll-vote "mastodon-http") ;; (autoload 'mastodon-toot--delete-and-redraft-toot "mastodon-toot") (autoload 'mastodon-profile--view-bookmarks "mastodon-profile") +(autoload 'mastoton-tl--view-filters "mastodon-tl") ;; (autoload 'mastodon-toot--bookmark-toot-toggle "mastodon-toot") (defgroup mastodon nil @@ -164,6 +165,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "v") #'mastodon-tl--poll-vote) (define-key map (kbd "k") #'mastodon-toot--bookmark-toot-toggle) (define-key map (kbd "K") #'mastodon-profile--view-bookmarks) + (define-key map (kbd "L") #'mastodon-tl--view-filters) map) "Keymap for `mastodon-mode'.") -- cgit v1.2.3 From d900cb6e73694be093f937e00f2c31486a130d16 Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 16 Feb 2022 12:06:02 +0100 Subject: readme update for foll reqs, foll suggests, filters readme follow req reject binding --- README.org | 88 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index fff0b09..a7a8407 100644 --- a/README.org +++ b/README.org @@ -6,50 +6,50 @@ This is a fork of of the great but seemingly dormant https://github.com/jdenen/m It adds the following features: -| Profiles: | | -| | display profile metadata fields | -| | display pinned toots first | -| | display relationship (follows you/followed by you) | -| | display toots/follows/followers counts | -| | links/tags/mentions in profile bios are active links | -| | show a lock icon for locked accounts | -| =R=, =C-c a=, =C-c r= | view/accept/reject follow requests | -| =V= | view your favorited toots | -| =i= | toggle pinning of toots | -| =S-C-P= | jump to your profile | -| =U= | update your profile bio note | -| =O= | jump to own profile | -| Notifications: | | -| | follow requests now also appear in notifications | -| =a=, =r= | accept/reject follow request | -| | notifications for when a user posts (=mastodon-tl--enable-notify-user-posts=) | -| Timelines: | | -| =C= | copy url of toot at point | -| =d= | delete your toot at point, and reload current timeline | -| =D= | delete and redraft toot at point, preserving reply/CW/visibility | -| =W=, =M=, =B= | (un)follow, (un)mute, (un)block author of toot at point | -| =k=, =K= | toggle bookmark of toot at point, view bookmarked toots | -| =L= | view, create, and delete filters | -| | display polls and vote on them | -| | images are links to the full image, can be zoomed/rotated/saved (see image keymap) | -| | images scale properly | -| | toot visibility (direct, followers only) icon appears in toot bylines | -| | display toot's number of favorites, boosts and replies | -| | play gifs and videos (requires =mpv= to be installed) | -| | customize option to cache images | -| Toots: | | -| | mention booster in replies by default | -| | replies preserve visibility status/CW of original toot | -| | autocompletion of user mentions, via =company-mode= (must be installed to work) | -| =C-c C-a= | media uploads, asynchronous | -| | media upload previews displayed in toot compose buffer | -| =C-c C-n= | and sensitive media/nsfw flag | -| =C-c C-e= | add emoji (if =emojify= installed) | -| | download and use your instance's custom emoji | -| | server's maximum toot length shown in toot compose buffer | -| Search: | | -| =S= | search (posts, users, tags) (NB: only posts you have interacted with are searched) | -| | | +| Profiles: | | +| | display profile metadata fields | +| | display pinned toots first | +| | display relationship (follows you/followed by you) | +| | display toots/follows/followers counts | +| | links/tags/mentions in profile bios are active links | +| | show a lock icon for locked accounts | +| =G= | view follow suggestions | +| =R=, =a=, =r= | view/accept/reject follow requests | +| =V= | view your favorited toots | +| =i= | toggle pinning of toots | +| =U= | update your profile bio note | +| =O= | jump to own profile | +| Notifications: | | +| | follow requests now also appear in notifications | +| =a=, =j= | accept/reject follow request | +| | notifications for when a user posts (=mastodon-tl--enable-notify-user-posts=) | +| Timelines: | | +| =C= | copy url of toot at point | +| =d= | delete your toot at point, and reload current timeline | +| =D= | delete and redraft toot at point, preserving reply/CW/visibility | +| =W=, =M=, =B= | (un)follow, (un)mute, (un)block author of toot at point | +| =k=, =K= | toggle bookmark of toot at point, view bookmarked toots | +| =I=, =c=, =d= | view, create, and delete filters | +| | display polls and vote on them | +| | images are links to the full image, can be zoomed/rotated/saved (see image keymap) | +| | images scale properly | +| | toot visibility (direct, followers only) icon appears in toot bylines | +| | display toot's number of favorites, boosts and replies | +| | play gifs and videos (requires =mpv= to be installed) | +| | customize option to cache images | +| Toots: | | +| | mention booster in replies by default | +| | replies preserve visibility status/CW of original toot | +| | autocompletion of user mentions, via =company-mode= (must be installed to work) | +| =C-c C-a= | media uploads, asynchronous | +| | media upload previews displayed in toot compose buffer | +| =C-c C-n= | and sensitive media/nsfw flag | +| =C-c C-e= | add emoji (if =emojify= installed) | +| | download and use your instance's custom emoji | +| | server's maximum toot length shown in toot compose buffer | +| Search: | | +| =S= | search (posts, users, tags) (NB: only posts you have interacted with are searched) | +| | | It also makes some small cosmetic changes to make timelines easier to read, and makes some functions asynchronous, based on https://github.com/ieure/mastodon.el. -- cgit v1.2.3 From 722fe98364621673c06b48a2ee3ccbc25cf0fcc4 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 14 Mar 2022 21:55:22 +0100 Subject: readme on translating toots, etc --- README.org | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index a7a8407..929f5ea 100644 --- a/README.org +++ b/README.org @@ -67,9 +67,26 @@ Works for federated, local, and home timelines and for notifications. It's prett To enable, it, add =(require 'mastodon-async)= to your =init.el=. Then you can view a timeline with one of the commands that begin with =mastodon-async--stream-=. +** translating toots + +You can translate toots with =mastodon-toot--translate-toot-text=. At the moment this requires [[https://codeberg.org/martianh/lingva.el][lingva.el]], a little interface I wrote to https://lingva.ml, to be installed to work. + +You could easily modify the simple function to use your emacs translator of choice (=google-translate=, =babel=, =go-translate=, etc.), you just need to fetch the toot's content with =(mastodon-tl--content toot)= and pass it to your translator function as its text argument. Here's what =mastodon-toot--translate-toot-text= looks like: + +#+begin_src emacs-lisp + (defun mastodon-toot--translate-toot-text () + "Translate text of toot at point. + Uses `lingva.el'." + (interactive) + (let* ((toot (mastodon-tl--property 'toot-json))) + (if toot + (lingva-translate nil (mastodon-tl--content toot)) + (message "No toot to translate?")))) +#+end_src + ** NB: dependency -This version depends on the library =request= (for uploading attachments). You can install it from MELPA, or https://github.com/tkf/emacs-request. +This version depends on the library =request= (for uploading attachments). If you installed =mastodon.el= from MELPA, it should be fine, else you can install it yourself from MELPA or https://github.com/tkf/emacs-request. ** NB: bugs @@ -83,7 +100,7 @@ It looks like 2-factor auth was never completed in the original repo. It's not a ** contributing -Contributions are welcome. Registration is disabled by default on the gitea instance, but if you are interested, get in touch with me on mastodon: +Contributions are welcome. Feel free to open an issue or get in touch with me on mastodon: [[https://todon.nl/@mousebot][@mousebot@todon.nl]] -- cgit v1.2.3