How to get emacs-helm list in files with fixed directory as parameters?

This is related to this question:

how-to-have-emacs-helm-list-offer-files-in-current-directory-as-options

but instead of adding files from the current directory, I would like to have a fixed list of directories from which helm-mini will always offer files. Ideally, I would like to have only files with a specific extension, and I would like this to be done recursively (in fact, only one layer).

+4
source share
3 answers

Here you go. I use this code to list all org files in a specific directory. If you want to list all the files, simply delete the source-converter-string in the source and delete the file emagician / helm-ct-is-org-file.

You probably also want to rename the source / variable / function .;)

edit: Fixed thanks to peeking at helm-cmd-t

note: This is my first real crack in creating a helmet source, and this implementation probably sucks. It also specifically solves my problem (searching for all org files in only one), and not a more generalized problem (creating a steering source based on files from a specific directory).

(defvar emagician/helm-c-source-files `((name . "Find Emagician Files") (header-name . (lambda (_))) (candidates . ,(lambda () (when (file-accessible-directory-p emagician-dir) (directory-files emagician-dir t)))) (match helm-c-match-on-file-name helm-c-match-on-directory-name) (keymap . ,helm-generic-files-map) (candidate-transformer . emagician/helm-ct-is-org-file) (help-message . helm-generic-file-help-message) (mode-line . ,helm-generic-file-mode-line-string) (type . file))) (defun emagician/helm-ct-is-org-file (candidates) (remove-if-not (lambda (c) (and (string= (substring c -4) ".org") (not (string= (substring (file-name-nondirectory c) 0 2) ".#")))) candidates)) (defun emagician/helm-emagician-dir () "List all the org files in the Emagician dir" (interactive) (helm :sources emagician/helm-c-source-files :candidate-number-limit 40 :buffer "*emagician-|-+-|-files*")) (global-set-key (kbd "S-<f3>") 'emagician/helm-emagician-dir) 
+1
source

Here is some excellent insight into what prefilters are for the org extension.

 (require 'helm-cmd-t) (defvar my-org-folders (list "~/org") "my permanent folders for helm-mini") (defun helm-my-org (&optional arg) "Use Cu arg to work with repos." (interactive "P") (if (consp arg) (call-interactively 'helm-cmd-t-repos) (let ((helm-ff-transformer-show-only-basename nil)) (helm :sources (mapcar (lambda (dir) (helm-cmd-t-get-create-source-dir dir)) my-org-folders) :candidate-number-limit 20 :buffer "*helm-my-org:*" :input "org$ ")))) 
+3
source

You can better solve this problem using the helm-cmd-t library. These catalog packages are recursive as repositories, which can be used as a source.

He understands how to read a lot of DVCS repositories very quickly.

The default functionality is not exactly what you are here for, but you can easily use the equipment to fulfill all your requirements.

For example, here I define a command that adds two repositories to default steering mini-sources.

 (require 'helm-cmd-t) (defvar my-mini-folders (list "~/src/ember/data" "~/src/ember/ember.js") "my permanent folders for helm-mini") (defun helm-my-mini (&optional arg) "my helm-mini. Use Cu arg to work with repos." (interactive "P") (if (consp arg) (call-interactively 'helm-cmd-t-repos) (let ((helm-ff-transformer-show-only-basename nil)) (helm :sources (nconc (list helm-c-source-buffers-list helm-c-source-recentf helm-c-source-buffer-not-found) (mapcar (lambda (dir) (helm-cmd-t-get-create-source-dir dir)) my-mini-folders)) :candidate-number-limit 20 :buffer "*helm-my-mini:*")))) 
+2
source

Source: https://habr.com/ru/post/1437159/


All Articles