diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-25 00:11:45 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-25 00:11:45 +0000 |
commit | 5837de87ff051f1c135111369a091590b500b314 (patch) | |
tree | fd2a7ec383ecceff53fd3870e7e7ab41448dd253 /sx.el | |
parent | 7513e83bd978dbd06b7298d32db71dce43d47c3e (diff) |
Move wrap-in-text-property/overlay to sx
Diffstat (limited to 'sx.el')
-rw-r--r-- | sx.el | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -129,7 +129,40 @@ would yield data)))) -;;; Interpreting request data +;;; Printing request data +(defvar sx--overlays nil + "Overlays created by sx on this buffer.") +(make-variable-buffer-local 'sx--overlays) + +(defmacro sx--wrap-in-overlay (properties &rest body) + "Start a scope with overlay PROPERTIES and execute BODY. +Overlay is pushed on the buffer-local variable `sx--overlays' and +given PROPERTIES. + +Return the result of BODY." + (declare (indent 1) + (debug t)) + `(let ((p (point-marker)) + (result (progn ,@body))) + (let ((ov (make-overlay p (point))) + (props ,properties)) + (while props + (overlay-put ov (pop props) (pop props))) + (push ov sx--overlays)) + result)) + +(defmacro sx--wrap-in-text-property (properties &rest body) + "Start a scope with PROPERTIES and execute BODY. +Return the result of BODY." + (declare (indent 1) + (debug t)) + `(let ((p (point-marker)) + (result (progn ,@body))) + (add-text-properties p (point) ,properties) + result)) + + +;;; Assoc-let (defun sx--deep-dot-search (data) "Find symbols somewhere inside DATA which start with a `.'. Returns a list where each element is a cons cell. The car is the |