Similar to this question, I'd like a tool/minor mode to quickly preview my files by merely having the cursor positioned over them (e.g. the currently selected file is displayed in the active buffer window). I don't care about depressing events and I don't want an overlay. If it's selected, I want it displayed in the active window. Pressing enter and switching to the buffer is too slow to skim through a bunch of raw data files. How could I do this?
Similarly, this question to firstname.lastname@example.org is essentially the same also.
My own answer to both questions is to use Icicles and to define this command:
(defun my-find-file () "Like `icicle-find-file', but alt action views file temporarily. Alternate action keys such as `C-S-down' visit the candidate file in `view-mode' and kill the buffer of the last such viewed candidate." (interactive) (let ((icicle-candidate-alt-action-fn (lambda (file) (when (and my-last-viewed (get-file-buffer my-last-viewed)) (kill-buffer (get-file-buffer my-last-viewed))) (setq my-last-viewed (abbreviate-file-name file)) (view-file file) (select-frame-set-input-focus (window-frame (active-minibuffer-window)))))) (icicle-find-file-of-content))) (defvar my-last-viewed nil "Last file viewed by alternate action of `my-find-file'.")
Then you can:
M-x my-find-file(or bind it to a key - e.g.,
- Optionally type part of a file name, to limit the matching names.
- Optionally use
upto cycle among file names.
C-S-downto visit the next file in order.
- Repeat #4 to see other files in order.
- Repeat #2 or #3 to see other sets of files.
- End with
RETto choose a file to visit or
See the linked posts for more info.
I discovered this functionality is already built-in to Helm. To use it, use the up and down arrows and press C-up/C-down.