[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a601e40 104/399: counsel.el (counsel-org-goto-all): Use or
From: |
Oleh Krehel |
Subject: |
[elpa] master a601e40 104/399: counsel.el (counsel-org-goto-all): Use org-mode outline settings |
Date: |
Sat, 20 Jul 2019 14:56:58 -0400 (EDT) |
branch: master
commit a601e40c8e27713c3dec83f805e95e8516d01078
Author: Eugene Sharygin <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-org-goto-all): Use org-mode outline settings
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 #1947
---
counsel.el | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/counsel.el b/counsel.el
index c09743b..3bb472c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -3054,6 +3054,20 @@ otherwise continue prompting for tags."
;;;###autoload
(defalias 'counsel-org-goto #'counsel-outline)
+(defcustom counsel-org-goto-all-outline-path-prefix nil
+ "Prefix for outline candidates in `counsel-org-goto-all'."
+ :type '(choice
+ (const :tag "None" nil)
+ (const :tag "File name" file-name)
+ (const :tag "File name (nondirectory part)" file-name-nondirectory)
+ (const :tag "Buffer name" buffer-name)))
+
+(defun counsel-org-goto-all--outline-path-prefix ()
+ (cl-case counsel-org-goto-all-outline-path-prefix
+ (file-name buffer-file-name)
+ (file-name-nondirectory (file-name-nondirectory buffer-file-name))
+ (buffer-name (buffer-name))))
+
;;;###autoload
(defun counsel-org-goto-all ()
"Go to a different location in any org file."
@@ -3062,7 +3076,11 @@ otherwise continue prompting for tags."
(dolist (b (buffer-list))
(with-current-buffer b
(when (derived-mode-p 'org-mode)
- (setq entries (nconc entries (counsel-outline-candidates))))))
+ (setq entries
+ (nconc entries
+ (counsel-outline-candidates
+ (cdr (assq 'org-mode counsel-outline-settings))
+ (counsel-org-goto-all--outline-path-prefix)))))))
(ivy-read "Goto: " entries
:history 'counsel-org-goto-history
:action #'counsel-org-goto-action
@@ -4176,12 +4194,13 @@ setting in `counsel-outline-settings', which see."
(defvar counsel-outline--preselect 0
"Index of the presected candidate in `counsel-outline'.")
-(defun counsel-outline-candidates (&optional settings)
+(defun counsel-outline-candidates (&optional settings prefix)
"Return an alist of outline heading completion candidates.
Each element is a pair (HEADING . MARKER), where the string
HEADING is located at the position of MARKER. SETTINGS is a
-plist entry from `counsel-outline-settings', which see."
- (let ((bol-regex (concat "^\\(?:"
+plist entry from `counsel-outline-settings', which see.
+PREFIX is a string prepended to all candidates."
+ (let* ((bol-regex (concat "^\\(?:"
(or (plist-get settings :outline-regexp)
outline-regexp)
"\\)"))
@@ -4199,7 +4218,9 @@ plist entry from `counsel-outline-settings', which see."
counsel-outline-custom-faces))
(stack-level 0)
(orig-point (point))
- cands name level marker stack)
+ (stack (and prefix (list (counsel-outline--add-face
+ prefix 0 face-style custom-faces))))
+ cands name level marker)
(save-excursion
(setq counsel-outline--preselect 0)
(goto-char (point-min))
- [elpa] master d92d43a 085/399: counsel.el (counsel-compile-root-functions): Tidy, (continued)
- [elpa] master d92d43a 085/399: counsel.el (counsel-compile-root-functions): Tidy, Oleh Krehel, 2019/07/20
- [elpa] master 2356a1d 091/399: ivy-test.el (counsel--grep-regex): Extend test, Oleh Krehel, 2019/07/20
- [elpa] master cdd7ada 094/399: counsel.el (counsel-url-expand): Avoid null error, Oleh Krehel, 2019/07/20
- [elpa] master 089107a 099/399: counsel.el (counsel-ag): Add a keyword argument caller, Oleh Krehel, 2019/07/20
- [elpa] master 776fbb7 103/399: Make ivy-switch-buffer-occur work with multi-pass regex builders, Oleh Krehel, 2019/07/20
- [elpa] master 8b4c939 100/399: counsel.el (counsel-cd): Add, Oleh Krehel, 2019/07/20
- [elpa] master 0c8cfe8 106/399: ivy-hydra.el (ivy-dispatching-done-idle): Add, Oleh Krehel, 2019/07/20
- [elpa] master 4c52362 110/399: swiper.el (swiper-occur): Make wgrep work for narrowed buffers, Oleh Krehel, 2019/07/20
- [elpa] master 8c1a2fa 107/399: Allow all re-builders to use ivy-highlight-grep-commands, Oleh Krehel, 2019/07/20
- [elpa] master 78b62f2 102/399: README.md: Mention char-fold-to-regexp, Oleh Krehel, 2019/07/20
- [elpa] master a601e40 104/399: counsel.el (counsel-org-goto-all): Use org-mode outline settings,
Oleh Krehel <=
- [elpa] master 468e914 109/399: counsel.el (counsel--file-name-filter): Clean up style, Oleh Krehel, 2019/07/20
- [elpa] master 6373a48 105/399: counsel.el: Fix compiler warning, Oleh Krehel, 2019/07/20
- [elpa] master 164fecb 108/399: Make find-file-occur work with multi-pass regex builders, Oleh Krehel, 2019/07/20
- [elpa] master 3b677d4 113/399: counsel.el (counsel-file-jump-args): Fix dotfiles not being shown, Oleh Krehel, 2019/07/20
- [elpa] master ffa2d8f 112/399: counsel.el (counsel-unicode-char): Fix sorting, Oleh Krehel, 2019/07/20
- [elpa] master 18d7f84 117/399: counsel.el (counsel-yank-pop-action): Also works for strings, Oleh Krehel, 2019/07/20
- [elpa] master c56ad2a 114/399: ivy-hydra.el (ivy-dispatching-done-hydra): Improve, Oleh Krehel, 2019/07/20
- [elpa] master 344aebc 116/399: counsel.el (counsel-dired-jump): Improve, Oleh Krehel, 2019/07/20
- [elpa] master b27ef9e 111/399: counsel.el (counsel-git-cands): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 1b5af1e 115/399: counsel.el (counsel-file-jump-args): Adjust, Oleh Krehel, 2019/07/20