Skip to content

Instantly share code, notes, and snippets.

@jaycfields
Last active December 16, 2015 21:49
Show Gist options
  • Save jaycfields/5502257 to your computer and use it in GitHub Desktop.
Save jaycfields/5502257 to your computer and use it in GitHub Desktop.
(defun char-at-point ()
(interactive)
(buffer-substring-no-properties (point) (+ 1 (point))))
(defun clj-string-name (s)
(substring s 1 -1))
(defun clj-keyword-name (s)
(substring s 1))
(defun delete-and-extract-sexp ()
(let* ((begin (point)))
(forward-sexp)
(let* ((result (buffer-substring-no-properties begin (point))))
(delete-region begin (point))
result)))
(defun toggle-clj-keyword-string ()
(interactive)
(save-excursion
(if (equal 1 (point))
(message "beginning of file reached, this was probably a mistake.")
(cond ((equal "\"" (char-at-point))
(insert ":" (clj-string-name (delete-and-extract-sexp))))
((equal ":" (char-at-point))
(insert "\"" (clj-keyword-name (delete-and-extract-sexp)) "\""))
(t (progn
(backward-char)
(toggle-clj-keyword-string)))))))
(global-set-key (kbd "C-:") 'toggle-clj-keyword-string)
@duelinmarkers
Copy link

Missing a clj- where you recur?

@jaycfields
Copy link
Author

yep, sorry & thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment