emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] bug report: emacs-wiki-highlight-title blows up


From: Vadim Nasardinov
Subject: [emacs-wiki-discuss] bug report: emacs-wiki-highlight-title blows up
Date: Fri, 17 Dec 2004 13:29:36 -0500
User-agent: KMail/1.5.4

I apologize in advance if this has been reported and/or fixed alredy.
I'm running emacs-wiki 2.64.

In my .emacs, I have

  | ;; Set the debug option to enable a backtrace when a problem occurs.
  | (add-hook 'after-init-hook
  |           (lambda () (setq debug-on-error t)))


When a start blank new wiki page, I often run into the following
error:

  | Debugger entered--Lisp error: (args-out-of-range 7 8)
  |   add-text-properties(8 7 (face emacs-wiki-header-1))
  |   emacs-wiki-highlight-title()
  |   emacs-wiki-highlight-region(1 7 nil)
  |   font-lock-fontify-region(1 7)
  |   run-hook-with-args(font-lock-fontify-region 1 7)
  |   jit-lock-fontify-now(1 501)
  |   jit-lock-function(1)

This happens when I type the string
#title

at the beginning of the top line.

Looking in emacs-wiki-publish.el, I see that the offending function is
defined as follows:


  | (defun emacs-wiki-highlight-title ()
  |   (add-text-properties (+ 7 (match-beginning 0))
  |                        (line-end-position)
  |                        '(face emacs-wiki-header-1)))


Implicit in this definition is the assumption that the value of
(+ 7 (match-beginning 0)) is less than the value of (line-end-position).

As the above stacktrace shows, this is not the case when the cursor is
positioned right after the character "e" in the string "#title".  In
this case, (line-end-position) is 7, whereas (match-beginning 0) is 1.

Perhaps a quick sanity check is in order.  Something along the lines
of
(defun emacs-wiki-highlight-title ()
  ;; 7 is the length of the string "#title" plus 1
  (let ((start (+ 7 (match-beginning 0)))
        (end (line-end-position)))
    (when (< start end)
      (add-text-properties start end '(face emacs-wiki-header-1)))))


Thanks,
Vadim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]