From 2cd16d4cd5ac8be1497f793cf366cb6403f0e7f9 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 2 Feb 2010 07:22:27 +0100 Subject: [PATCH] Make org-store-link point to directory in a dired buffer When the cursor is not in a line listing a file, that is. --- lisp/ChangeLog | 6 ++++++ lisp/org.el | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 97533718..646d2443 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-02 Stephen Eglen + + * 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 * org-exp.el (org-export-concatenate-multiline-links): The for diff --git a/lisp/org.el b/lisp/org.el index 2a983225..9488bf6f 100644 --- a/lisp/org.el +++ b/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"))) -- 2.11.4.GIT