add-log.el 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ;; Change log maintenance commands for Emacs
  2. ;; Copyright (C) 1985 Free Software Foundation, Inc.
  3. ;; This file is part of GNU Emacs.
  4. ;; GNU Emacs is distributed in the hope that it will be useful,
  5. ;; but WITHOUT ANY WARRANTY. No author or distributor
  6. ;; accepts responsibility to anyone for the consequences of using it
  7. ;; or for whether it serves any particular purpose or works at all,
  8. ;; unless he says so in writing. Refer to the GNU Emacs General Public
  9. ;; License for full details.
  10. ;; Everyone is granted permission to copy, modify and redistribute
  11. ;; GNU Emacs, but only under the conditions described in the
  12. ;; GNU Emacs General Public License. A copy of this license is
  13. ;; supposed to have been given to you along with GNU Emacs so you
  14. ;; can know your rights and responsibilities. It should be in a
  15. ;; file named COPYING. Among other things, the copyright notice
  16. ;; and this notice must be preserved on all copies.
  17. ;; >> Potential lossage if two people edit change log at same time.
  18. ;; >> Maybe should lock file and unlock when written out.
  19. (defun add-change-log-entry (&optional whoami)
  20. "Find change log file and add an entry for today.
  21. With ARG, prompt for name and site of person."
  22. (interactive "P")
  23. (let* ((default (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog"))
  24. (full-name (if whoami
  25. (read-input "Full name: " (user-full-name))
  26. (user-full-name)))
  27. ;; Note that some sites have room and phone number fields in
  28. ;; full name which look silly when inserted. Rather than do
  29. ;; anything about that here, let user give prefix argument so that
  30. ;; s/he can edit the full name field in prompter if s/he wants.
  31. (login-name (if whoami
  32. (read-input "Login name: " (user-login-name))
  33. (user-login-name)))
  34. (site-name (if whoami
  35. (read-input "Site name: " (system-name))
  36. (system-name)))
  37. (file-name (expand-file-name
  38. (read-file-name (format "Log file (default %s): " default)
  39. nil default))))
  40. (if (file-directory-p file-name)
  41. (setq file-name (concat (file-name-as-directory file-name)
  42. default)))
  43. (find-file file-name)
  44. (or (eq major-mode 'indented-text-mode)
  45. (progn
  46. (indented-text-mode)
  47. (setq left-margin 8)
  48. (setq fill-column 74)))
  49. (auto-fill-mode 1)
  50. (goto-char (point-min))
  51. (if (not (and (looking-at (substring (current-time-string) 0 10))
  52. (save-excursion (re-search-forward "(.* at")
  53. (skip-chars-backward "^(")
  54. (looking-at login-name))))
  55. (progn (insert (current-time-string)
  56. " " full-name
  57. " (" login-name
  58. " at " site-name ")\n\n")))
  59. (goto-char (point-min))
  60. (forward-line 1)
  61. (while (looking-at "\\sW")
  62. (forward-line 1))
  63. (delete-region (point)
  64. (progn
  65. (skip-chars-backward "\n")
  66. (point)))
  67. (open-line 3)
  68. (forward-line 2)
  69. (indent-to left-margin)
  70. (insert "* ")))