Created
October 9, 2010 19:05
-
-
Save tbatchelli/618494 to your computer and use it in GitHub Desktop.
Incremental mark for clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;; extend selection in clojure | |
;;;; from: http://xahlee.org/emacs/syntax_tree_walk.html | |
(defun semnav-up (arg) | |
(interactive "p") | |
(when (nth 3 (syntax-ppss)) | |
(if (> arg 0) | |
(progn | |
(skip-syntax-forward "^\"") | |
(goto-char (1+ (point))) | |
(decf arg)) | |
(skip-syntax-backward "^\"") | |
(goto-char (1- (point))) | |
(incf arg))) | |
(up-list arg)) | |
(defun extend-selection (arg &optional incremental) | |
"Mark the symbol surrounding point. | |
Subsequent calls mark higher levels of sexps." | |
(interactive (list (prefix-numeric-value current-prefix-arg) | |
(or (and transient-mark-mode mark-active) | |
(eq last-command this-command)))) | |
(if incremental | |
(progn | |
(semnav-up (- arg)) | |
(forward-sexp) | |
(mark-sexp -1)) | |
(if (> arg 1) | |
(extend-selection (1- arg) t) | |
(if (looking-at "\\=\\(\\s_\\|\\sw\\)*\\_>") | |
(goto-char (match-end 0)) | |
(unless (memq (char-before) '(?\) ?\")) | |
(forward-sexp))) | |
(mark-sexp -1)))) | |
(define-key clojure-mode-map [f6] 'extend-selection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment