Browse Source

Make C-c C-o open the attachment directory is there are no links

Carsten Dominik 15 years ago
parent
commit
10249d98d1
3 changed files with 23 additions and 7 deletions
  1. 11 0
      lisp/ChangeLog
  2. 4 4
      lisp/org-attach.el
  3. 8 3
      lisp/org.el

+ 11 - 0
lisp/ChangeLog

@@ -1,5 +1,16 @@
 2009-10-30  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org.el (org-offer-links-in-entry): Return nil if there are no
+	links, t if a link has been selected.
+	(org-open-at-point): Open attachment directory when called in the
+	headline and there are no links in the entry body.
+	(org-speed-commands-default): Add "o" for open-at-point as a speed
+	command.
+
+	* org-attach.el (org-attach-reveal): Optional prefix arg
+	IF-EXISTS, which avoids creating the attachment directory if it
+	does not yet exist.
+
 	* org-agenda.el (org-agenda, org-run-agenda-series): Evaluate
 	MATCH.
 

+ 4 - 4
lisp/org-attach.el

@@ -365,11 +365,11 @@ This ignores files starting with a \".\", and files ending in \"~\"."
 	(mapcar (lambda (x) (if (string-match "^\\." x) nil x))
 		(directory-files dir nil "[^~]\\'"))))
 
-(defun org-attach-reveal ()
+(defun org-attach-reveal (&optional if-exists)
   "Show the attachment directory of the current task in dired."
-  (interactive)
-  (let ((attach-dir (org-attach-dir t)))
-    (org-open-file attach-dir)))
+  (interactive "P")
+  (let ((attach-dir (org-attach-dir (not if-exists))))
+    (and attach-dir (org-open-file attach-dir))))
 
 (defun org-attach-reveal-in-emacs ()
   "Show the attachment directory of the current task.

+ 8 - 3
lisp/org.el

@@ -8040,7 +8040,8 @@ application the system uses for this file type."
 		       org-bracket-link-regexp "\\|"
 		       org-angle-link-re "\\|"
 		       "[ \t]:[^ \t\n]+:[ \t]*$"))))
-    (org-offer-links-in-entry in-emacs))
+    (or (org-offer-links-in-entry in-emacs)
+	(org-attach-reveal 'if-exists)))
    ((org-at-timestamp-p t) (org-follow-timestamp-link))
    ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p))
     (org-footnote-action))
@@ -8223,7 +8224,8 @@ there is one, offer it as link number zero."
       (setq links (org-uniquify (reverse links))))
 
     (cond
-     ((null links) (error "No links"))
+     ((null links)
+      (message "No links"))
      ((equal (length links) 1)
       (setq link (car links)))
      ((and (integerp nth) (>= (length links) (if have-zero (1+ nth) nth)))
@@ -8253,7 +8255,9 @@ there is one, offer it as link number zero."
       (unless (and (integerp nth) (>= (length links) nth))
 	(error "Invalid link selection"))
       (setq link (nth (1- nth) links))))
-    (org-open-link-from-string link in-emacs (current-buffer))))
+    (if link
+	(progn (org-open-link-from-string link in-emacs (current-buffer)) t)
+      nil)))
 
 ;;;; Time estimates
 
@@ -14644,6 +14648,7 @@ Some of the options can be changed using the variable
     ("i" . (progn (forward-char 1) (call-interactively
 				    'org-insert-heading-respect-content)))
     ("a" . org-archive-subtree-default)
+    ("o" . org-open-at-point)
     ("t" . org-todo)
     ("j" . org-goto)
     ("1" . (org-priority ?A))