diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-http.el | 5 | ||||
-rw-r--r-- | lisp/mastodon-profile.el | 4 | ||||
-rw-r--r-- | lisp/mastodon-search.el | 47 | ||||
-rw-r--r-- | lisp/mastodon-tl.el | 13 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 2 |
5 files changed, 48 insertions, 23 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 3fe47c9..58f6c7e 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -115,11 +115,12 @@ Pass response buffer to CALLBACK function." (url-retrieve-synchronously url)))) (defun mastodon-http--get-json (url) - "Make GET request to URL. Return JSON response" + "Make GET request to URL. Return JSON response." (with-current-buffer (mastodon-http--get url) (mastodon-http--process-json))) (defun mastodon-http--process-json () + "Process JSON response." (goto-char (point-min)) (re-search-forward "^$" nil 'move) (let ((json-string @@ -134,7 +135,7 @@ Pass response buffer to CALLBACK function." (defun mastodon-http--get-async (url &optional callback &rest cbargs) "Make GET request to URL. -Pass response buffer to CALLBACK function." +Pass response buffer to CALLBACK function with args CBARGS." (let ((url-request-method "GET") (url-request-extra-headers `(("Authorization" . ,(concat "Bearer " diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 11ad02e..f14b469 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -109,7 +109,7 @@ following the current profile." (mastodon-http--get-json url))) (defun mastodon-profile--fields-get (account) - "Fetch the fields vector (a.k.a profile metadata) from a profile. + "Fetch the fields vector (aka profile metadata) from profile of ACCOUNT. Returns a list of lists." (let ((fields (mastodon-profile--account-field account 'fields))) @@ -249,7 +249,7 @@ If toot is a boost, opens the profile of the booster." (mastodon-media--get-media-link-rendering url)))) (defun mastodon-profile--show-user (user-handle) - "Query user for user id from current status and show that user's profile." + "Query user for USER-HANDLE from current status and show that user's profile." (interactive (list (let ((user-handles (mastodon-profile--extract-users-handles diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 5c381fa..7b1dfb1 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -1,19 +1,43 @@ ;;; mastodon-search.el --- serach functions for mastodon.el -*- lexical-binding: t -*- -;; search functions: +;; Copyright (C) 2017-2019 Johnson Denen +;; Author: Johnson Denen <johnson.denen@gmail.com> +;; Version: 0.9.0 +;; Homepage: https://github.com/jdenen/mastodon.el +;; Package-Requires: ((emacs "24.4")) -;; autoloads? +;; 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 <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; A basic search function for mastodon.el + +;;; Code: + +;; autoloads ;; mastodon-tl--as-string ;; mastodon-tl--set-face ;; mastodon-tl--render-text ;; mastodon-tl--toot -;; mastodon-http--get-json +(autoload 'mastodon-http--get-json "mastodon-http") ;; mastodon-instance-url -;; code - (defun mastodon-search--search-query (query) "Prompt for a search QUERY and return accounts, statuses, and hashtags." (interactive "sSearch mastodon for: ") @@ -43,13 +67,13 @@ " STATUSES" "\n" " ------------\n") 'success)) - (mapcar 'mastodon-tl--toot toots-list-json) + (mapc 'mastodon-tl--toot toots-list-json) (insert (mastodon-tl--set-face (concat "\n ------------\n" " USERS" "\n" " ------------\n") 'success)) - (mapcar (lambda (el) + (mapc (lambda (el) (dolist (item el) (insert (mastodon-tl--render-text item nil) "")) (insert "----\n\n")) @@ -65,7 +89,7 @@ " HASHTAGS" "\n" " ------------\n") 'success)) - (mapcar (lambda (el) + (mapc (lambda (el) (dolist (item el) (insert (mastodon-tl--render-text item nil) "")) (insert "----\n\n")) @@ -113,6 +137,7 @@ This allows us to access the full account etc. details and to render them proper ;; http functions for search: (defun mastodon-http--process-json-search () + "Process JSON returned by a search query to the server." (goto-char (point-min)) (re-search-forward "^$" nil 'move) (let ((json-string @@ -123,13 +148,13 @@ This allows us to access the full account etc. details and to render them proper (json-read-from-string json-string))) (defun mastodon-http--get-search-json (url query) - "Make GET request to URL. Return JSON response" + "Make GET request to URL, searching for QUERY and return JSON response." (let ((buffer (mastodon-http--get-search url query))) (with-current-buffer buffer (mastodon-http--process-json-search)))) (defun mastodon-http--get-search (base-url query) - "Make GET request to URL. + "Make GET request to BASE-URL, searching for QUERY. Pass response buffer to CALLBACK function." (let ((url-request-method "GET") @@ -142,4 +167,4 @@ Pass response buffer to CALLBACK function." (url-retrieve-synchronously url nil nil mastodon-http--timeout)))) (provide 'mastodon-search) -;; mastodon-search.el ends here +;;; mastodon-search.el ends here diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 8ac9d9c..435938e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -677,7 +677,7 @@ it is `mastodon-tl--byline-boosted'" If any toots are pinned, display them first." (let* ((pinned-list)) - (mapcar (lambda (toot) + (mapc (lambda (toot) (when (equal (cdr (assoc 'pinned toot)) 't) (push toot pinned-list))) toots) @@ -845,7 +845,7 @@ webapp" (message "Toot deleted! There may be a delay before it disappears from your profile."))))))) (defun mastodon-tl--follow-user (user-handle) - "Query for user id from current status and follow that user." + "Query for USER-HANDLE from current status and follow that user." (interactive (list (let ((user-handles (mastodon-profile--extract-users-handles @@ -867,7 +867,7 @@ webapp" (message "Cannot find a user with handle %S" user-handle)))) (defun mastodon-tl--unfollow-user (user-handle) - "Query for user id from current status and unfollow that user." + "Query for USER-HANDLE from current status and unfollow that user." (interactive (list (let ((user-handles (mastodon-profile--extract-users-handles @@ -890,7 +890,7 @@ webapp" (message "Cannot find a user with handle %S" user-handle)))) (defun mastodon-tl--mute-user (user-handle) - "Query for user id from current status and mute that user." + "Query for USER-HANDLE from current status and mute that user." (interactive (list (let ((user-handles (mastodon-profile--extract-users-handles @@ -962,7 +962,7 @@ webapp" (message "Cannot find a user with handle %S" user-handle)))) (defun mastodon-tl--unblock-user (user-handle) - "Query for user from list of blocked users and unblock that user." + "Query for USER-HANDLE from list of blocked users and unblock that user." (interactive (list (let* ((blocks-url (mastodon-http--api (format "blocks"))) @@ -1043,8 +1043,7 @@ before (non-nil) or after (nil)" Returns nil if no such range exists. If SEARCH-BACKWARDS is non-nil it find a region before -START-POINT otherwise after START-POINT. -" +START-POINT otherwise after START-POINT." (if (get-text-property start-point property) ;; We are within a range, we need to start the search from ;; before/after this range: diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 4e57158..52af778 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -224,7 +224,7 @@ Mastodon requires the full user@domain, even in the case of local accts. eg. \"user\" -> \"user@local.social \" (when local.social is the domain of the mastodon-instance-url). eg. \"yourusername\" -> \"\" -eg. \"feduser@fed.social\" -> \"feduser@fed.social\" " +eg. \"feduser@fed.social\" -> \"feduser@fed.social\"." (cond ((string-match-p "@" acct) (concat "@" acct " ")) ; federated acct ((string= (mastodon-auth--user-acct) acct) "") ; your acct (t (concat "@" acct "@" ; local acct |