From 1da8ab0675928f84790bd684db28d0b7ee14dab8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 6 Nov 2023 11:52:30 +0100 Subject: add cmd to url-lookup with no fedi-like check --- lisp/mastodon.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index bb06d1b..6e05bd8 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -341,7 +341,7 @@ from the server and load anew." ;; URL lookup: should be available even if `mastodon.el' not loaded: ;;;###autoload -(defun mastodon-url-lookup (&optional query-url) +(defun mastodon-url-lookup (&optional query-url force) "If a URL resembles a mastodon link, try to load in `mastodon.el'. Does a WebFinger lookup. URL can be arg QUERY-URL, or URL at point, or provided by the user. @@ -352,7 +352,8 @@ not, just browse the URL in the normal fashion." (thing-at-point-url-at-point) (mastodon-tl--property 'shr-url :no-move) (read-string "Lookup URL: ")))) - (if (not (mastodon--fedi-url-p query)) + (if (and (not force) + (not (mastodon--fedi-url-p query))) ;; (shr-browse-url query) ; doesn't work (keep our shr keymap) (browse-url query) (message "Performing lookup...") @@ -374,6 +375,11 @@ not, just browse the URL in the normal fashion." (t (browse-url query))))))) +(defun mastodon-url-lookup-force () + "Call `mastodon-url-lookup' without checking if URL is fedi-like." + (interactive) + (mastodon-url-lookup nil :force)) + (defun mastodon--fedi-url-p (query) "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 -- cgit v1.2.3 From 138541647985aa408e9e15d018c23095af28fe08 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 23 Dec 2023 15:38:49 +0100 Subject: add RET binding for tl--thread --- 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 6e05bd8..acd1462 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -181,6 +181,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 "E") #'mastodon-toot--view-toot-edits) (define-key map (kbd "T") #'mastodon-tl--thread) + (define-key map (kbd "RET") #'mastodon-tl--thread) (define-key map (kbd "m") #'mastodon-tl--dm-user) (when (require 'lingva nil :no-error) (define-key map (kbd "a") #'mastodon-toot--translate-toot-text)) -- cgit v1.2.3 From 20b41bfa9512cc643c23b8e3d8062c8bebf0be79 Mon Sep 17 00:00:00 2001 From: Björn Bidar Date: Thu, 5 Oct 2023 21:24:08 +0300 Subject: Avoid error when there's only one window in a frame when closing window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use `(quit-window 'kill)` instead of `(kill-buffer-and-window)` to avoid error when there's only one window instead the frame: `kill-buffer-and-window: Attempt to delete minibuffer or sole ordinary window` Signed-off-by: Björn Bidar --- lisp/mastodon-discover.el | 4 +++- lisp/mastodon-profile.el | 7 ++++--- lisp/mastodon-toot.el | 3 ++- lisp/mastodon.el | 8 +++++++- 4 files changed, 16 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el index 5548b29..715954f 100644 --- a/lisp/mastodon-discover.el +++ b/lisp/mastodon-discover.el @@ -35,6 +35,8 @@ (declare-function discover-add-context-menu "discover") +(autoload 'mastodon-kill-window "mastodon") + (defun mastodon-discover () "Plug Mastodon functionality into `discover'." (interactive) @@ -115,7 +117,7 @@ ("C-c C-c" "Cycle profile views" mastodon-profile--account-view-cycle)) ("Quit" ("q" "Quit mastodon and bury buffer." kill-this-buffer) - ("Q" "Quit mastodon buffer and kill window." kill-buffer-and-window) + ("Q" "Quit mastodon buffer and kill window." mastodon--kill-window) ("M-C-q" "Quit mastodon and kill all buffers." mastodon-kill-all-buffers))))))) (provide 'mastodon-discover) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 0d93747..22dd586 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -50,6 +50,7 @@ (autoload 'mastodon-http--patch-json "mastodon-http") (autoload 'mastodon-http--post "mastodon-http.el") (autoload 'mastodon-http--triage "mastodon-http.el") +(autoload 'mastodon-kill-window "mastodon") (autoload 'mastodon-media--get-media-link-rendering "mastodon-media.el") (autoload 'mastodon-media--inline-images "mastodon-media.el") (autoload 'mastodon-mode "mastodon.el") @@ -294,7 +295,7 @@ NO-REBLOGS means do not display boosts in statuses." "Cancel updating user profile and kill buffer and window." (interactive) (when (y-or-n-p "Cancel updating your profile note?") - (kill-buffer-and-window))) + (mastodon-kill-window))) (defun mastodon-profile--note-remove-header () "Get the body of a toot from the current compose buffer." @@ -310,9 +311,9 @@ Ask for confirmation if length > 500 characters." (url (mastodon-http--api "accounts/update_credentials"))) (if (> (mastodon-toot--count-toot-chars note) 500) (when (y-or-n-p "Note is over mastodon's max for profile notes (500). Proceed?") - (kill-buffer-and-window) + (quit-window 'kill) (mastodon-profile--user-profile-send-updated-do url note)) - (kill-buffer-and-window) + (quit-window 'kill) (mastodon-profile--user-profile-send-updated-do url note)))) (defun mastodon-profile--user-profile-send-updated-do (url note) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index c96ee5b..c26db1e 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -64,6 +64,7 @@ (autoload 'mastodon-http--put "mastodon-http") (autoload 'mastodon-http--read-file-as-string "mastodon-http") (autoload 'mastodon-http--triage "mastodon-http") +(autoload 'mastodon-kill-window "mastodon") (autoload 'mastodon-profile--fetch-server-account-settings "mastodon-profile") (autoload 'mastodon-profile--fetch-server-account-settings-maybe "mastodon-profile") (autoload 'mastodon-profile--get-source-pref "mastodon-profile") @@ -682,7 +683,7 @@ CANCEL means the toot was not sent, so we save the toot text as a draft." mastodon-toot-draft-toots-list :test 'equal))) ;; prevent some weird bug when cancelling a non-empty toot: (delete #'mastodon-toot--save-toot-text after-change-functions) - (kill-buffer-and-window) + (quit-window 'kill) (mastodon-toot--restore-previous-window-config prev-window-config))) (defun mastodon-toot--cancel () diff --git a/lisp/mastodon.el b/lisp/mastodon.el index acd1462..bac4d67 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -142,6 +142,12 @@ 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) + +(defun mastodon-kill-window () + "Quit window and delete helper." + (interactive) + (quit-window 'kill)) + (defvar mastodon-mode-map (let ((map (make-sparse-keymap))) ;; navigation inside a timeline @@ -169,7 +175,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "/") #'mastodon-switch-to-buffer) ;; quitting mastodon (define-key map (kbd "q") #'kill-current-buffer) - (define-key map (kbd "Q") #'kill-buffer-and-window) + (define-key map (kbd "Q") #'mastodon-kill-window) (define-key map (kbd "M-C-q") #'mastodon-kill-all-buffers) ;; toot actions (define-key map (kbd "c") #'mastodon-tl--toggle-spoiler-text-in-toot) -- cgit v1.2.3 From fa73817c225783f09e59f71d8724c62352c36776 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Tue, 16 Jan 2024 13:54:26 +0000 Subject: Add 'z' binding to bury the current buffer --- 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 bac4d67..51fe6a5 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -225,6 +225,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'.") -- cgit v1.2.3 From f0137a0ad60df4ac8b78020f155e33f733493027 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Tue, 16 Jan 2024 14:00:34 +0000 Subject: Add 'o' binding to open the current toot in a browser --- lisp/mastodon-discover.el | 1 + lisp/mastodon-toot.el | 5 +++++ lisp/mastodon.el | 1 + 3 files changed, 7 insertions(+) (limited to 'lisp/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-toot.el b/lisp/mastodon-toot.el index 6febec7..bffa20e 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) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 51fe6a5..9dac1d1 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) -- cgit v1.2.3