Revision: 17064
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 21, 2009 16:08 by bigfaceworm
Initial Code
(defun my-insert-checkin-form (branch type date priority description module files dependencies other)
"Insert a checkin form string into current buffer.
Called interactively, will prompt for fields."
(interactive (list (read-string "Branch (default \"TOT\"): " nil nil "TOT")
(read-string "Check-in Type: (default \"internal enhancement\"): " nil nil "internal enhancement")
(format-time-string "%B %e, %Y")
(read-string "Priority: " "med")
(read-string "Description: ")
(read-string "Module: ")
(read-string "Files: ")
""
""))
(let* ((deps-other-str (if (not (and (= 0 (length dependencies))
(= 0 (length other))))
(format "
Dependencies: %s
Other: %s
" dependencies other)
""))
(checkin-string-format (format "Branch: %%s
Check-in Type: %%s
When Ready: %%s
Priority: %%s%s
Description: %%s
Module: %%s
Files: %%s
" deps-other-str))
(checkin-cvs-format "cvs ci -m '%s' %s"))
;; first insert the check-in notice
(insert (format checkin-string-format branch type date priority description module (my-format-files-for-checkin-string files)))
;; put a few newlines in
(insert "\n\n\n\n")
;; then insert a cvs commit line
(insert (format checkin-cvs-format (concat type " " description) (my-format-files-for-checkin-cvs files)))))
;; relies on string-replace http://snipplr.com/view/18683/stringreplace/
(defun my-format-files-for-checkin-string (fstr)
"replace all whitespace in string with a newline and 16 spaces"
(string-replace "\\s-+" "
" fstr t))
(defun my-format-files-for-checkin-cvs (fstr)
"replace all whitespace in string with a space"
(string-replace "\\s-+" " " fstr t))
Initial URL
http://stackoverflow.com/questions/41522/tips-for-learning-elisp/59589#59589
Initial Description
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/
Initial Title
insert-checkin-template
Initial Tags
template
Initial Language
Emacs Lisp