Skip to content

fix: #295 transcluding source file with search-option#296

Merged
nobiot merged 1 commit intomainfrom
fix/295
Apr 17, 2026
Merged

fix: #295 transcluding source file with search-option#296
nobiot merged 1 commit intomainfrom
fix/295

Conversation

@nobiot
Copy link
Copy Markdown
Owner

@nobiot nobiot commented Feb 17, 2026

fix #295
We really should have unit-test.
@AndreasMatthias , I'd appreciate it if you ran your unit-test.el for no-web. On my end, I don't think I am running it correctly but it looks like the test fails.

@AndreasMatthias
Copy link
Copy Markdown
Contributor

I see that the indentation is wrong for transclusions without a :src-block.
But as far as I can see this issue is not related to :noweb-chunk.

Here is a simple test case where the indentation is wrong, too.
This is broken since 6e5e6eb.

File foo.py:

def foo():
    print("foo")

File test.org:

#+transclude: [[./foo.py]]

Another issue that you might hit when running test-noweb-chunk.org is the
global setting of org-edit-src-content-indentation that was 0 when I created
the detached file.

@AndreasMatthias
Copy link
Copy Markdown
Contributor

Since the indentation inside a src-block is correct, the question is: Do we need to support code transclusion without a src-block at all?

@AndreasMatthias
Copy link
Copy Markdown
Contributor

Regarding unit-tests: What kind of unit-tests do you have in mind?

Some time ago I started with an ERT testsuite. It's not a strict unit testing, but a top-level white-box testing that does comparisions with detached files, similar to the noweb test file. This testsuite displays diff buffers for all tests that failed, and it can check simple live-editing as well.

If you are interested I can provide the code. But I need to refactor the code first.

@gggion
Copy link
Copy Markdown
Contributor

gggion commented Mar 13, 2026

Was just about to post an issue for this, I was fixing #304 related to thing-at-point (PR at #305 ) and also noticed the search-option issue.

Regarding more tests, I've added several thing-at-point org tests here:
https://raw.githubusercontent.com/gggion/org-transclusion/61f76beb509b21d26cb8f0f21f19b46b88bb6eda/test/things-at-point.org

I noticed after fixing 'defun' thing-at-point, even if the match to the defun was succesful, the transcluded region began at the exact position of the match instead of ht beginning of the line/indentation like it used to.

image

In this org test file I went over:

  • thing-at-point
    • elisp related, tested these with and without :src

      • sexp and sexp :end "N"
      • list
      • defun and defun :end "N"
      • symbol
    • prose related (tested :end with most of these too)

      • word
      • sentence
      • paragraph
      • line

I think I could make most of these into ert tests without much trouble since I've delineated expected results from multiple types of transclusions for all thing-at-point transclusions I could think of, we could add them to any other ert test suite for src-lines.el, since my tests focus mainly on thing-at-point.

I have also have several tests for org-transclusion-blocks.el which could be ported over to org-transclusion.el as ert tests, for :lines and :src, also have some for text properties and fringe creation.

@gggion
Copy link
Copy Markdown
Contributor

gggion commented Mar 13, 2026

I've ran the tests mentioned over this branch and it seems to have fixed the issues I was describing before.

image

@AndreasMatthias
Copy link
Copy Markdown
Contributor

@gggion: Looks good to me.

While looking into this, I noticed a few things that are not related to this fix, but are somehow related to this topic. Here's an example:

File code.el:

(defun foo ()
  (message "aaa") ;; This is important [id-123]
  (message "bbb"))

(message "this is not part of foo()")

File test.org:

Comment is stripped here. Is this intended?
#+transclude: [[./code.el::id-123]]  :src elisp :thing-at-point sexp

Comment not stripped in this case
#+transclude: [[./code.el::id-123]]  :src elisp

What's the supposed transclusion here?
I was expecting function `foo()` to be transcluded.
#+transclude: [[./code.el::id-123]]  :src emacs-lisp :thing-at-point defun

@nobiot nobiot merged commit 6e576fb into main Apr 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dedicated links in non-org files

3 participants