emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* coderef does not provide file path for org-insert-link when not in original buffre
@ 2018-05-14  1:52 stardiviner
  2018-06-23 22:02 ` Nicolas Goaziou
  0 siblings, 1 reply; 14+ messages in thread
From: stardiviner @ 2018-05-14  1:52 UTC (permalink / raw)
  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
      

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: coderef does not provide file path for org-insert-link when not in original buffre
@ 2018-09-26 13:18 Nicolas Goaziou
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Goaziou @ 2018-09-26 13:18 UTC (permalink / raw)
  To: Org Mode List

Hello,

stardiviner <numbchild@gmail.com> writes:

> I take a look at the org.el code of functions `org-store-link`,
> `org-insert-link`, they can't inherit the original buffer file name
> `buffer-file-name`.

Why can't they?

> So can't use `org-link-file-path-type 'adaptive` case. But I found
> `org-insert-link` function definition has this snippet of code:

[...]

>      ;; I tried to add this, but failed. because `coderef` is executed in `org-edit-src-code` which invokes `org-src--edit-element`, it create a dedicated buffer which does not have `buffer-file-name`. I don't know how to archive what I want now.
> 	   ;; ((eq org-link-file-path-type 'adaptive)

In "org-src.el", we create local variables to store information from
original buffer. See, e.g., `org-src--src-type' or `org-src--tab-width'.
Anyway, see my first question.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

end of thread, other threads:[~2018-11-06  4:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-14  1:52 coderef does not provide file path for org-insert-link when not in original buffre stardiviner
2018-06-23 22:02 ` Nicolas Goaziou
2018-06-24  9:10   ` stardiviner
2018-09-23  8:46   ` stardiviner
     [not found]     ` <875zysr0bb.fsf@nicolasgoaziou.fr>
2018-10-24  2:51       ` stardiviner
2018-10-26 16:08         ` Nicolas Goaziou
2018-10-27  2:55           ` stardiviner
2018-11-01 17:39             ` Nicolas Goaziou
2018-11-02  6:15               ` stardiviner
2018-11-04 15:47                 ` Nicolas Goaziou
2018-11-06  4:48                   ` stardiviner
2018-11-06  4:48                   ` [SOLVED] " stardiviner
2018-10-31  5:16           ` stardiviner
  -- strict thread matches above, loose matches on Subject: below --
2018-09-26 13:18 Nicolas Goaziou

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).