unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 23.0.60; M-x compile gives args out of range 0, 0
@ 2008-04-08 10:52 Jan Djärv
  2008-04-08 15:03 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Djärv @ 2008-04-08 10:52 UTC (permalink / raw)
  To: emacs-pretest-bug


Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the emacs-pretest-bug@gnu.org mailing list.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

When doing M-x compile I get:
font-lock-extend-region-multiline: Args out of range: 0, 0

It seems to be random, sometimes I can compile in other directories, sometimes
not.  But args out of range comes about 3 times out of 4.  It seems to always
come in the emacs/src directory.

Debug-on-error t gives:

Debugger entered--Lisp error: (args-out-of-range 0 0)
   get-text-property(0 font-lock-multiline)
   font-lock-extend-region-multiline()
   font-lock-default-fontify-region(0 0 nil)
   font-lock-fontify-region(0 0)
   font-lock-after-change-function(1 11 0)
   compilation-start("make -k " nil)
   compile("make -k " nil)
   call-interactively(compile t nil)
   execute-extended-command(nil)
   call-interactively(execute-extended-command nil nil)


	Jan D.


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
     `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/opt/src/emacs-cvs/etc/DEBUG for instructions.


In GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version 2.12.5)
  of 2008-04-08 on dentan.operax.com
Windowing system distributor `The X.Org Foundation', version 11.0.10300000
configured using `configure  '--prefix=/opt/emacs' '--verbose' 
'--enable-asserts' '--enable-font-backend' '--with-x-toolkit=gtk' 'CFLAGS=-g''

Important settings:
   value of $LC_ALL: nil
   value of $LC_COLLATE: C
   value of $LC_CTYPE: nil
   value of $LC_MESSAGES: nil
   value of $LC_MONETARY: nil
   value of $LC_NUMERIC: nil
   value of $LC_TIME: nil
   value of $LANG: sv_SE.UTF-8
   value of $XMODIFIERS: @im=none
   locale-coding-system: utf-8-unix
   default-enable-multibyte-characters: t

Major mode: C/l

Minor modes in effect:
   tooltip-mode: t
   tool-bar-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   global-auto-composition-mode: t
   auto-composition-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t
   abbrev-mode: t

Recent input:
<help-echo> M-x c o m p i l e <return> <return> <help-echo>
C-x C-f s r c <tab> g t <tab> c <return> M-x M-p <return>
<return> <help-echo> <help-echo> M-x r e p o <tab>
r <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
(No files need saving)
Compilation finished
Loading vc-cvs...done
(No files need saving)
font-lock-extend-region-multiline: Args out of range: 0, 0
Making completion list...




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 10:52 23.0.60; M-x compile gives args out of range 0, 0 Jan Djärv
@ 2008-04-08 15:03 ` Stefan Monnier
  2008-04-08 16:32   ` Jan Djärv
  2008-04-08 17:22   ` Alan Mackenzie
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2008-04-08 15:03 UTC (permalink / raw)
  To: Jan Dj\x1fFFFFFFFFFFFFFFrv; +Cc: emacs-pretest-bug

> When doing M-x compile I get:
> font-lock-extend-region-multiline: Args out of range: 0, 0

Does the patch below make it disappear, by any chance?


        Stefan


