# HG changeset patch # User Stefan Monnier # Date 1165890998 0 # Node ID ab428131b5286cc3ef1cba97beb6c5b3e832cbd8 # Parent 37d6b6cd4b63e136f41d700e7fcf9a01cb0f9bfe (syntax-ppss-toplevel-pos): New fun. diff -r 37d6b6cd4b63 -r ab428131b528 lisp/ChangeLog --- a/lisp/ChangeLog Mon Dec 11 16:44:53 2006 +0000 +++ b/lisp/ChangeLog Tue Dec 12 02:36:38 2006 +0000 @@ -1,3 +1,7 @@ +2006-12-12 Stefan Monnier + + * emacs-lisp/syntax.el (syntax-ppss-toplevel-pos): New fun. + 2006-12-11 Juanma Barranquero * subr.el (unread-command-char): Reformat obsolescence info. diff -r 37d6b6cd4b63 -r ab428131b528 lisp/emacs-lisp/syntax.el --- a/lisp/emacs-lisp/syntax.el Mon Dec 11 16:44:53 2006 +0000 +++ b/lisp/emacs-lisp/syntax.el Tue Dec 12 02:36:38 2006 +0000 @@ -52,6 +52,14 @@ (defsubst syntax-ppss-depth (ppss) (nth 0 ppss)) +(defun syntax-ppss-toplevel-pos (ppss) + "Return the last preceding position at toplevel. +\"At toplevel\" means that it is outside of any syntactic entity: +outside of any parentheses, or comments, or strings. +Returns nil iff PPSS itself corresponds to a toplevel position." + (or (car (nth 9 ppss)) + (nth 8 ppss))) + (defsubst syntax-ppss-context (ppss) (cond ((nth 3 ppss) 'string)