Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The contents-end property appears non-existing when inserting image below ai block #64

Closed
okomestudio opened this issue Jul 17, 2023 · 3 comments · Fixed by #104
Closed

Comments

@okomestudio
Copy link

When I try the image generation example in README:

#+begin_ai :image :size 256x256
Hyper realistic sci-fi rendering of super complicated technical machine.
#+end_ai

C-c C-c does generate the image file in local disk.

Contacting host: api.openai.com:443
saved /home/taro/Downloads/org-ai/20230717_256x256_image_4.png
Entering debugger...

However, image rendering below the ai block consistently fails with wrong-type-argument integer-or-marker-p nil which appears to be caused by the contents-end property missing from the output of org-ai-special-block function:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  goto-char(nil)
  (let ((name (plist-get (car (cdr (org-ai-special-block))) :name)) (contents-end (plist-get (car (cdr (org-ai-special-block))) :contents-end))) (goto-char contents-end) (forward-line) (if name (progn (insert (format "#+NAME: %s%s\n" name (if (> n 0) (format "_%s" i) ""))))) (insert (format "[[file:%s]]\n" file)) (org-display-inline-images))
  ...

Here, goto-char(nil) because :contents-end returns nil.

When I invoke org-ai-special-block within the ai block in the Org file, I confirm that :contents-end is not available:

(special-block (:standard-properties [179 295 211 284 2 179 nil nil nil nil nil planning ...] :type "ai" :parameters ":image :size 256x256"))

I see no similar issue reported prior. What could cause :contents-end to be unavailable?

(The only thing I could think of that could be different from the standard Emacs setting is that I'm running it on Wayland via pgtk. I'm not sure that matters at all.)

@rksm
Copy link
Owner

rksm commented Aug 2, 2023

Good question but it seems similar to #67 and #69, for some reason org-elements don't have the expected org-element--standard-properties. Can you run M-x org-version and report the result? Thank you!

@okomestudio
Copy link
Author

okomestudio commented Aug 2, 2023

The results of org-version:

Org mode version 9.7-pre (release_9.6.7-606-g63e8ca @ /home/taro/.config/emacs/straight/build/org/)

It's at the head of the main branch. When I created this PR, org-mode was pinned to a commit about a month old (7c6302e2034916ed38f1c61dd0806f48e6f8a21c) from the current head (63e8cac2cadd77896d67890d36f3d59b60b13f74). But I see the same behavior now and then. Emacs version is at 29.1.

@rksm
Copy link
Owner

rksm commented Aug 3, 2023

Got it, thank you. I'll do some testing.

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 a pull request may close this issue.

2 participants