=== modified file 'lisp/progmodes/cc-mode.el'
--- lisp/progmodes/cc-mode.el	2008-04-07 16:37:22 +0000
+++ lisp/progmodes/cc-mode.el	2008-04-08 15:01:47 +0000
@@ -601,7 +601,7 @@
   (add-hook 'before-change-functions 'c-before-change nil t)
   (make-local-hook 'after-change-functions)
   (add-hook 'after-change-functions 'c-after-change nil t)
-  (setq font-lock-extend-after-change-region-function
+  (set (make-local-variable 'font-lock-extend-after-change-region-function)
  	'c-extend-after-change-region))	; Currently (2008-04), only used by AWK.
 
 (defun c-setup-doc-comment-style ()





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 15:03 ` Stefan Monnier
@ 2008-04-08 16:32   ` Jan Djärv
  2008-04-08 17:22   ` Alan Mackenzie
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Djärv @ 2008-04-08 16:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-pretest-bug



Stefan Monnier skrev:
>> When doing M-x compile I get:
>> font-lock-extend-region-multiline: Args out of range: 0, 0
> 
> Does the patch below make it disappear, by any chance?
> 
> 

Aha, it is cc-mode.  No wonder it looked random, I don't always load a c-file
before M-x compile.

The patch does indeed fix the problem.

	Jan D.

>         Stefan
> 
> 
> === modified file 'lisp/progmodes/cc-mode.el'
> --- lisp/progmodes/cc-mode.el	2008-04-07 16:37:22 +0000
> +++ lisp/progmodes/cc-mode.el	2008-04-08 15:01:47 +0000
> @@ -601,7 +601,7 @@
>    (add-hook 'before-change-functions 'c-before-change nil t)
>    (make-local-hook 'after-change-functions)
>    (add-hook 'after-change-functions 'c-after-change nil t)
> -  (setq font-lock-extend-after-change-region-function
> +  (set (make-local-variable 'font-lock-extend-after-change-region-function)
>   	'c-extend-after-change-region))	; Currently (2008-04), only used by AWK.
>  
>  (defun c-setup-doc-comment-style ()
> 
> 
> 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 15:03 ` Stefan Monnier
  2008-04-08 16:32   ` Jan Djärv
@ 2008-04-08 17:22   ` Alan Mackenzie
  2008-04-08 18:05     ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2008-04-08 17:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-pretest-bug, Jan 

Hi, everybody!

On Tue, Apr 08, 2008 at 11:03:02AM -0400, Stefan Monnier wrote:
> > When doing M-x compile I get:
> > font-lock-extend-region-multiline: Args out of range: 0, 0
> 
> Does the patch below make it disappear, by any chance?
> 
> 
>         Stefan
> 
> 
> === modified file 'lisp/progmodes/cc-mode.el'
> --- lisp/progmodes/cc-mode.el	2008-04-07 16:37:22 +0000
> +++ lisp/progmodes/cc-mode.el	2008-04-08 15:01:47 +0000

With respect, that's the wrong place to patch.  It is liable to catch
out anybody else who uses font-lock-extend-after-change-region-function
in the future.  This variable should be made buffer-local once and for
all, like this:


Index: font-lock.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/font-lock.el,v
retrieving revision 1.333
diff -c -r1.333 font-lock.el
*** font-lock.el	14 Mar 2008 16:15:47 -0000	1.333
--- font-lock.el	8 Apr 2008 17:01:34 -0000
***************
*** 996,1002 ****
  (defvar font-lock-extend-after-change-region-function nil
    "A function that determines the region to refontify after a change.
  
! This variable is either nil, or is a function that determines the
  region to refontify after a change.
  It is usually set by the major mode via `font-lock-defaults'.
  Font-lock calls this function after each buffer change.
--- 996,1002 ----
  (defvar font-lock-extend-after-change-region-function nil
    "A function that determines the region to refontify after a change.
  
! This buffer-local variable is either nil, or is a function that determines the
  region to refontify after a change.
  It is usually set by the major mode via `font-lock-defaults'.
  Font-lock calls this function after each buffer change.
***************
*** 1007,1012 ****
--- 1007,1013 ----
  \(which directs the caller to fontify a default region).
  This function should preserve the match-data.
  The region it returns may start or end in the middle of a line.")
+ (make-variable-buffer-local 'font-lock-extend-after-change-region-function)
  
  (defun font-lock-fontify-buffer ()
    "Fontify the current buffer the way the function `font-lock-mode' would."


-- 
Alan Mackenzie (Nuremberg, Germany).




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 17:22   ` Alan Mackenzie
@ 2008-04-08 18:05     ` Stefan Monnier
  2008-04-08 19:21       ` Alan Mackenzie
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-04-08 18:05 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-pretest-bug, Jan 

>> > When doing M-x compile I get:
>> > font-lock-extend-region-multiline: Args out of range: 0, 0
>> 
>> Does the patch below make it disappear, by any chance?
>> 
>> 
>> Stefan
>> 
>> 
>> === modified file 'lisp/progmodes/cc-mode.el'
>> --- lisp/progmodes/cc-mode.el	2008-04-07 16:37:22 +0000
>> +++ lisp/progmodes/cc-mode.el	2008-04-08 15:01:47 +0000

> With respect, that's the wrong place to patch.  It is liable to catch
> out anybody else who uses font-lock-extend-after-change-region-function
> in the future.  This variable should be made buffer-local once and for
> all, like this:

I disagree.  A major mode should basically *never* change globally
a defvar, except maybe for its own vars (plus a few exceptions, of
course).  I.e. `setq' should only ever be used on let-bound variables.
If you happen to know that the variable is "automatically buffer-local",
it's OK to use `setq', but it's always safer to use
`make-local-variable', especially because unless the package that does
the defvar (and make-variable-buffer-local) is preloaded you may end up
calling `setq' before make-variable-buffer-local and get into trouble.

I'm not opposed to make-variable-buffer-local, but the bug was clearly
in CC-mode, because a major mode should by default use
(set (make-local-variable ...) ...) rather than setq.

BTW, why doesn't CC-mode set those vars via font-lock-defaults, as the
author of font-lock intended?


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 18:05     ` Stefan Monnier
@ 2008-04-08 19:21       ` Alan Mackenzie
  2008-04-08 20:22         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2008-04-08 19:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-pretest-bug, Jan 

Hi, Stefan!

On Tue, Apr 08, 2008 at 02:05:07PM -0400, Stefan Monnier wrote:
> >> > When doing M-x compile I get:
> >> > font-lock-extend-region-multiline: Args out of range: 0, 0

> >> Does the patch below make it disappear, by any chance?

> >> Stefan


> >> === modified file 'lisp/progmodes/cc-mode.el'
> >> --- lisp/progmodes/cc-mode.el	2008-04-07 16:37:22 +0000
> >> +++ lisp/progmodes/cc-mode.el	2008-04-08 15:01:47 +0000

> > With respect, that's the wrong place to patch.  It is liable to catch
> > out anybody else who uses
> > font-lock-extend-after-change-region-function in the future.  This
> > variable should be made buffer-local once and for all, like this:

> I disagree.  A major mode should basically *never* change globally
> a defvar, except maybe for its own vars (plus a few exceptions, of
> course).

Well, that's a bit philosophical.  In practice, major mode maintainers
_will_ be setting such variables without explicitly localising them,
causing just that little bit extra in debugging, stress, curse words, and
so on.

There's a category of variables which are _essentially_ buffer local, and
nobody ever explicitly localises them first - things like major-mode,
mark-ring, foo-minor-mode, buffer-undo-list, .....  fl-e-ac-rf is in this
category.

There are several other variables in font-lock.el which are explicity
buffer-localised, amongst them the similar variable
font-lock-extend-region-functions.  So it would promote consistency if we
did the same with fl-extend-ac-region-function.

[ .... ]

> I'm not opposed to make-variable-buffer-local, but the bug was clearly
> in CC-mode, because a major mode should by default use
> (set (make-local-variable ...) ...) rather than setq.

I don't think it's clear at all.  The same "bug", if such it be, exists
in font-lock.el itself, L1452:

        (setq font-lock-syntactically-fontified end))

> BTW, why doesn't CC-mode set those vars via font-lock-defaults, as the
> author of font-lock intended?

For portability's sake.  font-lock-defaults in XEmacs has a different
format.  In particular, it lacks the "other-vars" bit at the end.  It's
less hassle just not to use it.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 19:21       ` Alan Mackenzie
@ 2008-04-08 20:22         ` Stefan Monnier
  2008-04-09  9:24           ` Alan Mackenzie
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-04-08 20:22 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-pretest-bug, Jan 

>> I disagree.  A major mode should basically *never* change globally
>> a defvar, except maybe for its own vars (plus a few exceptions, of
>> course).

> Well, that's a bit philosophical.  In practice, major mode maintainers
> _will_ be setting such variables without explicitly localising them,
> causing just that little bit extra in debugging, stress, curse words,
> and so on.

It's not philosophical.  It's simply needed so as to avoid undesired
interference between unrelated buffers.  I know it's a common bug.

> There's a category of variables which are _essentially_ buffer local, and
> nobody ever explicitly localises them first - things like major-mode,
> mark-ring, foo-minor-mode, buffer-undo-list, .....

It's hard to clearly define which ones are "essentially" buffer local
and which ones aren't.

> fl-e-ac-rf is in this category.

In my mind, it's definitely not in the same category as `major-mode' or
`buffer-undo-list'.  But it doesn't matter anyway.

> There are several other variables in font-lock.el which are explicity
> buffer-localised, amongst them the similar variable
> font-lock-extend-region-functions.  So it would promote consistency if we
> did the same with fl-extend-ac-region-function.

As I said:

>> I'm not opposed to make-variable-buffer-local,

So feel free to apply your patch (except for the part that changes the
docstring, since C-h v will take care of warning the user that the
variable is automatically made buffer-local).

>> but the bug was clearly in CC-mode, because a major mode should by
>> default use (set (make-local-variable ...) ...) rather than setq.

> I don't think it's clear at all.  The same "bug", if such it be, exists
> in font-lock.el itself, L1452:

>         (setq font-lock-syntactically-fontified end))

As I said "If you happen to know that the variable is "automatically
buffer-local", it's OK to use `setq'".

>> BTW, why doesn't CC-mode set those vars via font-lock-defaults, as the
>> author of font-lock intended?

> For portability's sake.  font-lock-defaults in XEmacs has a different
> format.  In particular, it lacks the "other-vars" bit at the end.  It's
> less hassle just not to use it.

Duh!


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: 23.0.60; M-x compile gives args out of range 0, 0
  2008-04-08 20:22         ` Stefan Monnier
@ 2008-04-09  9:24           ` Alan Mackenzie
  0 siblings, 0 replies; 8+ messages in thread
From: Alan Mackenzie @ 2008-04-09  9:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-pretest-bug, Jan 

Morning, Stefan!

On Tue, Apr 08, 2008 at 04:22:23PM -0400, Stefan Monnier wrote:
> > There's a category of variables which are _essentially_ buffer local,
> > and nobody ever explicitly localises them first - things like
> > major-mode, mark-ring, foo-minor-mode, buffer-undo-list, .....

> It's hard to clearly define which ones are "essentially" buffer local
> and which ones aren't.

I'm not so sure about that.  Anything set by a major mode is almost
certainly such a variable.  font-lock-keywords, for example.  :-)  But
this is going towards the philosophical again.

[ .... ]

> So feel free to apply your patch (except for the part that changes the
> docstring, since C-h v will take care of warning the user that the
> variable is automatically made buffer-local).

DONE.

[ .... ]

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-04-09  9:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-08 10:52 23.0.60; M-x compile gives args out of range 0, 0 Jan Djärv
2008-04-08 15:03 ` Stefan Monnier
2008-04-08 16:32   ` Jan Djärv
2008-04-08 17:22   ` Alan Mackenzie
2008-04-08 18:05     ` Stefan Monnier
2008-04-08 19:21       ` Alan Mackenzie
2008-04-08 20:22         ` Stefan Monnier
2008-04-09  9:24           ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).