{"action":"created","comment":{"url":"https://api.github.com/repos/abo-abo/swiper/pulls/comments/205551476","pull_request_review_id":140845323,"id":205551476,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTU1MTQ3Ng==","diff_hunk":"@@ -4019,30 +3983,169 @@ TREEP is used to expand internal nodes.\"\n     (counsel-imenu)))\n \n ;;** `counsel-outline'\n-(defun counsel-outline-candidates ()\n+(defvar counsel-outline-settings\n+  '((emacs-lisp-mode\n+     :outline-regexp \";;[;*]+[\\s\\t]+\"\n+     :outline-level counsel-outline-level-emacs-lisp)\n+    (org-mode\n+     :outline-title counsel-outline-title-org\n+     :action counsel-org-goto-action)\n+    (markdown-mode\n+     :outline-title counsel-outline-title-markdown)\n+    (latex-mode\n+     :outline-title counsel-outline-title-latex))\n+  \"An alist holding `counsel-outline' settings for particular\n+major modes.\n+\n+Each entry is a pair \\(MAJOR-MODE . PLIST\\).  `counsel-outline'\n+checks whether an entry exists for the current buffer's\n+MAJOR-MODE and, if so, loads the settings specified by PLIST\n+instead of the default settings.  The following settings are\n+recognized:\n+\n+- `:outline-regexp' is a regexp to match the beggining of an\n+  outline heading.  It is only checked at the start of a line and\n+  so need not start with `^'.  The default is to use the value of\n+  the variable `outline-regexp'.\n+\n+- `:outline-level' is a function of no args to compute the level of\n+  an outline heading.  It is called with point at the beginning\n+  of `outline-regexp' and with the match data reflicting\n+  `outline-regexp'.  The default is to use the value of the\n+  variable `outline-level'.\n+\n+- `:outline-title' is a function of no args to get the title of an\n+  outline heading.  It is called with point at the end of\n+  `outline-regexp' and with the match data reflicting\n+  `outline-regexp'.  The default is to use the function\n+  `counsel-outline-title'.\n+\n+- `:action' is a function of one arg, a marker corresponding to the\n+  beginning of the selected outline heading, performing","path":"counsel.el","position":92,"original_position":92,"commit_id":"22f61a4ac6b823a950576f991566583643f27e79","original_commit_id":"22f61a4ac6b823a950576f991566583643f27e79","user":{"login":"basil-conto","id":9121222,"node_id":"MDQ6VXNlcjkxMjEyMjI=","avatar_url":"https://avatars2.githubusercontent.com/u/9121222?v=4","gravatar_id":"","url":"https://api.github.com/users/basil-conto","html_url":"https://github.com/basil-conto","followers_url":"https://api.github.com/users/basil-conto/followers","following_url":"https://api.github.com/users/basil-conto/following{/other_user}","gists_url":"https://api.github.com/users/basil-conto/gists{/gist_id}","starred_url":"https://api.github.com/users/basil-conto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basil-conto/subscriptions","organizations_url":"https://api.github.com/users/basil-conto/orgs","repos_url":"https://api.github.com/users/basil-conto/repos","events_url":"https://api.github.com/users/basil-conto/events{/privacy}","received_events_url":"https://api.github.com/users/basil-conto/received_events","type":"User","site_admin":false},"body":"Isn't this inaccurate? Neither `counsel-outline-action` nor `counsel-org-goto-action` take a marker; rather, they take a cons whose cdr is an integer or marker.","created_at":"2018-07-26T18:06:06Z","updated_at":"2018-07-26T18:06:06Z","html_url":"https://github.com/abo-abo/swiper/pull/1681#discussion_r205551476","pull_request_url":"https://api.github.com/repos/abo-abo/swiper/pulls/1681","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/abo-abo/swiper/pulls/comments/205551476"},"html":{"href":"https://github.com/abo-abo/swiper/pull/1681#discussion_r205551476"},"pull_request":{"href":"https://api.github.com/repos/abo-abo/swiper/pulls/1681"}}},"pull_request":{"url":"https://api.github.com/repos/abo-abo/swiper/pulls/1681","id":203859413,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzODU5NDEz","html_url":"https://github.com/abo-abo/swiper/pull/1681","diff_url":"https://github.com/abo-abo/swiper/pull/1681.diff","patch_url":"https://github.com/abo-abo/swiper/pull/1681.patch","issue_url":"https://api.github.com/repos/abo-abo/swiper/issues/1681","number":1681,"state":"closed","locked":false,"title":"Generalize counsel-outline to handle major modes and display styles","user":{"login":"ericdanan","id":11611353,"node_id":"MDQ6VXNlcjExNjExMzUz","avatar_url":"https://avatars3.githubusercontent.com/u/11611353?v=4","gravatar_id":"","url":"https://api.github.com/users/ericdanan","html_url":"https://github.com/ericdanan","followers_url":"https://api.github.com/users/ericdanan/followers","following_url":"https://api.github.com/users/ericdanan/following{/other_user}","gists_url":"https://api.github.com/users/ericdanan/gists{/gist_id}","starred_url":"https://api.github.com/users/ericdanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericdanan/subscriptions","organizations_url":"https://api.github.com/users/ericdanan/orgs","repos_url":"https://api.github.com/users/ericdanan/repos","events_url":"https://api.github.com/users/ericdanan/events{/privacy}","received_events_url":"https://api.github.com/users/ericdanan/received_events","type":"User","site_admin":false},"body":"Hello,\r\n\r\nThe first of the two commits is a simple fix making sure that `counsel-outline-candidates` only searches for `outline-regexp` at the beginning of a line (because from the docstring of `outline-regexp`, it does not necessarily start with `^`).\r\n\r\nThe second commit is the one that generalizes `counsel-outline`, in two ways. First, to handle display/face styles as in `counsel-org-goto`. This is simply done by moving code from `counsel-org-goto--get-headlines` to `counsel-outline-candidates` and make the former call the latter. Note that the display/face style in `counsel-outline` is also controlled by the variables `counsel-org-goto-display/face-style`, perhaps that's not elegant and new variables should be introduced, I'm not sure.\r\n\r\nSecond, to handle major modes in which the outline title does not simply go from the end of `outline-regexp` to the end of the line. For instance, in markdown-mode, the title is iside the regexp, such as markdown or latex. This is done by introducing a variable `counsel-outline-title` storing the function to use, which can be locally bound in major mode hooks. There are instructions in the docstring of `counsel-outline` about how to set this up. I've also put there instructions for emacs-lisp-mode, because the default values of `outline-regexp` and `outline-level` set by this mode are not adequate for `counsel-outline` (by the way, the dir-local value in the swiper repository ìs better but still matches all lines starting with `(` or the autoload cookie, which we don't want I think).\r\n\r\nI think this approach is quite flexible but I'm not sure it's the best one because `counsel-outline` will not work out of the box for these modes. Alternative I thought of:\r\n- Putting the `add-hook` statements directly in `counsel.el`, but I'm not sure it's good practice.\r\n- Storing mode settings for `counsel-outline` (regexp, level function, title function) in an alist varaible, with a working default value, but I'm not sure it's good practice either for the regexp and level because it would overlook file/dir-local bindings of these variables and introduce an inconsistency between `counsel-outline` and the vanilla outline commands (eg `outline-next-heading`).\r\n\r\nNote that after this generalization, `counsel-org-goto` is actually equivalent to `counsel-outline` after `counsel-outline-title` in `org-mode-hook` (actually there's one difference remaining in the action function, but that could accomodated). But `counsel-org-goto` works without setting anything, by let-binding `counsel-outline-title`. I didn't remove any existing function.\r\n\r\nFinally, I implemeted a `:preselect` for `counsel-outline`, it seems useful to me to have the current heading preselected, but this is an independent thing.\r\n\r\nIf you're interesed in this PR, let me know of course if I should make changes.\r\n\r\nThanks for your attention.\r\n\r\n","created_at":"2018-07-25T14:37:37Z","updated_at":"2018-07-26T18:06:06Z","closed_at":"2018-07-26T15:27:28Z","merged_at":null,"merge_commit_sha":"79d076ea0c633b3a0e08c2b452a89bc4bbaff880","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/abo-abo/swiper/pulls/1681/commits","review_comments_url":"https://api.github.com/repos/abo-abo/swiper/pulls/1681/comments","review_comment_url":"https://api.github.com/repos/abo-abo/swiper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/abo-abo/swiper/issues/1681/comments","statuses_url":"https://api.github.com/repos/abo-abo/swiper/statuses/22f61a4ac6b823a950576f991566583643f27e79","head":{"label":"ericdanan:outline2","ref":"outline2","sha":"22f61a4ac6b823a950576f991566583643f27e79","user":{"login":"ericdanan","id":11611353,"node_id":"MDQ6VXNlcjExNjExMzUz","avatar_url":"https://avatars3.githubusercontent.com/u/11611353?v=4","gravatar_id":"","url":"https://api.github.com/users/ericdanan","html_url":"https://github.com/ericdanan","followers_url":"https://api.github.com/users/ericdanan/followers","following_url":"https://api.github.com/users/ericdanan/following{/other_user}","gists_url":"https://api.github.com/users/ericdanan/gists{/gist_id}","starred_url":"https://api.github.com/users/ericdanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericdanan/subscriptions","organizations_url":"https://api.github.com/users/ericdanan/orgs","repos_url":"https://api.github.com/users/ericdanan/repos","events_url":"https://api.github.com/users/ericdanan/events{/privacy}","received_events_url":"https://api.github.com/users/ericdanan/received_events","type":"User","site_admin":false},"repo":{"id":116247213,"node_id":"MDEwOlJlcG9zaXRvcnkxMTYyNDcyMTM=","name":"swiper","full_name":"ericdanan/swiper","owner":{"login":"ericdanan","id":11611353,"node_id":"MDQ6VXNlcjExNjExMzUz","avatar_url":"https://avatars3.githubusercontent.com/u/11611353?v=4","gravatar_id":"","url":"https://api.github.com/users/ericdanan","html_url":"https://github.com/ericdanan","followers_url":"https://api.github.com/users/ericdanan/followers","following_url":"https://api.github.com/users/ericdanan/following{/other_user}","gists_url":"https://api.github.com/users/ericdanan/gists{/gist_id}","starred_url":"https://api.github.com/users/ericdanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericdanan/subscriptions","organizations_url":"https://api.github.com/users/ericdanan/orgs","repos_url":"https://api.github.com/users/ericdanan/repos","events_url":"https://api.github.com/users/ericdanan/events{/privacy}","received_events_url":"https://api.github.com/users/ericdanan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ericdanan/swiper","description":"Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!","fork":true,"url":"https://api.github.com/repos/ericdanan/swiper","forks_url":"https://api.github.com/repos/ericdanan/swiper/forks","keys_url":"https://api.github.com/repos/ericdanan/swiper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ericdanan/swiper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ericdanan/swiper/teams","hooks_url":"https://api.github.com/repos/ericdanan/swiper/hooks","issue_events_url":"https://api.github.com/repos/ericdanan/swiper/issues/events{/number}","events_url":"https://api.github.com/repos/ericdanan/swiper/events","assignees_url":"https://api.github.com/repos/ericdanan/swiper/assignees{/user}","branches_url":"https://api.github.com/repos/ericdanan/swiper/branches{/branch}","tags_url":"https://api.github.com/repos/ericdanan/swiper/tags","blobs_url":"https://api.github.com/repos/ericdanan/swiper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ericdanan/swiper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ericdanan/swiper/git/refs{/sha}","trees_url":"https://api.github.com/repos/ericdanan/swiper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ericdanan/swiper/statuses/{sha}","languages_url":"https://api.github.com/repos/ericdanan/swiper/languages","stargazers_url":"https://api.github.com/repos/ericdanan/swiper/stargazers","contributors_url":"https://api.github.com/repos/ericdanan/swiper/contributors","subscribers_url":"https://api.github.com/repos/ericdanan/swiper/subscribers","subscription_url":"https://api.github.com/repos/ericdanan/swiper/subscription","commits_url":"https://api.github.com/repos/ericdanan/swiper/commits{/sha}","git_commits_url":"https://api.github.com/repos/ericdanan/swiper/git/commits{/sha}","comments_url":"https://api.github.com/repos/ericdanan/swiper/comments{/number}","issue_comment_url":"https://api.github.com/repos/ericdanan/swiper/issues/comments{/number}","contents_url":"https://api.github.com/repos/ericdanan/swiper/contents/{+path}","compare_url":"https://api.github.com/repos/ericdanan/swiper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ericdanan/swiper/merges","archive_url":"https://api.github.com/repos/ericdanan/swiper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ericdanan/swiper/downloads","issues_url":"https://api.github.com/repos/ericdanan/swiper/issues{/number}","pulls_url":"https://api.github.com/repos/ericdanan/swiper/pulls{/number}","milestones_url":"https://api.github.com/repos/ericdanan/swiper/milestones{/number}","notifications_url":"https://api.github.com/repos/ericdanan/swiper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ericdanan/swiper/labels{/name}","releases_url":"https://api.github.com/repos/ericdanan/swiper/releases{/id}","deployments_url":"https://api.github.com/repos/ericdanan/swiper/deployments","created_at":"2018-01-04T10:31:52Z","updated_at":"2018-01-04T10:31:54Z","pushed_at":"2018-07-25T20:55:58Z","git_url":"git://github.com/ericdanan/swiper.git","ssh_url":"git@github.com:ericdanan/swiper.git","clone_url":"https://github.com/ericdanan/swiper.git","svn_url":"https://github.com/ericdanan/swiper","homepage":"http://oremacs.com/swiper/","size":4353,"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,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"abo-abo:master","ref":"master","sha":"93f4ea7f6951bc4b2f0b7a13fdfa7bd82013fb64","user":{"login":"abo-abo","id":2937359,"node_id":"MDQ6VXNlcjI5MzczNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/2937359?v=4","gravatar_id":"","url":"https://api.github.com/users/abo-abo","html_url":"https://github.com/abo-abo","followers_url":"https://api.github.com/users/abo-abo/followers","following_url":"https://api.github.com/users/abo-abo/following{/other_user}","gists_url":"https://api.github.com/users/abo-abo/gists{/gist_id}","starred_url":"https://api.github.com/users/abo-abo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abo-abo/subscriptions","organizations_url":"https://api.github.com/users/abo-abo/orgs","repos_url":"https://api.github.com/users/abo-abo/repos","events_url":"https://api.github.com/users/abo-abo/events{/privacy}","received_events_url":"https://api.github.com/users/abo-abo/received_events","type":"User","site_admin":false},"repo":{"id":31918222,"node_id":"MDEwOlJlcG9zaXRvcnkzMTkxODIyMg==","name":"swiper","full_name":"abo-abo/swiper","owner":{"login":"abo-abo","id":2937359,"node_id":"MDQ6VXNlcjI5MzczNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/2937359?v=4","gravatar_id":"","url":"https://api.github.com/users/abo-abo","html_url":"https://github.com/abo-abo","followers_url":"https://api.github.com/users/abo-abo/followers","following_url":"https://api.github.com/users/abo-abo/following{/other_user}","gists_url":"https://api.github.com/users/abo-abo/gists{/gist_id}","starred_url":"https://api.github.com/users/abo-abo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abo-abo/subscriptions","organizations_url":"https://api.github.com/users/abo-abo/orgs","repos_url":"https://api.github.com/users/abo-abo/repos","events_url":"https://api.github.com/users/abo-abo/events{/privacy}","received_events_url":"https://api.github.com/users/abo-abo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abo-abo/swiper","description":"Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!","fork":false,"url":"https://api.github.com/repos/abo-abo/swiper","forks_url":"https://api.github.com/repos/abo-abo/swiper/forks","keys_url":"https://api.github.com/repos/abo-abo/swiper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abo-abo/swiper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abo-abo/swiper/teams","hooks_url":"https://api.github.com/repos/abo-abo/swiper/hooks","issue_events_url":"https://api.github.com/repos/abo-abo/swiper/issues/events{/number}","events_url":"https://api.github.com/repos/abo-abo/swiper/events","assignees_url":"https://api.github.com/repos/abo-abo/swiper/assignees{/user}","branches_url":"https://api.github.com/repos/abo-abo/swiper/branches{/branch}","tags_url":"https://api.github.com/repos/abo-abo/swiper/tags","blobs_url":"https://api.github.com/repos/abo-abo/swiper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abo-abo/swiper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abo-abo/swiper/git/refs{/sha}","trees_url":"https://api.github.com/repos/abo-abo/swiper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abo-abo/swiper/statuses/{sha}","languages_url":"https://api.github.com/repos/abo-abo/swiper/languages","stargazers_url":"https://api.github.com/repos/abo-abo/swiper/stargazers","contributors_url":"https://api.github.com/repos/abo-abo/swiper/contributors","subscribers_url":"https://api.github.com/repos/abo-abo/swiper/subscribers","subscription_url":"https://api.github.com/repos/abo-abo/swiper/subscription","commits_url":"https://api.github.com/repos/abo-abo/swiper/commits{/sha}","git_commits_url":"https://api.github.com/repos/abo-abo/swiper/git/commits{/sha}","comments_url":"https://api.github.com/repos/abo-abo/swiper/comments{/number}","issue_comment_url":"https://api.github.com/repos/abo-abo/swiper/issues/comments{/number}","contents_url":"https://api.github.com/repos/abo-abo/swiper/contents/{+path}","compare_url":"https://api.github.com/repos/abo-abo/swiper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abo-abo/swiper/merges","archive_url":"https://api.github.com/repos/abo-abo/swiper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abo-abo/swiper/downloads","issues_url":"https://api.github.com/repos/abo-abo/swiper/issues{/number}","pulls_url":"https://api.github.com/repos/abo-abo/swiper/pulls{/number}","milestones_url":"https://api.github.com/repos/abo-abo/swiper/milestones{/number}","notifications_url":"https://api.github.com/repos/abo-abo/swiper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abo-abo/swiper/labels{/name}","releases_url":"https://api.github.com/repos/abo-abo/swiper/releases{/id}","deployments_url":"https://api.github.com/repos/abo-abo/swiper/deployments","created_at":"2015-03-09T19:29:06Z","updated_at":"2018-07-26T15:27:30Z","pushed_at":"2018-07-26T15:27:25Z","git_url":"git://github.com/abo-abo/swiper.git","ssh_url":"git@github.com:abo-abo/swiper.git","clone_url":"https://github.com/abo-abo/swiper.git","svn_url":"https://github.com/abo-abo/swiper","homepage":"https://oremacs.com/swiper/","size":4378,"stargazers_count":915,"watchers_count":915,"language":"Emacs Lisp","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":194,"mirror_url":null,"archived":false,"open_issues_count":236,"license":null,"forks":194,"open_issues":236,"watchers":915,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/abo-abo/swiper/pulls/1681"},"html":{"href":"https://github.com/abo-abo/swiper/pull/1681"},"issue":{"href":"https://api.github.com/repos/abo-abo/swiper/issues/1681"},"comments":{"href":"https://api.github.com/repos/abo-abo/swiper/issues/1681/comments"},"review_comments":{"href":"https://api.github.com/repos/abo-abo/swiper/pulls/1681/comments"},"review_comment":{"href":"https://api.github.com/repos/abo-abo/swiper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/abo-abo/swiper/pulls/1681/commits"},"statuses":{"href":"https://api.github.com/repos/abo-abo/swiper/statuses/22f61a4ac6b823a950576f991566583643f27e79"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"basil-conto"}}