From 075fc0eb2c4f4fb356339ed27370ea477a7b47e4 Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Mon, 24 Apr 2017 20:49:41 -0400 Subject: Fixed #70, added mastodon-toot--unfavorite --- lisp/mastodon-toot.el | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 166f95b..7d5a362 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -41,9 +41,21 @@ (defun mastodon-toot--action-success (marker) "Insert MARKER with 'success face in byline." (let ((inhibit-read-only t)) + (move-beginning-of-line '()) + (mastodon-tl--goto-next-toot) (insert (format "(%s) " - (propertize marker 'face 'success))) - (mastodon-tl--goto-prev-toot))) + (propertize marker 'face 'success))))) + +(defun mastodon-toot--action-success-undo (marker) + "Remove MARKER from byline." + (let ((inhibit-read-only t) + (start (progn (move-beginning-of-line '()) + (point))) + (end (progn (move-end-of-line '()) + (point)))) + (replace-regexp (format "(%s) " marker) "" '() start end) + (move-beginning-of-line '()) + (mastodon-tl--goto-next-toot))) (defun mastodon-toot--action (action callback) "Take ACTION on toot at point, then execute CALLBACK." @@ -103,6 +115,14 @@ Set `mastodon-toot--content-warning' to nil." (mastodon-toot--action "favourite" callback) (message (format "Favourited #%s" id)))) +(defun mastodon-toot--unfavourite () + "Favourite toot at `point'." + (interactive) + (let ((callback (lambda () ( mastodon-toot--action-success-undo "F"))) + (id (mastodon-tl--property 'toot-id))) + (mastodon-toot--action "unfavourite" callback) + (message (format "unfavourited #%s" id)))) + (defun mastodon-toot--reply () "Reply to toot at `point'." (interactive) -- cgit v1.2.3 From 91020494acfe590f19c9e2510be2377f2d69fdfe Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Mon, 24 Apr 2017 21:12:02 -0400 Subject: #70 all tabs to spaces --- lisp/mastodon-toot.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7d5a362..8197ba5 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -49,10 +49,10 @@ (defun mastodon-toot--action-success-undo (marker) "Remove MARKER from byline." (let ((inhibit-read-only t) - (start (progn (move-beginning-of-line '()) - (point))) - (end (progn (move-end-of-line '()) - (point)))) + (start (progn (move-beginning-of-line '()) + (point))) + (end (progn (move-end-of-line '()) + (point)))) (replace-regexp (format "(%s) " marker) "" '() start end) (move-beginning-of-line '()) (mastodon-tl--goto-next-toot))) -- cgit v1.2.3 From a7e87d827c0fde9cda67325446236834cc2f411f Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Mon, 24 Apr 2017 21:46:16 -0400 Subject: made some formating changes --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 8197ba5..79c5a2d 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -116,9 +116,9 @@ Set `mastodon-toot--content-warning' to nil." (message (format "Favourited #%s" id)))) (defun mastodon-toot--unfavourite () - "Favourite toot at `point'." + "Unfavourite toot at `point'." (interactive) - (let ((callback (lambda () ( mastodon-toot--action-success-undo "F"))) + (let ((callback (lambda () (mastodon-toot--action-success-undo "F"))) (id (mastodon-tl--property 'toot-id))) (mastodon-toot--action "unfavourite" callback) (message (format "unfavourited #%s" id)))) -- cgit v1.2.3 From c81c647c18906445f0a22299613fa4ec27c09caa Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 25 Apr 2017 13:03:08 -0400 Subject: Use toggle function approach for favourite/unfavourite TODOs: * Will require a boost/unboost toggle impl * Must pass favourite/boosted state to the toggle functions from mastodon-tl --- lisp/mastodon-toot.el | 53 +++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 79c5a2d..2da6cec 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -38,24 +38,19 @@ (defvar mastodon-toot--reply-to-id nil) (defvar mastodon-toot--content-warning nil) -(defun mastodon-toot--action-success (marker) - "Insert MARKER with 'success face in byline." - (let ((inhibit-read-only t)) - (move-beginning-of-line '()) - (mastodon-tl--goto-next-toot) - (insert (format "(%s) " - (propertize marker 'face 'success))))) +(defun mastodon-toot--action-success (marker &optional rm) + "Insert MARKER with 'success face in byline. -(defun mastodon-toot--action-success-undo (marker) - "Remove MARKER from byline." +Remove MARKER if RM is non-nil." (let ((inhibit-read-only t) - (start (progn (move-beginning-of-line '()) - (point))) - (end (progn (move-end-of-line '()) - (point)))) - (replace-regexp (format "(%s) " marker) "" '() start end) + (bol (progn (move-beginning-of-line '()) (point))) + (eol (progn (move-end-of-line '()) (point)))) + (when rm (replace-regexp (format "(%s) " marker) "" '() bol eol)) (move-beginning-of-line '()) - (mastodon-tl--goto-next-toot))) + (mastodon-tl--goto-next-toot) + (unless rm + (insert (format "(%s) " + (propertize marker 'face 'success)))))) (defun mastodon-toot--action (action callback) "Take ACTION on toot at point, then execute CALLBACK." @@ -67,6 +62,18 @@ (let ((response (mastodon-http--post url nil nil))) (mastodon-http--triage response callback)))) +(defun mastodon-toot--toggle-favourite (faved) + "Favourite/unfavourite toot based on current state. + +If FAVED is nil, favourite the toot. +If FAVED is non-nil, unfavourite the toot." + (interactive) + (let ((action (if faved "unfavourite" "favourite")) + (remove (when faved t)) + (id (mastodon-tl--property 'toot-id))) + (mastodon-toot--action action (lambda () (mastodon-toot--action-success "F" remove))) + (message (format "%sd #%s" action id)))) + (defun mastodon-toot--kill () "Kill `mastodon-toot-mode' buffer and window. @@ -107,22 +114,6 @@ Set `mastodon-toot--content-warning' to nil." (mastodon-toot--action "reblog" callback) (message (format "Boosted #%s" id)))) -(defun mastodon-toot--favourite () - "Favourite toot at `point'." - (interactive) - (let ((callback (lambda () (mastodon-toot--action-success "F"))) - (id (mastodon-tl--property 'toot-id))) - (mastodon-toot--action "favourite" callback) - (message (format "Favourited #%s" id)))) - -(defun mastodon-toot--unfavourite () - "Unfavourite toot at `point'." - (interactive) - (let ((callback (lambda () (mastodon-toot--action-success-undo "F"))) - (id (mastodon-tl--property 'toot-id))) - (mastodon-toot--action "unfavourite" callback) - (message (format "unfavourited #%s" id)))) - (defun mastodon-toot--reply () "Reply to toot at `point'." (interactive) -- cgit v1.2.3 From c694b7b2ef6d673125cbdb1985ccfe31762e0caf Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 25 Apr 2017 13:19:27 -0400 Subject: Parity with non-toggle favourite function TODOs: - Boost/unboost toggle function - Store 'favourite-p property on toots --- lisp/mastodon-toot.el | 9 +++++---- lisp/mastodon.el | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 2da6cec..104df1c 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -62,15 +62,16 @@ Remove MARKER if RM is non-nil." (let ((response (mastodon-http--post url nil nil))) (mastodon-http--triage response callback)))) -(defun mastodon-toot--toggle-favourite (faved) +(defun mastodon-toot--toggle-favourite () "Favourite/unfavourite toot based on current state. If FAVED is nil, favourite the toot. If FAVED is non-nil, unfavourite the toot." (interactive) - (let ((action (if faved "unfavourite" "favourite")) - (remove (when faved t)) - (id (mastodon-tl--property 'toot-id))) + (let* ((id (mastodon-tl--property 'toot-id)) + (faved (get-text-property (point) 'favourite-p)) + (action (if faved "unfavourite" "favourite")) + (remove (when faved t))) (mastodon-toot--action action (lambda () (mastodon-toot--action-success "F" remove))) (message (format "%sd #%s" action id)))) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 5921e2a..ea55559 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -100,7 +100,7 @@ If REPLY-TO-ID is non-nil, attach new toot to a conversation." :group 'mastodon (let ((map mastodon-mode-map)) (define-key map (kbd "b") #'mastodon-toot--boost) - (define-key map (kbd "f") #'mastodon-toot--favourite) + (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) -- cgit v1.2.3 From ab900b68f03d1182fb137c48c805285f0f66e2c3 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 25 Apr 2017 23:35:28 -0400 Subject: Store 'favourited-p and 'boosted-p properties on bylines --- lisp/mastodon-tl.el | 9 +++++---- lisp/mastodon-toot.el | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 46e923d..a1535b9 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -141,9 +141,10 @@ Return value from boosted content if available." (mastodon-tl--byline-author toot) (mastodon-tl--byline-boosted toot) (propertize "\n ------------" 'face 'default)) - 'toot-id id - 'toot-json toot))) - + 'favourited-p faved + 'boosted-p boosted + 'toot-id id + 'toot-json toot))) (defun mastodon-tl--set-face (string face render) "Set the face of a string. If `render' is not 'nil @@ -155,7 +156,7 @@ also render the html" (shr-render-region (point-min) (point-max))) (buffer-string)) 'face face)) - + (defun mastodon-tl--spoiler (toot) "Retrieve spoiler message from TOOT." (let* ((spoiler (mastodon-tl--field 'spoiler_text toot)) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 104df1c..41b69cc 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -69,7 +69,7 @@ If FAVED is nil, favourite the toot. If FAVED is non-nil, unfavourite the toot." (interactive) (let* ((id (mastodon-tl--property 'toot-id)) - (faved (get-text-property (point) 'favourite-p)) + (faved (get-text-property (point) 'favourited-p)) (action (if faved "unfavourite" "favourite")) (remove (when faved t))) (mastodon-toot--action action (lambda () (mastodon-toot--action-success "F" remove))) -- cgit v1.2.3 From 3db5e26449a87728e37b086004f1581121f2469a Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 25 Apr 2017 23:45:29 -0400 Subject: Add toggle function for boost/unboost --- lisp/mastodon-toot.el | 24 ++++++++++++------------ lisp/mastodon.el | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 41b69cc..6345e14 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -62,11 +62,19 @@ Remove MARKER if RM is non-nil." (let ((response (mastodon-http--post url nil nil))) (mastodon-http--triage response callback)))) -(defun mastodon-toot--toggle-favourite () - "Favourite/unfavourite toot based on current state. +(defun mastodon-toot--toggle-boost () + "Boost/unboost toot at `point'." + (interactive) + (let* ((id (mastodon-tl--property 'toot-id)) + (boosted (get-text-property (point) 'boosted-p)) + (action (if boosted "unreblog" "reblog")) + (msg (if boosted "unboosted" "boosted")) + (remove (when boosted t))) + (mastodon-toot--action action (lambda () (mastodon-toot--action-success "B" remove))) + (message (format "%s #%s" msg id)))) -If FAVED is nil, favourite the toot. -If FAVED is non-nil, unfavourite the toot." +(defun mastodon-toot--toggle-favourite () + "Favourite/unfavourite toot at `point'." (interactive) (let* ((id (mastodon-tl--property 'toot-id)) (faved (get-text-property (point) 'favourited-p)) @@ -107,14 +115,6 @@ Set `mastodon-toot--content-warning' to nil." (mastodon-http--triage response (lambda () (message "Toot toot!"))))))) -(defun mastodon-toot--boost () - "Boost toot at `point'." - (interactive) - (let ((callback (lambda () (mastodon-toot--action-success "B"))) - (id (mastodon-tl--property 'toot-id))) - (mastodon-toot--action "reblog" callback) - (message (format "Boosted #%s" id)))) - (defun mastodon-toot--reply () "Reply to toot at `point'." (interactive) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index ea55559..2926d08 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -99,7 +99,7 @@ If REPLY-TO-ID is non-nil, attach new toot to a conversation." "Major mode for Mastodon, the federated microblogging network." :group 'mastodon (let ((map mastodon-mode-map)) - (define-key map (kbd "b") #'mastodon-toot--boost) + (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) -- cgit v1.2.3 From 2b0a6f5b78c1e4f2f10492b22d4bacc05ce6ad18 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 25 Apr 2017 23:49:37 -0400 Subject: Fix #57 by moving messages into callbacks --- lisp/mastodon-toot.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 6345e14..ce365a1 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -70,8 +70,10 @@ Remove MARKER if RM is non-nil." (action (if boosted "unreblog" "reblog")) (msg (if boosted "unboosted" "boosted")) (remove (when boosted t))) - (mastodon-toot--action action (lambda () (mastodon-toot--action-success "B" remove))) - (message (format "%s #%s" msg id)))) + (mastodon-toot--action action + (lambda () + (mastodon-toot--action-success "B" remove) + (message (format "%s #%s" msg id)))))) (defun mastodon-toot--toggle-favourite () "Favourite/unfavourite toot at `point'." @@ -80,8 +82,10 @@ Remove MARKER if RM is non-nil." (faved (get-text-property (point) 'favourited-p)) (action (if faved "unfavourite" "favourite")) (remove (when faved t))) - (mastodon-toot--action action (lambda () (mastodon-toot--action-success "F" remove))) - (message (format "%sd #%s" action id)))) + (mastodon-toot--action action + (lambda () + (mastodon-toot--action-success "F" remove) + (message (format "%sd #%s" action id)))))) (defun mastodon-toot--kill () "Kill `mastodon-toot-mode' buffer and window. -- cgit v1.2.3 From 6832566c4639032a8142379fe1a5efae5b7a01e4 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Thu, 27 Apr 2017 16:12:41 -0400 Subject: Quick feedback fix on toggle functions --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index ce365a1..84d0286 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -73,7 +73,7 @@ Remove MARKER if RM is non-nil." (mastodon-toot--action action (lambda () (mastodon-toot--action-success "B" remove) - (message (format "%s #%s" msg id)))))) + (message (format "%s #%d" msg id)))))) (defun mastodon-toot--toggle-favourite () "Favourite/unfavourite toot at `point'." @@ -85,7 +85,7 @@ Remove MARKER if RM is non-nil." (mastodon-toot--action action (lambda () (mastodon-toot--action-success "F" remove) - (message (format "%sd #%s" action id)))))) + (message (format "%sd #%d" action id)))))) (defun mastodon-toot--kill () "Kill `mastodon-toot-mode' buffer and window. -- cgit v1.2.3 From cd1d0a78a3fc8649648c20ef1f3780a37a1b80c5 Mon Sep 17 00:00:00 2001 From: clarkenciel Date: Thu, 27 Apr 2017 10:41:14 -0700 Subject: adding keybinding documentation to the new-toot buffer --- lisp/mastodon-toot.el | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++- lisp/mastodon.el | 9 ++------ 2 files changed, 59 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 84d0286..6e70f8b 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -101,10 +101,15 @@ Set `mastodon-toot--content-warning' to nil." (interactive) (mastodon-toot--kill)) +(defun mastodon-toot--remove-docs (toot-buffer-contents) + "Get the body of a toot from a TOOT-BUFFER-CONTENTS composed in a toot compose buffer." + (let ((re "^=+\\(\n\\|.\\)*=+\nToot Text:\n\n")) + (replace-regexp-in-string re "" toot-buffer-contents))) + (defun mastodon-toot--send () "Kill new-toot buffer/window and POST contents to the Mastodon instance." (interactive) - (let* ((toot (buffer-string)) + (let* ((toot (mastodon-toot--remove-docs (buffer-string))) (endpoint (mastodon-http--api "statuses")) (spoiler (when mastodon-toot--content-warning (read-string "Warning: "))) @@ -134,6 +139,57 @@ Set `mastodon-toot--content-warning' to nil." (setq mastodon-toot--content-warning (not mastodon-toot--content-warning))) +(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))) + +(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))) + (format "\t%s - %s" key command))) + +(defun mastodon-toot--format-kbinds (kbinds) + "Format a list keybindings, KBINDS, for display in documentation." + (string-join (cons "" (mapcar #'mastodon-toot--format-kbind kbinds)) + "\n")) + +(defun mastodon-toot--make-mode-docs () + "Create formatted documentation text for the mastodon-toot-mode." + (let ((kbinds (mastodon-toot--get-mode-kbinds))) + (concat + "=================================================================\n" + "Compose a new toot here. The following keybindings are available:" + (mastodon-toot--format-kbinds kbinds) + "\n=================================================================\n" + "Toot Text:\n\n"))) + +(defun mastodon-toot--display-docs () + "Display documentation about mastodon-toot mode." + (insert + (propertize + (mastodon-toot--make-mode-docs) + 'face 'comment))) + +(defun mastodon-toot--setup-as-reply (reply-to-user reply-to-id) + "If REPLY-TO-USER is provided, inject their handle into the message. +If REPLY-TO-ID is provided, set the MASTODON-TOOT--REPLY-TO-ID var." + (when reply-to-user + (insert (format "@%s " reply-to-user)) + (setq mastodon-toot--reply-to-id reply-to-id))) + +(defun mastodon-toot--compose-buffer (reply-to-user reply-to-id) + "Create a new buffer to capture text for a new toot. +If REPLY-TO-USER is provided, inject their handle into the message. +If REPLY-TO-ID is provided, set the MASTODON-TOOT--REPLY-TO-ID var." + (let ((buffer (get-buffer-create "*new toot*"))) + (switch-to-buffer-other-window buffer) + (mastodon-toot--display-docs) + (mastodon-toot--setup-as-reply reply-to-user reply-to-id) + (mastodon-toot-mode t) + )) + (defvar mastodon-toot-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c C-c") #'mastodon-toot--send) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 7fb5c9a..801692b 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -91,13 +91,8 @@ Use. e.g. \"%c\" for your locale's date and time format." If USER is non-nil, insert after @ symbol to begin new toot. If REPLY-TO-ID is non-nil, attach new toot to a conversation." (interactive) - (require 'mastodon-toot nil t) - (progn - (switch-to-buffer-other-window (get-buffer-create "*new toot*")) - (when user - (insert (format "@%s " user)) - (setq mastodon-toot--reply-to-id reply-to-id)) - (mastodon-toot-mode t))) + (require 'mastodon-toot nil t) + (mastodon-toot--compose-buffer user reply-to-id)) ;;;###autoload (add-hook 'mastodon-mode-hook (lambda () -- cgit v1.2.3 From eea390b070ded93c0ab606a2db82e0b70664b813 Mon Sep 17 00:00:00 2001 From: clarkenciel Date: Thu, 27 Apr 2017 19:56:10 -0700 Subject: removing Toot Text prompt, moving dangling parens --- lisp/mastodon-toot.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 6e70f8b..09fd264 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -162,8 +162,7 @@ Set `mastodon-toot--content-warning' to nil." "=================================================================\n" "Compose a new toot here. The following keybindings are available:" (mastodon-toot--format-kbinds kbinds) - "\n=================================================================\n" - "Toot Text:\n\n"))) + "\n=================================================================\n\n"))) (defun mastodon-toot--display-docs () "Display documentation about mastodon-toot mode." @@ -187,8 +186,7 @@ If REPLY-TO-ID is provided, set the MASTODON-TOOT--REPLY-TO-ID var." (switch-to-buffer-other-window buffer) (mastodon-toot--display-docs) (mastodon-toot--setup-as-reply reply-to-user reply-to-id) - (mastodon-toot-mode t) - )) + (mastodon-toot-mode t))) (defvar mastodon-toot-mode-map (let ((map (make-sparse-keymap))) -- cgit v1.2.3 From 995e97a91da18ae77de78a9b16bc54cc4f481a54 Mon Sep 17 00:00:00 2001 From: clarkenciel Date: Thu, 27 Apr 2017 20:15:37 -0700 Subject: reformatting docs and changing removal func since we can't re-match on the "Toot Text:" string --- lisp/mastodon-toot.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 09fd264..af86b5f 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -101,15 +101,19 @@ Set `mastodon-toot--content-warning' to nil." (interactive) (mastodon-toot--kill)) -(defun mastodon-toot--remove-docs (toot-buffer-contents) - "Get the body of a toot from a TOOT-BUFFER-CONTENTS composed in a toot compose buffer." - (let ((re "^=+\\(\n\\|.\\)*=+\nToot Text:\n\n")) - (replace-regexp-in-string re "" toot-buffer-contents))) +(defun mastodon-toot--remove-docs () + "Get the body of a toot from the current compose buffer." + (let ((re "^|=+=|$")) + (save-excursion + (goto-char 0) + (re-search-forward re) + (re-search-forward re) ; end of the docs + (buffer-substring (+ 2 (point)) (length (buffer-string)))))) (defun mastodon-toot--send () "Kill new-toot buffer/window and POST contents to the Mastodon instance." (interactive) - (let* ((toot (mastodon-toot--remove-docs (buffer-string))) + (let* ((toot (mastodon-toot--remove-docs)) (endpoint (mastodon-http--api "statuses")) (spoiler (when mastodon-toot--content-warning (read-string "Warning: "))) @@ -159,10 +163,10 @@ Set `mastodon-toot--content-warning' to nil." "Create formatted documentation text for the mastodon-toot-mode." (let ((kbinds (mastodon-toot--get-mode-kbinds))) (concat - "=================================================================\n" - "Compose a new toot here. The following keybindings are available:" + "|=================================================================|\n" + " Compose a new toot here. The following keybindings are available:" (mastodon-toot--format-kbinds kbinds) - "\n=================================================================\n\n"))) + "\n|=================================================================|\n\n"))) (defun mastodon-toot--display-docs () "Display documentation about mastodon-toot mode." -- cgit v1.2.3 From 84b825296d731f631c3a64feb55ee8511326fa25 Mon Sep 17 00:00:00 2001 From: clarkenciel Date: Thu, 27 Apr 2017 20:30:22 -0700 Subject: changing creation of toot buffer so that we don't duplicate docs --- lisp/mastodon-toot.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index af86b5f..5131191 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -186,10 +186,12 @@ If REPLY-TO-ID is provided, set the MASTODON-TOOT--REPLY-TO-ID var." "Create a new buffer to capture text for a new toot. If REPLY-TO-USER is provided, inject their handle into the message. If REPLY-TO-ID is provided, set the MASTODON-TOOT--REPLY-TO-ID var." - (let ((buffer (get-buffer-create "*new toot*"))) + (let* ((buffer-exists (get-buffer "*new toot*")) + (buffer (or buffer-exists (get-buffer-create "*new toot*")))) (switch-to-buffer-other-window buffer) - (mastodon-toot--display-docs) - (mastodon-toot--setup-as-reply reply-to-user reply-to-id) + (when (not buffer-exists) + (mastodon-toot--display-docs) + (mastodon-toot--setup-as-reply reply-to-user reply-to-id)) (mastodon-toot-mode t))) (defvar mastodon-toot-mode-map -- cgit v1.2.3 From 9f130ae3a3d1f53607419115c3d9fedbf1213a66 Mon Sep 17 00:00:00 2001 From: clarkenciel Date: Thu, 27 Apr 2017 20:57:28 -0700 Subject: making keybinds and names nice --- lisp/mastodon-toot.el | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-toot.el') 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) -- cgit v1.2.3 From 66d54dff2e5b4493117c9c0074b07bba25844cc6 Mon Sep 17 00:00:00 2001 From: clarkenciel Date: Fri, 28 Apr 2017 10:52:32 -0700 Subject: consolidating re-searches --- lisp/mastodon-toot.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 135c57c..94bdf2a 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -106,8 +106,7 @@ Set `mastodon-toot--content-warning' to nil." (let ((re "^|=+=|$")) (save-excursion (goto-char 0) - (re-search-forward re) - (re-search-forward re) ; end of the docs + (re-search-forward re nil nil 2) (buffer-substring (+ 2 (point)) (+ 1 (length (buffer-string))))))) (defun mastodon-toot--send () -- cgit v1.2.3 From 1e6b6087db71460c19d4f44db337b76fc8506317 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Fri, 28 Apr 2017 19:48:03 -0400 Subject: Bump to v0.6.1 --- Cask | 2 +- lisp/mastodon-auth.el | 2 +- lisp/mastodon-client.el | 2 +- lisp/mastodon-http.el | 2 +- lisp/mastodon-inspect.el | 2 +- lisp/mastodon-tl.el | 2 +- lisp/mastodon-toot.el | 2 +- lisp/mastodon.el | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/Cask b/Cask index a7d2ccf..d692673 100644 --- a/Cask +++ b/Cask @@ -1,7 +1,7 @@ (source gnu) (source melpa) -(package "mastodon" "0.6.0" "Emacs client for Mastodon") +(package "mastodon" "0.6.1" "Emacs client for Mastodon") (files "lisp/*.el") (development diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 869ffeb..a8e5185 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index f0f2761..2fd9354 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index da13d8f..5e140cc 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el diff --git a/lisp/mastodon-inspect.el b/lisp/mastodon-inspect.el index 08ed085..fd6f1b0 100644 --- a/lisp/mastodon-inspect.el +++ b/lisp/mastodon-inspect.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 5c31dc9..27531c5 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 94bdf2a..be2a7da 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 801692b..2ebc069 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.0 +;; Version: 0.6.1 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el @@ -38,7 +38,7 @@ :prefix "mastodon-" :group 'external) -(defconst mastodon-version "0.6.0" +(defconst mastodon-version "0.6.1" "Current `mastodon' package version.") (defcustom mastodon-instance-url "https://mastodon.social" -- cgit v1.2.3 From c3df16964e2c739203829bf55b84576ae819e7cc Mon Sep 17 00:00:00 2001 From: Marcin Cieślak Date: Sat, 29 Apr 2017 17:49:28 +0200 Subject: Fix #103: Do not use functions unknown to GNU emacs We don't have to depend on CL package, yet --- lisp/mastodon-toot.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index be2a7da..b642eb6 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -147,9 +147,9 @@ Set `mastodon-toot--content-warning' to nil." (defun mastodon-toot--get-mode-kbinds () "Get a list of the keybindings in the mastodon-toot-mode." (let* ((binds (copy-tree mastodon-toot-mode-map)) - (prefix (caadr binds)) - (bindings (remove-if-not (lambda (x) (listp x)) - (cadr binds)))) + (prefix (car (cadr binds))) + (bindings (remove nil (mapcar (lambda (i) (if (listp i) i)) + (cadr binds))))) (mapcar (lambda (b) (progn (setf (car b) (vector prefix (car b))) @@ -174,7 +174,7 @@ e.g. mastodon-toot--send -> Send." (defun mastodon-toot--format-kbinds (kbinds) "Format a list keybindings, KBINDS, for display in documentation." - (string-join (cons "" (mapcar #'mastodon-toot--format-kbind kbinds)) + (mapconcat 'identity (cons "" (mapcar #'mastodon-toot--format-kbind kbinds)) "\n")) (defun mastodon-toot--make-mode-docs () -- cgit v1.2.3 From 5c3e01589656fd1439dc017d5b44f3a91ba11d1b Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Sat, 29 Apr 2017 12:32:49 -0400 Subject: Bump to v0.6.2 --- Cask | 2 +- lisp/mastodon-auth.el | 2 +- lisp/mastodon-client.el | 2 +- lisp/mastodon-http.el | 2 +- lisp/mastodon-inspect.el | 2 +- lisp/mastodon-tl.el | 2 +- lisp/mastodon-toot.el | 2 +- lisp/mastodon.el | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/Cask b/Cask index d692673..d0b73ef 100644 --- a/Cask +++ b/Cask @@ -1,7 +1,7 @@ (source gnu) (source melpa) -(package "mastodon" "0.6.1" "Emacs client for Mastodon") +(package "mastodon" "0.6.2" "Emacs client for Mastodon") (files "lisp/*.el") (development diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index a8e5185..1586e84 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 2fd9354..8097bf5 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 5e140cc..d3facc4 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el diff --git a/lisp/mastodon-inspect.el b/lisp/mastodon-inspect.el index fd6f1b0..ad4e8fa 100644 --- a/lisp/mastodon-inspect.el +++ b/lisp/mastodon-inspect.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3ff52b8..7ea38c4 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index b642eb6..618f734 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Homepage: https://github.com/jdenen/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 2ebc069..947cc6a 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen -;; Version: 0.6.1 +;; Version: 0.6.2 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el @@ -38,7 +38,7 @@ :prefix "mastodon-" :group 'external) -(defconst mastodon-version "0.6.1" +(defconst mastodon-version "0.6.2" "Current `mastodon' package version.") (defcustom mastodon-instance-url "https://mastodon.social" -- cgit v1.2.3