aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-14 15:23:24 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-14 15:51:09 -0400
commit48fcd12d9d753e99e7d22ba3f1e6bc2173ac482e (patch)
tree9fcf030275669fe78d52d4809bb0f1809001b892 /lisp
parentda84326539ef2e880ade0ab8dc033102d90c048e (diff)
Add major mode
- `mastodon' opens home buffer in new major mode - `F' switches to your federated timeline - `H' switches to your home timeline - `L' switches to your local timeline - `n' opens a `mastodon-toot' buffer - `q' quits by killing the buffer - `Q' quits by killing both the buffer and the window - `T' prompts your for a tag and then opens its timeline
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-tl.el3
-rw-r--r--lisp/mastodon.el20
2 files changed, 21 insertions, 2 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index e782631..2d2a588 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -88,7 +88,8 @@
(let* ((url (mastodon--api-for (concat "timelines/" timeline)))
(tl-buff (concat "*mastodon-" timeline "*"))
(tl-json (mastodon-http--get-json url)))
- (mastodon-tl--render-timeline tl-buff tl-json)))
+ (mastodon-tl--render-timeline tl-buff tl-json)
+ (mastodon-mode)))
(provide 'mastodon-tl)
;;; mastodon-tl.el ends here
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 1bd1a66..abbff09 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -47,6 +47,10 @@
:group 'mastodon
:type 'file)
+(defvar mastodon-mode-map
+ (make-sparse-keymap)
+ "Keymap for `mastodon-mode'.")
+
(defvar mastodon--api-version "v1")
;; FIXME #25
@@ -62,7 +66,7 @@
(defun mastodon ()
(interactive)
(require 'mastodon-tl)
- (mastodon-tl--get "home"))
+ (mastodon-home))
;;;###autoload
(defun mastodon-toot ()
@@ -80,5 +84,19 @@
(progn
(mastodon--store-client-id-and-secret)))
+(define-derived-mode mastodon-mode nil "Mastodon"
+ "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 "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)))))))
+
(provide 'mastodon)
;;; mastodon.el ends here