hniksic / emacs-htmlize

Convert buffer text and decorations to HTML.
193 stars 44 forks source link

Error running 'htmlize-region' #9

Closed gilbertw1 closed 6 years ago

gilbertw1 commented 7 years ago

Hi, I'm seeing this exact same issue as #6 and am not able to resolve it by restarting emacs, or any other means. I am able to call html-buffer just fine, however htmlize-region always fails with that exact same error.

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p (nil . 100))
<((nil . 100) 99)
#[514 "\300 !  !\"\207" [< cl-key] 6 "\n\n(fn CL-X CL-Y)"](#<overlay from 50652 to 51034 in BrandController.scala> #<overlay from 50652 to 51034 in BrandController.scala>)
sort((#<overlay from 50652 to 51034 in BrandController.scala>) #[514 "\300  !  !\"\207" [< cl-key] 6 "\n\n(fn CL-X CL-Y)"])
cl-sort((#<overlay from 50652 to 51034 in BrandController.scala>) < :key #[257 "\300\301\"\206\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"]))
  stable-sort((#<overlay from 50652 to 51034 in BrandController.scala>) < :key #[257 "\300\301\"\206\302\207" [overlay-get priority 0] 4 "\n\n(fn O)"])
  htmlize-faces-at-point()
  htmlize-buffer-1()
  htmlize-region(50652 51034)
  funcall-interactively(htmlize-region 50652 51034)
  call-interactively(htmlize-region record nil)
  command-execute(htmlize-region record)
  #[257 "\304\305!\203\f

I've only just used htmlize for the first time, and simply calling htmlize-region interactively is failing for me. I tried it on files of different types and sizes and it continues to fail.

I've narrowed this problem down the following lines: https://github.com/hniksic/emacs-htmlize/blob/master/htmlize.el#L1383-L1389

If I comment them out, then this function runs perfectly.

Thanks!

Hi-Angel commented 6 years ago

⁺¹, FTR the correct link is this because the code have changed since, and line marks point to wrong lines.

However commenting out the code and using C-xC-e on the function doesn't work for me, I'm still getting the same error for htmlize-region.

Hi-Angel commented 6 years ago

Ok, I just discovered this is not actually a function but some odd code that hangs there for some reason in pure air, so I commented it within the htmlize.el, byte-compiled the file, and restarted the emacs. Still same error.

Hi-Angel commented 6 years ago

Haha, I found how to workaround that, no need to comment the code!

Turns out, htmlize-region for some reason doesn't work with evil selection. I.e. if you're using evil-mode, you have to go into *insert-mode`, and select the region through basic means of Emacs, like M-S-f. And it works even without commenting the lines of code.

hniksic commented 6 years ago

Thanks for the report; the issue was that priority was not guaranteed to be a number. The new code simply lets Emacs sort the overlays itself.