Skip to content

Commit 2da1315

Browse files
Add helm-limit-to-sources command
1 parent 8a03a04 commit 2da1315

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

helm-core.el

+23
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ i.e. the loop is not entered after running COMMAND."
438438
(define-key map (kbd "M-a") #'helm-mark-all)
439439
(define-key map (kbd "M-U") #'helm-unmark-all)
440440
(define-key map (kbd "C-M-a") #'helm-show-all-candidates-in-source)
441+
(define-key map (kbd "C-M-f") #'helm-limit-to-sources)
441442
(define-key map (kbd "C-M-e") #'helm-display-all-sources)
442443
(define-key map (kbd "C-s") #'undefined)
443444
(define-key map (kbd "M-s") #'undefined)
@@ -2421,6 +2422,28 @@ show ARG number of candidates."
24212422
(helm-set-source-filter nil)))
24222423
(put 'helm-display-all-sources 'helm-only t)
24232424

2425+
(defun helm-limit-to-sources ()
2426+
"Limit sources to display from current session.
2427+
This is a toggle command, when hit a second time reset to all sources."
2428+
(interactive)
2429+
(with-helm-alive-p
2430+
(with-helm-buffer
2431+
(if (null helm-source-filter)
2432+
(when (cdr helm-sources)
2433+
(let ((headers (helm-comp-read
2434+
"Limit to source(s): "
2435+
(mapcar
2436+
(lambda (s)
2437+
(let* ((name (assoc-default 'name s))
2438+
(disp (helm-aif (assoc-default 'header-name s)
2439+
(funcall it name) name)))
2440+
(cons disp name)))
2441+
helm-sources)
2442+
:marked-candidates t
2443+
:allow-nest t
2444+
:buffer "*helm sources*")))
2445+
(helm-set-source-filter headers)))
2446+
(helm-set-source-filter nil)))))
24242447

24252448
;;; Source infos fns.
24262449
;;

0 commit comments

Comments
 (0)