emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* generalize %F in capture to dired buffers
@ 2011-07-18 15:56 Nicolas Goaziou
  2011-07-18 23:20 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Goaziou @ 2011-07-18 15:56 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

Hello,

After an interesting discussion with chu_ on #org-mode, I've written the
following patch, which makes %F in a capture template return the full
path of the directory if the capture process was called from a dired
buffer.

Any interest in applying it?

Regards,

-- 
Nicolas Goaziou

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-capture-F-is-directory-when-capture-starts-in-a-.patch --]
[-- Type: text/x-patch, Size: 1021 bytes --]

From ac5ad0078527ba4efcf12e091f048b82d6559422 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Mon, 18 Jul 2011 17:42:01 +0200
Subject: [PATCH] org-capture: %F is directory when capture starts in a dired
 buffer

* lisp/org-capture.el (org-capture): if no file is associated to
  current buffer, check dired buffer and try to retreive a possibly
  directory associated.
---
 lisp/org-capture.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index aeb04f2..8da12df 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -447,7 +447,8 @@ bypassed."
 	(org-capture-set-plist entry)
 	(org-capture-get-template)
 	(org-capture-put :original-buffer orig-buf
-			 :original-file (buffer-file-name orig-buf)
+			 :original-file (or (buffer-file-name orig-buf)
+					    (car (rassq orig-buf dired-buffers)))
 			 :original-file-nondirectory
 			 (and (buffer-file-name orig-buf)
 			      (file-name-nondirectory
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-18 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-18 15:56 generalize %F in capture to dired buffers Nicolas Goaziou
2011-07-18 23:20 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).