Browse Source

Make org-store-link point to directory in a dired buffer

When the cursor is not in a line listing a file, that is.
Carsten Dominik 15 years ago
parent
commit
2cd16d4cd5
2 changed files with 14 additions and 5 deletions
  1. 6 0
      lisp/ChangeLog
  2. 8 5
      lisp/org.el

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+2010-02-02  Stephen Eglen  <stephen@gnu.org>
+
+	* org.el (org-store-link): For dired buffers, use
+	default-directory as link name if dired-get-filename returns
+	nil.
+
 2010-02-02  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-exp.el (org-export-concatenate-multiline-links): The for

+ 8 - 5
lisp/org.el

@@ -7669,11 +7669,14 @@ For file links, arg negates `org-context-in-file-links'."
 
      ((eq major-mode 'dired-mode)
       ;; link to the file in the current line
-      (setq cpltxt (concat "file:"
-			   (abbreviate-file-name
-			    (expand-file-name
-			     (dired-get-filename nil t))))
-	    link (org-make-link cpltxt)))
+      (let ((file (dired-get-filename nil t)))
+ 	(setq file (if file
+ 		       (abbreviate-file-name
+ 			(expand-file-name (dired-get-filename nil t)))
+ 		     ;; otherwise, no file so use current directory.
+ 		     default-directory))
+ 	(setq cpltxt (concat "file:" file)
+ 	      link (org-make-link cpltxt))))
 
      ((and buffer-file-name (org-mode-p))
       (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))