all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Quickly Viewing Files in a File List, and then Quickly Closing
Date: Fri, 18 Oct 2013 13:32:24 +0200	[thread overview]
Message-ID: <m2haceak6v.fsf@polytechnique.org> (raw)
In-Reply-To: m2y55rp1g8.fsf@mac.com

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


  parent reply	other threads:[~2013-10-18 11:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2haceak6v.fsf@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.