Browse Source

org.el (org-open-at-point): Deleted mismatching `catch' form.

Bastien Guerry 18 years ago
parent
commit
1e77a00453
2 changed files with 188 additions and 185 deletions
  1. 4 0
      ChangeLog
  2. 184 185
      org.el

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+2008-02-28  Bastien Guerry  <bzg@altern.org>
+
+	* org.el (org-open-at-point): Deleted mismatching `catch' form.
+
 2008-02-28  Phil Jackson  <phil@shellarchive.co.uk>
 2008-02-28  Phil Jackson  <phil@shellarchive.co.uk>
 
 
 	* org-irc.el (org-irc-erc-store-link): Long log entry descriptions
 	* org-irc.el (org-irc-erc-store-link): Long log entry descriptions

+ 184 - 185
org.el

@@ -12681,192 +12681,191 @@ the end of the current subtree.
 Normally, files will be opened by an appropriate application.  If the
 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."
   (interactive "P")
   (interactive "P")
-  (catch 'abort
-    (move-marker org-open-link-marker (point))
-    (setq org-window-config-before-follow-link (current-window-configuration))
-    (org-remove-occur-highlights nil nil t)
-    (if (org-at-timestamp-p t)
-	(org-follow-timestamp-link)
-      (let (type path link line search (pos (point)))
-	(catch 'match
-	  (save-excursion
-	    (skip-chars-forward "^]\n\r")
-	    (when (org-in-regexp org-bracket-link-regexp)
-	      (setq link (org-link-unescape (org-match-string-no-properties 1)))
-	      (while (string-match " *\n *" link)
-		(setq link (replace-match " " t t link)))
-	      (setq link (org-link-expand-abbrev link))
-	      (if (string-match org-link-re-with-space2 link)
-		  (setq type (match-string 1 link) path (match-string 2 link))
-		(setq type "thisfile" path link))
-	      (throw 'match t)))
-
-	  (when (get-text-property (point) 'org-linked-text)
-	    (setq type "thisfile"
-		  pos (if (get-text-property (1+ (point)) 'org-linked-text)
-			  (1+ (point)) (point))
-		  path (buffer-substring
-			(previous-single-property-change pos 'org-linked-text)
-			(next-single-property-change pos 'org-linked-text)))
-	    (throw 'match t))
-
-	  (save-excursion
-	    (when (or (org-in-regexp org-angle-link-re)
-		      (org-in-regexp org-plain-link-re))
-	      (setq type (match-string 1) path (match-string 2))
-	      (throw 'match t)))
-	  (when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
-	    (setq type "tree-match"
+  (move-marker org-open-link-marker (point))
+  (setq org-window-config-before-follow-link (current-window-configuration))
+  (org-remove-occur-highlights nil nil t)
+  (if (org-at-timestamp-p t)
+      (org-follow-timestamp-link)
+    (let (type path link line search (pos (point)))
+      (catch 'match
+	(save-excursion
+	  (skip-chars-forward "^]\n\r")
+	  (when (org-in-regexp org-bracket-link-regexp)
+	    (setq link (org-link-unescape (org-match-string-no-properties 1)))
+	    (while (string-match " *\n *" link)
+	      (setq link (replace-match " " t t link)))
+	    (setq link (org-link-expand-abbrev link))
+	    (if (string-match org-link-re-with-space2 link)
+		(setq type (match-string 1 link) path (match-string 2 link))
+	      (setq type "thisfile" path link))
+	    (throw 'match t)))
+	
+	(when (get-text-property (point) 'org-linked-text)
+	  (setq type "thisfile"
+		pos (if (get-text-property (1+ (point)) 'org-linked-text)
+			(1+ (point)) (point))
+		path (buffer-substring
+		      (previous-single-property-change pos 'org-linked-text)
+		      (next-single-property-change pos 'org-linked-text)))
+	  (throw 'match t))
+	
+	(save-excursion
+	  (when (or (org-in-regexp org-angle-link-re)
+		    (org-in-regexp org-plain-link-re))
+	    (setq type (match-string 1) path (match-string 2))
+	    (throw 'match t)))
+	(when (org-in-regexp "\\<\\([^><\n]+\\)\\>")
+	  (setq type "tree-match"
+		path (match-string 1))
+	  (throw 'match t))
+	(save-excursion
+	  (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$"))
+	    (setq type "tags"
 		  path (match-string 1))
 		  path (match-string 1))
-	    (throw 'match t))
-	  (save-excursion
-	    (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$"))
-	      (setq type "tags"
-		    path (match-string 1))
-	      (while (string-match ":" path)
-		(setq path (replace-match "+" t t path)))
-	      (throw 'match t))))
-	(unless path
-	  (error "No link found"))
-	;; Remove any trailing spaces in path
-	(if (string-match " +\\'" path)
-	    (setq path (replace-match "" t t path)))
-
-	(cond
-
-	 ((assoc type org-link-protocols)
-	  (funcall (nth 1 (assoc type org-link-protocols)) path))
-
-	 ((equal type "mailto")
-	  (let ((cmd (car org-link-mailto-program))
-		(args (cdr org-link-mailto-program)) args1
-		(address path) (subject "") a)
-	    (if (string-match "\\(.*\\)::\\(.*\\)" path)
-		(setq address (match-string 1 path)
-		      subject (org-link-escape (match-string 2 path))))
-	    (while args
-	      (cond
-	       ((not (stringp (car args))) (push (pop args) args1))
-	       (t (setq a (pop args))
-		  (if (string-match "%a" a)
-		      (setq a (replace-match address t t a)))
-		  (if (string-match "%s" a)
-		      (setq a (replace-match subject t t a)))
-		  (push a args1))))
-	    (apply cmd (nreverse args1))))
-
-	 ((member type '("http" "https" "ftp" "news"))
-	  (browse-url (concat type ":" (org-link-escape
-					path org-link-escape-chars-browser))))
-
-	 ((member type '("message"))
-	  (browse-url (concat type ":" path)))
-
-	 ((string= type "tags")
-	  (org-tags-view in-emacs path))
-	 ((string= type "thisfile")
-	  (if in-emacs
-	      (switch-to-buffer-other-window
-	       (org-get-buffer-for-internal-link (current-buffer)))
-	    (org-mark-ring-push))
-	  (let ((cmd `(org-link-search
-		       ,path
-		       ,(cond ((equal in-emacs '(4)) 'occur)
-			      ((equal in-emacs '(16)) 'org-occur)
-			      (t nil))
-		       ,pos)))
-	    (condition-case nil (eval cmd)
-	      (error (progn (widen) (eval cmd))))))
-
-	 ((string= type "tree-match")
-	  (org-occur (concat "\\[" (regexp-quote path) "\\]")))
-
-	 ((string= type "file")
-	  (if (string-match "::\\([0-9]+\\)\\'" path)
-	      (setq line (string-to-number (match-string 1 path))
-		    path (substring path 0 (match-beginning 0)))
-	    (if (string-match "::\\(.+\\)\\'" path)
-		(setq search (match-string 1 path)
-		      path (substring path 0 (match-beginning 0)))))
-	  (if (string-match "[*?{]" (file-name-nondirectory path))
-	      (dired path)
-	    (org-open-file path in-emacs line search)))
-
-	 ((string= type "news")
-	  (org-follow-gnus-link path))
-
-	 ((string= type "bbdb")
-	  (org-follow-bbdb-link path))
-
-	 ((string= type "info")
-	  (org-follow-info-link path))
-
-	 ((string= type "gnus")
-	  (let (group article)
-	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-		(error "Error in Gnus link"))
-	    (setq group (match-string 1 path)
-		  article (match-string 3 path))
-	    (org-follow-gnus-link group article)))
-
-	 ((string= type "vm")
-	  (let (folder article)
-	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-		(error "Error in VM link"))
-	    (setq folder (match-string 1 path)
-		  article (match-string 3 path))
-	    ;; in-emacs is the prefix arg, will be interpreted as read-only
-	    (org-follow-vm-link folder article in-emacs)))
-
-	 ((string= type "wl")
-	  (let (folder article)
-	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-		(error "Error in Wanderlust link"))
-	    (setq folder (match-string 1 path)
-		  article (match-string 3 path))
-	    (org-follow-wl-link folder article)))
-
-	 ((string= type "mhe")
-	  (let (folder article)
-	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-		(error "Error in MHE link"))
-	    (setq folder (match-string 1 path)
-		  article (match-string 3 path))
-	    (org-follow-mhe-link folder article)))
-
-	 ((string= type "rmail")
-	  (let (folder article)
-	    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-		(error "Error in RMAIL link"))
-	    (setq folder (match-string 1 path)
-		  article (match-string 3 path))
-	    (org-follow-rmail-link folder article)))
-
-	 ((string= type "shell")
-	  (let ((cmd path))
-	    (if (or (not org-confirm-shell-link-function)
-		    (funcall org-confirm-shell-link-function
-			     (format "Execute \"%s\" in shell? "
-				     (org-add-props cmd nil
-						    'face 'org-warning))))
-		(progn
-		  (message "Executing %s" cmd)
-		  (shell-command cmd))
-	      (error "Abort"))))
-
-	 ((string= type "elisp")
-	  (let ((cmd path))
-	    (if (or (not org-confirm-elisp-link-function)
-		    (funcall org-confirm-elisp-link-function
-			     (format "Execute \"%s\" as elisp? "
-				     (org-add-props cmd nil
-						    'face 'org-warning))))
-		(message "%s => %s" cmd (eval (read cmd)))
-	      (error "Abort"))))
-
-	 (t
-	  (browse-url-at-point)))))
-    (move-marker org-open-link-marker nil)))
+	    (while (string-match ":" path)
+	      (setq path (replace-match "+" t t path)))
+	    (throw 'match t))))
+      (unless path
+	(error "No link found"))
+      ;; Remove any trailing spaces in path
+      (if (string-match " +\\'" path)
+	  (setq path (replace-match "" t t path)))
+      
+      (cond
+       
+       ((assoc type org-link-protocols)
+	(funcall (nth 1 (assoc type org-link-protocols)) path))
+       
+       ((equal type "mailto")
+	(let ((cmd (car org-link-mailto-program))
+	      (args (cdr org-link-mailto-program)) args1
+	      (address path) (subject "") a)
+	  (if (string-match "\\(.*\\)::\\(.*\\)" path)
+	      (setq address (match-string 1 path)
+		    subject (org-link-escape (match-string 2 path))))
+	  (while args
+	    (cond
+	     ((not (stringp (car args))) (push (pop args) args1))
+	     (t (setq a (pop args))
+		(if (string-match "%a" a)
+		    (setq a (replace-match address t t a)))
+		(if (string-match "%s" a)
+		    (setq a (replace-match subject t t a)))
+		(push a args1))))
+	  (apply cmd (nreverse args1))))
+       
+       ((member type '("http" "https" "ftp" "news"))
+	(browse-url (concat type ":" (org-link-escape
+				      path org-link-escape-chars-browser))))
+       
+       ((member type '("message"))
+	(browse-url (concat type ":" path)))
+       
+       ((string= type "tags")
+	(org-tags-view in-emacs path))
+       ((string= type "thisfile")
+	(if in-emacs
+	    (switch-to-buffer-other-window
+	     (org-get-buffer-for-internal-link (current-buffer)))
+	  (org-mark-ring-push))
+	(let ((cmd `(org-link-search
+		     ,path
+		     ,(cond ((equal in-emacs '(4)) 'occur)
+			    ((equal in-emacs '(16)) 'org-occur)
+			    (t nil))
+		     ,pos)))
+	  (condition-case nil (eval cmd)
+	    (error (progn (widen) (eval cmd))))))
+       
+       ((string= type "tree-match")
+	(org-occur (concat "\\[" (regexp-quote path) "\\]")))
+       
+       ((string= type "file")
+	(if (string-match "::\\([0-9]+\\)\\'" path)
+	    (setq line (string-to-number (match-string 1 path))
+		  path (substring path 0 (match-beginning 0)))
+	  (if (string-match "::\\(.+\\)\\'" path)
+	      (setq search (match-string 1 path)
+		    path (substring path 0 (match-beginning 0)))))
+	(if (string-match "[*?{]" (file-name-nondirectory path))
+	    (dired path)
+	  (org-open-file path in-emacs line search)))
+       
+       ((string= type "news")
+	(org-follow-gnus-link path))
+       
+       ((string= type "bbdb")
+	(org-follow-bbdb-link path))
+       
+       ((string= type "info")
+	(org-follow-info-link path))
+       
+       ((string= type "gnus")
+	(let (group article)
+	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+	      (error "Error in Gnus link"))
+	  (setq group (match-string 1 path)
+		article (match-string 3 path))
+	  (org-follow-gnus-link group article)))
+       
+       ((string= type "vm")
+	(let (folder article)
+	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+	      (error "Error in VM link"))
+	  (setq folder (match-string 1 path)
+		article (match-string 3 path))
+	  ;; in-emacs is the prefix arg, will be interpreted as read-only
+	  (org-follow-vm-link folder article in-emacs)))
+       
+       ((string= type "wl")
+	(let (folder article)
+	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+	      (error "Error in Wanderlust link"))
+	  (setq folder (match-string 1 path)
+		article (match-string 3 path))
+	  (org-follow-wl-link folder article)))
+       
+       ((string= type "mhe")
+	(let (folder article)
+	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+	      (error "Error in MHE link"))
+	  (setq folder (match-string 1 path)
+		article (match-string 3 path))
+	  (org-follow-mhe-link folder article)))
+       
+       ((string= type "rmail")
+	(let (folder article)
+	  (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
+	      (error "Error in RMAIL link"))
+	  (setq folder (match-string 1 path)
+		article (match-string 3 path))
+	  (org-follow-rmail-link folder article)))
+       
+       ((string= type "shell")
+	(let ((cmd path))
+	  (if (or (not org-confirm-shell-link-function)
+		  (funcall org-confirm-shell-link-function
+			   (format "Execute \"%s\" in shell? "
+				   (org-add-props cmd nil
+				     'face 'org-warning))))
+	      (progn
+		(message "Executing %s" cmd)
+		(shell-command cmd))
+	    (error "Abort"))))
+       
+       ((string= type "elisp")
+	(let ((cmd path))
+	  (if (or (not org-confirm-elisp-link-function)
+		  (funcall org-confirm-elisp-link-function
+			   (format "Execute \"%s\" as elisp? "
+				   (org-add-props cmd nil
+				     'face 'org-warning))))
+	      (message "%s => %s" cmd (eval (read cmd)))
+	    (error "Abort"))))
+       
+       (t
+	(browse-url-at-point)))))
+  (move-marker org-open-link-marker nil))
 
 
 ;;; File search
 ;;; File search