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.

36 lines
1.1 KiB

4 years ago
  1. (require 'yasnippet)
  2. ;; whitespace removing functions from Magnar Sveen ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. (defun yas-s-trim-left (s)
  4. "Remove whitespace at the beginning of S."
  5. (if (string-match "\\`[ \t\n\r]+" s)
  6. (replace-match "" t t s)
  7. s))
  8. (defun yas-s-trim-right (s)
  9. "Remove whitespace at the end of S."
  10. (if (string-match "[ \t\n\r]+\\'" s)
  11. (replace-match "" t t s)
  12. s))
  13. (defun yas-s-trim (s)
  14. "Remove whitespace at the beginning and end of S."
  15. (yas-s-trim-left (yas-s-trim-right s)))
  16. (defun yas-string-reverse (str)
  17. "Reverse a string STR manually to be compatible with emacs versions < 25."
  18. (apply #'string
  19. (reverse
  20. (string-to-list str))))
  21. (defun yas-trimmed-comment-start ()
  22. "This function returns `comment-start' trimmed by whitespaces."
  23. (yas-s-trim comment-start))
  24. (defun yas-trimmed-comment-end ()
  25. "This function returns `comment-end' trimmed by whitespaces if `comment-end' is not empty.
  26. Otherwise the reversed output of function `yas-trimmed-comment-start' is returned."
  27. (if (eq (length comment-end) 0)
  28. (yas-string-reverse (yas-trimmed-comment-start))
  29. (yas-s-trim comment-end)))