emacs ff-find-other-file and ff-search-directories

2019-04-12 12:34发布

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.

2条回答
劳资没心,怎么记你
2楼-- · 2019-04-12 13:07

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

查看更多
SAY GOODBYE
3楼-- · 2019-04-12 13:17

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.

查看更多
登录 后发表回答