Mercurial > hg > xemacs-beta
changeset 5788:6a6c89b53c5d
Add `check-parents' from GNU Emacs.
2014-01-27 Michael Sperber <mike@xemacs.org>
* lisp.el (check-parens): Add, from GNU Emacs.
author | Mike Sperber <sperber@deinprogramm.de> |
---|---|
date | Mon, 27 Jan 2014 17:45:03 +0100 |
parents | 10395934b99e |
children | 72c5d36ba3b6 |
files | lisp/ChangeLog lisp/lisp.el |
diffstat | 2 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Jan 27 17:41:46 2014 +0100 +++ b/lisp/ChangeLog Mon Jan 27 17:45:03 2014 +0100 @@ -1,3 +1,7 @@ +2014-01-27 Michael Sperber <mike@xemacs.org> + + * lisp.el (check-parens): Add, from GNU Emacs. + 2014-01-27 Michael Sperber <mike@xemacs.org> * custom.el (custom-declare-variable, defcustom): Add :risky and
--- a/lisp/lisp.el Mon Jan 27 17:41:46 2014 +0100 +++ b/lisp/lisp.el Mon Jan 27 17:45:03 2014 +0100 @@ -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.