dgutov / mmm-mode

New official home for mmm-mode, fixed for Emacs >= 23
http://mmm-mode.sourceforge.net/
GNU General Public License v2.0
334 stars 32 forks source link

mmm-parse-buffer not working (sometimes) #106

Closed esabol closed 4 years ago

esabol commented 4 years ago

Sometimes when I M-x mmm-parse-buffer, I get the following messages:

MMM-ifying buffer...
font-lock-compile-keywords: Font-lock trying to use keywords before setting them up

This does not happen when the file is first loaded. It only happens if I M-x mmm-parse-buffer after it is loaded and then only sometimes. Maybe it's file dependent. I'm not sure.

(setq debug-on-error t) shows this:

Debugger entered--Lisp error: (error "Font-lock trying to use keywords before setting them up")
  signal(error ("Font-lock trying to use keywords before setting them up"))
  error("Font-lock trying to use keywords before setting them up")
  font-lock-compile-keywords(nil)
  font-lock-fontify-keywords-region(225 273 nil)
  font-lock-default-fontify-region(225 273 nil)
  #f(compiled-function (reg) #<bytecode 0x171f7a5>)((225 273 #<overlay from 225 to 273 in test.form>))
  mapc(#f(compiled-function (reg) #<bytecode 0x171f7a5>) ((225 273 #<overlay from 225 to 273 in test.form>) (276 311 #<overlay from 276 to 311 in test.form>) (314 343 #<overlay from 314 to 343 in test.form>) (346 388 #<overlay from 346 to 388 in test.form>) (391 404 #<overlay from 391 to 404 in test.form>) (2027 2210 #<overlay from 2027 to 2210 in test.form>) (2213 2224 #<overlay from 2213 to 2224 in test.form>) (9997 10031 #<overlay from 9997 to 10031 in test.form>) (10037 10041 #<overlay from 10037 to 10041 in test.form>) (10169 10323 #<overlay from 10169 to 10323 in test.form>) (10326 10331 #<overlay from 10326 to 10331 in test.form>) (10337 10341 #<overlay from 10337 to 10341 in test.form>) (10537 10648 #<overlay from 10537 to 10648 in test.form>) (10651 10667 #<overlay from 10651 to 10667 in test.form>) (10670 10675 #<overlay from 10670 to 10675 in test.form>) (12449 12521 #<overlay from 12449 to 12521 in test.form>) (12524 12591 #<overlay from 12524 to 12591 in test.form>) (12594 12645 #<overlay from 12594 to 12645 in test.form>) (13084 13294 #<overlay from 13084 to 13294 in test.form>) (15881 16193 #<overlay from 15881 to 16193 in test.form>) (17588 17623 #<overlay from 17588 to 17623 in test.form>) (23285 23436 #<overlay from 23285 to 23436 in test.form>) (23439 23515 #<overlay from 23439 to 23515 in test.form>) (23518 23547 #<overlay from 23518 to 23547 in test.form>) (23981 24126 #<overlay from 23981 to 24126 in test.form>) (25346 25556 #<overlay from 25346 to 25556 in test.form>) (26416 26646 #<overlay from 26416 to 26646 in test.form>) (26803 26883 #<overlay from 26803 to 26883 in test.form>) (26886 26901 #<overlay from 26886 to 26901 in test.form>) (26904 26980 #<overlay from 26904 to 26980 in test.form>) (26983 27026 #<overlay from 26983 to 27026 in test.form>) (27029 27098 #<overlay from 27029 to 27098 in test.form>) (27101 27122 #<overlay from 27101 to 27122 in test.form>) (31585 31635 #<overlay from 31585 to 31635 in test.form>)))
  mmm-fontify-region-list(text-mode ((225 273 #<overlay from 225 to 273 in test.form>) (276 311 #<overlay from 276 to 311 in test.form>) (314 343 #<overlay from 314 to 343 in test.form>) (346 388 #<overlay from 346 to 388 in test.form>) (391 404 #<overlay from 391 to 404 in test.form>) (2027 2210 #<overlay from 2027 to 2210 in test.form>) (2213 2224 #<overlay from 2213 to 2224 in test.form>) (9997 10031 #<overlay from 9997 to 10031 in test.form>) (10037 10041 #<overlay from 10037 to 10041 in test.form>) (10169 10323 #<overlay from 10169 to 10323 in test.form>) (10326 10331 #<overlay from 10326 to 10331 in test.form>) (10337 10341 #<overlay from 10337 to 10341 in test.form>) (10537 10648 #<overlay from 10537 to 10648 in test.form>) (10651 10667 #<overlay from 10651 to 10667 in test.form>) (10670 10675 #<overlay from 10670 to 10675 in test.form>) (12449 12521 #<overlay from 12449 to 12521 in test.form>) (12524 12591 #<overlay from 12524 to 12591 in test.form>) (12594 12645 #<overlay from 12594 to 12645 in test.form>) (13084 13294 #<overlay from 13084 to 13294 in test.form>) (15881 16193 #<overlay from 15881 to 16193 in test.form>) (17588 17623 #<overlay from 17588 to 17623 in test.form>) (23285 23436 #<overlay from 23285 to 23436 in test.form>) (23439 23515 #<overlay from 23439 to 23515 in test.form>) (23518 23547 #<overlay from 23518 to 23547 in test.form>) (23981 24126 #<overlay from 23981 to 24126 in test.form>) (25346 25556 #<overlay from 25346 to 25556 in test.form>) (26416 26646 #<overlay from 26416 to 26646 in test.form>) (26803 26883 #<overlay from 26803 to 26883 in test.form>) (26886 26901 #<overlay from 26886 to 26901 in test.form>) (26904 26980 #<overlay from 26904 to 26980 in test.form>) (26983 27026 #<overlay from 26983 to 27026 in test.form>) (27029 27098 #<overlay from 27029 to 27098 in test.form>) (27101 27122 #<overlay from 27101 to 27122 in test.form>) (31585 31635 #<overlay from 31585 to 31635 in test.form>)))
  #f(compiled-function (elt) #<bytecode 0x171f7ed>)((text-mode (225 273 #<overlay from 225 to 273 in test.form>) (276 311 #<overlay from 276 to 311 in test.form>) (314 343 #<overlay from 314 to 343 in test.form>) (346 388 #<overlay from 346 to 388 in test.form>) (391 404 #<overlay from 391 to 404 in test.form>) (2027 2210 #<overlay from 2027 to 2210 in test.form>) (2213 2224 #<overlay from 2213 to 2224 in test.form>) (9997 10031 #<overlay from 9997 to 10031 in test.form>) (10037 10041 #<overlay from 10037 to 10041 in test.form>) (10169 10323 #<overlay from 10169 to 10323 in test.form>) (10326 10331 #<overlay from 10326 to 10331 in test.form>) (10337 10341 #<overlay from 10337 to 10341 in test.form>) (10537 10648 #<overlay from 10537 to 10648 in test.form>) (10651 10667 #<overlay from 10651 to 10667 in test.form>) (10670 10675 #<overlay from 10670 to 10675 in test.form>) (12449 12521 #<overlay from 12449 to 12521 in test.form>) (12524 12591 #<overlay from 12524 to 12591 in test.form>) (12594 12645 #<overlay from 12594 to 12645 in test.form>) (13084 13294 #<overlay from 13084 to 13294 in test.form>) (15881 16193 #<overlay from 15881 to 16193 in test.form>) (17588 17623 #<overlay from 17588 to 17623 in test.form>) (23285 23436 #<overlay from 23285 to 23436 in test.form>) (23439 23515 #<overlay from 23439 to 23515 in test.form>) (23518 23547 #<overlay from 23518 to 23547 in test.form>) (23981 24126 #<overlay from 23981 to 24126 in test.form>) (25346 25556 #<overlay from 25346 to 25556 in test.form>) (26416 26646 #<overlay from 26416 to 26646 in test.form>) (26803 26883 #<overlay from 26803 to 26883 in test.form>) (26886 26901 #<overlay from 26886 to 26901 in test.form>) (26904 26980 #<overlay from 26904 to 26980 in test.form>) (26983 27026 #<overlay from 26983 to 27026 in test.form>) (27029 27098 #<overlay from 27029 to 27098 in test.form>) (27101 27122 #<overlay from 27101 to 27122 in test.form>) (31585 31635 #<overlay from 31585 to 31635 in test.form>)))
  mapc(#f(compiled-function (elt) #<bytecode 0x171f7ed>) ((css-mode (1844 1893 #<overlay from 1844 to 1893 in test.form>) (2518 2534 #<overlay from 2518 to 2534 in test.form>) (7350 7434 #<overlay from 7350 to 7434 in test.form>) (9659 9676 #<overlay from 9659 to 9676 in test.form>) (10373 10390 #<overlay from 10373 to 10390 in test.form>) (10733 10786 #<overlay from 10733 to 10786 in test.form>) (10933 10958 #<overlay from 10933 to 10958 in test.form>) (11110 11127 #<overlay from 11110 to 11127 in test.form>) (11496 11532 #<overlay from 11496 to 11532 in test.form>) (11701 11718 #<overlay from 11701 to 11718 in test.form>) (12021 12057 #<overlay from 12021 to 12057 in test.form>) (12680 12697 #<overlay from 12680 to 12697 in test.form>) (12923 12940 #<overlay from 12923 to 12940 in test.form>) (13516 13537 #<overlay from 13516 to 13537 in test.form>) (15077 15116 #<overlay from 15077 to 15116 in test.form>) (16980 16997 #<overlay from 16980 to 16997 in test.form>) (18074 18091 #<overlay from 18074 to 18091 in test.form>) (18538 18557 #<overlay from 18538 to 18557 in test.form>) (18781 18798 #<overlay from 18781 to 18798 in test.form>) (19275 19294 #<overlay from 19275 to 19294 in test.form>) (19500 19517 #<overlay from 19500 to 19517 in test.form>) (20494 20511 #<overlay from 20494 to 20511 in test.form>) (20919 20938 #<overlay from 20919 to 20938 in test.form>) (21165 21182 #<overlay from 21165 to 21182 in test.form>) (21586 21603 #<overlay from 21586 to 21603 in test.form>) (21893 21910 #<overlay from 21893 to 21910 in test.form>) (22164 22181 #<overlay from 22164 to 22181 in test.form>) (22446 22463 #<overlay from 22446 to 22463 in test.form>) (22878 22897 #<overlay from 22878 to 22897 in test.form>) (23141 23158 #<overlay from 23141 to 23158 in test.form>) (23843 23860 #<overlay from 23843 to 23860 in test.form>) (24277 24294 #<overlay from 24277 to 24294 in test.form>) (24904 24921 #<overlay from 24904 to 24921 in test.form>) (25192 25209 #<overlay from 25192 to 25209 in test.form>) (25580 25597 #<overlay from 25580 to 25597 in test.form>) (26271 26288 #<overlay from 26271 to 26288 in test.form>) (26685 26702 #<overlay from 26685 to 26702 in test.form>) (27320 27339 #<overlay from 27320 to 27339 in test.form>) (27700 27717 #<overlay from 27700 to 27717 in test.form>) (28007 28024 #<overlay from 28007 to 28024 in test.form>) (28563 28580 #<overlay from 28563 to 28580 in test.form>) (29437 29496 #<overlay from 29437 to 29496 in test.form>) (30093 30110 #<overlay from 30093 to 30110 in test.form>) (30541 30558 #<overlay from 30541 to 30558 in test.form>) (30917 30934 #<overlay from 30917 to 30934 in test.form>) (31690 31707 #<overlay from 31690 to 31707 in test.form>) (31776 31795 #<overlay from 31776 to 31795 in test.form>) (32208 32227 #<overlay from 32208 to 32227 in test.form>) (32487 32522 #<overlay from 32487 to 32522 in test.form>) ...) (text-mode (225 273 #<overlay from 225 to 273 in test.form>) (276 311 #<overlay from 276 to 311 in test.form>) (314 343 #<overlay from 314 to 343 in test.form>) (346 388 #<overlay from 346 to 388 in test.form>) (391 404 #<overlay from 391 to 404 in test.form>) (2027 2210 #<overlay from 2027 to 2210 in test.form>) (2213 2224 #<overlay from 2213 to 2224 in test.form>) (9997 10031 #<overlay from 9997 to 10031 in test.form>) (10037 10041 #<overlay from 10037 to 10041 in test.form>) (10169 10323 #<overlay from 10169 to 10323 in test.form>) (10326 10331 #<overlay from 10326 to 10331 in test.form>) (10337 10341 #<overlay from 10337 to 10341 in test.form>) (10537 10648 #<overlay from 10537 to 10648 in test.form>) (10651 10667 #<overlay from 10651 to 10667 in test.form>) (10670 10675 #<overlay from 10670 to 10675 in test.form>) (12449 12521 #<overlay from 12449 to 12521 in test.form>) (12524 12591 #<overlay from 12524 to 12591 in test.form>) (12594 12645 #<overlay from 12594 to 12645 in test.form>) (13084 13294 #<overlay from 13084 to 13294 in test.form>) (15881 16193 #<overlay from 15881 to 16193 in test.form>) (17588 17623 #<overlay from 17588 to 17623 in test.form>) (23285 23436 #<overlay from 23285 to 23436 in test.form>) (23439 23515 #<overlay from 23439 to 23515 in test.form>) (23518 23547 #<overlay from 23518 to 23547 in test.form>) (23981 24126 #<overlay from 23981 to 24126 in test.form>) (25346 25556 #<overlay from 25346 to 25556 in test.form>) (26416 26646 #<overlay from 26416 to 26646 in test.form>) (26803 26883 #<overlay from 26803 to 26883 in test.form>) (26886 26901 #<overlay from 26886 to 26901 in test.form>) (26904 26980 #<overlay from 26904 to 26980 in test.form>) (26983 27026 #<overlay from 26983 to 27026 in test.form>) (27029 27098 #<overlay from 27029 to 27098 in test.form>) (27101 27122 #<overlay from 27101 to 27122 in test.form>) (31585 31635 #<overlay from 31585 to 31635 in test.form>)) (perl-mode (49 61 #<overlay from 49 to 61 in test.form>) (155 167 #<overlay from 155 to 167 in test.form>) (484 496 #<overlay from 484 to 496 in test.form>) (1468 1480 #<overlay from 1468 to 1480 in test.form>) (1687 1699 #<overlay from 1687 to 1699 in test.form>) (1961 1973 #<overlay from 1961 to 1973 in test.form>) (2226 2227 #<overlay from 2226 to 2227 in test.form>) (2624 2636 #<overlay from 2624 to 2636 in test.form>) (2756 2768 #<overlay from 2756 to 2768 in test.form>) (2882 2894 #<overlay from 2882 to 2894 in test.form>) (3008 3020 #<overlay from 3008 to 3020 in test.form>) (3208 3261 #<overlay from 3208 to 3261 in test.form>) (3371 3429 #<overlay from 3371 to 3429 in test.form>) (3563 3622 #<overlay from 3563 to 3622 in test.form>) (3730 3787 #<overlay from 3730 to 3787 in test.form>) (3879 3891 #<overlay from 3879 to 3891 in test.form>) (4034 4073 #<overlay from 4034 to 4073 in test.form>) (4149 4161 #<overlay from 4149 to 4161 in test.form>) (4308 4407 #<overlay from 4308 to 4407 in test.form>) (4486 4498 #<overlay from 4486 to 4498 in test.form>) (4657 4695 #<overlay from 4657 to 4695 in test.form>) (4778 4790 #<overlay from 4778 to 4790 in test.form>) (4961 4999 #<overlay from 4961 to 4999 in test.form>) (5076 5088 #<overlay from 5076 to 5088 in test.form>) (5236 5288 #<overlay from 5236 to 5288 in test.form>) (5370 5382 #<overlay from 5370 to 5382 in test.form>) (5550 5584 #<overlay from 5550 to 5584 in test.form>) (5667 5679 #<overlay from 5667 to 5679 in test.form>) (5851 5910 #<overlay from 5851 to 5910 in test.form>) (5982 5994 #<overlay from 5982 to 5994 in test.form>) (6125 6180 #<overlay from 6125 to 6180 in test.form>) (6261 6273 #<overlay from 6261 to 6273 in test.form>) (6433 6493 #<overlay from 6433 to 6493 in test.form>) (6568 6580 #<overlay from 6568 to 6580 in test.form>) (6716 6774 #<overlay from 6716 to 6774 in test.form>) (6853 6865 #<overlay from 6853 to 6865 in test.form>) (7024 7066 #<overlay from 7024 to 7066 in test.form>) (7168 7180 #<overlay from 7168 to 7180 in test.form>) (7918 7930 #<overlay from 7918 to 7930 in test.form>) (8068 8080 #<overlay from 8068 to 8080 in test.form>) (8218 8230 #<overlay from 8218 to 8230 in test.form>) (8368 8380 #<overlay from 8368 to 8380 in test.form>) (8517 8529 #<overlay from 8517 to 8529 in test.form>) (8955 8977 #<overlay from 8955 to 8977 in test.form>) (9096 9114 #<overlay from 9096 to 9114 in test.form>) (9353 9365 #<overlay from 9353 to 9365 in test.form>) (9752 9764 #<overlay from 9752 to 9764 in test.form>) (10033 10034 #<overlay from 10033 to 10034 in test.form>) (10093 10105 #<overlay from 10093 to 10105 in test.form>) ...) (html-helper-mode (1 49 nil) (61 155 nil) (167 225 nil) (273 276 nil) (311 314 nil) (343 346 nil) (388 391 nil) (404 484 nil) (496 1468 nil) (1480 1687 nil) (1699 1844 nil) (1893 1961 nil) (1973 2027 nil) (2210 2213 nil) (2224 2226 nil) (2227 2518 nil) (2534 2624 nil) (2636 2756 nil) (2768 2882 nil) (2894 3008 nil) (3020 3208 nil) (3261 3371 nil) (3429 3563 nil) (3622 3730 nil) (3787 3879 nil) (3891 4034 nil) (4073 4149 nil) (4161 4308 nil) (4407 4486 nil) (4498 4657 nil) (4695 4778 nil) (4790 4961 nil) (4999 5076 nil) (5088 5236 nil) (5288 5370 nil) (5382 5550 nil) (5584 5667 nil) (5679 5851 nil) (5910 5982 nil) (5994 6125 nil) (6180 6261 nil) (6273 6433 nil) (6493 6568 nil) (6580 6716 nil) (6774 6853 nil) (6865 7024 nil) (7066 7168 nil) (7180 7350 nil) (7434 7918 nil) ...)))
  mmm-fontify-region(1 38543 nil)
  font-lock-fontify-region(1 38543)
  #f(compiled-function (fun) #<bytecode 0x13c0e91>)(font-lock-fontify-region)
  run-hook-wrapped(#f(compiled-function (fun) #<bytecode 0x13c0e91>) font-lock-fontify-region)
  jit-lock--run-functions(1 38543)
  jit-lock-fontify-now(1 38543)
  font-lock-ensure(1 38543)
  mmm-refontify-maybe(1 38543)
  mmm-apply-all()
  mmm-parse-buffer()
  funcall-interactively(mmm-parse-buffer)
  call-interactively(mmm-parse-buffer record nil)
  command-execute(mmm-parse-buffer record)
  execute-extended-command(nil "mmm-parse-buffer" nil)
  funcall-interactively(execute-extended-command nil "mmm-parse-buffer" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Any insights into this?

dgutov commented 4 years ago

Here's a patch you can try:

diff --git a/mmm-region.el b/mmm-region.el
index b518d59..ce7bbe7 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -514,6 +514,7 @@ is non-nil, don't quit if the info is already there."
               (funcall mode)
               (when (featurep 'font-lock)
                 (put mode 'mmm-font-lock-mode font-lock-mode)
+                (font-lock-set-defaults)
                 ;; These can't be in the local variables list, because we
                 ;; replace their actual values, but we want to use their
                 ;; original values elsewhere.

If it doesn't help, though, a step-by-step scenario is needed.

esabol commented 4 years ago

Yes, I think that has eliminated the problem! Thanks!

dgutov commented 4 years ago

Thanks for testing!