From f19f3bc2735bd78bb3150b8507b6f8949108cece Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 4 Jul 2024 13:17:13 +0200 Subject: replace persist with multisession --- lisp/mastodon.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index d0dddee..0747d53 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -7,7 +7,7 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.24 -;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4")) +;; Package-Requires: ((emacs "27.1") (request "0.3.0")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From 4e8d28616431d2ddedc01eb021d20718f1eb1877 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 6 Jul 2024 17:04:46 +0200 Subject: mastodon-use-emojify customize --- lisp/mastodon-toot.el | 5 +---- lisp/mastodon.el | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 694d9c0..496f334 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -158,10 +158,7 @@ If the original toot visibility is different we use the more restricted one." "Whether to enable your instance's custom emoji by default." :type 'boolean) -(defcustom mastodon-toot--emojify-in-compose-buffer t - "Whether to enable `emojify-mode' in the compose buffer. -We only attempt to enable it if its bound." - :type 'boolean) +(defvar mastodon-use-emojify) (defcustom mastodon-toot--proportional-fonts-compose nil "Nonnil to enable using proportional fonts in the compose buffer. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 0747d53..8a0aa91 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -144,6 +144,11 @@ The default value \"%F %T\" prints ISO8601-style YYYY-mm-dd HH:MM:SS. Use. e.g. \"%c\" for your locale's date and time format." :type 'string) +(defcustom mastodon-use-emojify nil + "Whether to use emojify.el to display emojis. +From version 28, Emacs can display emojis natively. But +currently, it doesn't seem to have a way to handle custom emoji, +while emojify,el has this feature and mastodon.el implements it.") (defun mastodon-kill-window () "Quit window and delete helper." @@ -464,7 +469,8 @@ Calls `mastodon-tl--get-buffer-type', which see." (defun mastodon-mode-hook-fun () "Function to add to `mastodon-mode-hook'." - (when (require 'emojify nil :noerror) + (when (and mastodon-use-emojify + (require 'emojify nil :noerror)) (emojify-mode t) (when mastodon-toot--enable-custom-instance-emoji (mastodon-toot--enable-custom-emoji))) -- cgit v1.2.3 From cf72fb5af09123663ef80dd373e44bc1e26233b0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 30 Jul 2024 16:04:34 +0200 Subject: bind fold toggle --- lisp/mastodon.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 8a0aa91..c771705 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -234,6 +234,7 @@ while emojify,el has this feature and mastodon.el implements it.") (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 "!") #'mastodon-tl--fold-post-toggle) (define-key map (kbd "z") #'bury-buffer) map) "Keymap for `mastodon-mode'.") -- cgit v1.2.3 From 5621b2df84802fca40ea5461308f601aeb9b361a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 2 Aug 2024 16:34:55 +0200 Subject: add underscores to user-like url regexes --- lisp/mastodon.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index c771705..cd32a2d 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -414,24 +414,27 @@ not, just browse the URL in the normal fashion." "Check if QUERY resembles a fediverse URL." ;; calqued off https://github.com/tuskyapp/Tusky/blob/c8fc2418b8f5458a817bba221d025b822225e130/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt ;; thx to Conny Duck! + ;; mastodon at least seems to allow only [a-z0-9_] for usernames, plus "." + ;; but not at beginning or end, see https://github.com/mastodon/mastodon/issues/6830 + ;; objects may have - in them (let* ((uri-parsed (url-generic-parse-url query)) (query (url-filename uri-parsed))) (save-match-data (or (string-match "^/@[^/]+$" query) (string-match "^/@[^/]+/[[:digit:]]+$" query) - (string-match "^/user[s]?/@?[[:alnum:]]+$" query) ; @: pleroma or soapbox + (string-match "^/user[s]?/@?[[:alnum:]_]+$" query) ; @: pleroma or soapbox (string-match "^/notice/[[:alnum:]]+$" query) (string-match "^/objects/[-a-f0-9]+$" query) (string-match "^/notes/[a-z0-9]+$" query) (string-match "^/display/[-a-f0-9]+$" query) - (string-match "^/profile/[[:alpha:]]+$" query) - (string-match "^/p/[[:alpha:]]+/[[:digit:]]+$" query) - (string-match "^/[[:alpha:]]+$" query) - (string-match "^/u/[[:alpha:]]+$" query) - (string-match "^/c/[[:alnum:]]+$" query) + (string-match "^/profile/[[:alpha:]_]+$" query) + (string-match "^/p/[[:alpha:]_]+/[[:digit:]]+$" query) + (string-match "^/[[:alpha:]_]+$" query) + (string-match "^/u/[[:alpha:]_]+$" query) + (string-match "^/c/[[:alnum:]_]+$" query) (string-match "^/post/[[:digit:]]+$" query) (string-match "^/comment/[[:digit:]]+$" query) ; lemmy - (string-match "^/user[s]?/[[:alnum:]]+/statuses/[[:digit:]]+$" query) ; hometown + (string-match "^/user[s]?/[[:alnum:]_]+/statuses/[[:digit:]]+$" query) ; hometown (string-match "^/notes/[[:alnum:]]+$" query))))) ; misskey post (defun mastodon-live-buffers () -- cgit v1.2.3 From 46b66e332a95096773c952598c363df5e0091d53 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 2 Aug 2024 16:50:16 +0200 Subject: commentary --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index cd32a2d..41b6fbe 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -32,8 +32,8 @@ ;; mastodon.el is a client for fediverse services that implement the Mastodon ;; API. See . -;; See the readme file at https://codeberg.org/martianh/mastodon.el for set up -;; and usage details. +;; For set up and usage details, see the Info documentation, or the readme +;; file at https://codeberg.org/martianh/mastodon.el. ;;; Code: (require 'cl-lib) ; for `cl-some' call in mastodon -- cgit v1.2.3 From 49261b91b075b9ee77c96bbd04fa05043d29d28a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 4 Aug 2024 09:39:04 +0200 Subject: Revert "replace persist with multisession" This reverts commit f19f3bc2735bd78bb3150b8507b6f8949108cece. --- lisp/mastodon-profile.el | 19 ++++++++----------- lisp/mastodon-toot.el | 4 +--- lisp/mastodon.el | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index cd1978f..de16b7d 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -35,6 +35,7 @@ ;;; Code: (require 'seq) (require 'cl-lib) +(require 'persist) (require 'parse-time) (require 'mastodon-http) (eval-when-compile @@ -124,8 +125,8 @@ It contains details of the current user's account.") map) "Keymap for `mastodon-profile-update-mode'.") -(define-multisession-variable mastodon-profile-account-settings nil - "An alist of account settings saved from the server. +(persist-defvar mastodon-profile-account-settings nil + "An alist of account settings saved from the server. Other clients can change these settings on the server at any time, so this list is not the canonical source for settings. It is updated on entering mastodon mode and on toggle any setting it @@ -364,16 +365,13 @@ SOURCE means that the preference is in the `source' part of the account JSON." (defun mastodon-profile--get-pref (pref) "Return PREF from `mastodon-profile-account-settings'." - (plist-get (multisession-value mastodon-profile-account-settings) - pref)) + (plist-get mastodon-profile-account-settings pref)) (defun mastodon-profile--update-preference-plist (pref val) "Set local account preference plist preference PREF to VAL. This is done after changing the setting on the server." - (setf (multisession-value mastodon-profile-account-settings) - (plist-put - (multisession-value mastodon-profile-account-settings) - pref val))) + (setq mastodon-profile-account-settings + (plist-put mastodon-profile-account-settings pref val))) ;; used in toot.el (defun mastodon-profile--fetch-server-account-settings-maybe () @@ -386,8 +384,7 @@ Only do so if `mastodon-profile-account-settings' is nil." Store the values in `mastodon-profile-account-settings'. Run in `mastodon-mode-hook'. If NO-FORCE, only fetch if `mastodon-profile-account-settings' is nil." - (unless (and no-force - (multisession-value mastodon-profile-account-settings)) + (unless (and no-force mastodon-profile-account-settings) (let ((keys '(locked discoverable display_name bot)) (source-keys '(privacy sensitive language))) (mapc (lambda (k) @@ -405,7 +402,7 @@ If NO-FORCE, only fetch if `mastodon-profile-account-settings' is nil." ;; TODO: remove now redundant vars, replace with fetchers from the plist (setq mastodon-toot--visibility (mastodon-profile--get-pref 'privacy) mastodon-toot--content-nsfw (mastodon-profile--get-pref 'sensitive)) - (multisession-value mastodon-profile-account-settings)))) + mastodon-profile-account-settings))) (defun mastodon-profile--account-locked-toggle () "Toggle the locked status of your account. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 1269516..6387bea 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1951,9 +1951,7 @@ EDIT means we are editing an existing toot, not composing a new one." (mastodon-toot-mode t) ;; set visibility: (setq mastodon-toot--visibility - (or (plist-get - (multisession-value mastodon-profile-account-settings) - 'privacy) + (or (plist-get mastodon-profile-account-settings 'privacy) ;; use toot visibility setting from the server: (mastodon-profile--get-source-value 'privacy) "public")) ; fallback diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 41b6fbe..82a2491 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -7,7 +7,7 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.24 -;; Package-Requires: ((emacs "27.1") (request "0.3.0")) +;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3