From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Haselwarter Newsgroups: gmane.emacs.help Subject: Re: emacs and xdg-open Date: Tue, 10 Jan 2012 20:29:47 +0100 Message-ID: <87ipkjmk44.fsf@nzebook.haselwarter.org> References: <8739bp5gkn.fsf@ericabrahamsen.net> <87vcokms1v.fsf@nzebook.haselwarter.org> <87obuc45nf.fsf@ericabrahamsen.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1326223807 18406 80.91.229.12 (10 Jan 2012 19:30:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 10 Jan 2012 19:30:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Eric Abrahamsen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 10 20:30:04 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RkhOU-0002Sr-Jt for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Jan 2012 20:30:02 +0100 Original-Received: from localhost ([::1]:47484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkhOU-0001SE-06 for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Jan 2012 14:30:02 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkhOP-0001Rl-HR for help-gnu-emacs@gnu.org; Tue, 10 Jan 2012 14:29:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkhOL-0000oL-Cv for help-gnu-emacs@gnu.org; Tue, 10 Jan 2012 14:29:57 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:34955) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RkhOL-0000o9-2Z for help-gnu-emacs@gnu.org; Tue, 10 Jan 2012 14:29:53 -0500 Original-Received: (qmail invoked by alias); 10 Jan 2012 19:29:51 -0000 Original-Received: from 52.65.113.78.rev.sfr.net (EHLO nzebook.haselwarter.org) [78.113.65.52] by mail.gmx.net (mp034) with SMTP; 10 Jan 2012 20:29:51 +0100 X-Authenticated: #26138819 X-Provags-ID: V01U2FsdGVkX19WlHkRmqxWaCD28lE8uLfGinEAaCbqEvNPiR0I1T 3kh/3sYGfAOUUp X-NSA-Fodder: Plame MD2 Armani mania Juiliett Class Submarine credit card X-Flame: Let me tell you something, you wally, most Iranian people have operations. In-Reply-To: <87obuc45nf.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Tue, 10 Jan 2012 11:07:16 +0800") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.92 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.22 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:83438 Archived-At: Eric Abrahamsen writes: > On Tue, Jan 10 2012, Philipp Haselwarter wrote: > >> Eric Abrahamsen writes: >> ---8<---[snipped 13 lines]---8<--- > >> What command you use to call `xdg-open'? > > I modified something I found on the internet that originally used > gnome-open: > > (defun dired-xdg-open-file () > "Opens the current file in a Dired buffer." > (interactive) > (xdg-open-file (dired-get-file-for-visit))) > > (defun xdg-open-file (filename) > "xdg-opens the specified file." > (interactive "fFile to open: ") > (let ((process-connection-type nil)) > (start-process "" nil "/usr/bin/xdg-open" filename))) > > ;;'e' usually does 'dired-find-file, same as RET, rebinding it here > (add-hook 'dired-mode-hook > (lambda () > (define-key dired-mode-map (kbd "e") 'dired-xdg-open-file))) > > (setq image-dired-external-viewer "/usr/bin/xdg-open") > > >> Some programs (eg. mplayer) exit uncleanly when their stderr and stdout >> are closed, which causes xdg-open to reopen the file with the default >> application for unknown mime types, as it appears. >> And allocating a buffer to every started program.... >> remains unsolved --8<---------------cut here---------------start------------->8--- (eval-after-load 'dired '(progn (define-key dired-mode-map "E" 'my-dired-xdg-open) (define-key dired-mode-map [tool-bar my-dired-xdg-open] `(menu-item "ext" my-dired-xdg-open :help "Open file(s) with xdg-open" :image ,(find-image '((:type xpm :file "right-arrow.xpm"))))))) (defun my-dired-xdg-open (arg) "Open files from `dired-get-marked-files' with `my-xdg-open-file'" (interactive "P") (mapcar 'my-xdg-open-file (dired-get-marked-files nil arg))) (defun dired-xdg-open-file () "Opens the current file in a Dired buffer." (interactive) (xdg-open-file (dired-get-file-for-visit))) --8<---------------cut here---------------end--------------->8--- The only annoyance left is that opening multiple files calls the program several times as xdg-open accepts only one file. I'd glad to hear ideas how to solve this! ---8<---[snipped 53 lines]---8<--- > > Anyway, thanks for getting me the rest of the way there! > > Eric Glad it works; usually I have {tool,menu,scroll}-bar-mode turned off but I kind of like them for a file manager. Here's what I ended up with: --8<---------------cut here---------------start------------->8--- #!/bin/sh [ "$1" ] || set "`pwd`" OPT='((tool-bar-lines . 1) (menu-bar-lines . 1) (vertical-scroll-bars . right))' emacsclient -n -c -F "$OPT" "$@" --8<---------------cut here---------------end--------------->8--- -- Philipp Haselwarter