I am seeking advice for how to get tab completion in the minibar with a custom set of completion candidates that are either subdirectories or build targets from Makefiles.
For context, I'm using the Emacs compile command to build code, with the instructions for the build inside Makefiles. There may be multiple Makefiles in the project and each one might contain multiple targets which I want to build. I would like something like an augmented
read-file-name that either lets me move through the directory tree to find Makefiles in some subdirectory or that completes with the list of make targets if the current directory contains a Makefile.
To be concrete, say the layout of my project is as follows.
. ├── dir │ ├── README │ ├── some_config_file │ └── subdir │ ├── do_it.sh │ └── Makefile └── Makefile
Lets says that the top-level Makefile has possible targets "target1" and "target2", and dir/subdir/Makefile has "target3".
How can I write somethign like read-file-name which would offer possible completions:
target2when in the top-level directory
subdirwhen in dir
target3when in subdir
I am only guessing that
read-file-name is the right starting point, but if that guess is wrong, please feel free to suggest alternatives too.