From 9f9a6e8c45e329d58a772dcf25942f7093ba5fc0 Mon Sep 17 00:00:00 2001 From: H Durer Date: Mon, 19 Mar 2018 15:54:23 +0000 Subject: Give mastodon-media--inline-images a saner interface. (#191) Instead of making it search the whole buffer every time to find images to load, give it a range where this work should be done. We then call this immediately after inserting a single status, notification, ... There should be no big noticible difference - images might load a tiny bit sooner although I doubt you can see that. This should be more efficient on large buffers although Alex didn't notice any problems when testing streamed buffers. We should still do it as it make things easier to understand. I was always worried about these global operations. --- lisp/mastodon-tl.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4d6d0b6..5411d42 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -635,13 +635,16 @@ the byline that takes one variable. By default it is `mastodon-tl--byline-author ACTION-BYLINE is also an optional function for adding an action, such as boosting favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'" - (insert - (propertize - (concat body - (mastodon-tl--byline toot author-byline action-byline)) - 'toot-id (cdr (assoc 'id toot)) - 'toot-json toot) - "\n\n")) + (let ((start-pos (point))) + (insert + (propertize + (concat body + (mastodon-tl--byline toot author-byline action-byline)) + 'toot-id (cdr (assoc 'id toot)) + 'toot-json toot) + "\n\n") + (when mastodon-tl--display-media-p + (mastodon-media--inline-images start-pos (point))))) (defun mastodon-tl--toot(toot) "Formats TOOT and insertes it into the buffer." @@ -657,9 +660,7 @@ it is `mastodon-tl--byline-boosted'" (defun mastodon-tl--timeline (toots) "Display each toot in TOOTS." (mapc 'mastodon-tl--toot toots) - (goto-char (point-min)) - (when mastodon-tl--display-media-p - (mastodon-media--inline-images))) + (goto-char (point-min))) (defun mastodon-tl--get-update-function (&optional buffer) "Get the UPDATE-FUNCTION stored in `mastodon-tl--buffer-spec'" -- cgit v1.2.3