Skip to content

Instantly share code, notes, and snippets.

@hchbaw
Created September 18, 2009 23:14
Show Gist options
  • Save hchbaw/189348 to your computer and use it in GitHub Desktop.
Save hchbaw/189348 to your computer and use it in GitHub Desktop.
diff --git a/vimpulse-text-object-system.el b/vimpulse-text-object-system.el
index d62225b..21e5445 100644
--- a/vimpulse-text-object-system.el
+++ b/vimpulse-text-object-system.el
@@ -135,6 +135,12 @@ (defun vimpulse-get-vWord-bounds (pos)
(re-search-backward "[\n\r[:space:]]")
(cons (1+ (point)) result))))
+ (defun vimpulse-get-sexp-bounds (pos)
+ (save-excursion
+ (goto-char pos)
+ (let ((cell (bounds-of-thing-at-point 'sexp)))
+ (list (car cell) (1- (cdr cell))))))
+
(defun vimpulse-get-sentence-bounds (pos)
"Returns the boundaries of a sentence."
(let ((result))
@@ -189,6 +195,7 @@ (defun vimpulse-get-text-object-bounds-i (pos motion)
`motion' identifies the text object:
- w -> word
- W -> Word
+ - x -> sexp
- s -> sentence
- p -> paragraph
- <paren> -> paren block (see variable `vimpulse-paren-matching-table'
@@ -198,6 +205,7 @@ (defun vimpulse-get-text-object-bounds-i (pos motion)
(cond
((= motion ?w) (vimpulse-get-vword-bounds pos))
((= motion ?W) (vimpulse-get-vWord-bounds pos))
+ ((= motion ?x) (vimpulse-get-sexp-bounds pos))
((= motion ?s) (vimpulse-get-sentence-bounds pos))
((= motion ?p) (vimpulse-get-paragraph-bounds pos))
((memq motion vimpulse-paired-expression-delimiters)
@@ -241,6 +249,7 @@ (defun vimpulse-get-text-object-bounds-a (pos motion)
((= motion ?w)
(vimpulse-get-bounds-with-whitespace 'vimpulse-get-vword-bounds pos))
((= motion ?W) (vimpulse-get-bounds-with-whitespace 'vimpulse-get-vWord-bounds pos))
+ ((= motion ?x) (vimpulse-get-bounds-with-whitespace 'vimpulse-get-sexp-bounds pos))
((= motion ?s) (vimpulse-get-bounds-with-whitespace 'vimpulse-get-sentence-bounds pos))
((= motion ?p) (vimpulse-get-bounds-with-whitespace 'vimpulse-get-paragraph-bounds pos t))
((memq motion vimpulse-paired-expression-delimiters)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment