emacs-php / php-mode

A powerful and flexible Emacs major mode for editing PHP scripts
GNU General Public License v3.0
583 stars 118 forks source link

Repeated "parse-sexp-propertize-function did not move syntax-propertize--done" with emacs built from git master #570

Open hexmode opened 5 years ago

hexmode commented 5 years ago

Recently, editing PHP files in emacs has become rather frustrating. It seems that at any point I could end up with an backtrace like the following one I got when I tried to close the parens:

Debugger entered--Lisp error: (error "parse-sexp-propertize-function did not move syntax-propertize--done")
  re-search-backward("<<<\\(?:\\_<.+?\\_>\\|'\\_<.+?\\_>'\\|\"\\_<.+?\\_>\"\\)$" nil t)
  (if (re-search-backward php-heredoc-start-re nil t) (progn (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t) (if (> (point) end) (progn (setq new-end (point)))) (setq new-end (point-max)))))
  (let ((new-start) (new-end)) (goto-char start) (if (re-search-backward php-heredoc-start-re nil t) (progn (let ((maybe (point))) (if (and (re-search-forward (php-heredoc-end-re ...) nil t) (> (point) start)) (progn (setq new-start maybe)))))) (goto-char end) (if (re-search-backward php-heredoc-start-re nil t) (progn (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t) (if (> (point) end) (progn (setq new-end (point)))) (setq new-end (point-max))))) (if (or new-start new-end) (progn (cons (or new-start start) (or new-end end)))))
  php-syntax-propertize-extend-region(41007 41507)
  syntax-propertize(41008)
  indent-according-to-mode()
  c-electric-paren(nil)
  funcall-interactively(c-electric-paren nil)
  call-interactively(c-electric-paren nil nil)
  command-execute(c-electric-paren)

I don't know what other info you need, but here are the results of php-mode-debug:

