How do I find org-mode files with completion in Emacs?

1k views Asked by At

I have a growing set of org files stored in org-directory. How can I navigate between them, preferably with interactive filtering and completion?

I thought there was a way to get org-mode to produce a list of known org files for quick navigation, but I can't seem to find it. If org-mode does not have this feature, how can I make a simple command that launches something like helm or icicles to find them?

4

There are 4 answers

2
Drew On BEST ANSWER

The question is not very clear to me. But if your Org-mode files all have a certain file-name pattern (e.g. *.org) and all are in the same directory (org-directory) then you can use several methods Emacs method to access them:

  1. C-x C-f *.org RETURN in org-directory opens them all (the buffers are visiting them but only the last one is shown).

  2. C-x C-f *.org TAB in org-directory, to show them using completion, then pick whichever one you want (or pick more than one, using a glob pattern, as in #1).

  3. The same as #2, using Icicles or Helm. In Icicles, at least, you can also match using regexps and in other ways.

  4. Open Dired for just those files: C-x d *.org.

There are really any number of ways to do what you've described. But I'm guessing that you have not really described your request/problem/question well enough, and when you do you will get a narrower set of answers.


UPDATE after your comments:

Here's one way: Open Dired on all of your Org files in and under org-directory.

(defun foo ()
  "Open Dired for (only) the Org files in and under `org-directory`."
  (interactive)
  (cd org-directory)
  (dired "*.org" "-lRF"))

Test it with M-x foo. Put this in your init file:

(foo)

And here's another way: M-x bar or bind bar to a key.

(defun bar ()
  "Open an Org file in or under `org-directory`."
  (interactive)
  (let ((default-directory         org-directory)
        (icicle-file-match-regexp  ".*\\.org"))
    (icicle-locate-file-of-content)))
1
abo-abo On

I have a package that does just that: plain-org-wiki. It's nothing too elaborate: I just dump all of my 45 org files into a single directory and get completion for them.

1
GJStein On

My favorite solution to this is helm-mode which is activated with the helm package from MELPA. Here's a demo:

Helm Mode Completion

It really makes for a great environment for searching ones files quickly. In addition, one can enable fuzzy completion! Here's a minimal configuration (after installing the helm package):

(require 'helm-config)
(helm-mode 1)
(global-set-key (kbd "C-x C-f") 'helm-find-files)

You can also run grep on the files if you'd like to search their content. Take a look at this amazing guide if you'd like to learn more.

0
Jeffrey DeLeo On

How about org-iswitchb, which is provided by org already?

Switch between Org buffers. With one prefix argument, restrict available buffers to files. With two prefix arguments, restrict available buffers to agenda files.

Add this to your startup file after org is loaded: (global-set-key "\C-cb" 'org-iswitchb)