diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-01-10 10:12:14 +1100 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-01-10 10:12:14 +1100 |
commit | 8ef99af1b32d6f85368474dbea9fffe50d12b614 (patch) | |
tree | 897f298b7c3258813b71a8273ca9055127efd336 /lisp/mastodon-tl.el | |
parent | a37171ea14bd727493188e3c753dd60580f563ce (diff) |
optional no-error arg for get-buffer-property
used by update-params and link-header, as they are optionally set in buffer spec
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 5bd5963..1372777 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1388,20 +1388,22 @@ Optionally get it for BUFFER." (defun mastodon-tl--link-header (&optional buffer) "Get the LINK HEADER stored in `mastodon-tl--buffer-spec'. Optionally get it for BUFFER." - (mastodon-tl--get-buffer-property 'link-header buffer)) + (mastodon-tl--get-buffer-property 'link-header buffer :no-error)) (defun mastodon-tl--update-params (&optional buffer) "Get the UPDATE PARAMS stored in `mastodon-tl--buffer-spec'. Optionally get it for BUFFER." - (mastodon-tl--get-buffer-property 'update-params buffer)) + (mastodon-tl--get-buffer-property 'update-params buffer :no-error)) -(defun mastodon-tl--get-buffer-property (property &optional buffer) - "Get PROPERTY from `mastodon-tl--buffer-spec' in BUFFER or `current-buffer'." +(defun mastodon-tl--get-buffer-property (property &optional buffer no-error) + "Get PROPERTY from `mastodon-tl--buffer-spec' in BUFFER or `current-buffer'. +If NO-ERROR is non-nil, do not error when property is empty." (with-current-buffer (or buffer (current-buffer)) - ;; (or - (plist-get mastodon-tl--buffer-spec property))) - ;; (error "Mastodon-tl--buffer-spec is not defined for buffer %s" - ;; (or buffer (current-buffer)))))) + (if no-error + (plist-get mastodon-tl--buffer-spec property) + (or (plist-get mastodon-tl--buffer-spec property) + (error "Mastodon-tl--buffer-spec is not defined for buffer %s" + (or buffer (current-buffer))))))) (defun mastodon-tl--set-buffer-spec (buffer endpoint update-function &optional link-header update-params) |