aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon.el
diff options
context:
space:
mode:
authorH Durer <h.duerer@gmail.com>2018-03-10 16:43:54 +0000
committerJohnson Denen <johnson.denen@gmail.com>2018-08-10 22:20:04 -0400
commitcb37df4cb3ddf8839c3b44db565a18c86e65705c (patch)
tree1e0d0a05f3e9ef95c1c8bfe26d54e65cfa634a93 /lisp/mastodon.el
parent12b4620c34a490b324e08d8bb56f77b2ec926f59 (diff)
Some small tweaks to our keymap handling. (#183)
- Use special mode which sets up a sensible base keymap. - Define the keymap just once so that users can tweak it as they wish without us messing with that on each invocation of mastodon-mode.
Diffstat (limited to 'lisp/mastodon.el')
-rw-r--r--lisp/mastodon.el54
1 files changed, 30 insertions, 24 deletions
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 16bb43f..290c9ce 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -32,6 +32,7 @@
;;; Code:
(declare-function discover-add-context-menu "discover")
(declare-function emojify-mode "emojify")
+(autoload 'special-mode "simple")
(autoload 'mastodon-tl--get-federated-timeline "mastodon-tl")
(autoload 'mastodon-tl--get-home-timeline "mastodon-tl")
(autoload 'mastodon-tl--get-local-timeline "mastodon-tl")
@@ -68,7 +69,33 @@ Use. e.g. \"%c\" for your locale's date and time format."
:type 'string)
(defvar mastodon-mode-map
- (make-sparse-keymap)
+ (let ((map (make-sparse-keymap)))
+ ;; Navigation
+ (define-key map (kbd "j") #'mastodon-tl--goto-next-toot)
+ (define-key map (kbd "k") #'mastodon-tl--goto-prev-toot)
+ (define-key map [?\t] #'mastodon-tl--next-tab-item)
+ (define-key map [backtab] #'mastodon-tl--previous-tab-item)
+ (define-key map [?\S-\t] #'mastodon-tl--previous-tab-item)
+ (define-key map [?\M-\t] #'mastodon-tl--previous-tab-item)
+ ;; Navigating to other buffers:
+ (define-key map (kbd "N") #'mastodon-notifications--get)
+ (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 "t") #'mastodon-tl--thread)
+ (define-key map (kbd "T") #'mastodon-tl--get-tag-timeline)
+ (define-key map (kbd "q") #'kill-this-buffer)
+ (define-key map (kbd "Q") #'kill-buffer-and-window)
+ ;; Actions
+ (define-key map (kbd "c") #'mastodon-tl--toggle-spoiler-text-in-toot)
+ (define-key map (kbd "g") #'undefined) ;; override special mode binding
+ (define-key map (kbd "n") #'mastodon-toot)
+ (define-key map (kbd "r") #'mastodon-toot--reply)
+ (define-key map (kbd "u") #'mastodon-tl--update)
+ (define-key map (kbd "b") #'mastodon-toot--toggle-boost)
+ (define-key map (kbd "f") #'mastodon-toot--toggle-favourite)
+ ;; Finally, return the map:
+ map)
"Keymap for `mastodon-mode'.")
(defcustom mastodon-mode-hook nil
@@ -117,31 +144,10 @@ If REPLY-TO-ID is non-nil, attach new toot to a conversation."
(when (require 'emojify nil :noerror)
(emojify-mode t))))
-(define-derived-mode mastodon-mode nil "Mastodon"
+(define-derived-mode mastodon-mode special-mode "Mastodon"
"Major mode for Mastodon, the federated microblogging network."
:group 'mastodon
- (let ((map mastodon-mode-map))
- (define-key map (kbd "c") #'mastodon-tl--toggle-spoiler-text-in-toot)
- (define-key map (kbd "b") #'mastodon-toot--toggle-boost)
- (define-key map (kbd "f") #'mastodon-toot--toggle-favourite)
- (define-key map (kbd "F") #'mastodon-tl--get-federated-timeline)
- (define-key map (kbd "H") #'mastodon-tl--get-home-timeline)
- (define-key map (kbd "j") #'mastodon-tl--goto-next-toot)
- (define-key map (kbd "k") #'mastodon-tl--goto-prev-toot)
- (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 "r") #'mastodon-toot--reply)
- (define-key map (kbd "t") #'mastodon-tl--thread)
- (define-key map (kbd "T") #'mastodon-tl--get-tag-timeline)
- (define-key map (kbd "u") #'mastodon-tl--update)
- (define-key map [?\t] #'mastodon-tl--next-tab-item)
- (define-key map [backtab] #'mastodon-tl--previous-tab-item)
- (define-key map [?\S-\t] #'mastodon-tl--previous-tab-item)
- (define-key map [?\M-\t] #'mastodon-tl--previous-tab-item)
- (define-key map (kbd "N") #'mastodon-notifications--get)
- ))
+ (read-only-mode 1))
(with-eval-after-load 'mastodon
(when (require 'discover nil :noerror)