Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)

Bug #354363 reported by hobbes
2
Affects Status Importance Assigned to Milestone
nXhtml
Fix Released
High
Unassigned

Bug Description

Hello,

I start emacs22 in debian (sid) with the following :
emacs22 -Q -l nxhtml/autostart.el

(autostart patched to load nxml asap, see my previous bug report)

I open a very simple php file, attached to the report.

If I edit anything in the php, a backtrace pops up :

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  rng-after-change-function(18 18 1)
  delete-backward-char(1 nil)
  backward-delete-char-untabify(1)
  c-electric-backspace(nil)
  call-interactively(c-electric-backspace)

The exact output depends on where I edit, and what I do (add chars, delete chars, backspace,...)
Strange thing, if I go out of the php block before editing (example in my file, first going to EOF), there is no error anymore when I edit. So just adding a blank line to my php file is enough to not trigger the error.

HTH, don't hesitate to ask for more info if needed.

Revision history for this message
hobbes (hobbes-poukram) wrote :
Revision history for this message
hobbes (hobbes-poukram) wrote :

note :

- exact same problem with debian lenny, first going out of the php part also solves the problem
- similar problem using emacs-snapshot, except that first going out of the php block doesn't solve the problem

Revision history for this message
lborgman (lennart-borgman) wrote :

Hi hobbes,

Please try the 1.77 beta and see if the problem is gone. (See EmacsWiki.)

Changed in nxhtml:
importance: Undecided → High
status: New → In Progress
Revision history for this message
hobbes (hobbes-poukram) wrote :

Hi,

fixed in emacs22
not fixed in emacs-snapshot, and it still errors when out of the php block

Revision history for this message
lborgman (lennart-borgman) wrote :

Hi hobbes,

Could you please try doing the same thing in a new instance of Emacs which has just nXhtml loaded? Start it from inside Emacs with

   M-x emacs-Q-nxhtm

Revision history for this message
hobbes (hobbes-poukram) wrote :

Still there in emacs-snapshot
Anyway I always test with "emacs -Q -l nxhtml/autostart.el" so M-x emacs-Q-nxhtml shouldn't change anything

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

I can confirm this also. It still errors in emacs-snapshot. Just when I thought I finally could use nxhtml. This happens for me when I want to indent with <Tab> in a PHP chunk.

Revision history for this message
lborgman (lennart-borgman) wrote :

Ok, thanks. I will probably forget that you are doing that again ... ;-)

I wonder if it perhaps could be an old version of nxml-mode that is involved. Could you please see if you are using the nxml-mode that is included with Emacs?

To do that you can do for example

  F1 f nxml-mode

and then click on the link in the help buffer that opens the file where nxml-mode was defined.

Hm, but if Debian have done something strange that might not work as I expect it to do. Then you have to look at load-history

   F1 v load-history

Search for the string "nxml-mode.el" there. Or maybe for "rng-valid.el" since that is where the function rng-after-change-function is declared.

Revision history for this message
lborgman (lennart-borgman) wrote :

Dennis, could you perhaps show me a small php file where this happens? Are you using nxhtml-mumamo-mode in the buffer?

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

Ofcourse. The modeline says I am using PHP/nxhtml/Abbrev major/minor modes. See attachment. I doesn't want to indent at all anymore.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks Dennis,

I wonder if it could be that another php-mode than the one that comes with nXhtml is used. Can you check which php-mode is used? Do

   F1 f php-mode

and follow the link there. But see also the answer I gave above to hobbes about load-history.

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

It says the following:
php-mode is an interactive Lisp function in `php-mode.el'. I also tried the same thing hobbes does, still no effect. Do you have any idea what is causing all these problems? It must drive you insane. It has something to do how Debian packages emacs. :-)

Revision history for this message
lborgman (lennart-borgman) wrote :

No, they are not driving me insane. I am already insane ;-)

Could you please click on on the link `php-mode.el' and see where the file is located? Could you also check load-history?

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

It goes to line 406:

