Add `check-parents'

Michael Sperber <[email protected]>
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
Another straightforward synch from GNU Emacs.

2014-01-27  Michael Sperber  <[email protected]>

	* lisp.el (check-parens): Add, from GNU Emacs.

-- 
Regards,
Mike

diff --git a/lisp/lisp.el b/lisp/lisp.el
--- a/lisp/lisp.el
+++ b/lisp/lisp.el
@@ -328,6 +328,26 @@
     (delete-indentation))
   (forward-char 1)
   (newline-and-indent))
+
+(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"))))
 
 (defun lisp-complete-symbol ()
   "Perform completion on Lisp symbol preceding point.

_______________________________________________
XEmacs-Patches mailing list
[email protected]
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.