emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-mode fontification error [6 times]
@ 2011-08-17 13:17 Leo
  2011-08-18  7:22 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Leo @ 2011-08-17 13:17 UTC (permalink / raw)
  To: emacs-orgmode

Just a heads-up. I saw this in my *message* buffer. I don't know how it
happened.

I am using org-mode 7.7 on Emacs 23.3.50.

Leo

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

* Re: org-mode fontification error [6 times]
  2011-08-17 13:17 org-mode fontification error [6 times] Leo
@ 2011-08-18  7:22 ` Bastien
  2011-08-18  8:01   ` Leo
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-08-18  7:22 UTC (permalink / raw)
  To: Leo; +Cc: emacs-orgmode

Hi Leo,

Leo <sdl.web@gmail.com> writes:

> Just a heads-up. I saw this in my *message* buffer. I don't know how
> it happened.

Is this with emacs -Q?

I am unable to reproduce this with emacs-23.3.1 and emacs-24.0.50.1.

Thanks,

-- 
 Bastien

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

* Re: org-mode fontification error [6 times]
  2011-08-18  7:22 ` Bastien
@ 2011-08-18  8:01   ` Leo
  2012-04-03 19:43     ` Henning Redestig
  0 siblings, 1 reply; 9+ messages in thread
From: Leo @ 2011-08-18  8:01 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

On 2011-08-18 15:22 +0800, Bastien wrote:
>> Just a heads-up. I saw this in my *message* buffer. I don't know how
>> it happened.
>
> Is this with emacs -Q?
>
> I am unable to reproduce this with emacs-23.3.1 and emacs-24.0.50.1.

It is in my normal running emacs session. I haven't found a reproduction
recipe. But I have been using the same org-mode setup for years.

Leo

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

* Re: org-mode fontification error [6 times]
  2011-08-18  8:01   ` Leo
@ 2012-04-03 19:43     ` Henning Redestig
  2012-04-03 21:23       ` Nick Dokos
  0 siblings, 1 reply; 9+ messages in thread
From: Henning Redestig @ 2012-04-03 19:43 UTC (permalink / raw)
  To: emacs-orgmode

+1 on this, I get 'org-mode fontification error' all the time after
having typed just

#+

in an org buffer. with org 7.8.08 and emacs 23.1.50.1 and running with emacs -Q

2011/8/18 Leo <sdl.web@gmail.com>:
> On 2011-08-18 15:22 +0800, Bastien wrote:
>>> Just a heads-up. I saw this in my *message* buffer. I don't know how
>>> it happened.
>>
>> Is this with emacs -Q?
>>
>> I am unable to reproduce this with emacs-23.3.1 and emacs-24.0.50.1.
>
> It is in my normal running emacs session. I haven't found a reproduction
> recipe. But I have been using the same org-mode setup for years.
>
> Leo
>



-- 
/Henning

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

* Re: org-mode fontification error [6 times]
  2012-04-03 19:43     ` Henning Redestig
@ 2012-04-03 21:23       ` Nick Dokos
  2012-04-04  6:30         ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Dokos @ 2012-04-03 21:23 UTC (permalink / raw)
  To: Henning Redestig; +Cc: nicholas.dokos, emacs-orgmode

Henning Redestig <henning.red@googlemail.com> wrote:

> +1 on this, I get 'org-mode fontification error' all the time after
> having typed just
> 
> #+
> 
> in an org buffer. with org 7.8.08 and emacs 23.1.50.1 and running with emacs -Q
> 
> 2011/8/18 Leo <sdl.web@gmail.com>:
> > On 2011-08-18 15:22 +0800, Bastien wrote:
> >>> Just a heads-up. I saw this in my *message* buffer. I don't know how
> >>> it happened.
> >>
> >> Is this with emacs -Q?
> >>
> >> I am unable to reproduce this with emacs-23.3.1 and emacs-24.0.50.1.
> >
> > It is in my normal running emacs session. I haven't found a reproduction
> > recipe. But I have been using the same org-mode setup for years.
> >
> > Leo
> >

Confirmed. It only happens when you start typing into an empty buffer.
Looks like an off-by-one error in org.el:org-fontify-meta-lines-and-blocks-1,
aroung line 5487:

