unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jay Belanger <belanger@truman.edu>
Subject: Re: calc-embedded-activate
Date: Tue, 13 Jan 2004 16:22:00 -0600	[thread overview]
Message-ID: <87smij32wn.fsf@truman.edu> (raw)
In-Reply-To: mailman.557.1074026001.928.help-gnu-emacs@gnu.org

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	other threads:[~2004-01-13 22:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.557.1074026001.928.help-gnu-emacs@gnu.org>
2004-01-13 22:22 ` Jay Belanger [this message]
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
2004-01-13 16:33 calc-embedded-activate Roger Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87smij32wn.fsf@truman.edu \
    --to=belanger@truman.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).