From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.bugs Subject: bug#14110: 24.3.50; Add command to open files outside of Emacs (use xdg-open, open etc) Date: Thu, 04 Apr 2013 08:55:12 +0530 Message-ID: <871uarou3r.fsf@gmail.com> References: <87zjxi4u15.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1365045970 6419 80.91.229.3 (4 Apr 2013 03:26:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Apr 2013 03:26:10 +0000 (UTC) Cc: 14110@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 04 05:26:38 2013 Return-path: Envelope-to: geb-bug-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 1UNaos-0004tK-7c for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Apr 2013 05:26:34 +0200 Original-Received: from localhost ([::1]:45026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNaoT-0007OB-Ba for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Apr 2013 23:26:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNaoL-0007Mz-1h for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2013 23:26:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UNaoG-0005g1-CK for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2013 23:26:00 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNaoG-0005fo-40 for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2013 23:25:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UNarG-0007zY-G3 for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2013 23:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jambunathan K Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Apr 2013 03:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14110 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14110-submit@debbugs.gnu.org id=B14110.136504611830665 (code B ref 14110); Thu, 04 Apr 2013 03:29:02 +0000 Original-Received: (at 14110) by debbugs.gnu.org; 4 Apr 2013 03:28:38 +0000 Original-Received: from localhost ([127.0.0.1]:60976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UNaqq-0007yV-IZ for submit@debbugs.gnu.org; Wed, 03 Apr 2013 23:28:38 -0400 Original-Received: from mail-pa0-f50.google.com ([209.85.220.50]:35043) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UNaqn-0007yH-BZ for 14110@debbugs.gnu.org; Wed, 03 Apr 2013 23:28:34 -0400 Original-Received: by mail-pa0-f50.google.com with SMTP id bg2so1252020pad.37 for <14110@debbugs.gnu.org>; Wed, 03 Apr 2013 20:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=J4L5eVIStYopO7oYt8PHLsZiW/+oHPs9OCAtGQ1YwlQ=; b=DJj0i7AWVMIdEv7qk8sPv7Q1nyiy63BTLYF414fJBAXM8FmyKswdeeLQ4PAAcVUuyY Qs9FUb4xYF0OsNXIIbaGyFYoEuUaIGBi9o7Z0wuCkcNlHCUltx8iI3DhnUc1Qho0hYNz 6N4gEttbiuqLbQYpoYWXF74Qwi9pf5f460UcuNdFzJcz47GDLCn+cvl82WA4YgpLF4oy XynYfFAeBsFBVwOS8TVrGyKQBYqKO0lzmEimkiYzdsfOeJ392yViTEMg9XN2IkoO8oej CJUVPDX3dcksafl+OMevBN7nKyRKcxE27J3BBCyiVWZ3lzlMNivkiZavPNAIPiaWPkrj dwtQ== X-Received: by 10.68.96.34 with SMTP id dp2mr5770416pbb.193.1365045925252; Wed, 03 Apr 2013 20:25:25 -0700 (PDT) Original-Received: from debian-6.05 ([115.242.147.166]) by mx.google.com with ESMTPS id ri1sm8345297pbc.16.2013.04.03.20.25.21 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 20:25:24 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Wed, 03 Apr 2013 21:08:29 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73142 Archived-At: Stefan Monnier writes: >> Add support for opening files outside of Emacs (use xdg-open, open etc). >> This is something that I sorely missed or continue to miss. > > For those people who find xdg-open not customizable enough, I think > open-file deserves an alist associating different commands to different > file kinds. > I guess in this sense I agree with Leo, that it should probably use > dired-guess-shell or something like that. I have looked at the variable that Leo mentions, prior to preparting the patch. (Hint: The COMMAND is a sexp. It can theoretically be a `cond' or a `case' statement.) I want the new customization to be simple and not over-engineered and in a way that is welcoming of the new user while giving power to the more experienced. To allow for a possibility that a generic open command may not be available, I have arranged for a `read-shell-command' and remembering the command name so entered in `dired-shell-command-history'. Furthermore, the open command need not be xdg-open, it could be gnome-open or kde-open. (If you look xdg-open you will see that it internally checks for desktop open and calls the native open method.) (defun open-file (filename) "Open FILENAME (presumably) outside of Emacs. Use shell command from `open-file-command' to open the file." (interactive "fOpen file:") (require 'dired-aux) (let* ((default-directory (file-name-directory filename)) (filename (file-name-nondirectory filename)) | (command (or (eval (cadr (assq system-type open-file-command))) | (read-shell-command (format "Open %s with: " filename) nil | 'dired-shell-command-history)))) (when (and command (string-match "\\S-" command)) (dired-run-shell-command (dired-shell-stuff-it command (list filename) t))))) > Stefan