Almost every directory I work with, is either directly under “~/Dropbox/” or
under “~/Dropbox/Work/”. However, I never actually visit these two directories,
only the directories inside them. The number of possible targets for find-file
is approaching the outer borders of two-digit land, so there's no hope for my
brain to remember registers for all of these.
The best solution I've found is to compile a list of all possible targets
(directories inside those directories) and offer them using ido. This is
somewhat similar to using a bookmark for each possible destination, except it
it's always up to date with the directory contents and doesn't clog up my actual
bookmarks.
(require'ido)(require'cl-lib)(defcustomendless/favorite-directories'("~/Dropbox/Trabalho/""~/Dropbox/")"List of favorite directories.
Used in `endless/visit-favorite-dir'. The order here
affects the order that completions will be offered.":type'(repeatdirectory):group'endless)(defunendless/visit-favorite-dir(files-too)"Offer all directories inside a set of directories.
Compile a list of all directories inside each element of
`endless/favorite-directories', and visit one of them with
`ido-completing-read'.
With prefix argument FILES-TOO also offer to find files."(interactive"P")(let((completions(mapcar#'abbreviate-file-name(cl-remove-if-not(iffiles-too#'file-readable-p#'file-directory-p)(apply#'append(mapcar(lambda(x)(directory-files(expand-file-namex)t"^[^\.].*"t))endless/favorite-directories))))))(dired(ido-completing-read"Open directory: "completions'ignorednil""))));; Note that C-x d is usually bound to dired. I find;; this redundant with C-x C-f, so I don't mind;; overriding it, but you should know before you do.(define-keyctl-x-map"d"#'endless/visit-favorite-dir)
Some random notes:
Having a quick key for this is fantastic. Whenever I want to get work done, I
just hit C-x d and I'll my options are presented before me.
With a prefix argument it also shows files instead of just directories.
If ido is not your completion engine of choice, that's trivial to change.
Visit Directory inside a Set of Directories
23 Feb 2015, by Artur Malabarba.Almost every directory I work with, is either directly under “~/Dropbox/” or under “~/Dropbox/Work/”. However, I never actually visit these two directories, only the directories inside them. The number of possible targets for
find-file
is approaching the outer borders of two-digit land, so there's no hope for my brain to remember registers for all of these.The best solution I've found is to compile a list of all possible targets (directories inside those directories) and offer them using ido. This is somewhat similar to using a bookmark for each possible destination, except it it's always up to date with the directory contents and doesn't clog up my actual bookmarks.
Some random notes:
ido-vertical
.Tags: init.el, emacs,
Prettify your Apostrophes »
« Paradox 2.0 Released: Execution hook, Interface improvements, Async Execution
Content © 2019, All rights reserved. Icons under CC3.0.