diff options
author | fap <fap-@users.noreply.github.com> | 2017-04-14 23:57:38 +0200 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-15 21:15:08 -0400 |
commit | cb985db2f37eabd76b9c2643387b4e94009b3f88 (patch) | |
tree | 0c15935d55454e7e1172d0d6739b0e1b8182ce50 /lisp/mastodon.el | |
parent | f731da950c0f5f461c0dc23bb1cdd990ca1f7992 (diff) |
Fixes #29 - Provide context menu for discover mode
* provides a `discover.el` context menu through mode-hook
* moves lambdas from keymap to functions so `discover-my-major` can pick
them up
Diffstat (limited to 'lisp/mastodon.el')
-rw-r--r-- | lisp/mastodon.el | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 5fd069d..8511d9e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -53,6 +53,12 @@ (defvar mastodon--api-version "v1") +(defcustom mastodon-mode-hook nil + "Hook run when entering Mastodon mode." + :type 'hook + :options '(provide-discover-context-menu) + :group 'mastodon) + ;; FIXME #25 (defun mastodon-version () "Message package version." @@ -88,15 +94,37 @@ "Major mode for Mastodon, the federated microblogging network." :group 'mastodon (let ((map mastodon-mode-map)) - (define-key map (kbd "F") (lambda () (interactive) (mastodon-tl--get "public"))) - (define-key map (kbd "H") (lambda () (interactive) (mastodon-tl--get "home"))) - (define-key map (kbd "L") (lambda () (interactive) (mastodon-tl--get "public?local=true"))) + (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-toot) (define-key map (kbd "q") #'kill-this-buffer) (define-key map (kbd "Q") #'kill-buffer-and-window) - (define-key map (kbd "T") (lambda () (interactive) - (let ((tag (read-string "Tag: "))) - (mastodon-tl--get (concat "tag/" tag))))))) + (define-key map (kbd "T") #'mastodon-tl--get-tag-timeline))) + +(defun provide-discover-context-menu () + "Provides a shortcut overview through Discover mode. +Press '?' to activate it." + (when (bound-and-true-p discover-mode) + (discover-add-context-menu + :bind "?" + :mode 'mastodon-mode + :mode-hook 'mastodon-mode-hook + :context-menu '(mastodon + (description "Mastodon feed viewer") + (actions + ("Feed switch" + ("F" "Open federated timeline" mastodon-tl--get-federated-timeline) + ("H" "Open home timeline" mastodon-tl--get-home-timeline) + ("L" "Open local timeline" mastodon-tl--get-local-timeline) + ("T" "Prompt for tag and open its timeline" mastodon-tl--get-tag-timeline)) + ("Toot" + ("n" "Switch to 'mastodon-toot' buffer" mastodon-toot)) + ("Quit" + ("q" "Quit mastodon buffer. Leave window open." kill-this-buffer) + ("Q" "Quit mastodon buffer and kill window." kill-buffer-and-window))))))) + +(add-hook 'mastodon-mode-hook 'provide-discover-context-menu t) (provide 'mastodon) ;;; mastodon.el ends here |