user108754
user108754

Reputation: 607

emacs ff-find-other-file and ff-search-directories isn't recursive

Can we make ff-find-other-file to search recursively in directories which are listed in ff-search-directories.

Instead of searching only in /usr/include, it would also search in /usr/include/llvm. Or likewise.

Upvotes: 3

Views: 1042

Answers (2)

zanedp
zanedp

Reputation: 427

I've added this function to my .emacs file:

(defun get-all-subdirectories(dir-list)
  "Returns a list of all recursive subdirectories of dir-list, 
   ignoring directories with names that start with . (dot)"
  (split-string 
   (shell-command-to-string 
     (concat "find " 
             (mapconcat 'identity dir-list " ")
             " -type d -not -regex \".*/\\\..*\""))))

And, in my c-mode-common-hook, I have this:

(setq ff-search-directories (get-all-subdirectories (list "dirA" "dirB")))

This assumes you have a standard Unix find command in your PATH. If you're on Windows, you can get a copy of find here: http://unxutils.sourceforge.net/

It takes a little while to run if you have many directories for it to recurse through.

Upvotes: 3

Michael Hoffman
Michael Hoffman

Reputation: 34324

Add a /* after the directories where you want subdirectories searched. So set ff-search-directories so that it contains "/usr/include/*".

Upvotes: 2

Related Questions