7

What I actually want

I have deep folder structures, and often use a dozen folders pretty far down the directory tree. In Nautilus, I use bookmarks to get to them quickly. I want the same thing in Emacs, as I plan to use Dired more.

My plan

My plan is to have a folder of symlinks to all my bookmarks somewhere on my file system, and a function in Emacs which launches dired with that folder and then invokes ace-jump-mode.

My question

What does that function look like?

Of course, if there is a better way to achieve this, I'd be happy to learn about it. I read about dired bookmarks and they don't seem to do what I want (if I understand what they do, which is not necessarily the case) as I can't have changes in my ~/.emacs.d folder during normal use and those bookmarks would change every time I mark something.

1
  • 5 years later I can confidently say: My original plan was stupid. Emacs bookmarks are so much better than anything I could've come up with myself. Also: Have I really been using Emacs for this long? Time flies ...
    – UTF-8
    Commented Sep 3, 2022 at 18:55

4 Answers 4

7

It's unclear to me why you want/need to add such symlinks. Why not just use Emacs bookmarks?

If you use Bookmark+ then you can have:

  • Bookmarks to Dired buffers (which record lots of stuff, including markings, subdir insertions, omit settings, etc.).

  • Bookmarks to bookmark files (to load different sets of bookmarks).

  • Bookmarks to bookmark-list displays (different sets of bookmarks, together with specific sort orders, markings, etc. - like Dired bookmarks, but for bookmarks, not files).

  • Tags on bookmarks (to define and find arbitrary sets bookmarks, defined by their labels).

I don't understand this part of what you say: "I can't have changes in my ~/.emacs.d folder during normal use and those bookmarks would change every time I mark something."

4
  • I use 2 machines and sync ~/.emacs.d between them so I always have the same init file and the same packages installed in Emacs on both machines. If I use Bookmark+, (according to my understanding) there will be changes in the ~/.emacs.d folder when I do normal file operations which will lead to synchronization conflicts. Making changes in ~/.emacs.d for configuration purposes and installing/removing packages is fine as I always only do this on one machine and can make sure Emacs isn't started on the other machine before synchronization is completed as it doesn't happen all the time.
    – UTF-8
    Commented Sep 17, 2017 at 14:06
  • (1) You can store your bookmark files anywhere. They can be in ~/.emacs.d but they need not be. (2) Your bookmark files can be the same for all your machines. Or they can be different. It's all up to you.
    – Drew
    Commented Sep 17, 2017 at 17:26
  • Thank you! No need to store them in a different place. I somehow thought that once I set a bookmark to something, it'd be updated each time I visit it and change something in the resulting buffer. If there only are changes when I create bookmarks, that's perfectly fine.
    – UTF-8
    Commented Sep 17, 2017 at 17:52
  • A bookmark is stored in a bookmarks file, separately from the file or buffer that it bookmarks. In general, each time you jump to (aka invoke) a bookmark the bookmark data is updated - including the number of visits, last visit time, and possibly text around the bookmark location (to help locate it later, in case the targeted file or buffer text has changed somewhat). But those changes are in the bookmark itself, not in the target. See the Emacs manual, node Bookmarks.
    – Drew
    Commented Sep 17, 2017 at 19:28
2

Emacs has built-in bookmark functionnality, bound to C-x r b.

If you install Helm you get helm-bookmarks, an interactive and colorful version, that lets you jump to one or set a bookmark in the same interface (C-j has shown in its buffer).

I bind the helm function to the usual shortcut:

(global-set-key (kbd "C-x r b") 'helm-bookmarks)
1

You might also investigate filesets. They allow you to define groups of files and do things to them as a group: e.g you can visit all of them, run a query-replace or a shell command on all of them. You can have multiple groups of course. They appear under a Filesets tab in the File menu and there are menu entries that allow you to create new groups and manipulate existing ones.

3
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Drew
    Commented Sep 17, 2017 at 19:29
  • @Drew: is that better?
    – NickD
    Commented Sep 17, 2017 at 21:23
  • Much better. Thx.
    – Drew
    Commented Sep 17, 2017 at 22:52
0

Add something like the following to your .emacs file:

(global-set-key (kbd "C-c f") (lambda() (interactive) (find-file "~/Folder")))

The above shortcut C-c f will take you directly to the folder ~/Folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.