Guest User

Untitled

a guest
Jun 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. (progn
  2. ;; inserts hello name
  3. (defun hello (name)
  4. (insert (format "Hello %s!\n" name)))
  5. ;; calls hello with list of names in another window
  6. (defun greeting (names)
  7. (progn
  8. (switch-to-buffer-other-window "*test*")
  9. (erase-buffer)
  10. (mapcar 'hello names)
  11. (other-window 1)
  12. )
  13. )
  14. ;; replace hellos with a word
  15. (defun replace-hello (with)
  16. (progn
  17. (switch-to-buffer-other-window "*test*")
  18. (goto-char (point-min))
  19. (while (search-forward "Hello" nil t)
  20. (replace-match with))
  21. (other-window 1)))
  22. ;; search for word and add bold text properties
  23. (defun boldify-names (name)
  24. (progn
  25. (switch-to-buffer-other-window "*test*")
  26. (goto-char (point-min))
  27. (while (re-search-forward (format "%s \\(.+\\)!" name) nil t)
  28. (add-text-properties (match-beginning 1)
  29. (match-end 1)
  30. (list 'face 'bold)))
  31. (other-window 1)
  32. )
  33. )
  34. ;; run the functions
  35. (setq list-of-names '("chloe" "clare" "bob" "hope") list-of-last-names '("jones" "town" "city" "street"))
  36. (let ((replaced-name "Gutten Tag"))
  37. (push "steph" list-of-names)
  38. (greeting list-of-names)
  39. (replace-hello replaced-name)
  40. (boldify-names replaced-name)))
Add Comment
Please, Sign In to add comment