From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: coderef does not provide file path for org-insert-link when not in original buffre Date: Mon, 14 May 2018 09:52:36 +0800 Message-ID: <87po1zvw9n.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI6kX-0006dK-RG for emacs-orgmode@gnu.org; Mon, 14 May 2018 02:14:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fI2fM-0001aW-MP for emacs-orgmode@gnu.org; Sun, 13 May 2018 21:52:48 -0400 Received: from [183.249.136.205] (port=3299 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI2fL-0001To-6C for emacs-orgmode@gnu.org; Sun, 13 May 2018 21:52:44 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org-mode Suppose I have a src block: #+begin_src emacs-lisp (let ((case-fold-search nil) (str (prin1-to-string (with-temp-buffer (set-buffer-multibyte nil) ; (ref:set the temp buffer to unibyte) (insert (with-current-buffer (url-retrieve-synchronously "https://nginx.org/en/docs/dirindex.html") (buffer-string))) (let ((tree (libxml-parse-html-region (point-min) (point-max)))) tree))))) (and (string-match "\"content" str) (match-string 0 str))) ;=> "\"content" #+end_src On the `(set-buffer-multibyte nil)` line, then I use `org-store-link` to add coderef link. It insert [[(set the temp buffer to unibyte)]] for current buffer. But when in other file buffer, it still is this link. It suppose contains file path like: [[file:~/Org/elquery.org::(set%20the%20temp%20buffer%20to%20unibyte)][(set the temp buffer to unibyte)]] `org-insert-link` should be smart on decide whether current buffer is the same buffer with `org-store-link` source buffer, if yes, use [[(set the temp buffer to unibyte)]]. If no, use: [[file:~/Org/elquery.org::(set%20the%20temp%20buffer%20to%20unibyte)][(set the temp buffer to unibyte)]] WDYT? -- [ stardiviner ] don't need to convince with trends. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3