diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-05-18 13:31:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-18 13:31:01 -0400 |
commit | a9e595142eee69fe84f0ab06f7fde76cef27cdac (patch) | |
tree | 8cab32b1228283bdad86f426e346c5aa9ad41368 /lisp/mastodon-client.el | |
parent | 9ccc0e8cf74b938493753e2b64f95591f771de44 (diff) | |
parent | 8c841d2ad3d60997f7aea725da86b83ac80dcd61 (diff) |
Merge pull request #135 from jdenen/develop
Release 0.7.0
Diffstat (limited to 'lisp/mastodon-client.el')
-rw-r--r-- | lisp/mastodon-client.el | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index f8e8a5c..cbb276b 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen <johnson.denen@gmail.com> -;; Version: 0.6.3 +;; Version: 0.7.0 ;; Homepage: https://github.com/jdenen/mastodon.el ;; Package-Requires: ((emacs "24.4")) @@ -30,14 +30,16 @@ ;;; Code: (require 'plstore) -(require 'mastodon-http nil t) +(autoload 'mastodon-http--api "mastodon-http") +(autoload 'mastodon-http--post "mastodon-http") -(defgroup mastodon-client nil - "Register your client with Mastodon." - :prefix "mastodon-client-" - :group 'mastodon) -(defvar mastodon-client nil +(defcustom mastodon-client--token-file (concat user-emacs-directory "mastodon.plstore") + "File path where Mastodon access tokens are stored." + :group 'mastodon + :type 'file) + +(defvar mastodon-client--client-details nil "Client id and secret.") (defun mastodon-client--register () @@ -62,11 +64,11 @@ (json-read-from-string json-string)))) (defun mastodon-client--token-file () - "Return `mastodon-token-file'." - mastodon-token-file) + "Return `mastodon-client--token-file'." + mastodon-client--token-file) (defun mastodon-client--store () - "Store client_id and client_secret in `mastodon-token-file'. + "Store client_id and client_secret in `mastodon-client--token-file'. Make `mastodon-client--fetch' call to determine client values." (let ((plstore (plstore-open (mastodon-client--token-file))) @@ -77,19 +79,19 @@ Make `mastodon-client--fetch' call to determine client values." client)) (defun mastodon-client--read () - "Retrieve client_id and client_secret from `mastodon-token-file'." + "Retrieve client_id and client_secret from `mastodon-client--token-file'." (let* ((plstore (plstore-open (mastodon-client--token-file))) (mastodon (plstore-get plstore "mastodon"))) (when mastodon (delete "mastodon" mastodon)))) (defun mastodon-client () - "Return variable `mastodon-client' plist. + "Return variable `mastodon-client--client-details' plist. -Read plist from `mastodon-token-file' if variable is nil. +Read plist from `mastodon-client--token-file' if variable is nil. Fetch and store plist if `mastodon-client--read' returns nil." - (or mastodon-client - (setq mastodon-client + (or mastodon-client--client-details + (setq mastodon-client--client-details (or (mastodon-client--read) (mastodon-client--store))))) |