davidmiller / pony-mode

Django mode for emacs
Other
149 stars 32 forks source link

{% comment %} tag freezes emacs #15

Closed oleiade closed 12 years ago

oleiade commented 12 years ago

After many tries, I think I've identified that using {% comment %} template tag with pony-mode freezes emacs. Any one can reproduce?

davidmiller commented 12 years ago

Any one can reproduce?

Not here, but it's not inconceivable that the font-lock regexes are inefficient, especially with large files.

Can you post the output of C-h v pony-tpl-font-lock-keywords ?

A link to a Gist/Pastebin of the tpl file wouldn't hurt either

Love regards etc

David Miller http://www.deadpansincerity.com 07854 880 883

oleiade commented 12 years ago

There's the pony-tpl-font-lock-keywords variable description:

pony-tpl-font-lock-keywords is a variable defined in `pony-tpl.el'.
Its value is shown below.

  This variable is potentially risky when used as a file local variable.

Documentation:
Highlighting for pony-tpl-mode

Value: (("<\\([!?][_:[:alpha:]][-_.:[:alnum:]]*\\)" 1 font-lock-keyword-face)
 ("</?\\([_[:alpha:]][-_.[:alnum:]]*\\)\\(?::\\([_:[:alpha:]][-_.:[:alnum:]]*\\)\\)?"
  (1
   (if
       (match-end 2)
       sgml-namespace-face font-lock-function-name-face))
  (2 font-lock-function-name-face nil t))
 ("\\(?:^\\|[   ]\\)\\([_[:alpha:]][-_.[:alnum:]]*\\)\\(?::\\([_:[:alpha:]][-_.:[:alnum:]]*\\)\\)?=[\"']"
  (1
   (if
       (match-end 2)
       sgml-namespace-face font-lock-variable-name-face))
  (2 font-lock-variable-name-face nil t))
 ("[&%][_:[:alpha:]][-_.:[:alnum:]]*;?" . font-lock-variable-name-face)
 ("{%.*\\(\\bor\\b\\).*%}" 1 font-lock-builtin-face)
 ("{% ?comment ?%}\\(\n?.*?\\)+?{% ?endcomment ?%}" . font-lock-comment-face)
 ("{% ?\\(\\(end\\)?\\(extends\\|for\\|cache\\|cycle\\|filter\\|firstof\\|debug\\|if\\(changed\\|equal\\|notequal\\|\\)\\|include\\|load\\|now\\|regroup\\|spaceless\\|ssi\\|templatetag\\|widthratio\\|block\\|trans\\)\\) ?.*? ?%}" . 1)
 ("{{ ?\\(.*?\\) ?}}" 1 font-lock-variable-name-face)
 ("{%\\|\\%}\\|{{\\|}}" . font-lock-builtin-face))

And I actually don't really have the right to post out any code from the application I'm working on (in production, very, very large application).

Thanks for you help! :-)

davidmiller commented 12 years ago

And I actually don't really have the right to post out any code from the application I'm working on (in production, very, very large application).

Shure - Not a problem :)

I've tried editing http://www.gnu.org/software/emacs/manual/html_mono/emacs.html (3.3M html file) in pony-tpl mode and including the comment tag, seems fine.

Have you tried emacs in "Clean" mode - e.g.

$ emacs -q -Q M-S-: add-to-list 'load-path "path/to/pony-mode" M-S-: require 'pony-mode

Then see if you're still freezing

That'll at least establish that the problem is definitely caused by pony-mode...

Love regards etc

David Miller http://www.deadpansincerity.com 07854 880 883

oleiade commented 12 years ago

Unfortunately : still freezing... :-)

davidmiller commented 12 years ago

Unfortunately : still freezing... :-)

Hmm... so now the problem is one of reproducibility here. The problematic line is almost certainly pony-tpl.el 50 https://github.com/davidmiller/pony-mode/blob/master/pony-tpl.el#L50

This should in fact almost certainly be done with a syntax table entry rather than a font-lock keyword regex, I'll try that & then we can see if that helps

Love regards etc

David Miller http://www.deadpansincerity.com 07854 880 883

oleiade commented 12 years ago

I'm not feeling very confortable with elisp syntax (actually i'm a haskell addict) so I'm relying on you ^^ Tell me what I can test on my own configuration, I'll tell you if it works.

Love regards and so on

Theo Crevon http://diasporamas.com tcrevon@gmail.com

davidmiller commented 12 years ago

Turns out that Emacs support for comment delimiters that are more than two characters is pretty slim.

I may well turn {% comment %} into another keyword and not syntax highlight everything in-between as a per-tem measure while I research into complex comment delimiters.

davidmiller commented 12 years ago

Closing as the "Freeze" issue is no longer relevant.