help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: calc-embedded-activate


From: Jay Belanger
Subject: Re: calc-embedded-activate
Date: Tue, 13 Jan 2004 16:22:00 -0600
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux)

Roger Mason <rmason@esd.mun.ca> writes:

...
> %Embed 
> % $f := 2$
> % $g := 2$
> % $foo := 5$
> % $f + g => $
...
> The key combination `C-u 1 M-# a' leads to the following
> backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)

It looks like a bug with calc-embed, which perhaps can be fixed by
commenting out the lines
    (if (looking-at calc-embedded-open-formula)
        (goto-char (match-end 1)))
from the definition of calc-do-embed-activate in calc-embed.el.
(It works for me.)

Here's my analysis (I tried it on cvs emacs, by the way, and got a
similar problem) in case anybody wants to critique it.

`M-# a' (equivalent to `C-u 1 M-# a') calls calc-embedded-activate,
which calls calc-do-embedded-activate, which looks for embedded
formulas. 
The pattern that it searches for consists of symbols like  := and =>,
or (in parentheses) another regular expression. 
So calc-do-embedded-activate  keeps searching for the pattern, and
whenever it finds it, it checks to see if it is looking at the
beginning of another formula, in which case it goes to the end of the
part of the matched pattern that was in the parentheses.  (match-end 1)

The problem is, if the match is := or => then the parenthesized
expression wasn't matched, and so (match-end 1) returns nil.
The crucial loop begins at line 343 in calc-embed.el, and looks like
  (while (re-search-forward pat nil t)
    (if (looking-at calc-embedded-open-formula)
        (goto-char (match-end 1)))
    (setq info (calc-embedded-make-info (point) cbuf nil))
    (or (eq (car-safe (aref info 8)) 'error)
        (goto-char (aref info 5))))
I don't see what the 
    (if (looking-at calc-embedded-open-formula)
        (goto-char (match-end 1)))
is doing there at all.  If the parenthesized part of the pattern is
matched, then (match-end 1) will be the point and nothing happens, if
the parenthesized part is not matched, this gives an error.

Jay Belanger



reply via email to

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