emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* bug processing non emacs-lisp blocks
@ 2021-07-29  3:37 dmg
  2021-07-29  4:13 ` Tim Cross
  2021-08-07 20:24 ` Nicolas Goaziou
  0 siblings, 2 replies; 4+ messages in thread
From: dmg @ 2021-07-29  3:37 UTC (permalink / raw)
  To: emacs-orgmode

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

org-babel-load-file will try to tangle any source block that contains
the substring emacs-lisp or elisp in their language.

For example, the following code block will be tangled:

#+begin_src emacs-lispDONOT
(use-package "org-sidebar")
#+end_src

the following patch fixes that problem. The Regular expression should
be more stringent, so it does match exactly the string and not a
substring.

I think this is a regression. I used to comment out blocks from my
.org init files by simply adding a XXX (as in emacs-lispXXXX). In
current org these blocks are tangled :(



-- 
--dmg

---
D M German
http://turingmachine.org

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 488 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 1bd9e02eb..099655ff6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -229,7 +229,7 @@ byte-compiled before it is loaded."
 	     tangled-file
 	     (file-attribute-modification-time
 	      (file-attributes (file-truename file))))
-      (org-babel-tangle-file file tangled-file "emacs-lisp\\|elisp"))
+      (org-babel-tangle-file file tangled-file "^\\(emacs-lisp\\|elisp\\)$"))
     (if compile
 	(progn
 	  (byte-compile-file tangled-file)

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

* Re: bug processing non emacs-lisp blocks
  2021-07-29  3:37 bug processing non emacs-lisp blocks dmg
@ 2021-07-29  4:13 ` Tim Cross
  2021-07-29 14:54   ` Maxim Nikulin
  2021-08-07 20:24 ` Nicolas Goaziou
  1 sibling, 1 reply; 4+ messages in thread
From: Tim Cross @ 2021-07-29  4:13 UTC (permalink / raw)
  To: emacs-orgmode

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

dmg <dmg@turingmachine.org> writes:

> org-babel-load-file will try to tangle any source block that contains
> the substring emacs-lisp or elisp in their language.
>
> For example, the following code block will be tangled:
>
> #+begin_src emacs-lispDONOT
> (use-package "org-sidebar")
> #+end_src
>
> the following patch fixes that problem. The Regular expression should
> be more stringent, so it does match exactly the string and not a
> substring.
>
> I think this is a regression. I used to comment out blocks from my
> .org init files by simply adding a XXX (as in emacs-lispXXXX). In
> current org these blocks are tangled :(

I think your right. The regexp should only match on complete string.

BTW an easy way to comment out code blocks from tangling is to just add :tangle no to the header. This will work better because the code block will still work for editing etc and have correct syntax highlighting etc. 

Regards,

Tim

--
*Tim Cross*

/For gor sake stop laughing, this is serious!/

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

* Re: bug processing non emacs-lisp blocks
  2021-07-29  4:13 ` Tim Cross
@ 2021-07-29 14:54   ` Maxim Nikulin
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Nikulin @ 2021-07-29 14:54 UTC (permalink / raw)
  To: emacs-orgmode

On 29/07/2021 11:13, Tim Cross wrote:
> dmg writes:
> 
>> org-babel-load-file will try to tangle any source block that contains
>> the substring emacs-lisp or elisp in their language.
>>
>> For example, the following code block will be tangled:
>>
>> #+begin_src emacs-lispDONOT
>> (use-package "org-sidebar")
>> #+end_src
>>
>> I think this is a regression. I used to comment out blocks from my
>> .org init files by simply adding a XXX (as in emacs-lispXXXX). In
>> current org these blocks are tangled :(
> 
> I think your right. The regexp should only match on complete string.

I agree as well. Related code changed in 9.4:
- 
https://orgmode.org/list/CALOSHoRNnLxJMa6jnrt-iKiE-b9f9o3CLQDxFekrZVYiyzE0Qw@mail.gmail.com/T/#u
- https://code.orgmode.org/bzg/org-mode/commit/be93859c78

The following is just my opinion, not a request for an update of the patch.

Maybe it will be better to change `org-babel-tangle-collect-blocks' 
function in lisp/ob-tangle.el instead and to wrap passed argument in the 
suggested way (at first I thought of non-capturing group "\\(?:" "\\)", 
but it is not necessary since the regexp is passed to `string-match-p'). 
I suppose, it is more reliable default. If anyone really needs partial 
match, he may express it explicitly by adding ".*", "?", etc. I hope, 
such change will break no existing code.



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

* Re: bug processing non emacs-lisp blocks
  2021-07-29  3:37 bug processing non emacs-lisp blocks dmg
  2021-07-29  4:13 ` Tim Cross
@ 2021-08-07 20:24 ` Nicolas Goaziou
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2021-08-07 20:24 UTC (permalink / raw)
  To: dmg; +Cc: emacs-orgmode

Hello,

dmg <dmg@turingmachine.org> writes:

> org-babel-load-file will try to tangle any source block that contains
> the substring emacs-lisp or elisp in their language.
>
> For example, the following code block will be tangled:
>
> #+begin_src emacs-lispDONOT
> (use-package "org-sidebar")
> #+end_src
>
> the following patch fixes that problem. The Regular expression should
> be more stringent, so it does match exactly the string and not a
> substring.

Thank you. I applied an equivalent patch.

Regards,
-- 
Nicolas Goaziou


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

end of thread, other threads:[~2021-08-07 20:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-29  3:37 bug processing non emacs-lisp blocks dmg
2021-07-29  4:13 ` Tim Cross
2021-07-29 14:54   ` Maxim Nikulin
2021-08-07 20:24 ` 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).