lotsa changes and inclusion of elpy
[emacs.git] / .emacs.d / elisp / yasnippet / snippets / emacs-lisp-mode / x-word-or-region
1 #contributor: Xah Lee (XahLee.org)
2 #name: Command that works on region or word
3 # key: x-word-or-region
4 # --
5 ;; example of a command that works on current word or text selection
6 (defun down-case-word-or-region ()
7 "Lower case the current word or text selection."
8 (interactive)
9 (let (pos1 pos2 meat)
10 (if (and transient-mark-mode mark-active)
11 (setq pos1 (region-beginning)
12 pos2 (region-end))
13 (setq pos1 (car (bounds-of-thing-at-point 'symbol))
14 pos2 (cdr (bounds-of-thing-at-point 'symbol))))
15
16 ; now, pos1 and pos2 are the starting and ending positions
17 ; of the current word, or current text selection if exists
18
19 ;; put your code here.
20 $0
21 ;; Some example of things you might want to do
22 (downcase-region pos1 pos2) ; example of a func that takes region as args
23 (setq meat (buffer-substring-no-properties pos1 pos2)) ; grab the text.
24 (delete-region pos1 pos2) ; get rid of it
25 (insert "newText") ; insert your new text
26
27 )
28 )