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') 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') 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') 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') 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') 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') 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') 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') 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') 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 c7a000355809bbe0496c3fb54ac70d75e3ef65b8 Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Thu, 27 Apr 2017 13:28:16 -0400 Subject: #87 added support for inspection toot under Point --- lisp/mastodon-inspect.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lisp/mastodon-inspect.el (limited to 'lisp') diff --git a/lisp/mastodon-inspect.el b/lisp/mastodon-inspect.el new file mode 100644 index 0000000..08ed085 --- /dev/null +++ b/lisp/mastodon-inspect.el @@ -0,0 +1,59 @@ +;;; mastodon-inspect.el --- Client for Mastodon + +;; Copyright (C) 2017 Johnson Denen +;; Author: Johnson Denen +;; Version: 0.6.0 +;; Package-Requires: ((emacs "24.4")) +;; Homepage: https://github.com/jdenen/mastodon.el + +;; This file is not part of GNU Emacs. + +;; This file is part of mastodon.el. + +;; mastodon.el is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; mastodon.el is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with mastodon.el. If not, see . + +;;; Commentary: + +;; Some tools to help inspect / debug mastodon.el + +;;; Code: + +(require 'mastodon-tl nil t) + +(defgroup mastodon-inspect nil + "Tools to help inspect toots." + :prefix "mastodon-inspect-" + :group 'external) + +(defun mastodon-inspect--dump-json-in-buffer (name json) + "Buffer NAME is opened and JSON in printed into it." + (switch-to-buffer-other-window name) + (progn (setf print-level nil + print-length nil) + (insert (pp json t)) + (goto-char 1) + (emacs-lisp-mode) + (message "success"))) + +(defun mastodon-inspect--toot () + "Find next toot and dump its meta data into new buffer." + (interactive) + (mastodon-inspect--dump-json-in-buffer + (concat "*mastodon-inspect-toot-" + (int-to-string (mastodon-tl--property 'toot-id)) + "*") + (mastodon-tl--property 'toot-json))) + +(provide 'mastodon-inspect) +;;; mastodon-inspect.el ends here -- cgit v1.2.3 From 4057f8d7577308fd79afa9c4d1823faf9c088665 Mon Sep 17 00:00:00 2001 From: Holger Dürer Date: Thu, 27 Apr 2017 18:35:32 +0100 Subject: Add the time of posting to the byline. --- lisp/mastodon-tl.el | 4 ++ lisp/mastodon.el | 9 +++ test/mastodon-tl-tests.el | 178 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index a1535b9..5c31dc9 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -31,6 +31,7 @@ (require 'mastodon-http) (require 'mastodon-toot) (require 'mastodon-media) +(require 'time-date) (defgroup mastodon-tl nil "Timelines in Mastodon." @@ -130,6 +131,7 @@ Return value from boosted content if available." (defun mastodon-tl--byline (toot) "Generate byline for TOOT." (let ((id (cdr (assoc 'id toot))) + (timestamp (mastodon-tl--field 'created_at toot)) (faved (mastodon-tl--field 'favourited toot)) (boosted (mastodon-tl--field 'reblogged toot))) (propertize @@ -140,6 +142,8 @@ Return value from boosted content if available." (format "(%s) " (propertize "F" 'face 'success))) (mastodon-tl--byline-author toot) (mastodon-tl--byline-boosted toot) + " " + (format-time-string mastodon-toot-timestamp-format (date-to-time timestamp)) (propertize "\n ------------" 'face 'default)) 'favourited-p faved 'boosted-p boosted diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 2926d08..7fb5c9a 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -51,6 +51,15 @@ :group 'mastodon :type 'file) +(defcustom mastodon-toot-timestamp-format "%F %T" + "Format to use for timestamps. + +For valid formatting options see `format-time-string`. +The default value \"%F %T\" prints ISO8601-style YYYY-mm-dd HH:MM:SS. +Use. e.g. \"%c\" for your locale's date and time format." + :group 'mastodon + :type 'string) + (defvar mastodon-mode-map (make-sparse-keymap) "Keymap for `mastodon-mode'.") diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index 384f46c..e89d313 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -1,5 +1,91 @@ (require 'el-mock) +(defconst mastodon-tl-test-base-toot + '((id . 61208) + (created_at . "2017-04-24T19:01:02.000Z") + (in_reply_to_id) + (in_reply_to_account_id) + (sensitive . :json-false) + (spoiler_text . "Spoiler text") + (visibility . "public") + (account (id . 42) + (username . "acct42") + (acct . "acct42@example.space") + (display_name . "Account 42") + (locked . :json-false) + (created_at . "2017-04-01T00:00:00.000Z") + (followers_count . 99) + (following_count . 13) + (statuses_count . 101) + (note . "E")) + (media_attachments . []) + (mentions . []) + (tags . []) + (uri . "tag:example.space,2017-04-24:objectId=654321:objectType=Status") + (url . "https://example.space/users/acct42/updates/123456789") + (reblogs_count . 0) + (favourites_count . 0) + (reblog)) + "A sample toot (parsed json)") + +(defconst mastodon-tl-test-base-boosted-toot + '((id . 61208) + (created_at . "2017-04-24T20:59:59.000Z") + (in_reply_to_id) + (in_reply_to_account_id) + (sensitive . :json-false) + (spoiler_text . "Spoiler text") + (visibility . "public") + (account (id . 42) + (username . "acct42") + (acct . "acct42@example.space") + (display_name . "Account 42") + (locked . :json-false) + (created_at . "2017-04-01T00:00:00.000Z") + (followers_count . 99) + (following_count . 13) + (statuses_count . 101) + (note . "E")) + (media_attachments . []) + (mentions . []) + (tags . []) + (uri . "tag:example.space,2017-04-24:objectId=654321:objectType=Status") + (url . "https://example.space/users/acct42/updates/123456789") + (reblogs_count . 0) + (favourites_count . 0) + (reblog (id . 4543919) + (created_at . "2017-04-24T19:01:02.000Z") + (in_reply_to_id) + (in_reply_to_account_id) + (sensitive . :json-false) + (spoiler_text . "") + (visibility . "public") + (application) + (account (id . 43) + (username . "acct43") + (acct . "acct43@example.space") + (display_name . "Account 43") + (locked . :json-false) + (created_at . "2017-04-02T00:00:00.000Z") + (followers_count . 1) + (following_count . 1) + (statuses_count . 1) + (note . "Other account")) + (media_attachments . []) + (mentions . [((url . "https://mastodon.social/@johnson") + (acct . "acct42") + (id . 42) + (username . "acct42"))]) + (tags . []) + (uri . "tag:example.space,2017-04-24:objectId=654321:objectType=Status") + (content . "

@acct42 boost

") + (url . "https://example.space/users/acct42/updates/123456789") + (reblogs_count . 1) + (favourites_count . 1) + (favourited) + (reblogged))) + "A sample reblogged/boosted toot (parsed json)") + (ert-deftest remove-html-1 () "Should remove all tags." (let ((input "foobar foobaz")) @@ -16,3 +102,95 @@ (with-mock (mock (mastodon-http--get-json "https://instance.url/api/v1/timelines/foo?max_id=12345")) (mastodon-tl--more-json "foo" 12345)))) + +(ert-deftest mastodon-tl--byline-regular () + "Should format the regular toot correctly." + (let ((timestamp (cdr (assoc 'created_at mastodon-tl-test-base-toot)))) + (with-mock + (mock (date-to-time timestamp) => '(22782 21551)) + (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22") + + (should (string= (substring-no-properties + (mastodon-tl--byline mastodon-tl-test-base-toot)) + " + | Account 42 (@acct42@example.space) 2999-99-99 00:11:22 + ------------"))))) + +(ert-deftest mastodon-tl--byline-boosted () + "Should format the boosted toot correctly." + (let* ((toot (cons '(reblogged . t) mastodon-tl-test-base-toot)) + (timestamp (cdr (assoc 'created_at toot)))) + (with-mock + (mock (date-to-time timestamp) => '(22782 21551)) + (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22") + + (should (string= (substring-no-properties (mastodon-tl--byline toot)) + " + | (B) Account 42 (@acct42@example.space) 2999-99-99 00:11:22 + ------------"))))) + +(ert-deftest mastodon-tl--byline-favorited () + "Should format the favourited toot correctly." + (let* ((toot (cons '(favourited . t) mastodon-tl-test-base-toot)) + (timestamp (cdr (assoc 'created_at toot)))) + (with-mock + (mock (date-to-time timestamp) => '(22782 21551)) + (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22") + + (should (string= (substring-no-properties (mastodon-tl--byline toot)) + " + | (F) Account 42 (@acct42@example.space) 2999-99-99 00:11:22 + ------------"))))) + + +(ert-deftest mastodon-tl--byline-boosted/favorited () + "Should format the boosted & favourited toot correctly." + (let* ((toot `((favourited . t) (reblogged . t) ,@mastodon-tl-test-base-toot)) + (timestamp (cdr (assoc 'created_at toot)))) + (with-mock + (mock (date-to-time timestamp) => '(22782 21551)) + (mock (format-time-string mastodon-toot-timestamp-format '(22782 21551)) => "2999-99-99 00:11:22") + + (should (string= (substring-no-properties (mastodon-tl--byline toot)) + " + | (B) (F) Account 42 (@acct42@example.space) 2999-99-99 00:11:22 + ------------"))))) + +(ert-deftest mastodon-tl--byline-reblogged () + "Should format the reblogged toot correctly." + (let* ((toot mastodon-tl-test-base-boosted-toot) + (original-toot (cdr (assoc 'reblog mastodon-tl-test-base-boosted-toot))) + (timestamp (cdr (assoc 'created_at toot))) + (original-timestamp (cdr (assoc 'created_at original-toot)))) + (with-mock + ;; We don't expect to use the toot's timestamp but the timestamp of the + ;; reblogged toot: + (mock (date-to-time timestamp) => '(1 2)) + (mock (format-time-string mastodon-toot-timestamp-format '(1 2)) => "reblogging time") + (mock (date-to-time original-timestamp) => '(3 4)) + (mock (format-time-string mastodon-toot-timestamp-format '(3 4)) => "original time") + + (should (string= (substring-no-properties (mastodon-tl--byline toot)) + " + | Account 42 (@acct42@example.space) Boosted Account 43 (@acct43@example.space) original time + ------------"))))) + +(ert-deftest mastodon-tl--byline-reblogged-boosted/favorited () + "Should format the reblogged toot that was also boosted & favoritedcorrectly." + (let* ((toot `((favourited . t) (reblogged . t) ,@mastodon-tl-test-base-boosted-toot)) + (original-toot (cdr (assoc 'reblog mastodon-tl-test-base-boosted-toot))) + (timestamp (cdr (assoc 'created_at toot))) + (original-timestamp (cdr (assoc 'created_at original-toot)))) + (with-mock + ;; We don't expect to use the toot's timestamp but the timestamp of the + ;; reblogged toot: + (mock (date-to-time timestamp) => '(1 2)) + (mock (format-time-string mastodon-toot-timestamp-format '(1 2)) => "reblogging time") + (mock (date-to-time original-timestamp) => '(3 4)) + (mock (format-time-string mastodon-toot-timestamp-format '(3 4)) => "original time") + + (should (string= (substring-no-properties (mastodon-tl--byline toot)) + " + | (B) (F) Account 42 (@acct42@example.space) Boosted Account 43 (@acct43@example.space) original time + ------------"))))) + -- 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') 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') 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') 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') 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') 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') 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') 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 fdfb30f8d18d28aaf3b98513814ba71afc457d62 Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Mon, 24 Apr 2017 20:00:16 -0400 Subject: en #74 added autofill for tag timeline --- lisp/mastodon-tl.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 27531c5..a68b1f3 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -56,7 +56,10 @@ (defun mastodon-tl--get-tag-timeline () "Prompts for tag and opens its timeline." (interactive) - (let ((tag (read-string "Tag: "))) + (let* ((word (word-at-point)) + (input (read-string (format "Tag(%s): " word))) + (tag (if (equal input "") word input))) + (print tag) (mastodon-tl--get (concat "tag/" tag)))) (defun mastodon-tl--goto-toot-pos (find-pos refresh &optional pos) -- cgit v1.2.3 From d2e61d3d258a9acf1bed5dd8b347c7aaea12c5c7 Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Thu, 27 Apr 2017 19:17:40 -0400 Subject: word is no longer nil when no word-at-point is nil --- lisp/mastodon-tl.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index a68b1f3..3ff52b8 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -56,7 +56,7 @@ (defun mastodon-tl--get-tag-timeline () "Prompts for tag and opens its timeline." (interactive) - (let* ((word (word-at-point)) + (let* ((word (or (word-at-point) "")) (input (read-string (format "Tag(%s): " word))) (tag (if (equal input "") word input))) (print tag) -- 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') 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') 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