* calc-embedded-activate
@ 2004-01-13 16:33 Roger Mason
0 siblings, 0 replies; 5+ messages in thread
From: Roger Mason @ 2004-01-13 16:33 UTC (permalink / raw)
Hello,
I wish to use calc-embedded in a LaTeX document. Having read through
the calc-2.02f manual I see that it should be possible to activate all formulae
in a buffer using `M-# a'. I have the following simple test document:
\documentclass(article)
\begin(document)
%Embed
% $f := 2$
% $g := 2$
% $foo := 5$
% $f + g => $
\end{document}
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)
calc-do-embedded-activate(1 nil)
calc-embedded-activate(1)
call-interactively(calc-embedded-activate)
calc-do-dispatch(1)
calc-dispatch(1)
* call-interactively(calc-dispatch)
The key combination `C-u -1 M-# a' works correctly, but `M-# a', with
or without any other prefix fails with an error similar to the above.
I am trying to learn lisp, but my skill are not yet sufficient to
debug a complicated set of routines like calc.
Any help will be much appreciated.
Thanks,
Roger Mason
P.S. I'm using emacs 21.1 on a linux box and I applied all the patches
specified in the PROBLEMS file before compiling and installing
calc-2.02f. The tests in calc-2.02f INSTALL ran without any problem.
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.557.1074026001.928.help-gnu-emacs@gnu.org>]
* Re: calc-embedded-activate
[not found] <mailman.557.1074026001.928.help-gnu-emacs@gnu.org>
@ 2004-01-13 22:22 ` Jay Belanger
2004-01-14 11:20 ` calc-embedded-activate Roger Mason
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jay Belanger @ 2004-01-13 22:22 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: calc-embedded-activate
2004-01-13 22:22 ` calc-embedded-activate Jay Belanger
@ 2004-01-14 11:20 ` Roger Mason
[not found] ` <mailman.618.1074079249.928.help-gnu-emacs@gnu.org>
2004-01-14 18:40 ` calc-embedded-activate Jay Belanger
2 siblings, 0 replies; 5+ messages in thread
From: Roger Mason @ 2004-01-14 11:20 UTC (permalink / raw)
Hello,
Jay Belanger <belanger@truman.edu> writes:
> 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.)
>
( lines snipped )
Thanks for your response.
I discovered later that terminating the %Embed % $...$ group with
another %Embed cures the problem. I'm not sure if this is consistent
with your analysis or not. The terminating %Embed is not part of the
regex in calc-do-embedded-activate, indeed that regex pertains only to
the announcement of a group of formulae, so the `correct' behaviour could
be fortuitous. Commenting out the ofending lines is cleaner, I'll try
it here and report back.
Having got `M-# a' to work, albeit by trial and error, I have been
trying to update all the fomulae in the buffer using `C-u 1 M-# u'.
This command fails silently: nothing happens and there is no error
signalled. `M-u' works as described in the manual, so I assume the
bug (if it is a bug and not my stupidity) is in the code that steps
through the buffer finding active formulae. I presume the best way to
proceed is to improve my aquaintance with the lisp debugger, but if
anyone has any suggestions I'd be grateful to receive them.
Thanks,
Roger Mason
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.618.1074079249.928.help-gnu-emacs@gnu.org>]
* Re: calc-embedded-activate
[not found] ` <mailman.618.1074079249.928.help-gnu-emacs@gnu.org>
@ 2004-01-14 18:27 ` Jay Belanger
0 siblings, 0 replies; 5+ messages in thread
From: Jay Belanger @ 2004-01-14 18:27 UTC (permalink / raw)
Roger Mason <rmason@esd.mun.ca> writes:
...
> I discovered later that terminating the %Embed % $...$ group with
> another %Embed cures the problem.
Not here; but then we are using different versions of calc.
Another way to fix the problem without messing with the source is to
put an extra space after the "=> ". Right now, with
% $f + g => $
after calc finds the "=> ", it is looking at the "$", which causes the
problems. So there shouldn't be (and aren't here) problems if you
used
% $f + g => $
> Having got `M-# a' to work, albeit by trial and error, I have been
> trying to update all the fomulae in the buffer using `C-u 1 M-# u'.
> This command fails silently: nothing happens and there is no error
> signalled. `M-u' works as described in the manual, so I assume the
> bug (if it is a bug and not my stupidity) is in the code that steps
> through the buffer finding active formulae.
I would guess that the terminal %Embed somehow convinces calc to skip
activating that formula. But I can't say for sure.
> I presume the best way to proceed is to improve my aquaintance with
> the lisp debugger, but if anyone has any suggestions I'd be grateful
> to receive them.
It looks like someone should file a bug report; I'll do it if you
don't want to.
Jay
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: calc-embedded-activate
2004-01-13 22:22 ` calc-embedded-activate Jay Belanger
2004-01-14 11:20 ` calc-embedded-activate Roger Mason
[not found] ` <mailman.618.1074079249.928.help-gnu-emacs@gnu.org>
@ 2004-01-14 18:40 ` Jay Belanger
2 siblings, 0 replies; 5+ messages in thread
From: Jay Belanger @ 2004-01-14 18:40 UTC (permalink / raw)
Jay Belanger <belanger@truman.edu> writes:
...
> 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.
Okay, I was stupid here. The `looking-at' will give new `match-end'
data. (Although calc-embedded-open-formula doesn't have any
parenthesized expressions, so the (goto-char (match-end 1)) still
gives the error. And I still don't see what the `if' is doing there.)
Jay
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-01-14 18:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-13 16:33 calc-embedded-activate Roger Mason
[not found] <mailman.557.1074026001.928.help-gnu-emacs@gnu.org>
2004-01-13 22:22 ` calc-embedded-activate Jay Belanger
2004-01-14 11:20 ` calc-embedded-activate Roger Mason
[not found] ` <mailman.618.1074079249.928.help-gnu-emacs@gnu.org>
2004-01-14 18:27 ` calc-embedded-activate Jay Belanger
2004-01-14 18:40 ` calc-embedded-activate Jay Belanger
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).