emacsorphanage / dart-mode

An Emacs mode for the Dart language
GNU General Public License v3.0
15 stars 2 forks source link

Can't export org file when there is a dart source code block #117

Closed nesteiner closed 2 years ago

nesteiner commented 2 years ago

You can try write a dart source code block in a org file, and then org-html-export-to-html, you will find an error that wrong type argument: number-of-marker-p, nil.

When I try to debug it, the stack top is some function about dart-mode, can you check out that ??

bradyt commented 2 years ago

I tried to reproduce the issue with emacs -Q, and I did not see an error. Please provide minimal instructions to reproduce the issue. One idea for creating a minimal broken example would be the following.

mkdir /tmp/mbe
cd /tmp/mbe
echo '#+begin_src dart\nmain() {}\n#+end_src' > test.org
HOME=. emacs -nw test.org
# C-c C-e h o

Maybe you can describe minimal contents to add to /tmp/mbe/.emacs in order to reproduce the error you see.

Also, might as well have provided the backtrace or what is "some function about dart-mode".

bradyt commented 2 years ago

You may want something like the following in your /tmp/mbe/.emacs or /tmp/mbe/.emacs.d/init.el.

(setq package-archives
      '(("gnu" . "https://elpa.gnu.org/packages/")
    ("melpa" . "https://melpa.org/packages/")))

;; (package-refresh-contents)
;; (package-install 'dart-mode)
nesteiner commented 2 years ago

https://user-images.githubusercontent.com/46296608/133862545-75d6317c-6489-4146-a759-cda10a8c81ca.mp4

bradyt commented 2 years ago

I don't feel you provided what I asked for. But I will try some other strategies next.

If you see an error there in the echo area, can you try M-x toggle-debug-on-error RET beforehand, so that the error will provoke a backtrace? Then share the text of the backtrace please, ideally videos are not necessary. You can wrap the text with the markdown markup, like this:

``` ```` And that will render like this: ``` ``` Please also consider asking for help on #emacs channel of Libera.chat, on tips to create a minimal broken example.
nesteiner commented 2 years ago

here you are, 2021-09-18 10-36-09 的屏幕截图

bradyt commented 2 years ago

Please share backtrace as text, wrapped with ```. See https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#quoting-code.

Images are not conducive to discussing code. Compare the discussion at https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors.

nesteiner commented 2 years ago

I think I found the problem, that when there is syntax error in the dart source block. the org file can't be export normally
you can try this code:

#+title: This is a test

* hello world
#+begin_src dart
  var expose = context.read<ExposedType>();
#+end_src

#+begin_src c++
  int main()
#+end_src
  1. there is a syntax error in c++ source block
  2. there is no syntax in dart source block
  3. but when modify the dart source block to var expose = context.read<ExposedType>(), which has no ;, the org file can't be exported normally
bradyt commented 2 years ago

I'm not clear where the blame has to go, but I hope we can find a fix that has a low risk of breaking dart-mode.el.

Bug seems to be at https://github.com/bradyt/dart-mode/blob/1.0.7/dart-mode.el#L434-L437.

         ;; If point is followed by semi-colon, we are done.
         ((or (> (point) limit)
              (= (char-after (point)) ?\;)
              (< (car (syntax-ppss)) depth))

So it seems somehow with org export, not even htmlize by itself, that (char-after (point)) evaluates as nil, and Emacs errors on the comparison. So presumably we can avoid the error with (or ... (null (char-after (point))) ...).

Drafted solution at https://github.com/bradyt/dart-mode/commit/e800e0301d58cc2f7e60695edd48253df14e8b46, on temporary branch, https://github.com/bradyt/dart-mode/tree/scratch/fix/org-export.

If it's easy for you to install that, I think you'll find it fixes the bug. But you may be satisfied with your workaround for now.

I guess I should use the commit for a while before I provoke a release to nongnu-elpa and melpa-stable with a git tag.

Thank you for reporting, and your patience with clarifying.

nesteiner commented 2 years ago

it seems that the matter of ;, :yum:

bradyt commented 2 years ago

Drafted solution is pushed to main branch. Closing. Let me know if the issue continues after the change. Closing optimistically.