- Emacs Lisp 100%
|
Alexey Veretennikov
ebb2c9c24c
Filesystem operations reintroduced via wrappers.
This enables writing tests for the CFF module. |
||
|---|---|---|
| cff-fs.el | Filesystem operations reintroduced via wrappers. | |
| cff.el | Filesystem operations reintroduced via wrappers. | |
| README.md | Fixed typo | |
Yet another C/C++ find other file
About
This extension allows to quickly switch between C/C++ header and a source file with the same name located in the directory tree or a git repository.
It is an alternative to ff-find-other-file.
Rationale
The idea behind this extension is to have the solution which just works for the typical C/C++ projects with the minimal organizational discipline, without any project configuration in Emacs.
Usage
Add the following to your .emacs file:
(require 'cff)
;; defines shortcut for find source/header file for the current
;; file
(add-hook 'c++-mode-hook
'(lambda ()
(define-key c-mode-base-map (kbd "M-o") 'cff-find-other-file)))
(add-hook 'c-mode-hook
'(lambda ()
(define-key c-mode-base-map (kbd "M-o") 'cff-find-other-file)))
Algorithm
- This command tries to find the file with the same name as current but another extension, i.e. if the current file has a .cc extension, the command will try to find other file with the same basename but the possible extensions .h, .hpp etc. and vise versa.
- If the file is not found, it will be looked for in the subdirectories like inc and include.
- If not found, the procedure repeats with the upper directory.
- If still nothing found and the current VCS is git, try to search in the whole git repository.
- If still nothing, try to find a corresponding file in git repository which contains basename as a part.
If multiple files found, present a selection to the user.
When helm is enabled, present selection using helm, otherwise (or when the variable cff-use-helm-choice set to nil) use the custom mode to present selection.
The file selected once is stored in the cache; to get the selection choice again one should prefix the command, i.e. C-u M-o if the command binded to M-o.