Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel-org-goto-all: Add candidate prefixes & use org-mode settings #1947

Closed
wants to merge 5 commits into from

Conversation

eush77
Copy link
Contributor

@eush77 eush77 commented Feb 28, 2019

Hi,

I'd like to contribute two changes to counsel-org-goto-all that make the command much more useful to me:

  1. Pass the settings for org-mode to counsel-outline-candidates so that it respects Org-specific variables such as counsel-org-goto-display-tags, counsel-org-goto-display-todo, etc.

  2. Add customization setting to prepend file/buffer name of a heading as a prefix in the candidate list, with the same choices as for org-refile-use-outline-path.

I believe the changes aren't legally significant (half of the diff is whitespace changes).

This passes `counsel-outline-settings` for `org-mode` to
`counsel-outline-candidates` so that it respects Org-specific settings.
This adds `counsel-org-goto-all-outline-path-prefix` variable that
controls a prefix included into outline path candidates.

- If the value is `file`, the prefix is the file name without directory.
- If the value is `full-file-path`, the prefix is the full file name.
- If the value is `buffer-name`, the prefix is the buffer name.
counsel.el Outdated Show resolved Hide resolved
@@ -3127,6 +3127,26 @@ otherwise continue prompting for tags."
;;;###autoload
(defalias 'counsel-org-goto #'counsel-outline)

(defcustom counsel-org-goto-all-outline-path-prefix nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: is this too specific a name? Could this user option become useful for a related but slightly different purpose in the future, e.g. outside of "goto-all"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that seems a little too specific.

For starters, I think this variable can immediately be used in counsel-org-agenda-headlines.

Also, it seems to me that counsel-org-goto-all itself should be generalized to other modes supported by counsel-outline, and counsel-org-goto-all should be a wrapper around this new function. The variable would then be used in the hypothetical counsel-outline-all and by proxy, counsel-emacs-lisp-goto-all, counsel-outline-latex-goto-all, etc.

Given these use cases and the existing variable counsel-outline-path-separator, I think a name like counsel-outline-path-prefix would be fitting, although it should be made clear that the prefix is only used when outlines from multiple buffers are displayed in one candidate list.

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, though it's been a while since I last looked at the implementation of these features, so I could be missing something.

Either way, I don't see anything wrong with making the name of the new user option more general.

Thanks.

counsel.el Outdated Show resolved Hide resolved
counsel.el Show resolved Hide resolved
counsel.el Outdated Show resolved Hide resolved
counsel.el Outdated Show resolved Hide resolved
@basil-conto
Copy link
Collaborator

Thanks for working on this, looks good!

This fixes docstring according to (info "(elisp) Documentation Tips").
This mentions the argument PREFIX in the docstring.
This replaces `if` with `and` in a logical expression, for clarity.
@abo-abo abo-abo closed this in a601e40 Mar 27, 2019
@abo-abo
Copy link
Owner

abo-abo commented Mar 27, 2019

Merged, thanks. Please look into getting an Emacs CA if you plan future contributions.

astoff pushed a commit to astoff/swiper that referenced this pull request Jan 1, 2021
This passes `counsel-outline-settings' for `org-mode' to
`counsel-outline-candidates' so that it respects Org-specific settings.

counsel.el (counsel-org-goto-all): Add buffer/file name as prefix

This adds `counsel-org-goto-all-outline-path-prefix' variable that
controls a prefix included into outline path candidates.

- If the value is 'file, the prefix is the file name without directory.
- If the value is 'full-file-path, the prefix is the full file name.
- If the value is 'buffer-name, the prefix is the buffer name.

Fixes abo-abo#1947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants