home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / packages / add-log.el next >
Encoding:
Text File  |  1992-06-29  |  3.4 KB  |  91 lines

  1. ;; Change log maintenance commands for Emacs
  2. ;; Copyright (C) 1985 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 1, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. (defun prompt-for-change-log-name ()
  22.   "Prompt for a change log name."
  23.   (let ((default
  24.       (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog")))
  25.     (expand-file-name
  26.      (read-file-name (format "Log file (default %s): " default)
  27.              nil default))))
  28.  
  29. (defun add-change-log-entry (whoami file-name &optional other-window)
  30.   "Find change log file and add an entry for today.
  31. First arg (interactive prefix) non-nil means prompt for user name and site.
  32. Second arg is file name of change log.
  33. Optional third arg OTHER-WINDOW non-nil means visit in other window."
  34.   (interactive
  35.    (list current-prefix-arg
  36.      (prompt-for-change-log-name)))
  37.   (let* ((default
  38.        (if (eq system-type 'vax-vms)
  39.            "$CHANGE_LOG$.TXT" "ChangeLog"))
  40.      (full-name (if whoami
  41.             (read-input "Full name: " (user-full-name))
  42.               (user-full-name)))
  43.      ;; Note that some sites have room and phone number fields in
  44.      ;; full name which look silly when inserted.  Rather than do
  45.      ;; anything about that here, let user give prefix argument so that
  46.      ;; s/he can edit the full name field in prompter if s/he wants.
  47.      (login-name (if whoami
  48.              (read-input "Login name: " (user-login-name))
  49.                (user-login-name)))
  50.      (site-name (if whoami
  51.             (read-input "Site name: " (system-name))
  52.               (system-name))))
  53.     (if (file-directory-p file-name)
  54.     (setq file-name (concat (file-name-as-directory file-name)
  55.                 default)))
  56.     (if (and other-window (not (equal file-name buffer-file-name)))
  57.     (find-file-other-window file-name)
  58.       (find-file file-name))
  59.     (undo-boundary)
  60.     (goto-char (point-min))
  61.     (if (not (and (looking-at (substring (current-time-string) 0 10))
  62.           (looking-at (concat ".* " full-name "  (" login-name " at"))))
  63.     (progn (insert (current-time-string)
  64.                "  " full-name
  65.                "  (" login-name
  66.                " at " site-name ")\n\n")))
  67.     (goto-char (point-min))
  68.     (forward-line 1)
  69.     (while (looking-at "\\sW")
  70.       (forward-line 1))
  71.     (delete-region (point)
  72.            (progn
  73.              (skip-chars-backward "\n")
  74.              (point)))
  75.     (open-line 3)
  76.     (forward-line 2)
  77.     (indent-to left-margin)
  78.     (insert "* ")))
  79.  
  80. (defun add-change-log-entry-other-window (whoami file-name)
  81.   "Find change log file and add an entry for today.
  82. First arg (interactive prefix) non-nil means prompt for user name and site.
  83. Second arg is file name of change log.
  84. Interactively, with a prefix argument, the file name is prompted for."
  85. ;  "Find change log file in other window, and add an entry for today."
  86.   (interactive (if current-prefix-arg
  87.            (list current-prefix-arg
  88.              (prompt-for-change-log-name))
  89.          (list nil default-directory)))
  90.   (add-change-log-entry whoami file-name t))
  91.