emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH[ Re: Indirect buffers, org-store-link, and org-insert-link
Date: Fri, 28 Aug 2020 21:54:50 +0700	[thread overview]
Message-ID: <rib5rr$7t4$1@ciao.gmane.io> (raw)
In-Reply-To: <rhob8q$t26$1@ciao.gmane.io>

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

It seems I have managed to fix store/insert link for indirect buffers by 
applying changes similar to
https://orgmode.org/list/8162z2tf8n.fsf_-_@gmail.com/
to another couple of code fragments.

Due to monkey-typing approach I am unsure that I have not broken 
something else.


[-- Attachment #2: indirect-buffer-links.patch --]
[-- Type: text/x-patch, Size: 2218 bytes --]

From 3d42f1e659b2c797629e6c041b38ae67dbe099a1 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Fri, 28 Aug 2020 14:49:03 +0000
Subject: [PATCH] ol.el: Fix store and insert link in indirect buffer

* lisp/ol.el(org-store-link): Store link with CUSTOM_ID anchor
in indirect buffer.
(org-insert-link): Do not add file name to search and CUSTOM_ID
links pointed to the same file when called from indirect buffer.

When a subtree was open in an indirect buffer, wrong argument
of `abbreviate-file-name' prevented storing link to a CUSTOM_ID
anchor. Internal link to a header line or to a CUSTOM_ID anchor
was created with file name instead of concise form.
This is a follow up of 784e5f1488.

TINYCHANGE
---
 lisp/ol.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index 76a9aca2b..951bb74e7 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1699,8 +1699,10 @@ non-nil."
 	  (push (list link desc) org-stored-links)
 	  (message "Stored: %s" (or desc link))
 	  (when custom-id
-	    (setq link (concat "file:" (abbreviate-file-name
-					(buffer-file-name)) "::#" custom-id))
+	    (setq link (concat "file:"
+			       (abbreviate-file-name
+				(buffer-file-name (buffer-base-buffer)))
+			       "::#" custom-id))
 	    (push (list link desc) org-stored-links)))
 	(car org-stored-links)))))
 
@@ -1841,13 +1843,14 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
     ;; Check if we are linking to the current file with a search
     ;; option If yes, simplify the link by using only the search
     ;; option.
-    (when (and buffer-file-name
+    (when (and (buffer-file-name (buffer-base-buffer))
 	       (let ((case-fold-search nil))
 		 (string-match "\\`file:\\(.+?\\)::" link)))
       (let ((path (match-string-no-properties 1 link))
 	    (search (substring-no-properties link (match-end 0))))
 	(save-match-data
-	  (when (equal (file-truename buffer-file-name) (file-truename path))
+	  (when (equal (file-truename (buffer-file-name (buffer-base-buffer)))
+		       (file-truename path))
 	    ;; We are linking to this same file, with a search option
 	    (setq link search)))))
 
-- 
2.17.1


  reply	other threads:[~2020-08-28 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 11:30 Indirect buffers, org-store-link, and org-insert-link Maxim Nikulin
2020-08-28 14:54 ` Maxim Nikulin [this message]
2020-09-04 16:00   ` [PATCH[ " 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='rib5rr$7t4$1@ciao.gmane.io' \
    --to=manikulin@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).