* Quickly Viewing Files in a File List, and then Quickly Closing @ 2013-10-18 5:55 Eric Brown 2013-10-18 7:46 ` Thorsten Jolitz ` (5 more replies) 0 siblings, 6 replies; 8+ messages in thread From: Eric Brown @ 2013-10-18 5:55 UTC (permalink / raw) To: help-gnu-emacs I am looking for a "QuickLook" feature for Emacs. For example, when scrolling through a file list in dired (or sunrise commander): - is it possible to automatically show the contents of the file under point in a second window? But if point is moved, quickly move along and show the next file/image whatnot? - is there a "hold-down-button" to view, and let off button to resume browsing the file list? I currently use C-x 1 or C-x o q approaches, but I usually end up with e a bunch of buffers or sore fingers when going through many files. Does anyone have suggestions? I apologize if the answer is sitting in the Emacs manual. Thanks, Eric ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown @ 2013-10-18 7:46 ` Thorsten Jolitz 2013-10-18 8:38 ` Eric Abrahamsen ` (4 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Thorsten Jolitz @ 2013-10-18 7:46 UTC (permalink / raw) To: help-gnu-emacs Eric Brown <eric.c.brown@mac.com> writes: > I am looking for a "QuickLook" feature for Emacs. For example, when > scrolling through a file list in dired (or sunrise commander): > > - is it possible to automatically show the contents of the file under > point in a second window? But if point is moved, quickly move along > and show the next file/image whatnot? > > - is there a "hold-down-button" to view, and let off button to resume > browsing the file list? > > I currently use C-x 1 or C-x o q approaches, but I usually end up with > e a bunch of buffers or sore fingers when going through many files. > > Does anyone have suggestions? I apologize if the answer is sitting in > the Emacs manual. There *is* an Emacs mode for putting files into a group/list and then operate on the whole list of files - but unfortunately I don't remember its name anymore. It seemed quite powerful (and works with icicles etc). And then there are [[http://www.emacswiki.org/emacs/OccurMode#IciclesOccur][multi-occur]] and 'M-x find-grep' that both offer a second result window allowing to scroll through the search results in several buffers. -- cheers, Thorsten ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown 2013-10-18 7:46 ` Thorsten Jolitz @ 2013-10-18 8:38 ` Eric Abrahamsen 2013-10-18 11:32 ` Alan Schmitt ` (3 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Eric Abrahamsen @ 2013-10-18 8:38 UTC (permalink / raw) To: help-gnu-emacs Eric Brown <eric.c.brown@mac.com> writes: > I am looking for a "QuickLook" feature for Emacs. For example, when > scrolling through a file list in dired (or sunrise commander): > > - is it possible to automatically show the contents of the file under > point in a second window? But if point is moved, quickly move along > and show the next file/image whatnot? > > - is there a "hold-down-button" to view, and let off button to resume > browsing the file list? > > I currently use C-x 1 or C-x o q approaches, but I usually end up with > e a bunch of buffers or sore fingers when going through many files. > > Does anyone have suggestions? I apologize if the answer is sitting in > the Emacs manual. Dired has some very nice shortcuts for this sort of thing: If you hit "v" on a file, you'll visit it in view mode, which means you can hit "q" to close it. So looking quickly though a bunch of text files just means bouncing between "n", "v" and "q". I think view mode is great. Also check "o" and "C-o" -- the latter might be all you need. Other than that, it wouldn't be too hard to write something like a "follow mode" for dired. If it closed the files afterwards that would be nice. E ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown 2013-10-18 7:46 ` Thorsten Jolitz 2013-10-18 8:38 ` Eric Abrahamsen @ 2013-10-18 11:32 ` Alan Schmitt 2013-10-18 14:23 ` Drew Adams ` (2 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Alan Schmitt @ 2013-10-18 11:32 UTC (permalink / raw) To: help-gnu-emacs Eric Brown <eric.c.brown@mac.com> writes: > I am looking for a "QuickLook" feature for Emacs. For example, when > scrolling through a file list in dired (or sunrise commander): > > - is it possible to automatically show the contents of the file under > point in a second window? But if point is moved, quickly move along > and show the next file/image whatnot? > > - is there a "hold-down-button" to view, and let off button to resume > browsing the file list? > > I currently use C-x 1 or C-x o q approaches, but I usually end up with > e a bunch of buffers or sore fingers when going through many files. > > Does anyone have suggestions? I apologize if the answer is sitting in > the Emacs manual. If you're using OS X, you could call the system's quicklook. This is what I'm using here (it works great for images or pdf files, for instance, I'm also including the code to open the file in the external application). #+begin_src emacs-lisp (defun do-ql-dwim() (interactive) (save-window-excursion (let* ((proc (get-buffer-process "*Async Shell Command*"))) (if proc (kill-process proc) (dired-do-async-shell-command "qlmanage -p 2>/dev/null" "" (dired-get-marked-files)) ) (bury-buffer proc) )) ) (defun open-in-external-app () "Open the current file or dired marked files in external app. Works in Microsoft Windows, Mac OS X, Linux." (interactive) (let ( doIt (myFileList (cond ((string-equal major-mode "dired-mode") (dired-get-marked-files)) (t (list (buffer-file-name))) ) ) ) (setq doIt (if (<= (length myFileList) 5) t (y-or-n-p "Open more than 5 files?") ) ) (when doIt (cond ((string-equal system-type "windows-nt") (mapc (lambda (fPath) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList) ) ((string-equal system-type "darwin") (mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "open" fPath)) ) myFileList) ) ((string-equal system-type "gnu/linux") (mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" fPath)) ) myFileList) ) ) ) ) ) (add-hook 'dired-mode-hook (lambda () (define-key dired-mode-map " " 'do-ql-dwim) (define-key dired-mode-map (kbd "C-<return>") 'open-in-external-app) )) #+end_src Alan ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown ` (2 preceding siblings ...) 2013-10-18 11:32 ` Alan Schmitt @ 2013-10-18 14:23 ` Drew Adams 2013-10-18 16:55 ` Drew Adams 2013-10-19 7:13 ` Vagn Johansen 2013-10-28 11:45 ` escherdragon 5 siblings, 1 reply; 8+ messages in thread From: Drew Adams @ 2013-10-18 14:23 UTC (permalink / raw) To: Eric Brown, help-gnu-emacs > I am looking for a "QuickLook" feature for Emacs. For example, when > scrolling through a file list in dired (or sunrise commander): > > - is it possible to automatically show the contents of the file > under point in a second window? But if point is moved, quickly > move along and show the next file/image whatnot? > > - is there a "hold-down-button" to view, and let off button to > resume browsing the file list? > > I currently use C-x 1 or C-x o q approaches, but I usually end up > with e a bunch of buffers or sore fingers when going through many > files. > > Does anyone have suggestions? I apologize if the answer is sitting > in the Emacs manual. Others have responded with various ways to accomplish what you want. Here is yet another. In Icicles, the commands that access files are multi-commands, which means that you can use various keys to act on different completion candidates. For example, you can cycle among the candidates that match your current minibuffer input, using the `up' and `down' arrows. If you hold down `Control' while doing that (i.e., `C-down') then you act on each file in turn. (You can use `C-RET' to act on a file that you have cycled to using just `up' or `down'.) For `C-x C-f', for instance, the action is to visit the file, so if you use `C-x C-f' and then hit `C-down' you will visit the next file. Holding down Control and repeating `down' visits successive files, in the current sort order. (You can change the sort order at any time during completion, using `C-,'.) The behavior is exactly as you described, with this exception: the file buffers remain. That is, the default action for `C-x C-f' only visits the file; it does not also kill the file's buffer later on. You could easily define a command that would do that, say putting the `kill-buffer' action on a timer or associating it with an event (e.g. visiting the next file). On the other hand, it is also easy to manually kill a lot of buffers at the same time. (BTW, when you use `C-x C-f' you can match not only the file names but also file contents, if you like. And `C-M-down', `C-RET' etc. displays metadata about a file, instead of visiting it: permissions, size, time of last this-and-that, etc.) Icicles is available at EmacsWiki and MELPA: http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Libraries#BulkIciclesDownload -- Here is the doc string for `icicle-find-file': Visit a file or dir whose name and/or content matches. Candidate files and directories for completion are examined, and those whose names and/or contents match your multi-completion input are available to visit. (Option `find-file-run-dired' determines whether you can actually visit a directory candidate that you choose.) If you use a prefix argument when you act on a completion candidate (see below for the use of a prefix arg for the command itself.), then you visit the file or dir in read-only mode. This includes when you act on all candidates using `C-!': precede the `C-!' with a prefix arg. This does not apply to the final candidate chosen (using `RET' or `mouse-2') - a prefix arg has no effect for that. Completion candidates are two-part multi-completions, with the second part optional. If both parts are present they are separated by `icicle-list-join-string' ("^G^J", by default). The first part is matched as a regexp against a file or directory name. The second part is matched as a regexp against the file or directory content. Candidates that do not match are filtered out. When matching file content, Icicles just looks for a single match. Visiting the file does not move to that match or to any other match. Matching is used only to filter candidate files. However, if your input includes a content-matching part and it matches, that part is automatically added to the Isearch regexp history, `regexp-search-ring' whenever you hit `S-TAB' to complete. This means that when you visit the file you can immediately search for matches using `C-M-s' or `C-M-r'. Your minibuffer input can match a name or content, or both. Use `C-M-j' (equivalent here to `C-q C-g C-j') to input the default separator. For example: To match `foo' against file and dir names, use input `foo'. To match `bar' against file and dir contents, use input `C-M-j bar'. To match both names and content, use input `foo C-M-j bar'. Only the matching file and directory names are shown in buffer `*Completions*', and only the chosen name is returned. The actual content matches are unimportant anyway: content matching is used only to filter the candidates. If your input does not include a content-matching part then this command acts similar to `icicle-find-file-no-search' (but with a different use of the prefix argument). If your input includes a content-matching part then all files and directories matching the name part of your input (or all, if no name part) are visited. This creates buffers visiting each matching candidate. For a directory, a Dired buffer is used - that is the content that is searched. (Actually, this is determined by option `find-directory-functions'.) As you would expect, content matching can be costly in time, even though it can be quite helpful. Use name matching to narrow the set of files that must be visited to search their contents. When this command is finished, any unused buffers that were created for content matching are killed, if option `icicle-kill-visited-buffers-flag' is non-nil. But a prefix argument flips the behavior specified by that option. During completion (`*' means this requires library `Bookmark+'), you can use the following keys: C-c + - create a new directory M-| - open Dired on the currently matching file names S-delete - delete candidate file or (empty) dir * C-x C-t * - narrow to files with all of the tags you specify * C-x C-t + - narrow to files with some of the tags you specify * C-x C-t % * - narrow to files with all tags matching a regexp * C-x C-t % + - narrow to files with some tags matching a regexp * C-x a + - add tags to current candidate * C-x a - - remove tags from current candidate * C-x m - access file bookmarks (not just autofiles) Read input, then act on it. Input-candidate completion and cycling are available. While cycling, these keys with prefix `C-' are active: `C-mouse-2', `C-return' - Act on current completion candidate only `C-down', `C-wheel-down' - Move to next completion candidate and act `C-up', `C-wheel-up' - Move to previous completion candidate and act `C-next' - Move to next apropos-completion candidate and act `C-prior' - Move to previous apropos-completion candidate and act `C-end' - Move to next prefix-completion candidate and act `C-home' - Move to previous prefix-completion candidate and act `C-!' - Act on *all* candidates, successively (careful!) When candidate action and cycling are combined (e.g. `C-next'), user option `icicle-act-before-cycle-flag' determines which occurs first. With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', `C-M-RET', `C-M-down', and so on) provide help about candidates. Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or `C-g' to quit. This is an Icicles command - see command `icicle-mode'. ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 14:23 ` Drew Adams @ 2013-10-18 16:55 ` Drew Adams 0 siblings, 0 replies; 8+ messages in thread From: Drew Adams @ 2013-10-18 16:55 UTC (permalink / raw) To: Eric Brown, help-gnu-emacs > If you hold down `Control' while doing that (i.e., `C-down') then > you act on each file in turn. (You can use `C-RET' to act on a file > that you have cycled to using just `up' or `down'.) ... > You could easily define a command that would do that, say putting > the `kill-buffer' action on a timer or associating it with an event > (e.g. visiting the next file). Here is a quick command definition that does that. It lets you use the Icicles alternate action keys, `C-S-RET', `C-S-down', etc., which are analogous to the main action keys, `C-RET', `C-down', etc. (which visit the candidate), to visit the candidate in `view-mode' and at the same time kill the buffer of the last such visited candidate. (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'.") So you would: 1. Use `M-x my-find-file' (or bind it to a key - e.g., `C-x C-f'). 2. Optionally type part of a file name, to limit the matching names. 3. Optionally use `down' or `up' to cycle among file names. 4. Use `C-S-down' to visit the next file in order. 5. Repeat #4 to see other files in order. 6. Repeat #2 or #3 to see other sets of files. 7. End with `RET' to choose a file to visit or `C-g' to cancel. Each file buffer you visited with `C-S-down' was killed when you viewed the next one. You can also mix in `C-down' or `C-RET' to also visit files whose buffers you do not want to kill automatically. (Change `view-file' to `find-file' if you don't want to visit in `view-mode', which is read-only.) [By default, the alternate action for `icicle-find-file' is `icicle-alt-act-fn-for-type', which prompts you for a file- appropriate action to use on the particular candidate chosen for the action. Command `my-find-file' just substitutes a different alternate action function (for all candidates you choose).] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown ` (3 preceding siblings ...) 2013-10-18 14:23 ` Drew Adams @ 2013-10-19 7:13 ` Vagn Johansen 2013-10-28 11:45 ` escherdragon 5 siblings, 0 replies; 8+ messages in thread From: Vagn Johansen @ 2013-10-19 7:13 UTC (permalink / raw) To: help-gnu-emacs Eric Brown <eric.c.brown@mac.com> writes: > I am looking for a "QuickLook" feature for Emacs. For example, when > scrolling through a file list in dired (or sunrise commander): > [...] > > Does anyone have suggestions? I apologize if the answer is sitting in > the Emacs manual. You can do this with helm with its follow-mode. It also works with images https://github.com/emacs-helm/helm/wiki#wiki-turninimageviewer "C-M-v runs the command scroll-other-window" works as usual. -- Vagn Johansen ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quickly Viewing Files in a File List, and then Quickly Closing 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown ` (4 preceding siblings ...) 2013-10-19 7:13 ` Vagn Johansen @ 2013-10-28 11:45 ` escherdragon 5 siblings, 0 replies; 8+ messages in thread From: escherdragon @ 2013-10-28 11:45 UTC (permalink / raw) To: Help-gnu-emacs (...) > I am looking for a "QuickLook" feature for Emacs. For example, when > scrolling through a file list in dired (or sunrise commander): (...) The Sunrise Commander has a quick-view function bound to the 'o' (or 'v') key. This is the docstring of that function: On regular files, opens the file in quick-view mode (see `sr-quick-view-file' for more details), on directories, visits the selected directory in the passive pane, and on symlinks follows the file the link points to in the passive pane. With optional argument kills the last quickly viewed file without opening a new buffer. and the one of the `sr-quick-view-file' function: Open the selected file on the viewer window without selecting it. Kills any other buffer opened previously the same way. The "viewer window" is the window that opens at the bottom, beneath the panes. Hope this helps, Cheers, -- José A. Romero L. escherdragon at gmail "We who cut mere stones must always be envisioning cathedrals." (Quarry worker's creed) -- View this message in context: http://emacs.1067599.n5.nabble.com/Quickly-Viewing-Files-in-a-File-List-and-then-Quickly-Closing-tp300152p301006.html Sent from the Emacs - Help mailing list archive at Nabble.com. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-10-28 11:45 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-10-18 5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown 2013-10-18 7:46 ` Thorsten Jolitz 2013-10-18 8:38 ` Eric Abrahamsen 2013-10-18 11:32 ` Alan Schmitt 2013-10-18 14:23 ` Drew Adams 2013-10-18 16:55 ` Drew Adams 2013-10-19 7:13 ` Vagn Johansen 2013-10-28 11:45 ` escherdragon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).