From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Robert D. Crawford" Newsgroups: gmane.emacs.help Subject: Re: elisp beginner's parens question ?? Date: Thu, 26 Apr 2007 21:58:31 -0500 Message-ID: <87d51qcylk.fsf@comcast.net> References: <87y7kfx783.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1177644873 10833 80.91.229.12 (27 Apr 2007 03:34:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2007 03:34:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 27 05:34:31 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HhHE3-00054o-Bn for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 05:34:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhHJq-0000rv-Ul for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Apr 2007 23:40:26 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Thu, 26 Apr 2007 21:58:26 -0500 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.98 (gnu/linux) Cancel-Lock: sha1:+M7CYOi5xCc97jykpWoFY/DFTWY= Original-Lines: 43 Original-NNTP-Posting-Host: 68.52.51.66 Original-X-Trace: sv3-KxQV1whwbBtq07V6UdePl7XSU6y3R575OT9uDVTD0kgx+18x/f7qcSTWLWFW+K4qCZipr5iwCfaDfFL!AFJHRIy3kPHj/WoFPILVyvNZCBPRA1d7Gtzmyg9ygqGdvHn/KLxSyTGwdhJHemOUIbYHI8cAZ6aP!hek= Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Original-Xref: shelby.stanford.edu gnu.emacs.help:147646 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:43249 Archived-At: William Case writes: > However, the "mental tips or tricks" was really a 'by the way' or an > after thought question. What I was really asking was how the > interpreter or emacs uses parenthesis or how parenthesis are nested. > Put another way, I was trying to develop for myself a minds eye view of > how check-parens works. Does check-parens just count left parens and > compare that to the number of right parens to find an error, or does it > actually examine nested parens pairs and work inword (or outward) ? This might provide your answer. If you do C-h f and supply a function name, the resulting buffer, in X anyway, will have a link to the function's definition. (defun check-parens () ; lame name? "Check for unbalanced parentheses in the current buffer. More accurately, check the narrowed part of the buffer for unbalanced expressions (\"sexps\") in general. This is done according to the current syntax table and will find unbalanced brackets or quotes as appropriate. (See Info node `(emacs)Parentheses'.) If imbalance is found, an error is signaled and point is left at the first unbalanced character." (interactive) (condition-case data ;; Buffer can't have more than (point-max) sexps. (scan-sexps (point-min) (point-max)) (scan-error (goto-char (nth 2 data)) ;; Could print (nth 1 data), which is either ;; "Containing expression ends prematurely" or ;; "Unbalanced parentheses", but those may not be so ;; accurate/helpful, e.g. quotes may actually be ;; mismatched. (error "Unmatched bracket or quote")) (error (cond ((eq 'scan-error (car data)) (goto-char (nth 2 data)) (error "Unmatched bracket or quote")) (t (signal (car data) (cdr data))))))) -- Robert D. Crawford rdc1x@comcast.net If ignorance is bliss, why aren't there more happy people?