From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: [PATCH 2/2] org-store-link: Fix storing of links to headlines in indirect buffers Date: Mon, 23 Aug 2010 04:41:20 +0530 Message-ID: <8162z2tf8n.fsf_-_@gmail.com> References: <20524da70811261844o3f47782ay3437fdfdc55bda95@mail.gmail.com> <81fwybeoem.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=58281 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnJhO-0002HU-QN for emacs-orgmode@gnu.org; Sun, 22 Aug 2010 19:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnJhN-0007JT-EI for emacs-orgmode@gnu.org; Sun, 22 Aug 2010 19:11:34 -0400 Received: from mail-px0-f169.google.com ([209.85.212.169]:41837) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnJhN-0007JM-7N for emacs-orgmode@gnu.org; Sun, 22 Aug 2010 19:11:33 -0400 Received: by pxi5 with SMTP id 5so3528460pxi.0 for ; Sun, 22 Aug 2010 16:11:32 -0700 (PDT) In-Reply-To: <81fwybeoem.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 19 Aug 2010 00:31:05 +0530") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Summary: When org-store-link is invoked on a headline in indirect buffer (as in a capture buffer), hyperlink gets created to the file and NOT the headline. This is a bug. The attached patch fixes this. Setup: # ~/.emacs (defun my-conversation-id () (interactive) (remove-hook 'org-capture-before-finalize-hook 'my-conversation-id) (let ((org-link-to-org-use-id t)) (call-interactively 'org-store-link) ) ) # org-capture-templates ("x" "Conversations" entry (file+headline "~/conversation.org" "Conversations") "%(progn (add-hook 'org-capture-before-finalize-hook 'my-conversation-id) \"\")** Note taken on %U\n %? " :prepend t :empty-lines 1) Steps for reproduction: Trigger org-capture for the above capture entry. Examine conversation.org before/after the patch is applied. Note the absence/presence of IDs for the captured entry. Check for the stored links using C-c C-l. Note the file/headline links. # file conversation.org before and after the patch * Conversations ** Note taken on [2010-08-23 Mon 04:33] :PROPERTIES: :ID: 7e1974a6-8fa1-43cf-bef3-2adf37d99130 :END: ** Note taken on [2010-08-23 Mon 04:32] # (org-insert-link) showing stored links before and after the patch file:~/conversation.org (file:~/conversation.org) id:7e1974a6-8fa1-43cf-bef3-2adf37d99130 (Note taken on [2010-08-23 Mon 04:33]) Jambunathan K. --=-=-= Content-Disposition: inline >From 90628b45ee4d270b32f8a56618ca75ceb4a16b21 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 23 Aug 2010 02:32:15 +0530 Subject: [PATCH 2/2] org-store-link: Fix storing of links to headlines in indirect buffers * org.el (org-store-link): Storing of links to headlines in indirect buffers was broken. Fix it. TINYCHANGE --- lisp/org.el | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5db7aab..15379ef 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8301,13 +8301,14 @@ For file links, arg negates `org-context-in-file-links'." (setq cpltxt (concat "file:" file) link (org-make-link cpltxt)))) - ((and buffer-file-name (org-mode-p)) + ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p)) (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID"))) (cond ((org-in-regexp "<<\\(.*?\\)>>") (setq cpltxt (concat "file:" - (abbreviate-file-name buffer-file-name) + (abbreviate-file-name + (buffer-file-name (buffer-base-buffer))) "::" (match-string 1)) link (org-make-link cpltxt))) ((and (featurep 'org-id) @@ -8329,11 +8330,13 @@ For file links, arg negates `org-context-in-file-links'." (error ;; probably before first headline, link to file only (concat "file:" - (abbreviate-file-name buffer-file-name)))))) + (abbreviate-file-name + (buffer-file-name (buffer-base-buffer)))))))) (t ;; Just link to current headline (setq cpltxt (concat "file:" - (abbreviate-file-name buffer-file-name))) + (abbreviate-file-name + (buffer-file-name (buffer-base-buffer))))) ;; Add a context search string (when (org-xor org-context-in-file-links arg) (setq txt (cond -- 1.7.0.4 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--