summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2008-11-05 10:46:20 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2008-11-05 10:46:20 +0100
commit8787f59cef83d60aa4dc57b3de31d0cda2d99e04 (patch)
tree940120e68d1c439192a0dd7e4a0b9e8bdf65d6b3
parenta80b84425b6127d0a4b8b28df645c102e5aadcc5 (diff)
downloadorg-mode-8787f59cef83d60aa4dc57b3de31d0cda2d99e04.tar.gz
`C-u C-u C-c C-o' forces opening in an external application
Org-mode uses a special setup with a number of different customization variables to specify how a file should be opened when following a :file:..." link with `C-c C-o'. By using a `C-u' prefix, it was possible to overrule the customized setup and to force opening the file in Emacs. Samuel Wales requested to amend this process, so that a double prefix argument would do the opposite: force opening the application *outside* of Emacs, using a system default application. This is what this patch implements. Internally this works through a new entry in system specific constants `org-file-apps-defaults-gnu', org-file-apps-defaults-macosx', and `org-file-apps-defaults-windowsnt'. The new entry has the car `system' and specifies the command that should be used for the double C-u calls. As before, the user option `org-file-apps' can overrule these default settings. Note that all this only applies to following "file:" links, and does not make a difference for, for example, "http:" links.
-rw-r--r--doc/ChangeLog6
-rw-r--r--doc/org.texi3
-rwxr-xr-xlisp/ChangeLog12
-rw-r--r--lisp/org.el44
4 files changed, 57 insertions, 8 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 0b2faca..125df86 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+
+2008-11-05 Carsten Dominik <dominik@science.uva.nl>
+
+ * org.texi (Handling links): Explain the effect of a double prefix
+ arg to `C-c C-o'.
+
2008-11-02 Charles Sebold <csebold@gmail.com>
* org.texi (Org Plot): Add documentation for timefmt option.
diff --git a/doc/org.texi b/doc/org.texi
index e44cfa6..e24342f 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -2637,7 +2637,8 @@ date. Furthermore, it will visit text and remote files in @samp{file:} links
with Emacs and select a suitable application for local non-text files.
Classification of files is based on file extension only. See option
@code{org-file-apps}. If you want to override the default application and
-visit the file with Emacs, use a @kbd{C-u} prefix.
+visit the file with Emacs, use a @kbd{C-u} prefix. If you want to avoid
+opening in Emacs, use a @kbd{C-u C-u} prefix.
@c
@kindex mouse-2
@kindex mouse-1
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index acc5465..fd336e1 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
+2008-11-05 Carsten Dominik <dominik@science.uva.nl>
+
+ * org.el (org-file-apps-defaults-gnu)
+ (org-file-apps-defaults-macosx)
+ (org-file-apps-defaults-windowsnt): Add an entry defining the
+ system command.
+ (org-file-apps): Allow `system' as key and value.
+ (org-open-at-point): Explain the effect of a double prefix arg.
+ (org-open-file): If the argument `in-emacs' is (16),
+ i.e. corresponding to a double prefix argument, try to open the
+ file externally.
+
2008-11-04 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-insert-link): Abbreviate absolute files names in
diff --git a/lisp/org.el b/lisp/org.el
index 7296bec..3a0f45d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1117,6 +1117,7 @@ single keystroke rather than having to type \"yes\"."
(defconst org-file-apps-defaults-gnu
'((remote . emacs)
+ (system . mailcap)
(t . mailcap))
"Default file applications on a UNIX or GNU/Linux system.
See `org-file-apps'.")
@@ -1124,6 +1125,7 @@ See `org-file-apps'.")
(defconst org-file-apps-defaults-macosx
'((remote . emacs)
(t . "open %s")
+ (system . "open %s")
("ps.gz" . "gv %s")
("eps.gz" . "gv %s")
("dvi" . "xdvi %s")
@@ -1140,6 +1142,11 @@ See `org-file-apps'.")
(list (if (featurep 'xemacs)
'mswindows-shell-execute
'w32-shell-execute)
+ "open" 'file))
+ (cons 'system
+ (list (if (featurep 'xemacs)
+ 'mswindows-shell-execute
+ 'w32-shell-execute)
"open" 'file)))
"Default file applications on a Windows NT system.
The system \"open\" is used for most files.
@@ -1165,11 +1172,15 @@ file identifier are
Remote files most likely should be visited through Emacs
because external applications cannot handle such paths.
`auto-mode' Matches files that are mached by any entry in `auto-mode-alist',
- so all files Emacs knows how to handle. Useing this with
+ so all files Emacs knows how to handle. Using this with
command `emacs' will open most files in Emacs. Beware that this
will also open html files insite Emacs, unless you add
(\"html\" . default) to the list as well.
t Default for files not matched by any of the other options.
+ `system' The system command to open files, like `open' on Windows
+ and Mac OS X, and mailcap under GNU/Linux. This is the command
+ that will be selected if you call `C-c C-o' with a double
+ `C-u C-u' prefix.
Possible values for the command are:
`emacs' The file will be visited by the current Emacs process.
@@ -1178,6 +1189,11 @@ Possible values for the command are:
part.
This can be used to overrule an unwanted seting in the
system-specific variable.
+ `system' Use the system command for opening files, like \"open\".
+ This command is specified by the entry whose car is `system'.
+ Most likely, the system-specific version of this variable
+ does define this command, but you can overrule/replace it
+ here.
string A command to be executed by a shell; %s will be replaced
by the path to the file.
sexp A Lisp form which will be evaluated. The file path will
@@ -1190,6 +1206,7 @@ For more examples, see the system specific constants
:type '(repeat
(cons (choice :value ""
(string :tag "Extension")
+ (const :tag "System command to open files" system)
(const :tag "Default for unrecognized files" t)
(const :tag "Remote file" remote)
(const :tag "Links to a directory" directory)
@@ -1197,7 +1214,8 @@ For more examples, see the system specific constants
auto-mode))
(choice :value ""
(const :tag "Visit with Emacs" emacs)
- (const :tag "Use system default" default)
+ (const :tag "Use default" default)
+ (const :tag "Use the system command" system)
(string :tag "Command")
(sexp :tag "Lisp form")))))
@@ -6619,7 +6637,9 @@ Org-mode syntax."
If there is no link at point, this function will search forward up to
the end of the current subtree.
Normally, files will be opened by an appropriate application. If the
-optional argument IN-EMACS is non-nil, Emacs will visit the file."
+optional argument IN-EMACS is non-nil, Emacs will visit the file.
+With a double prefix argument, try to open outside of Emacs, in the
+application the system uses for this file type."
(interactive "P")
(org-load-modules-maybe)
(move-marker org-open-link-marker (point))
@@ -7048,8 +7068,13 @@ onto the ring."
First, this expands any special file name abbreviations. Then the
configuration variable `org-file-apps' is checked if it contains an
entry for this file type, and if yes, the corresponding command is launched.
+
If no application is found, Emacs simply visits the file.
-With optional argument IN-EMACS, Emacs will visit the file.
+
+With optional prefix argument IN-EMACS, Emacs will visit the file.
+With a double C-c C-u prefix arg, Org tries to avoid opening in Emacs
+and o use an external application to visit the file.
+
Optional LINE specifies a line to go to, optional SEARCH a string to
search for. If LINE or SEARCH is given, the file will always be
opened in Emacs.
@@ -7074,14 +7099,19 @@ If the file does not exist, an error is thrown."
(setq ext (match-string 1 dfile))
(if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile)
(setq ext (match-string 1 dfile))))
- (if in-emacs
- (setq cmd 'emacs)
+ (cond
+ ((equal in-emacs '(16))
+ (setq cmd (cdr (assoc 'system apps))))
+ (in-emacs (setq cmd 'emacs))
+ (t
(setq cmd (or (and remp (cdr (assoc 'remote apps)))
(and dirp (cdr (assoc 'directory apps)))
(assoc-default dfile (org-apps-regexp-alist apps a-m-a-p)
'string-match)
(cdr (assoc ext apps))
- (cdr (assoc t apps)))))
+ (cdr (assoc t apps))))))
+ (when (eq cmd 'system)
+ (setq cmd (cdr (assoc 'system apps))))
(when (eq cmd 'default)
(setq cmd (cdr (assoc t apps))))
(when (eq cmd 'mailcap)