--- PHP-MODE DEBUG BEGIN ---
versions: GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2019-09-08; PHP Mode 1.21.4 of 2019-05-29
package-version: nil
major-mode: php-mode
minor-modes: (projectile-mode flycheck-mode editorconfig-mode buffer-face-mode direnv-mode flx-ido-mode yahoo-weather-mode magit-file-mode magit-wip-after-save-mode magit-wip-after-save-local-mode magit-auto-revert-mode auto-revert-mode async-bytecomp-package-mode shell-dirtrack-mode display-time-mode ido-everywhere emojify-mode auto-compile-on-load-mode auto-compile-on-save-mode tooltip-mode electric-indent-mode mouse-wheel-mode prettify-symbols-mode file-name-shadow-mode font-lock-mode auto-composition-mode auto-encryption-mode auto-compression-mode column-number-mode line-number-mode transient-mark-mode abbrev-mode)
variables: ((indent-tabs-mode t) (tab-width 4))
custom variables: ((php-extras-insert-previous-variable-key [(control c) (control $)]) (php-extras-auto-complete-insert-parenthesis t) (php-executable /usr/bin/php) (php-site-url https://php.net/) (php-manual-url en) (php-search-url nil) (php-class-suffix-when-insert ::) (php-namespace-suffix-when-insert \) (php-default-major-mode php-mode) (php-html-template-major-mode web-mode) (php-blade-template-major-mode web-mode) (php-template-mode-alist ((\.blade . web-mode) (\.phpt\' . web-mode) (\.phtml\' . web-mode))) (php-mode-maybe-hook nil) (php-search-documentation-browser-function nil))
c-indentation-style: pear
c-style-variables: ((c-basic-offset 4) (c-comment-only-line-offset 0) (c-indent-comment-alist ((anchored-comment column . 0) (end-block space . 1) (cpp-end-block space . 2))) (c-indent-comments-syntactically-p nil) (c-block-comment-prefix * ) (c-comment-prefix-regexp ((pike-mode . //+!?\|\**) (awk-mode . #+) (other . //+\|\**))) (c-cleanup-list (scope-operator)) (c-hanging-braces-alist ((brace-list-open) (brace-entry-open) (statement-cont) (substatement-open after) (block-close . c-snug-do-while) (extern-lang-open after) (namespace-open after) (module-open after) (composition-open after) (inexpr-class-open after) (inexpr-class-close before) (arglist-cont-nonempty))) (c-hanging-colons-alist nil) (c-hanging-semi&comma-criteria (c-semi&comma-inside-parenlist)) (c-backslash-column 48) (c-backslash-max-column 72) (c-special-indent-hook nil) (c-label-minimum-indentation 1))
c-doc-comment-style: ((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc) (c++-mode . gtkdoc))
c-offsets-alist: ((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . 0) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont first php-lineup-cascaded-calls 0) (comment-intro . 0) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (access-label . -) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-close . 0) (block-close . 0) (block-open . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (func-decl-cont . +) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (topmost-intro-cont first php-lineup-cascaded-calls +) (brace-list-intro . +) (brace-list-open . 0) (inline-open . 0) (arglist-intro . php-lineup-arglist-intro) (statement-cont first php-lineup-cascaded-calls php-lineup-string-cont +) (statement-case-open . 0) (label . +) (substatement-label . 2) (substatement-open . 0) (knr-argdecl-intro . +) (statement-block-intro . +) (case-label . 0) (arglist-cont-nonempty first php-lineup-cascaded-calls c-lineup-arglist) (arglist-close . php-lineup-arglist-close))
--- PHP-MODE DEBUG END ---
hexmode commented 5 years ago

emacs26 seems ok.

mallt commented 5 years ago

Could you try to delete and reinstall (or recompile) the php-mode package in emacs 27.0.50 to see if this fixes this problem?

hexmode commented 5 years ago

It did disappear once I removed the elc file. Then it showed up again, but, today, it looks like it is gone.

hexmode commented 5 years ago

Note the problem may be related to flycheck and any of the -php, -phpcs, -phpmd, or my -psalm checkers.

Because yesterday was evidently my "play with emacs" day, I managed to get eglot (which uses flymake) working and ditched flycheck.

hexmode commented 5 years ago

doh.... I spoke to soon. Just after I typed that comment I went to try to edit the file again and ran into the error while trying to save.

backtrace:

Debugger entered--Lisp error: (error "parse-sexp-propertize-function did not move syntax...")
  re-search-forward("\\s-$" nil t)
  delete-trailing-whitespace()
  run-hook-with-args-until-success(delete-trailing-whitespace)
  basic-save-buffer(t)
  save-buffer(1)
  funcall-interactively(save-buffer 1)
  call-interactively(save-buffer nil nil)
  command-execute(save-buffer)
hexmode commented 5 years ago

And, because I have changed my config here are the results of php-mode-debug:

--- PHP-MODE DEBUG BEGIN ---
versions: GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2019-09-11; PHP Mode 1.21.4 of 2019-05-29
package-version: 1.21.4
major-mode: php-mode
minor-modes: (projectile-mode buffer-face-mode editorconfig-mode direnv-mode flx-ido-mode yahoo-weather-mode display-time-mode eglot--managed-mode flymake-mode magit-file-mode magit-wip-after-save-mode magit-wip-after-save-local-mode magit-auto-revert-mode auto-revert-mode shell-dirtrack-mode server-mode async-bytecomp-package-mode ido-everywhere emojify-mode auto-compile-on-load-mode auto-compile-on-save-mode tooltip-mode eldoc-mode electric-indent-mode mouse-wheel-mode prettify-symbols-mode file-name-shadow-mode font-lock-mode auto-composition-mode auto-encryption-mode auto-compression-mode column-number-mode line-number-mode transient-mark-mode abbrev-mode)
variables: ((indent-tabs-mode t) (tab-width 4))
custom variables: ((php-extras-insert-previous-variable-key [(control c) (control $)]) (php-extras-auto-complete-insert-parenthesis t) (php-executable /usr/bin/php) (php-site-url https://php.net/) (php-manual-url en) (php-search-url nil) (php-class-suffix-when-insert ::) (php-namespace-suffix-when-insert \) (php-default-major-mode php-mode) (php-html-template-major-mode web-mode) (php-blade-template-major-mode web-mode) (php-template-mode-alist ((\.blade . web-mode) (\.phpt\' . web-mode) (\.phtml\' . web-mode))) (php-mode-maybe-hook nil) (php-search-documentation-browser-function nil))
c-indentation-style: pear
c-style-variables: ((c-basic-offset 4) (c-comment-only-line-offset 0) (c-indent-comment-alist ((anchored-comment column . 0) (end-block space . 1) (cpp-end-block space . 2))) (c-indent-comments-syntactically-p nil) (c-block-comment-prefix * ) (c-comment-prefix-regexp ((pike-mode . //+!?\|\**) (awk-mode . #+) (other . //+\|\**))) (c-cleanup-list (scope-operator)) (c-hanging-braces-alist ((brace-list-open) (brace-entry-open) (statement-cont) (substatement-open after) (block-close . c-snug-do-while) (extern-lang-open after) (namespace-open after) (module-open after) (composition-open after) (inexpr-class-open after) (inexpr-class-close before) (arglist-cont-nonempty))) (c-hanging-colons-alist nil) (c-hanging-semi&comma-criteria (c-semi&comma-inside-parenlist)) (c-backslash-column 48) (c-backslash-max-column 72) (c-special-indent-hook nil) (c-label-minimum-indentation 1))
c-doc-comment-style: ((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc) (c++-mode . gtkdoc))
c-offsets-alist: ((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . 0) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont first php-lineup-cascaded-calls 0) (comment-intro . 0) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (access-label . -) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-close . 0) (block-close . 0) (block-open . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (func-decl-cont . +) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (topmost-intro-cont first php-lineup-cascaded-calls +) (brace-list-intro . +) (brace-list-open . 0) (inline-open . 0) (arglist-intro . php-lineup-arglist-intro) (statement-cont first php-lineup-cascaded-calls php-lineup-string-cont +) (statement-case-open . 0) (label . +) (substatement-label . 2) (substatement-open . 0) (knr-argdecl-intro . +) (statement-block-intro . +) (case-label . 0) (arglist-cont-nonempty first php-lineup-cascaded-calls c-lineup-arglist) (arglist-close . php-lineup-arglist-close))
--- PHP-MODE DEBUG END ---
hexmode commented 5 years ago

And, if it makes any difference, I just ran M-x php-mode RET and, immediately after, I could save.

However, once eglot highlighted problems that it found with the psalm-language-server, the error returned.

hexmode commented 5 years ago

disabling some minor modes makes saving work again. php-mode-debug is the same as above with the following minor modes removed: magit-wip-after-safe-mode magit-wip-after-save-local-mode emojify-mode prettify-symbols-mode.

hexmode commented 5 years ago

Eh... This seems intermittent. In any case, I just ran into this again and saw that fontification stops on line 344. Don't know if that means anything. I suppose it could be the results of multiple invocations of php-mode.