diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-search.el | 9 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 28 |
2 files changed, 20 insertions, 17 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 687b50c..03301ce 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -46,10 +46,11 @@ ;; functions for company completion of mentions in mastodon-toot -(defun mastodon-search--get-user-info-no-url (account) +(defun mastodon-search--get-user-info (account) "Get user handle, display name and account URL from ACCOUNT." (list (cdr (assoc 'display_name account)) - (concat "@" (cdr (assoc 'acct account))))) + (concat "@" (cdr (assoc 'acct account))) + (cdr (assoc 'url account)))) (defun mastodon-search--search-accounts-query (query) "Prompt for a search QUERY and return accounts synchronously. @@ -57,10 +58,10 @@ Returns a nested list containing user handle, display name, and URL." (interactive "sSearch mastodon for: ") (let* ((url (format "%s/api/v1/accounts/search" mastodon-instance-url)) ;; (buffer (format "*mastodon-search-%s*" query)) - (response (if (equal mastodon-toot--enable-completion-for-mentions "followers") + (response (if (equal mastodon-toot--enable-completion-for-mentions "following") (mastodon-http--get-search-json url query "following=true") (mastodon-http--get-search-json url query)))) - (mapcar #'mastodon-search--get-user-info-no-url + (mapcar #'mastodon-search--get-user-info response))) ;; functions for mastodon search diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index dd13251..b0b7e13 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -89,12 +89,12 @@ Must be one of \"public\", \"unlisted\", \"private\" (for followers-only), or \" :type 'integer) (when (require 'company nil :noerror) - (defcustom mastodon-toot--enable-completion-for-mentions "followers" + (defcustom mastodon-toot--enable-completion-for-mentions "following" "Whether to enable company completion for mentions in toot compose buffer." :group 'mastodon-toot :type '(choice (const :tag "off" nil) - (const :tag "followers only" "followers") + (const :tag "following only" "following") (const :tag "all users" "all")))) (defvar mastodon-toot--content-warning nil @@ -436,18 +436,18 @@ eg. \"feduser@fed.social\" -> \"feduser@fed.social\"." (reverse (append mentions nil)) ""))) -;; (defun mastodon-toot--mentions-company-meta (candidate) -;; (format "meta %s of candidate %s" -;; (get-text-property 0 'meta candidate) -;; (substring-no-properties candidate))) +(defun mastodon-toot--mentions-company-meta (candidate) + "Format company completion CANDIDATE's meta field." + (format " %s" + (get-text-property 0 'meta candidate))) (defun mastodon-toot--mentions-company-annotation (candidate) - "Construct a company completion CANDIDATE's annotation for display." - (format " %s" (get-text-property 0 'meta candidate))) + "Format company completion CANDIDATE's annotation." + (format " %s" (get-text-property 0 'annot candidate))) (defun mastodon-toot--mentions-company-candidates (prefix) - "Given a company PREFIX, build a list of candidates. -The prefix string can match against both user handles and display names." + "Given a company PREFIX query, build a list of candidates. +The prefix can match against both user handles and display names." (let (res) (dolist (item (mastodon-search--search-accounts-query prefix)) (when (or (string-prefix-p prefix (cadr item)) @@ -458,8 +458,9 @@ The prefix string can match against both user handles and display names." (defun mastodon-toot--mentions-company-make-candidate (candidate) "Construct a company completion CANDIDATE for display." (let ((display-name (car candidate)) - (handle (cadr candidate))) - (propertize handle 'meta display-name))) + (handle (cadr candidate)) + (url (caddr candidate))) + (propertize handle 'annot display-name 'meta url))) (defun mastodon-toot--mentions-completion (command &optional arg &rest ignored) "A company completion backend for toot mentions." @@ -474,7 +475,8 @@ The prefix string can match against both user handles and display names." ;; @ + thing before point (concat "@" (company-grab-symbol)))) (candidates (mastodon-toot--mentions-company-candidates arg)) - (annotation (mastodon-toot--mentions-company-annotation arg)))) + (annotation (mastodon-toot--mentions-company-annotation arg)) + (meta (mastodon-toot--mentions-company-meta arg)))) (defun mastodon-toot--reply () "Reply to toot at `point'." |