{"action":"created","comment":{"url":"https://api.github.com/repos/jdenen/mastodon.el/pulls/comments/116391031","pull_request_review_id":38008882,"id":116391031,"diff_hunk":"@@ -212,22 +212,72 @@ also render the html\"\n   (replace-regexp \"\\n\\n\\n | \" \"\\n | \" nil (point-min) (point-max))\n   (mastodon-media--inline-images))\n \n-(defun mastodon-tl--more-json (timeline id)\n-  \"Return JSON for TIMELINE before ID.\"\n-  (let ((url (mastodon-http--api (concat \"timelines/\"\n-                                         timeline\n-                                         \"?max_id=\"\n-                                         (number-to-string id)))))\n+(defun mastodon-tl--get-endpoint (buffer-string)\n+  \"Match BUFFER-STRING against buffer-names.\n+\n+Returns the matching plist\"\n+  (let* ((mastodon-buffer-endpoints ;; can be made a global var\n+          '((buffer-name \"home\" endpoint \"timelines/home\"\n+                         update-function mastodon-tl--timeline)\n+            (buffer-name \"local\" endpoint \"timelines/public?local=true\"\n+                         update-function mastodon-tl--timeline)\n+            (buffer-name \"federated\" endpoint \"timelines/public\"\n+                         update-function mastodon-tl--timeline)\n+            (buffer-name \"public?local=true\"\n+                         endpoint \"timelines/public?local=true\"\n+                         update-function mastodon-tl--timeline)\n+            (buffer-name \"public\"\n+                         endpoint \"timelines/public\"\n+                         update-function mastodon-tl--timeline)\n+            (buffer-name \"tag/.*\"\n+                         endpoint (lambda (x) (concat \"timelines/\" x))\n+                         update-function mastodon-tl--timeline\n+                         endpoint-function)\n+            (buffer-name \"notifications\"\n+                         endpoint \"notifications\"\n+                         update-function\n+                         mastodon-notifications--notifications)))\n+         (match-endpoint-string\n+             (lambda (endpoint-plist)\n+               (when (string-match\n+                      (plist-get endpoint-plist 'buffer-name) buffer-string)\n+                 (unless (functionp\n+                          (plist-get endpoint-plist 'update-function))\n+                   (error\n+                    (format \"%s not a function\"\n+                            (plist-get endpoint-plist 'update-function))))\n+                 (cond\n+                  ((stringp (plist-get endpoint-plist 'endpoint))\n+                   endpoint-plist)\n+                  ((functionp (plist-get endpoint-plist 'endpoint))\n+                   (plist-put end 'endpoint","path":"lisp/mastodon-tl.el","position":48,"original_position":48,"commit_id":"fcda70903fccc94eaebbe3fed898376cbe1d76b9","original_commit_id":"fcda70903fccc94eaebbe3fed898376cbe1d76b9","user":{"login":"alexjgriffith","id":6475397,"avatar_url":"https://avatars1.githubusercontent.com/u/6475397?v=3","gravatar_id":"","url":"https://api.github.com/users/alexjgriffith","html_url":"https://github.com/alexjgriffith","followers_url":"https://api.github.com/users/alexjgriffith/followers","following_url":"https://api.github.com/users/alexjgriffith/following{/other_user}","gists_url":"https://api.github.com/users/alexjgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/alexjgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexjgriffith/subscriptions","organizations_url":"https://api.github.com/users/alexjgriffith/orgs","repos_url":"https://api.github.com/users/alexjgriffith/repos","events_url":"https://api.github.com/users/alexjgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/alexjgriffith/received_events","type":"User","site_admin":false},"body":"I.e. perhaps I should write tests :p","created_at":"2017-05-14T21:30:00Z","updated_at":"2017-05-14T21:30:00Z","html_url":"https://github.com/jdenen/mastodon.el/pull/122#discussion_r116391031","pull_request_url":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122","_links":{"self":{"href":"https://api.github.com/repos/jdenen/mastodon.el/pulls/comments/116391031"},"html":{"href":"https://github.com/jdenen/mastodon.el/pull/122#discussion_r116391031"},"pull_request":{"href":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122"}}},"pull_request":{"url":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122","id":120223030,"html_url":"https://github.com/jdenen/mastodon.el/pull/122","diff_url":"https://github.com/jdenen/mastodon.el/pull/122.diff","patch_url":"https://github.com/jdenen/mastodon.el/pull/122.patch","issue_url":"https://api.github.com/repos/jdenen/mastodon.el/issues/122","number":122,"state":"open","locked":false,"title":"Fix for #84","user":{"login":"alexjgriffith","id":6475397,"avatar_url":"https://avatars1.githubusercontent.com/u/6475397?v=3","gravatar_id":"","url":"https://api.github.com/users/alexjgriffith","html_url":"https://github.com/alexjgriffith","followers_url":"https://api.github.com/users/alexjgriffith/followers","following_url":"https://api.github.com/users/alexjgriffith/following{/other_user}","gists_url":"https://api.github.com/users/alexjgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/alexjgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexjgriffith/subscriptions","organizations_url":"https://api.github.com/users/alexjgriffith/orgs","repos_url":"https://api.github.com/users/alexjgriffith/repos","events_url":"https://api.github.com/users/alexjgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/alexjgriffith/received_events","type":"User","site_admin":false},"body":"This PR lets us use `mastodon-mode` commands to update timeline like buffers, such as `*mastodon-notifications*` and `*mastodon-profile-user*`, and give the current mastodon buffers more user friendly names in the future (`*mastodon-local*` vs `*mastodon-public?local=true*`.\r\n\r\nFor simplicity this method still relies on the buffer naming convention. This is a liability and probably should be changed in the future to our own buffer local variable.\r\n\r\nThe parsed buffer name is matched against a list of plists.  A buffer specific endpoint is then passed to `mastodon-tl--more-json` and a buffer specific update function is used in `mastodon-tl--more`, rather than calling `mastodon-tl--timelines` directly. This list of plists is currently contained within `mastodon-tl--get-endpoint` but could be moved to a global variable so each buffer type could append their own endpoints and update function.\r\n\r\n## Example mastodon-buffer-endpoints\r\n``` elisp\r\n          '((buffer-name \"home\" endpoint \"timelines/home\"\r\n                         update-function mastodon-tl--timeline)\r\n            (buffer-name \"local\" endpoint \"timelines/public?local=true\"\r\n                         update-function 'mastodon-tl--timeline)\r\n            (buffer-name \"federated\" endpoint \"timelines/public\"\r\n                         update-function 'mastodon-tl--timeline)\r\n            (buffer-name \"public?local=true\"\r\n                         endpoint \"timelines/public?local=true\"\r\n                         update-function 'mastodon-tl--timeline)\r\n            (buffer-name \"public\"\r\n                         endpoint \"timelines/public\"\r\n                         update-function 'mastodon-tl--timeline)\r\n            (buffer-name \"notifications\"\r\n                         endpoint \"notifications\"\r\n                         update-function\r\n                         mastodon-notifications--notifications))\r\n```\r\n\r\nside note, renaming the `*mastodon-public?local=true*` buffer to `*mastodon-local*` works like a charm!","created_at":"2017-05-11T23:36:27Z","updated_at":"2017-05-14T21:30:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"72f80c75279e85529aa76ea717c7034884ab1c7a","assignee":{"login":"alexjgriffith","id":6475397,"avatar_url":"https://avatars1.githubusercontent.com/u/6475397?v=3","gravatar_id":"","url":"https://api.github.com/users/alexjgriffith","html_url":"https://github.com/alexjgriffith","followers_url":"https://api.github.com/users/alexjgriffith/followers","following_url":"https://api.github.com/users/alexjgriffith/following{/other_user}","gists_url":"https://api.github.com/users/alexjgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/alexjgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexjgriffith/subscriptions","organizations_url":"https://api.github.com/users/alexjgriffith/orgs","repos_url":"https://api.github.com/users/alexjgriffith/repos","events_url":"https://api.github.com/users/alexjgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/alexjgriffith/received_events","type":"User","site_admin":false},"assignees":[{"login":"alexjgriffith","id":6475397,"avatar_url":"https://avatars1.githubusercontent.com/u/6475397?v=3","gravatar_id":"","url":"https://api.github.com/users/alexjgriffith","html_url":"https://github.com/alexjgriffith","followers_url":"https://api.github.com/users/alexjgriffith/followers","following_url":"https://api.github.com/users/alexjgriffith/following{/other_user}","gists_url":"https://api.github.com/users/alexjgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/alexjgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexjgriffith/subscriptions","organizations_url":"https://api.github.com/users/alexjgriffith/orgs","repos_url":"https://api.github.com/users/alexjgriffith/repos","events_url":"https://api.github.com/users/alexjgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/alexjgriffith/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122/commits","review_comments_url":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122/comments","review_comment_url":"https://api.github.com/repos/jdenen/mastodon.el/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jdenen/mastodon.el/issues/122/comments","statuses_url":"https://api.github.com/repos/jdenen/mastodon.el/statuses/fcda70903fccc94eaebbe3fed898376cbe1d76b9","head":{"label":"alexjgriffith:84-local-vars","ref":"84-local-vars","sha":"fcda70903fccc94eaebbe3fed898376cbe1d76b9","user":{"login":"alexjgriffith","id":6475397,"avatar_url":"https://avatars1.githubusercontent.com/u/6475397?v=3","gravatar_id":"","url":"https://api.github.com/users/alexjgriffith","html_url":"https://github.com/alexjgriffith","followers_url":"https://api.github.com/users/alexjgriffith/followers","following_url":"https://api.github.com/users/alexjgriffith/following{/other_user}","gists_url":"https://api.github.com/users/alexjgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/alexjgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexjgriffith/subscriptions","organizations_url":"https://api.github.com/users/alexjgriffith/orgs","repos_url":"https://api.github.com/users/alexjgriffith/repos","events_url":"https://api.github.com/users/alexjgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/alexjgriffith/received_events","type":"User","site_admin":false},"repo":{"id":89093856,"name":"mastodon.el","full_name":"alexjgriffith/mastodon.el","owner":{"login":"alexjgriffith","id":6475397,"avatar_url":"https://avatars1.githubusercontent.com/u/6475397?v=3","gravatar_id":"","url":"https://api.github.com/users/alexjgriffith","html_url":"https://github.com/alexjgriffith","followers_url":"https://api.github.com/users/alexjgriffith/followers","following_url":"https://api.github.com/users/alexjgriffith/following{/other_user}","gists_url":"https://api.github.com/users/alexjgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/alexjgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexjgriffith/subscriptions","organizations_url":"https://api.github.com/users/alexjgriffith/orgs","repos_url":"https://api.github.com/users/alexjgriffith/repos","events_url":"https://api.github.com/users/alexjgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/alexjgriffith/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexjgriffith/mastodon.el","description":"Emacs client for Mastodon","fork":true,"url":"https://api.github.com/repos/alexjgriffith/mastodon.el","forks_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/forks","keys_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/teams","hooks_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/hooks","issue_events_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/issues/events{/number}","events_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/events","assignees_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/assignees{/user}","branches_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/branches{/branch}","tags_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/tags","blobs_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/statuses/{sha}","languages_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/languages","stargazers_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/stargazers","contributors_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/contributors","subscribers_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/subscribers","subscription_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/subscription","commits_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/contents/{+path}","compare_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/merges","archive_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/downloads","issues_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/issues{/number}","pulls_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/pulls{/number}","milestones_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/milestones{/number}","notifications_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/labels{/name}","releases_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/releases{/id}","deployments_url":"https://api.github.com/repos/alexjgriffith/mastodon.el/deployments","created_at":"2017-04-22T19:24:55Z","updated_at":"2017-04-22T19:24:56Z","pushed_at":"2017-05-13T15:03:39Z","git_url":"git://github.com/alexjgriffith/mastodon.el.git","ssh_url":"git@github.com:alexjgriffith/mastodon.el.git","clone_url":"https://github.com/alexjgriffith/mastodon.el.git","svn_url":"https://github.com/alexjgriffith/mastodon.el","homepage":null,"size":198,"stargazers_count":0,"watchers_count":0,"language":"Emacs Lisp","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jdenen:develop","ref":"develop","sha":"4d0bd43c0ede0159c0f0130a5565ea5a6511997a","user":{"login":"jdenen","id":4671695,"avatar_url":"https://avatars0.githubusercontent.com/u/4671695?v=3","gravatar_id":"","url":"https://api.github.com/users/jdenen","html_url":"https://github.com/jdenen","followers_url":"https://api.github.com/users/jdenen/followers","following_url":"https://api.github.com/users/jdenen/following{/other_user}","gists_url":"https://api.github.com/users/jdenen/gists{/gist_id}","starred_url":"https://api.github.com/users/jdenen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdenen/subscriptions","organizations_url":"https://api.github.com/users/jdenen/orgs","repos_url":"https://api.github.com/users/jdenen/repos","events_url":"https://api.github.com/users/jdenen/events{/privacy}","received_events_url":"https://api.github.com/users/jdenen/received_events","type":"User","site_admin":false},"repo":{"id":87654033,"name":"mastodon.el","full_name":"jdenen/mastodon.el","owner":{"login":"jdenen","id":4671695,"avatar_url":"https://avatars0.githubusercontent.com/u/4671695?v=3","gravatar_id":"","url":"https://api.github.com/users/jdenen","html_url":"https://github.com/jdenen","followers_url":"https://api.github.com/users/jdenen/followers","following_url":"https://api.github.com/users/jdenen/following{/other_user}","gists_url":"https://api.github.com/users/jdenen/gists{/gist_id}","starred_url":"https://api.github.com/users/jdenen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdenen/subscriptions","organizations_url":"https://api.github.com/users/jdenen/orgs","repos_url":"https://api.github.com/users/jdenen/repos","events_url":"https://api.github.com/users/jdenen/events{/privacy}","received_events_url":"https://api.github.com/users/jdenen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jdenen/mastodon.el","description":"Emacs client for Mastodon","fork":false,"url":"https://api.github.com/repos/jdenen/mastodon.el","forks_url":"https://api.github.com/repos/jdenen/mastodon.el/forks","keys_url":"https://api.github.com/repos/jdenen/mastodon.el/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jdenen/mastodon.el/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jdenen/mastodon.el/teams","hooks_url":"https://api.github.com/repos/jdenen/mastodon.el/hooks","issue_events_url":"https://api.github.com/repos/jdenen/mastodon.el/issues/events{/number}","events_url":"https://api.github.com/repos/jdenen/mastodon.el/events","assignees_url":"https://api.github.com/repos/jdenen/mastodon.el/assignees{/user}","branches_url":"https://api.github.com/repos/jdenen/mastodon.el/branches{/branch}","tags_url":"https://api.github.com/repos/jdenen/mastodon.el/tags","blobs_url":"https://api.github.com/repos/jdenen/mastodon.el/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jdenen/mastodon.el/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jdenen/mastodon.el/git/refs{/sha}","trees_url":"https://api.github.com/repos/jdenen/mastodon.el/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jdenen/mastodon.el/statuses/{sha}","languages_url":"https://api.github.com/repos/jdenen/mastodon.el/languages","stargazers_url":"https://api.github.com/repos/jdenen/mastodon.el/stargazers","contributors_url":"https://api.github.com/repos/jdenen/mastodon.el/contributors","subscribers_url":"https://api.github.com/repos/jdenen/mastodon.el/subscribers","subscription_url":"https://api.github.com/repos/jdenen/mastodon.el/subscription","commits_url":"https://api.github.com/repos/jdenen/mastodon.el/commits{/sha}","git_commits_url":"https://api.github.com/repos/jdenen/mastodon.el/git/commits{/sha}","comments_url":"https://api.github.com/repos/jdenen/mastodon.el/comments{/number}","issue_comment_url":"https://api.github.com/repos/jdenen/mastodon.el/issues/comments{/number}","contents_url":"https://api.github.com/repos/jdenen/mastodon.el/contents/{+path}","compare_url":"https://api.github.com/repos/jdenen/mastodon.el/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jdenen/mastodon.el/merges","archive_url":"https://api.github.com/repos/jdenen/mastodon.el/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jdenen/mastodon.el/downloads","issues_url":"https://api.github.com/repos/jdenen/mastodon.el/issues{/number}","pulls_url":"https://api.github.com/repos/jdenen/mastodon.el/pulls{/number}","milestones_url":"https://api.github.com/repos/jdenen/mastodon.el/milestones{/number}","notifications_url":"https://api.github.com/repos/jdenen/mastodon.el/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jdenen/mastodon.el/labels{/name}","releases_url":"https://api.github.com/repos/jdenen/mastodon.el/releases{/id}","deployments_url":"https://api.github.com/repos/jdenen/mastodon.el/deployments","created_at":"2017-04-08T18:10:17Z","updated_at":"2017-05-13T19:43:26Z","pushed_at":"2017-05-13T18:19:30Z","git_url":"git://github.com/jdenen/mastodon.el.git","ssh_url":"git@github.com:jdenen/mastodon.el.git","clone_url":"https://github.com/jdenen/mastodon.el.git","svn_url":"https://github.com/jdenen/mastodon.el","homepage":null,"size":182,"stargazers_count":64,"watchers_count":64,"language":"Emacs Lisp","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":36,"forks":9,"open_issues":36,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122"},"html":{"href":"https://github.com/jdenen/mastodon.el/pull/122"},"issue":{"href":"https://api.github.com/repos/jdenen/mastodon.el/issues/122"},"comments":{"href":"https://api.github.com/repos/jdenen/mastodon.el/issues/122/comments"},"review_comments":{"href":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122/comments"},"review_comment":{"href":"https://api.github.com/repos/jdenen/mastodon.el/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jdenen/mastodon.el/pulls/122/commits"},"statuses":{"href":"https://api.github.com/repos/jdenen/mastodon.el/statuses/fcda70903fccc94eaebbe3fed898376cbe1d76b9"}}}}
{"actor":{"display_login":"alexjgriffith"}}