From 7a6bb0f05e349068b0a89514f1da33d6d7de30a9 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 24 Apr 2012 23:29:38 +0200 Subject: emacs.d/lisp/yasnippet: added yasnippet --- .../emacs-lisp-mode/x-word-or-region.yasnippet | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 emacs.d/lisp/yasnippet/snippets/emacs-lisp-mode/x-word-or-region.yasnippet (limited to 'emacs.d/lisp/yasnippet/snippets/emacs-lisp-mode/x-word-or-region.yasnippet') diff --git a/emacs.d/lisp/yasnippet/snippets/emacs-lisp-mode/x-word-or-region.yasnippet b/emacs.d/lisp/yasnippet/snippets/emacs-lisp-mode/x-word-or-region.yasnippet new file mode 100755 index 0000000..0f3d1b8 --- /dev/null +++ b/emacs.d/lisp/yasnippet/snippets/emacs-lisp-mode/x-word-or-region.yasnippet @@ -0,0 +1,27 @@ +#contributor: Xah Lee (XahLee.org) +#name: Command that works on region or word +# -- +;; example of a command that works on current word or text selection +(defun down-case-word-or-region () + "Lower case the current word or text selection." +(interactive) +(let (pos1 pos2 meat) + (if (and transient-mark-mode mark-active) + (setq pos1 (region-beginning) + pos2 (region-end)) + (setq pos1 (car (bounds-of-thing-at-point 'symbol)) + pos2 (cdr (bounds-of-thing-at-point 'symbol)))) + + ; now, pos1 and pos2 are the starting and ending positions + ; of the current word, or current text selection if exists + + ;; put your code here. + $0 + ;; Some example of things you might want to do + (downcase-region pos1 pos2) ; example of a func that takes region as args + (setq meat (buffer-substring-no-properties pos1 pos2)) ; grab the text. + (delete-region pos1 pos2) ; get rid of it + (insert "newText") ; insert your new text + + ) +) -- cgit v1.2.3