From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jay Belanger Newsgroups: gmane.emacs.help Subject: Re: calc-embedded-activate Date: Tue, 13 Jan 2004 16:22:00 -0600 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87smij32wn.fsf@truman.edu> References: Reply-To: belanger@truman.edu NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1074035927 32539 80.91.224.253 (13 Jan 2004 23:18:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 13 Jan 2004 23:18:47 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 14 00:18:42 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AgXo2-00067s-00 for ; Wed, 14 Jan 2004 00:18:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AgX3y-0003XM-A0 for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Jan 2004 17:31:06 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.maxwell.syr.edu!nntp.newsfirst.net!newshub.more.net!news.more.net!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:Og+hvcg65lTlrLMtpC1pB9mnd5A= Original-Lines: 52 Original-NNTP-Posting-Host: 150.243.170.122 Original-X-Trace: news.more.net 1074032518 150.243.170.122 (Tue, 13 Jan 2004 16:21:58 CST) Original-NNTP-Posting-Date: Tue, 13 Jan 2004 16:21:58 CST Original-Xref: shelby.stanford.edu gnu.emacs.help:120063 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:16006 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16006 Roger Mason 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