Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs ido: How to show particular file endings first?

Tags:

emacs

ido

I use ido-mode under Emacs 24 with the following settings:

(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(setq ido-use-filename-at-point 'guess)
(setq ido-use-url-at-point t)
(setq ffap-require-prefix t)

Assume you have several files with the same name but different endings in the current directory. If you change buffers via C-x b, you receive several suggestions. Can the order of these suggestions be somehow influenced?

As an example, assume you have multiple Sweave (.Rnw) files in the current directory. They are always more important than the corresponding (.tex) files which are created from them. So in most of the cases, you want to change the buffer to the .Rnw file, not the .tex file. It would therefore be nice if the .Rnw files were suggested first (in all directories where both .Rnw and .tex files with the same base name exist).

like image 871
Marius Hofert Avatar asked Jan 16 '13 13:01

Marius Hofert


1 Answers

"If you'd like to tweak the default file sorting, like making Sweave-files appear first, tell ido which files to give a higher sort priority:"

(setq ido-file-extensions-order '(".Rnw" ".tex"))

But it works only for ido-find-file not for ido-switch-buffer. Buffers are sorted by most recent property. I don't know about functionality, which adds another sorting property over most recent. Function ido-file-extension-lessp could be used for sorting list of buffers this way. But two kind of sorting may conflict with each other.

like image 116
artscan Avatar answered Sep 28 '22 09:09

artscan