emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: generalize %F in capture to dired buffers
Date: Mon, 18 Jul 2011 17:56:15 +0200	[thread overview]
Message-ID: <87vcuza8gw.fsf@gmail.com> (raw)

[-- 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


             reply	other threads:[~2011-07-18 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 15:56 Nicolas Goaziou [this message]
2011-07-18 23:20 ` generalize %F in capture to dired buffers Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vcuza8gw.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).