insert-checkin-template


/ Published in: Emacs Lisp
Save to your folder(s)

An example solution for the 'insert-checkin-template exercise listed here: http://stackoverflow.com/questions/41522/tips-for-learning-elisp/59589#59589

It generates a "pretty" check in notice to be emailed, and also generates a line you can cut/paste into a shell to check in a list of files.

Note, it relies on a previous example listed here: http://snipplr.com/view/18683/stringreplace/


Copy this code and paste it in your HTML
  1. (defun my-insert-checkin-form (branch type date priority description module files dependencies other)
  2. "Insert a checkin form string into current buffer.
  3. Called interactively, will prompt for fields."
  4. (interactive (list (read-string "Branch (default \"TOT\"): " nil nil "TOT")
  5. (read-string "Check-in Type: (default \"internal enhancement\"): " nil nil "internal enhancement")
  6. (format-time-string "%B %e, %Y")
  7. (read-string "Priority: " "med")
  8. (read-string "Description: ")
  9. (read-string "Module: ")
  10. (read-string "Files: ")
  11. ""
  12. ""))
  13. (let* ((deps-other-str (if (not (and (= 0 (length dependencies))
  14. (= 0 (length other))))
  15. (format "
  16. Dependencies: %s
  17. Other: %s
  18. " dependencies other)
  19. ""))
  20. (checkin-string-format (format "Branch: %%s
  21. Check-in Type: %%s
  22. When Ready: %%s
  23. Priority: %%s%s
  24. Description: %%s
  25. Module: %%s
  26. Files: %%s
  27. " deps-other-str))
  28. (checkin-cvs-format "cvs ci -m '%s' %s"))
  29.  
  30. ;; first insert the check-in notice
  31. (insert (format checkin-string-format branch type date priority description module (my-format-files-for-checkin-string files)))
  32. ;; put a few newlines in
  33. (insert "\n\n\n\n")
  34. ;; then insert a cvs commit line
  35. (insert (format checkin-cvs-format (concat type " " description) (my-format-files-for-checkin-cvs files)))))
  36.  
  37. ;; relies on string-replace http://snipplr.com/view/18683/stringreplace/
  38. (defun my-format-files-for-checkin-string (fstr)
  39. "replace all whitespace in string with a newline and 16 spaces"
  40. (string-replace "\\s-+" "
  41. " fstr t))
  42.  
  43. (defun my-format-files-for-checkin-cvs (fstr)
  44. "replace all whitespace in string with a space"
  45. (string-replace "\\s-+" " " fstr t))

URL: http://stackoverflow.com/questions/41522/tips-for-learning-elisp/59589#59589

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.