emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ob-tangle.el: fix ‘:comments noweb’ double linking


From: Max Nikulin
Subject: Re: [PATCH] ob-tangle.el: fix ‘:comments noweb’ double linking
Date: Sat, 13 Aug 2022 15:06:14 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 13/08/2022 13:42, Ihor Radchenko wrote:
Max Nikulin writes:

+             (bare (and (string-match org-link-bracket-re l)
+                        (match-string 1 l))))
+        (when bare
+          (if (and org-babel-tangle-use-relative-file-links
+                   (string-match org-link-types-re bare)
+                   (string= (match-string 1 bare) "file"))

It looks like (string-prefix-p "file:" bare) but without the complex
regexp. I see, such code was used before. By the way, why it is "bare",
not e.g. "target"?

match-end is used later in the code. Thus, string-match is justified.

The matched string is always "file:", so there is no actual point in `string-match'. It does not really matter however.

(let ((params '((:tangle . "/home/user/file.el")))
      (type "file:")
      (target "file:///dev/null"))
  (if (and target
           org-babel-tangle-use-relative-file-links
           (string-prefix-p type target))
      (concat type
              (file-relative-name
               (substring target (length type))
               (file-name-directory (alist-get :tangle params))))
    target))

In the code existed before and moved by the committed patch I do not like that "then" branch of the `if' form uses side effect of evaluation of the condition.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]