From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: open file link in dired? Date: Thu, 11 Dec 2014 08:36:26 +0100 Message-ID: References: <87vcbdlz75.fsf@bzg.ath.cx> <87ehi0lxfy.fsf@bzg.ath.cx> <87a92w8as9.fsf@stevenarntson.com> <87bnnb97fa.fsf@wmi.amu.edu.pl> <87fvcn8gtg.fsf@stevenarntson.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyyIh-00069e-OR for emacs-orgmode@gnu.org; Thu, 11 Dec 2014 02:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyyIb-00046A-F3 for emacs-orgmode@gnu.org; Thu, 11 Dec 2014 02:36:39 -0500 Received: from mx1.polytechnique.org ([129.104.30.34]:40029) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyyIa-00045P-U8 for emacs-orgmode@gnu.org; Thu, 11 Dec 2014 02:36:33 -0500 In-Reply-To: <87fvcn8gtg.fsf@stevenarntson.com> (Steven Arntson's message of "Wed, 10 Dec 2014 11:07:07 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Steven Arntson Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2014-12-10 11:07, Steven Arntson writes: > For me, I'll construct a list of project files in an org-mode buffer. > Then I'll be able to easily visit those files in a dired directory and > do whatever I need to (usually copying the files to a stick drive or > other portable media to transfer to collaborators). I'm very glad it helps, but Bastien should get all the credit here (I only tweaked the solution he sent me). My main motivation for using this is that I have some code to preview a file using Quicklook (I'm on OS X), and code to open a file in an external app when in dired, so it's quite useful for files that emacs cannot display: #+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 (<=3D (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-p= rocess "" nil "open" fPath)) ) myFileList) ) ((string-equal system-type "gnu/linux") (mapc (lambda (fPath) (let ((process-connection-type nil)) (start-p= rocess "" nil "xdg-open" fPath)) ) myFileList)))))) (add-hook 'dired-mode-hook=20 (lambda () (define-key dired-mode-map " " 'do-ql-dwim) (define-key dired-mode-map (kbd "C-") 'open-in-external= -app))) #+end_src Alan =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJUiUl+AAoJEAQNCjtO0uXH1XkH/RDsNYbMvpx4c5KNTAy3/PJz 9qP293DjwKJ0DQf5mubMoN5qIv47LfGeE2+ylhIJe7U27O1P7UwkJ9UyQIBH/LxQ jH2OOfChso7IUfqe1RfJ7BkYGCVsR/uxKVMWr8MW8Cgg7gZWseYEN6bjCwi9T+md mRTJ3wKtNjtpbUpCh0C6aomIHR7NLwk/anKHZWMqtmsF6YbjHlrTOyyd8u7+7vd1 r1FKCGrixXgmbT8jVPTeC9+Ojm/A06fU5lhiO7YPuW4zA7qZgVfrjdD9vnJejwvC nrXlO8dyiueXsLGQvCxEMbYtaJ626SKHMNOvB5whg9PHsOHYseusLsEAnXSF/H4= =qpKs -----END PGP SIGNATURE----- --=-=-=--