;;;###autoload
(define-derived-mode php-mode c-mode "PHP"
  "Major mode for editing PHP code.\n\n\\{php-mode-map}"
  (c-add-language 'php-mode 'c-mode)

The file is located in the nxhtml related directory.

Loading 00debian-vars...
No /etc/mailname. Reverting to default...
Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Skipping dictionaries-common setup for emacs-snapshot
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...done
Loading /etc/emacs/site-start.d/50git-core.el (source)...done
Loading /etc/emacs/site-start.d/50haskell-mode.el (source)...done
Loading /etc/emacs/site-start.d/50icicles.el (source)...done
Loading /etc/emacs/site-start.d/50psvn.el (source)...done
Loading /etc/emacs-snapshot/site-start.d/60nxml-mode.el (source)...
Loading /usr/share/emacs-snapshot/site-lisp/nxml-mode/rng-auto.el (source)...done
Loading /etc/emacs-snapshot/site-start.d/60nxml-mode.el (source)...done
Loading /home/dennis/src/nxhtml/autostart.el (source)...
Nxml/Nxhtml Autostart.el loading ...
Loading /home/dennis/src/nxhtml/nxhtml-loaddefs.el (source)...done
html-site-current (information): No current site set
ad-handle-definition: `syntax-ppss-flush-cache' got redefined
Loading `mumamo': old-style backquotes detected!
Loading /home/dennis/src/nxhtml/etc/schema/schema-path-patch.el (source)...done
xhtml-loader.rnc was ok
(No changes need to be saved)
Loading /home/dennis/src/nxhtml/nxhtml/nxhtml-autoload.el (source)...
nxhtml-autoload starting ... (hm, should maybe be renamed ...)
majmodpri-sort-lists running ...
nxhtml-autoload finished
Loading /home/dennis/src/nxhtml/nxhtml/nxhtml-autoload.el (source)...done
=== Loaded at nxhtml/autostart.el end:
(feature 'html-imenu)=t
(feature 'html-quote)=t
(feature 'html-site)=t
(feature 'html-upl)=t
(feature 'mumamo)=t
(feature 'nxhtml-menu)=t
(feature 'nxhtml-mode)=t
(feature 'rngalt)=t
(feature 'tidy-xhtml)=t
Loading /home/dennis/src/nxhtml/autostart.el (source)...done
Loading /home/dennis/scripts/xml-rpc.el (source)...done
Loading /home/dennis/scripts/trac-wiki.el (source)...done

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

Forgot to attach load-history. Here it is.

Revision history for this message
lborgman (lennart-borgman) wrote :

Ok, thanks. So the php-mode is the one that comes with nXhtml, good.

But the loading of nxml-mode looks strange. It looks like it is loaded from the site-lisp directory, but is not the snap-shot you are using there for Emacs 23? Then there should be no nxml-mode in site-lisp, because it is included in Emacs 23.

Could you try to rename or remove those files from site-lisp?

I will ask Romain Francoise about why Debian has put nxml-mode there now.

Revision history for this message
lborgman (lennart-borgman) wrote :

I just uploaded a new version of the 1.77 beta where I have made a test if the correct nxml-mode libraries are used.

Revision history for this message
Romain Francoise (rfrancoise) wrote :

The `/usr/share/emacs-snapshot/site-lisp/nxml-mode' directory comes from the nxml-mode package (http://packages.ubuntu.com/nxml-mode), not from emacs-snapshot. This is how add-on Emacs packages work on Debian, see the Debian Emacs policy for more info.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks Romain.

The old nxml-mode package does not work in Emacs 23, but it looks like it is loaded in the snap-shot. Can the old nxml-mode be removed from the snap-shot, please?

Revision history for this message
lborgman (lennart-borgman) wrote :

Romain has told me that there is already a bug report for this in Ubuntu/Debian:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=479040

Now we just need to figure out how to get it fixed. Anyone knows who should be contacted?

Revision history for this message
hobbes (hobbes-poukram) wrote :

I hate losing my http session after crafting a long post, so here it comes (again) in several separate comments. I hope that I don't forget anything because I tried several things...

First of all, I don't know what happened when I told that the 1.77 beta solved the problem in emacs22. I can't seem to be able to reproduce this with the latest beta or any earlier tried beta. So emacs22 is still plagued with this bug.

Revision history for this message
hobbes (hobbes-poukram) wrote :

Regarding nxml-mode in debian, I think that there is a misunderstanding.

There is indeed an individual debian package for nxml-mode. It has to be used with the emacs22 debian package since emacs22 doesn't provide nxml-mode.

The emacs-snapshot debian package does include its own version of nxml-mode, and the nxml-mode individual package doesn't handle coexistence gracefully. So people using emacs-snapshot should remove the individual nxml-mode package.

Revision history for this message
hobbes (hobbes-poukram) wrote :

Armed with the above knowledge, I made some new tests.

The good news : now I have coherent behaviour between emacs22 + the individual nxml-mode debian package on one side, and emacs-snapshot with its included nxml-mode on the other side.

The bad news : while behaving the same, both combinations still display the bug : directly editing something in the php code brings the backtrace, and first going out of the php code solves the problem.

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

Romain Francoise just committed new emacs-snapshot packages to the Debian servers and it seems to fix all my problems. I did remove the nxml-mode Debian package though. It looks awesome, especially with crisp XFT fonts and the beautifull colors of my emacs color theme. Thanks Lennart en Romain! I am still using 1.77.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks Dennis (and Romain of course!!).

hobbes, can you please do as Dennis and see if your myserious problem is still there with the Emacs 23 snap-shot from today?

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

Oops. I was just trying the same index.php I provided earlier and I was dropped into the debugger with the same error. (just trying to indent) Don't shoot me....

Revision history for this message
Dennis de Vaal (d-devaal) wrote :
Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks. I finally understand why I have not got this error... - now.

I have patched rng-after-change-function and forgot about it because of lack of time when I found this problem. The patch is needed when you are using nXml together with MuMaMo. It is very simple. Just add as the first line in the function

  (when rng-validate-up-to-date-end

and a corresponding closing ) at the end of the function.

Revision history for this message
lborgman (lennart-borgman) wrote :

I have made a patch for this and hope it can get into Emacs 23 even though it is said that only regressions compared to Emacs 22 should be fixed now. Since this patch only does some error checking it should be safe enough.

I have attached the patch here and I have sent it to Emacs Devel.

Revision history for this message
hobbes (hobbes-poukram) wrote :

thanks a lot for that patch, I'll try to use it, but it's a bit over my abilities :-)

Revision history for this message
lborgman (lennart-borgman) wrote :

Hi hobbes,

It is enough to edit rng-valid.el as I told above. The other parts of the patch is for errors that happens more seldom (at least I believe so).

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

The one that comes with emacs-snapshot is bytecompiled. I would edit these?

Revision history for this message
lborgman (lennart-borgman) wrote :

Hi Dennis,

You should edit rng-valid.el and then byte compile it. There is an entry in the Emacs menu under Emacs-Lisp for byte compiling.

Revision history for this message
hobbes (hobbes-poukram) wrote :

Hi,

there is the package emacs-snapshot-el which contains the uncompiled compressed source files.

gunzip rng-valid.el.gz, edit it as told, byte-compile it, and *It Works* !!!

Yay, thanks

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

That is what I wanted to know Hobbes, Thanks. :-)

Revision history for this message
lborgman (lennart-borgman) wrote :

The bug fix is commited to Emacs Devel ...

Changed in nxhtml:
status: In Progress → Fix Committed
Revision history for this message
lborgman (lennart-borgman) wrote :

hobbes, Great! Does that mean that the problem in https://bugs.launchpad.net/nxhtml/+bug/369800 also is solved for you?

Revision history for this message
hobbes (hobbes-poukram) wrote :

unfortunately not, I just updated that bug report

Revision history for this message
Dennis de Vaal (d-devaal) wrote :

I have modified the file and byte compiled it. The problem seems to be solved for me. But I will need to test it more thoroughly just to be sure.

Revision history for this message
lborgman (lennart-borgman) wrote :

I think this problem should be solved in the latest beta 1.77 (or actually earlier). If someone still have this problem then please try the latest beta and report details about it here.

Changed in nxhtml:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.