Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
961 B

4 years ago
  1. # -*- mode: snippet -*-
  2. # name: Command that works on region or word
  3. # contributor : Xah Lee
  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. ; now, pos1 and pos2 are the starting and ending positions
  16. ; of the current word, or current text selection if exists
  17. ;; put your code here.
  18. $0
  19. ;; Some example of things you might want to do
  20. (downcase-region pos1 pos2) ; example of a func that takes region as args
  21. (setq meat (buffer-substring-no-properties pos1 pos2)) ; grab the text.
  22. (delete-region pos1 pos2) ; get rid of it
  23. (insert "newText") ; insert your new text
  24. )
  25. )