[climacs-cvs] CVS climacs

thenriksen thenriksen at common-lisp.net
Tue May 2 14:29:44 UTC 2006


Update of /project/climacs/cvsroot/climacs
In directory clnet:/tmp/cvs-serv4439

Modified Files:
	lisp-syntax.lisp 
Log Message:
Added two form extraction functions.


--- /project/climacs/cvsroot/climacs/lisp-syntax.lisp	2006/05/02 14:25:24	1.58
+++ /project/climacs/cvsroot/climacs/lisp-syntax.lisp	2006/05/02 14:29:44	1.59
@@ -1307,6 +1307,27 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
+;;; Useful functions for selecting forms based on the mark.
+
+(defun expression-at-mark (mark syntax)
+  "Return the form at `mark'. If `mark' is just after,
+or inside, a top-level-form, or if there are no forms after
+`mark', the form preceding `mark' is returned. Otherwise, the
+form following `mark' is returned."
+  (or (form-around syntax (offset mark))
+      (form-after syntax (offset mark))
+      (form-before syntax (offset mark))))
+
+(defun definition-at-mark (mark syntax)
+  "Return the top-level form at `mark'. If `mark' is just after,
+or inside, a top-level-form, or if there are no forms after
+`mark', the top-level-form preceding `mark' is
+returned. Otherwise, the top-level-form following `mark' is
+returned."
+  (form-toplevel (expression-at-mark mark syntax) syntax))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
 ;;; display
 
 (defvar *white-space-start* nil)




More information about the Climacs-cvs mailing list