branch: elpa/fedi
commit 1ba7f340913ee8499462935e40349b805e7b8a16
Merge: e53f4d61cab a75c22bad1d
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
Merge branch 'dev'
---
fedi-http.el | 6 +++---
fedi-post.el | 16 ++++++++++------
fedi.el | 34 +++++++++++++++++++---------------
3 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/fedi-http.el b/fedi-http.el
index ca3e5526e9c..378193bea0a 100644
--- a/fedi-http.el
+++ b/fedi-http.el
@@ -73,11 +73,11 @@ A random one is picked at package initialization.")
;;; UTILS
-(defun fedi-http--api (endpoint &optional url ver-str)
+(defun fedi-http--api (endpoint &optional url ver-str no-slash)
"Return Fedi API URL for ENDPOINT."
(concat (or url fedi-instance-url) "/api/"
(or ver-str fedi-http--api-version)
- "/" endpoint))
+ (unless no-slash "/") endpoint))
(defun fedi-http--render-html-err (string)
"Render STRING as HTML in a temp buffer.
@@ -250,7 +250,7 @@ to returnany error message needed."
(with-current-buffer response
(url-http-parse-response))
(wrong-type-argument
- "Looks like we got no response from the server."))))
+ (user-error "Failed to check http response code.")))))
(cond ((and (>= status 200)
(<= status 299))
(funcall success response))
diff --git a/fedi-post.el b/fedi-post.el
index 31d516d3acd..ab3a959aba9 100644
--- a/fedi-post.el
+++ b/fedi-post.el
@@ -229,7 +229,8 @@ Buffer-local variable `fedi-post-previous-window-config'
holds the config."
(match-end 1))))))
(defun fedi-post--return-capf (regex completion-fun &optional
- annot-fun _affix-fun exit-fun)
+ annot-fun _affix-fun exit-fun
+ category)
"Return a completion at point function.
REGEX is used to get the item before point.
@@ -265,6 +266,7 @@ and a status."
;; FIXME: we "should" use :affixation-function for this but i
;; can't get it to work so use an exit-fun hack:
:exit-function
+ :category category
(when exit-fun
(lambda (str status)
(funcall exit-fun str status)))
@@ -484,7 +486,7 @@ Item-var, containing the data to be displayed, can be a
string, or a
cons cell, or a list. If the latter two, the first element is displayed."
(let-alist item
(let ((region (fedi--find-property-range .prop (point-min)))
- (val (eval .item-var))) ;; FIXME: remove this eval?
+ (val (symbol-value .item-var)))
(add-text-properties
(car region) (cdr region)
(list 'display
@@ -618,7 +620,8 @@ Added to `after-change-functions'."
;;; COMPOSE BUFFER FUNCTION
(defun fedi-post--compose-buffer
- (&optional edit major minor prefix type capf-funs fields init-text
reply-text)
+ (&optional edit major minor prefix type capf-funs fields
+ init-text reply-text buf-prefix)
"Create a new buffer to capture text for a new post.
EDIT means we are editing an existing post, not composing a new one.
MAJOR is the major mode to enable.
@@ -631,10 +634,11 @@ TYPE is a string for the buffer name.
FIELDS is a list of alists containing status fields for bindings
and options display. Each alist should have a name, prop,
item-var and face elements. Element name should be a hyphen-separated
-string, the other elements should be symbols."
+string, the other elements should be symbols.
+BUF-PREFIX is a string to prepend to the buffer name."
(let* ((buffer-name (if edit
- (format "*edit %s*" type)
- (format "*new %s*" type)))
+ (format "*%sedit %s*" buf-prefix type)
+ (format "*%snew %s*" buf-prefix type)))
(buffer-exists (get-buffer buffer-name))
(buffer (or buffer-exists (get-buffer-create buffer-name)))
(inhibit-read-only t)
diff --git a/fedi.el b/fedi.el
index e60f4b77302..2e351d2a18f 100644
--- a/fedi.el
+++ b/fedi.el
@@ -177,7 +177,12 @@ For example:
(include-desc :alias \"includeDesc\"
:boolean \"true\")
(list :list (\"123\" \"abc\")
- order page limit)."
+ order page limit).
+
+To use this in combination with mandatory parameters, you can do this:
+
+\(append `((\"mandatory\" . ,value))
+ (fedi-opt-params a b c d))."
(declare (debug t))
`(append ,@(fedi--opt-params-whens params)))
@@ -189,7 +194,7 @@ For example:
(defun fedi--opt-param-expr (param)
"For PARAM, return a when expression.
It takes the form:
-\(when param '(\"param\" . param)).
+\(when param \\='(\"param\" . param)).
Param itself can also be an expression. See `fedi-opt-params' for
details."
(if (consp param)
@@ -741,9 +746,9 @@ the whole likes count in order to propertize it fully."
;;; PROPERTIZING SPECIAL ITEMS
-(defun fedi-propertize-items (str regex type json keymap subexp
- &optional item-subexp domain-subexp link
- extra-props face)
+(defun fedi-propertize-items (regex type json keymap subexp
+ &optional item-subexp domain-subexp link
+ extra-props face)
"Propertize items of TYPE matching REGEX in STR as links using JSON.
KEYMAP and LINK are properties to add to the match.
EXTRA-PROPS is a property list of any extra properties to add.
@@ -756,11 +761,9 @@ used in a link function. For an example of regexes'
subgroups, see
`fedi-post-handle-regex'."
;; FIXME: ideally we'd not do this in a sep buffer (gc)
;; this runs on every item for every regex type!
- (with-temp-buffer
- (switch-to-buffer (current-buffer))
- (insert str)
- (goto-char (point-min))
+ (save-excursion
(save-match-data
+ (goto-char (point-min))
;; ideally we'd work errors out, but we don't want to ruin
;; our caller, which might make a page load fail:
(ignore-errors
@@ -778,21 +781,22 @@ used in a link function. For an example of regexes'
subgroups, see
(domain (when domain-subexp ; fedi-post-handle-regex
(buffer-substring-no-properties (match-beginning
domain-subexp)
(match-end
domain-subexp))))
- (link (if (functionp link)
- (funcall link)
- link)))
+ (link (cond ((eq type 'shr)
+ item-str) ;; IF TYPE SHR: USE MATCHED URL
+ ((functionp link)
+ (funcall link))
+ (t link))))
(add-text-properties beg
end
(fedi-link-props face link item type item-str
keymap))
(add-text-properties beg end
- extra-props)))))
- (buffer-string)))
+ extra-props)))))))
(defun fedi-link-props (&optional face link item type help-echo keymap)
"Return a plist for a link."
`(face ,(or face '(shr-text shr-link))
mouse-face highlight
- shr-tabstop t
+ shr-tab-stop t
shr-url ,link
button t
type ,type