,----
| 	    ;; just any other in-buffer setting, but not indented
| 	    (add-text-properties
| 	     beg (1+ (match-end 0))
| 	     '(font-lock-fontified t face org-meta-line))
`----

The second arg should probably be just (match-end 0).

Nick

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

* Re: org-mode fontification error [6 times]
  2012-04-03 21:23       ` Nick Dokos
@ 2012-04-04  6:30         ` Bastien
  2012-04-04 17:46           ` Henning Redestig
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-04-04  6:30 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

Hi Nick,

Nick Dokos <nicholas.dokos@hp.com> writes:

> Confirmed. It only happens when you start typing into an empty buffer.
> Looks like an off-by-one error in org.el:org-fontify-meta-lines-and-blocks-1,
> aroung line 5487:
>
> ,----
> | 	    ;; just any other in-buffer setting, but not indented
> | 	    (add-text-properties
> | 	     beg (1+ (match-end 0))
> | 	     '(font-lock-fontified t face org-meta-line))
> `----
>
> The second arg should probably be just (match-end 0).

That's correct.  I first thought (min (point-max) (1+ (match-end 0)))
would have been safer, but I really don't see why the 1+.  

Please confirm this is fixed.

Thanks,

-- 
 Bastien

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

* Re: org-mode fontification error [6 times]
  2012-04-04  6:30         ` Bastien
@ 2012-04-04 17:46           ` Henning Redestig
  2012-04-04 18:41             ` Nick Dokos
  2012-04-09 17:21             ` Bastien
  0 siblings, 2 replies; 9+ messages in thread
From: Henning Redestig @ 2012-04-04 17:46 UTC (permalink / raw)
  To: Bastien; +Cc: nicholas.dokos, emacs-orgmode

Better now but still some issues here, now if I start a new org buffer and type

<s [TAB]

to complete the source block, I get org-mode fontification error again.

2012/4/4 Bastien <bzg@gnu.org>:
> Hi Nick,
>
> Nick Dokos <nicholas.dokos@hp.com> writes:
>
>> Confirmed. It only happens when you start typing into an empty buffer.
>> Looks like an off-by-one error in org.el:org-fontify-meta-lines-and-blocks-1,
>> aroung line 5487:
>>
>> ,----
>> |         ;; just any other in-buffer setting, but not indented
>> |         (add-text-properties
>> |          beg (1+ (match-end 0))
>> |          '(font-lock-fontified t face org-meta-line))
>> `----
>>
>> The second arg should probably be just (match-end 0).
>
> That's correct.  I first thought (min (point-max) (1+ (match-end 0)))
> would have been safer, but I really don't see why the 1+.
>
> Please confirm this is fixed.
>
> Thanks,
>
> --
>  Bastien



-- 
/Henning

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

* Re: org-mode fontification error [6 times]
  2012-04-04 17:46           ` Henning Redestig
@ 2012-04-04 18:41             ` Nick Dokos
  2012-04-09 17:21             ` Bastien
  1 sibling, 0 replies; 9+ messages in thread
From: Nick Dokos @ 2012-04-04 18:41 UTC (permalink / raw)
  To: Henning Redestig; +Cc: nicholas.dokos, emacs-orgmode

Henning Redestig <henning.red@googlemail.com> wrote:

> Better now but still some issues here, now if I start a new org buffer and type
> 
> <s [TAB]
> 
> to complete the source block, I get org-mode fontification error again.


Probably more off-by-1 errors - the backtrace shows:

,----
| 
| Debugger entered--Lisp error: (args-out-of-range 15 25)
|   add-text-properties(25 15 (face org-block-end-line))
|   (progn (setq end (match-end 0) end1 ....))
|   (if (re-search-forward (concat "^[ 	]*#\\+end" (match-string 4) "\\>.*") nil t) (progn (setq end (match-end 0) end1 ...)))
|   (when (re-search-forward (concat "^[ 	]*#\\+end" (match-string 4) "\\>.*") nil t) (setq end (match-end 0) end1 ...)))
|   ...
|   org-fontify-meta-lines-and-blocks-1(24)
|   (condition-case nil (org-fontify-meta-lines-and-blocks-1 limit) ((debug error) (message "org-mode fontification error")))
|   org-fontify-meta-lines-and-blocks(24)
|   font-lock-fontify-keywords-region(1 24 nil)
|   font-lock-default-fontify-region(1 24 nil)
|   font-lock-fontify-region(1 24)
|   run-hook-with-args(font-lock-fontify-region 1 24)
|   byte-code("\302\303\b	#\207" [start next run-hook-with-args jit-lock-functions] 4)
|   jit-lock-fontify-now(1 501)
|   jit-lock-function(1)
`----

so this code is probably at fault:


,----
|                ...
| 	       (quoting
| 		(add-text-properties beg1 (min (point-max) (1+ end1))
| 				     '(face org-block))) ; end of source block
| 	       ((not org-fontify-quote-and-verse-blocks))
| 	       ((string= block-type "quote")
| 		(add-text-properties beg1 (1+ end1) '(face org-quote)))
| 	       ((string= block-type "verse")
| 		(add-text-properties beg1 (1+ end1) '(face org-verse))))
|       	      (add-text-properties beg beg1 '(face org-block-begin-line))
|       	      (add-text-properties (1+ end) (1+ end1) '(face org-block-end-line))  <<<<<<<<
|               ...
`----

In this case, adding 1 to end1 seems to be correct, but adding 1 to end
does not.  However, I'm getting more and more worried that fixing things
in this instance might break other situations.

Also, as you can see there are more (1+ end1) instances, which will
probably cause similar problems in other situations: this whole function
could do with a review.

And another point: even though these changes apparently fix these
problems, if there are *other* problems (e.g. the wrong thing fontified,
particularly if the "wrong" thing is displaced one char from the "right"
thing), then these changes are probably wrong and will need some more
complicated solution, perhaps along the lines of Bastien's suggestion
below. So keep an eye out not only for the fontification error message,
but also for wrong fontification in the buffer.

Nick

PS. BTW, here's a debugging hint: getting a backtrace from inside a
    condition-case that eats the error required two things: setting
    debug-on-error to t and modifying 

--8<---------------cut here---------------start------------->8---
(defun org-fontify-meta-lines-and-blocks (limit)
  (condition-case nil
      (org-fontify-meta-lines-and-blocks-1 limit)
    ((debug error) (message "org-mode fontification error"))))
--8<---------------cut here---------------end--------------->8---

to add that debug cookie - see the doc for condition-case: C-h f
condition-case RET.

> 
> 2012/4/4 Bastien <bzg@gnu.org>:
> > Hi Nick,
> >
> > Nick Dokos <nicholas.dokos@hp.com> writes:
> >
> >> Confirmed. It only happens when you start typing into an empty buffer.
> >> Looks like an off-by-one error in org.el:org-fontify-meta-lines-and-blocks-1,
> >> aroung line 5487:
> >>
> >> ,----
> >> |         ;; just any other in-buffer setting, but not indented
> >> |         (add-text-properties
> >> |          beg (1+ (match-end 0))
> >> |          '(font-lock-fontified t face org-meta-line))
> >> `----
> >>
> >> The second arg should probably be just (match-end 0).
> >
> > That's correct.  I first thought (min (point-max) (1+ (match-end 0)))
> > would have been safer, but I really don't see why the 1+.
> >
> > Please confirm this is fixed.
> >
> > Thanks,
> >
> > --
> >  Bastien
> 
> 
> 
> -- 
> /Henning
> 

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

* Re: org-mode fontification error [6 times]
  2012-04-04 17:46           ` Henning Redestig
  2012-04-04 18:41             ` Nick Dokos
@ 2012-04-09 17:21             ` Bastien
  1 sibling, 0 replies; 9+ messages in thread
From: Bastien @ 2012-04-09 17:21 UTC (permalink / raw)
  To: Henning Redestig; +Cc: nicholas.dokos, emacs-orgmode

Hi Henning,

Henning Redestig <henning.red@googlemail.com> writes:

> Better now but still some issues here, now if I start a new org buffer and type
>
> <s [TAB]
>
> to complete the source block, I get org-mode fontification error
> again.

This is fixed now.

Thanks to you and Nick for digging this.

-- 
 Bastien

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

end of thread, other threads:[~2012-04-09 17:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-17 13:17 org-mode fontification error [6 times] Leo
2011-08-18  7:22 ` Bastien
2011-08-18  8:01   ` Leo
2012-04-03 19:43     ` Henning Redestig
2012-04-03 21:23       ` Nick Dokos
2012-04-04  6:30         ` Bastien
2012-04-04 17:46           ` Henning Redestig
2012-04-04 18:41             ` Nick Dokos
2012-04-09 17:21             ` Bastien

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).