davidmiller / pony-mode

Django mode for emacs
Other
149 stars 32 forks source link

Template indentation (sgml-lexical-context: Wrong type argument: stringp, nil) #101

Open kriku opened 6 years ago

kriku commented 6 years ago

Hello!

So I use emacs 0.300.0@25.3.1 (spacemacs).

I add django to configuration layers.

Then I try to pony-indent in django template (firstly turn on pony-tpl-mode and pony-tpl-minor-mode). And it work for this template fine:

{% extends "geonode_base.html" %}
{% load i18n %}
{% load url from future %}

{% block title %} {{ block.super }} {% endblock %}

{% block body_class %}people{% endblock %}

{% block body_outer %}
  {% block body %}{% endblock body %}
  {% block sidebar %}{% endblock sidebar %}

{% endblock body_outer %}

But for any other template with html markup, for example:

{% extends "geonode_base.html" %}
{% load i18n %}

{% block body_outer %}
  <div class="page-header">
  <h2>{% trans "Forgot Username" %}</h2>
</div>
<div class="row">
  <div class="col-md-8">
    <p class="lead">{% trans "Enter your email address and click the submit button. <br />Your username will be sent to you." %}</p>
    <form method="post" action="">
      {% csrf_token %}
      {{ form.as_p }}
      <div class="form-actions">
        <input class="btn btn-primary" type="submit" value="{% trans 'Submit' %}" />
      </div>
    </form>
    {% if message %}
    <div class="alert alert-danger grid-spacer">{{ message }}</div>
    {% endif %}
  </div>
</div>
{% endblock %}

it fails with:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil)
  sgml-lexical-context()
  sgml-calculate-indent()
  (save-excursion (back-to-indentation) (if (>= (point) savep) (setq savep nil)) (sgml-calculate-indent))
  (let* ((savep (point)) (indent-col (save-excursion (back-to-indentation) (if (>= (point) savep) (setq savep nil)) (sgml-calculate-indent)))) (if (null indent-col) 0 (if savep (save-excursion indent-col) indent-col)))
  sgml-indent-line-num()
  (let ((indent-width sgml-basic-offset) (default (sgml-indent-line-num))) (if (looking-at "^[  ]*{%-? *\\(e\\(nd\\|lse\\|lif\\|mpty\\)\\|plural\\)") (progn (forward-line -1) (if (and (looking-at (concat "^[     ]*{%-? *" pony-indenting-tags-regexp "\\>")) (not (looking-at (concat "^[   ]*{%-? *.*?{% *end" pony-indenting-tags-regexp "\\>")))) (current-indentation) (- (current-indentation) indent-width))) (if (looking-at "^[     ]*</") default (pony-calculate-indent-backward default))))
  (if (bobp) 0 (let ((indent-width sgml-basic-offset) (default (sgml-indent-line-num))) (if (looking-at "^[     ]*{%-? *\\(e\\(nd\\|lse\\|lif\\|mpty\\)\\|plural\\)") (progn (forward-line -1) (if (and (looking-at (concat "^[     ]*{%-? *" pony-indenting-tags-regexp "\\>")) (not (looking-at ...))) (current-indentation) (- (current-indentation) indent-width))) (if (looking-at "^[     ]*</") default (pony-calculate-indent-backward default)))))
  (save-excursion (beginning-of-line) (if (bobp) 0 (let ((indent-width sgml-basic-offset) (default (sgml-indent-line-num))) (if (looking-at "^[     ]*{%-? *\\(e\\(nd\\|lse\\|lif\\|mpty\\)\\|plural\\)") (progn (forward-line -1) (if (and (looking-at ...) (not ...)) (current-indentation) (- (current-indentation) indent-width))) (if (looking-at "^[  ]*</") default (pony-calculate-indent-backward default))))))
  pony-calculate-indent()
  (let ((pos (- (point-max) (point))) (indent (pony-calculate-indent))) (if (< indent 0) (setq indent 0)) (indent-line-to indent) (let ((moved-pos (- (point-max) pos))) (if (> moved-pos (point)) (goto-char moved-pos))))
  pony-indent()
  funcall-interactively(pony-indent)
  call-interactively(pony-indent record nil)
  command-execute(pony-indent record)
  #[257 "\304\305!\203\f\306\307!!\210\307!\211\310\307!\311\")\207" [current-prefix-arg prefix-arg this-command real-this-command featurep smex smex-rank intern command-execute record] 4 "\n\n(fn CMD)"]("pony-indent")
  ivy-call()
  ivy-read("M-x " ("toggle-debug-on-error" "pony-tpl-minor-mode" "pony-tpl-mode" "pony-minor-mode" "shell-script-mode" "pony-tags" "pony-mode-disable" "shell-mode" "react-mode" "gitter" "gitter-minor-mode" "markdown-mode" "fundamental-mode" "describe-variable" "cd" "5x5" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "pdb" "pwd" "rsh" "pony-mode" "sdb" "xdb" "calc" "diff" "dirs" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "ping" "pong" "smex" "talk" ...) :predicate nil :require-match t :history counsel-M-x-history :action #[257 "\304\305!\203\f\306\307!!\210\307!\211\310\307!\311\")\207" [current-prefix-arg prefix-arg this-command real-this-command featurep smex smex-rank intern command-execute record] 4 "\n\n(fn CMD)"] :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)
kriku commented 6 years ago

So in configuration layers I also have javascript and react layers... After removing them (actually react layer only) this issue doesn't repeat.

Is this way around it?