aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authorclarkenciel <clarkenciel@gmail.com>2017-04-27 20:57:28 -0700
committerJohnson Denen <johnson.denen@gmail.com>2017-04-28 19:57:23 -0400
commit6fc589020b0358cb7504f9252a22adeae812cb88 (patch)
tree5587e9a5139e0a3a8fa31384e2d9c2fa258c1859 /lisp/mastodon-toot.el
parent9c816bcecf46554f29600590f72fafc0ed001d6d (diff)
making keybinds and names nice
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el29
1 files changed, 24 insertions, 5 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 5131191..135c57c 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -108,7 +108,7 @@ Set `mastodon-toot--content-warning' to nil."
(goto-char 0)
(re-search-forward re)
(re-search-forward re) ; end of the docs
- (buffer-substring (+ 2 (point)) (length (buffer-string))))))
+ (buffer-substring (+ 2 (point)) (+ 1 (length (buffer-string)))))))
(defun mastodon-toot--send ()
"Kill new-toot buffer/window and POST contents to the Mastodon instance."
@@ -143,15 +143,34 @@ Set `mastodon-toot--content-warning' to nil."
(setq mastodon-toot--content-warning
(not mastodon-toot--content-warning)))
+;; we'll need to revisit this if the binds get
+;; more diverse than two-chord bindings
(defun mastodon-toot--get-mode-kbinds ()
"Get a list of the keybindings in the mastodon-toot-mode."
- (remove-if-not (lambda (x) (listp x))
- (cadr mastodon-toot-mode-map)))
+ (let* ((binds (copy-tree mastodon-toot-mode-map))
+ (prefix (caadr binds))
+ (bindings (remove-if-not (lambda (x) (listp x))
+ (cadr binds))))
+ (mapcar (lambda (b)
+ (progn
+ (setf (car b) (vector prefix (car b)))
+ b))
+ bindings)))
+
+(defun mastodon-toot--format-kbind-command (cmd)
+ "Format CMD to be more readable.
+e.g. mastodon-toot--send -> Send."
+ (let* ((str (symbol-name cmd))
+ (re "--\\(.*\\)$")
+ (str2 (save-match-data
+ (string-match re str)
+ (match-string 1 str))))
+ (capitalize (replace-regexp-in-string "-" " " str2))))
(defun mastodon-toot--format-kbind (kbind)
"Format a single keybinding, KBIND, for display in documentation."
- (let ((key (help-key-description (vector (car kbind)) nil))
- (command (cdr kbind)))
+ (let ((key (help-key-description (car kbind) nil))
+ (command (mastodon-toot--format-kbind-command (cdr kbind))))
(format "\t%s - %s" key command)))
(defun mastodon-toot--format-kbinds (kbinds)