4

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?

Community
  • 1
  • 1
shader
  • 801
  • 1
  • 7
  • 25
  • EmacsWiki has some examples using `ido` -- e.g., **Helper Function to Select Based on Mode**: http://emacswiki.org/emacs/InteractivelyDoThings There are also buffer-list menus already built-in -- e.g., imenu, list-buffers, speedbar (buffers view), etc. -- sorting is possible by major-mode; and, it is also possible to set up filters to display only buffers of interest. – lawlist Jul 16 '15 at 00:08

4 Answers4

2

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)))
Drew
  • 29,895
  • 7
  • 74
  • 104
  • Yes, all of my org files match `*.org` and are in somewhere under `org-directory` (perhaps a subdir). I am looking for a single command that can set up the search similar to how you are suggesting, but without having to navigate to the directory and type in the regex each time. – shader Jul 16 '15 at 17:55
  • That's useful for opening a list of the org files, but not for quickly jumping to one of them. How would you do the same thing for initializing one of the find-file options you mention in #2 and #3? – shader Jul 16 '15 at 18:56
1

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.

abo-abo
  • 20,038
  • 3
  • 50
  • 71
  • This looks pretty close to what I was asking for. Do you have any documentation or tips on how to set it up and use it? A readme file on your repo would be helpful. – shader Jul 16 '15 at 17:50
1

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)

Jeffrey DeLeo
  • 1,672
  • 13
  • 19
0

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.

GJStein
  • 648
  • 5
  • 13
  • I agree that helm is cool for interactively narrowing files, but I was hoping to learn how to set up a search for only org files. It seems possible to do with helm, but I don't know how. – shader Jul 16 '15 at 17:56