From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Schmitt Newsgroups: gmane.emacs.help Subject: Re: Quickly Viewing Files in a File List, and then Quickly Closing Date: Fri, 18 Oct 2013 13:32:24 +0200 Organization: IRISA, INRIA Rennes (FR) Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1382097021 4922 80.91.229.3 (18 Oct 2013 11:50:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Oct 2013 11:50:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 18 13:50:24 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VX8ZT-00052k-2t for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Oct 2013 13:50:23 +0200 Original-Received: from localhost ([::1]:57072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VX8ZS-0005s5-OQ for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Oct 2013 07:50:22 -0400 Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-NNTP-Posting-Host: top-wifi.irisa.fr Original-X-Trace: news-v3.irisa.fr 1382095943 3763 131.254.66.192 (18 Oct 2013 11:32:23 GMT) Original-X-Complaints-To: abuse@irisa.fr Original-NNTP-Posting-Date: Fri, 18 Oct 2013 11:32:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:WRLUntQ4mOMtFAwYhLyZk0MWOr8= Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!porbandar.httrack.net!news.httrack.net!feed.ac-versailles.fr!news.ecp.fr!news-rocq.inria.fr!news.irisa.fr!.POSTED!not-for-mail Original-Xref: usenet.stanford.edu gnu.emacs.help:201814 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94083 Archived-At: Eric Brown 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-") 'open-in-external-app) )) #+end_src Alan