diff lisp/packages/add-log.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 56c54cf7c5b6
children 8619ce7e4c50
line wrap: on
line diff
--- a/lisp/packages/add-log.el	Mon Aug 13 09:00:04 2007 +0200
+++ b/lisp/packages/add-log.el	Mon Aug 13 09:02:59 2007 +0200
@@ -1,6 +1,6 @@
 ;;; add-log.el --- change log maintenance commands for Emacs
 
-;; Copyright (C) 1985, 86, 88, 93, 94, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1988, 1993, 1994 Free Software Foundation, Inc.
 
 ;; Keywords: maint
 
@@ -21,7 +21,7 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: Emacs 20.0.
+;;; Synched up with: FSF 19.34.
 
 ;;; Commentary:
 
@@ -53,37 +53,14 @@
   "*Electronic mail address of user, for inclusion in ChangeLog daily headers.
 This defaults to the value of `user-mail-address'.")
 
-;; XEmacs:
 ;; So that the dump-time value doesn't go into loaddefs.el with the autoload.
 (or add-log-mailing-address
     (setq add-log-mailing-address user-mail-address))
 
-
 (defvar change-log-font-lock-keywords
-  '(;;
-    ;; Date lines, new and old styles.
-    ("^\\sw.........[0-9: ]*"
-     (0 font-lock-string-face)
-     ("\\([^<]+\\)<\\([A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\\)>" nil nil
-      (1 font-lock-reference-face)
-      (2 font-lock-variable-name-face)))
-    ;;
-    ;; File names.
-    ("^\t\\* \\([^ ,:([\n]+\\)"
-     (1 font-lock-function-name-face)
-     ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 font-lock-function-name-face)))
-    ;;
-    ;; Function or variable names.
-    ("(\\([^ ,:\n]+\\)"
-     (1 font-lock-keyword-face)
-     ("\\=, \\([^ ,:\n]+\\)" nil nil (1 font-lock-keyword-face)))
-    ;;
-    ;; Conditionals.
-    ("\\[!?\\([^]\n]+\\)\\]\\(:\\| (\\)" (1 font-lock-variable-name-face))
-    ;;
-    ;; Acknowledgments.
-    ("^\t\\(From\\|Reported by\\)" 1 font-lock-comment-face)
-    )
+  '(("^[SMTWF].+" . font-lock-function-name-face)	; Date line.
+    ("^\t\\* \\([^ :\n]+\\)" 1 font-lock-comment-face)	; File name.
+    ("(\\([^)\n]+\\)):" 1 font-lock-keyword-face))	; Function name.
   "Additional expressions to highlight in Change Log mode.")
 (put 'change-log-mode 'font-lock-defaults
      '(change-log-font-lock-keywords t))
@@ -92,31 +69,16 @@
   "Keymap for Change Log major mode.")
 (if change-log-mode-map
     nil
-  (setq change-log-mode-map (make-sparse-keymap)))
-
-(defvar change-log-time-zone-rule nil
-  "Time zone used for calculating change log time stamps.
-It takes the same format as the TZ argument of `set-time-zone-rule'.
-If nil, use local time.")
-
-(defun iso8601-time-zone (time)
-  (let* ((utc-offset (or (car (current-time-zone time)) 0))
-	 (sign (if (< utc-offset 0) ?- ?+))
-	 (sec (abs utc-offset))
-	 (ss (% sec 60))
-	 (min (/ sec 60))
-	 (mm (% min 60))
-	 (hh (/ min 60)))
-    (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d")
-		  ((not (zerop mm)) "%c%02d:%02d")
-		  (t "%c%02d"))
-	    sign hh mm ss)))
+  (setq change-log-mode-map (make-sparse-keymap))
+  (define-key change-log-mode-map "\M-q" 'change-log-fill-paragraph))
 
 (defun change-log-name ()
   (or change-log-default-name
       (if (eq system-type 'vax-vms) 
-	  "$CHANGE_LOG$.TXT"
-	"ChangeLog")))
+	  "$CHANGE_LOG$.TXT" 
+	(if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
+	    "changelo"
+	  "ChangeLog"))))
 
 ;;;###autoload
 (defun prompt-for-change-log-name ()
@@ -200,8 +162,7 @@
 Second arg is file name of change log.  If nil, uses `change-log-default-name'.
 Third arg OTHER-WINDOW non-nil means visit in other window.
 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
-never append to an existing entry.  Today's date is calculated according to
-`change-log-time-zone-rule' if non-nil, otherwise in local time."
+never append to an existing entry."
   (interactive (list current-prefix-arg
 		     (prompt-for-change-log-name)))
   (or add-log-full-name
@@ -241,23 +202,14 @@
 	(change-log-mode))
     (undo-boundary)
     (goto-char (point-min))
-    (let ((new-entry (concat (if change-log-time-zone-rule
-				 (let ((tz (getenv "TZ"))
-				       (now (current-time)))
-				   (unwind-protect
-				       (progn
-					 (set-time-zone-rule
-					  change-log-time-zone-rule)
-					 (concat
-					  (format-time-string "%Y-%m-%d " now)
-					  (iso8601-time-zone now)))
-				     (set-time-zone-rule tz)))
-			       (format-time-string "%Y-%m-%d"))
-			     "  " add-log-full-name
-			     "  <" add-log-mailing-address ">")))
-      (if (looking-at (regexp-quote new-entry))
-	  (forward-line 1)
-	(insert new-entry "\n\n")))
+    (if (looking-at (concat (regexp-quote (substring (current-time-string)
+						     0 10))
+			    ".* " (regexp-quote add-log-full-name)
+			    "  <" (regexp-quote add-log-mailing-address)))
+	(forward-line 1)
+      (insert (current-time-string)
+	      "  " add-log-full-name
+	      "  <" add-log-mailing-address ">\n\n"))
 
     ;; Search only within the first paragraph.
     (if (looking-at "\n*[^\n* \t]")
@@ -330,6 +282,14 @@
   (add-change-log-entry whoami file-name t))
 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
 
+(defvar change-log-mode-map nil
+  "Keymap for Change Log major mode.")
+(if change-log-mode-map
+    nil
+  (setq change-log-mode-map (make-sparse-keymap))
+  (set-keymap-name change-log-mode-map 'change-log-mode-map)
+  (define-key change-log-mode-map "\M-q" 'change-log-fill-paragraph))
+
 ;;;###autoload
 (defun change-log-mode ()
   "Major mode for editing change logs; like Indented Text Mode.
@@ -347,21 +307,17 @@
 	indent-tabs-mode t
 	tab-width 8)
   (use-local-map change-log-mode-map)
-  (set (make-local-variable 'fill-paragraph-function)
-       'change-log-fill-paragraph)
   ;; Let each entry behave as one paragraph:
   ;; We really do want "^" in paragraph-start below: it is only the lines that
   ;; begin at column 0 (despite the left-margin of 8) that we are looking for.
-  (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\<")
-  (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\<")
+  (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\sw")
+  (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\sw")
   ;; Let all entries for one day behave as one page.
   ;; Match null string on the date-line so that the date-line
   ;; is grouped with what follows.
   (set (make-local-variable 'page-delimiter) "^\\<\\|^\f")
   (set (make-local-variable 'version-control) 'never)
   (set (make-local-variable 'adaptive-fill-regexp) "\\s *")
-  ;;(set (make-local-variable 'font-lock-defaults)
-       ;;'(change-log-font-lock-keywords t))
   (run-hooks 'change-log-mode-hook))
 
 ;; It might be nice to have a general feature to replace this.  The idea I
@@ -372,32 +328,16 @@
   "Fill the paragraph, but preserve open parentheses at beginning of lines.
 Prefix arg means justify as well."
   (interactive "P")
-  (let ((end (progn (forward-paragraph) (point)))
-	(beg (progn (backward-paragraph) (point)))
+  (let ((end (save-excursion (forward-paragraph) (point)))
+	(beg (save-excursion (backward-paragraph)(point)))
 	(paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
-    (fill-region beg end justify)
-    t))
+    (fill-region beg end justify)))
 
 (defvar add-log-current-defun-header-regexp
   "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[-_a-zA-Z]+\\)[ \t]*[:=]"
   "*Heuristic regexp used by `add-log-current-defun' for unknown major modes.")
 
 ;;;###autoload
-(defvar add-log-lisp-like-modes
-    '(emacs-lisp-mode lisp-mode scheme-mode lisp-interaction-mode)
-  "*Modes that look like Lisp to `add-log-current-defun'.")
-
-;;;###autoload
-(defvar add-log-c-like-modes
-    '(c-mode c++-mode c++-c-mode objc-mode)
-  "*Modes that look like C to `add-log-current-defun'.")
-
-;;;###autoload
-(defvar add-log-tex-like-modes
-    '(TeX-mode plain-TeX-mode LaTeX-mode plain-tex-mode latex-mode)
-  "*Modes that look like TeX to `add-log-current-defun'.")
-
-;;;###autoload
 (defun add-log-current-defun ()
   "Return name of function definition point is in, or nil.
 
@@ -413,7 +353,8 @@
   (condition-case nil
       (save-excursion
 	(let ((location (point)))
-	  (cond ((memq major-mode add-log-lisp-like-modes)
+	  (cond ((memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode
+						    lisp-interaction-mode))
 		 ;; If we are now precisely at the beginning of a defun,
 		 ;; make sure beginning-of-defun finds that one
 		 ;; rather than the previous one.
@@ -432,15 +373,14 @@
 		       (skip-chars-forward " '")
 		       (buffer-substring (point)
 					 (progn (forward-sexp 1) (point))))))
-		((and (memq major-mode add-log-c-like-modes)
-		      (save-excursion
-			(beginning-of-line)
-			;; Use eq instead of = here to avoid
-			;; error when at bob and char-after
-			;; returns nil.
-			(while (eq (char-after (- (point) 2)) ?\\)
-			  (forward-line -1))
-			(looking-at "[ \t]*#[ \t]*define[ \t]")))
+		((and (memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
+		      (save-excursion (beginning-of-line)
+				      ;; Use eq instead of = here to avoid
+				      ;; error when at bob and char-after
+				      ;; returns nil.
+				      (while (eq (char-after (- (point) 2)) ?\\)
+					(forward-line -1))
+				      (looking-at "[ \t]*#[ \t]*define[ \t]")))
 		 ;; Handle a C macro definition.
 		 (beginning-of-line)
 		 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
@@ -449,7 +389,7 @@
 		 (skip-chars-forward " \t")
 		 (buffer-substring (point)
 				   (progn (forward-sexp 1) (point))))
-		((memq major-mode add-log-c-like-modes)
+		((memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
 		 (beginning-of-line)
 		 ;; See if we are in the beginning part of a function,
 		 ;; before the open brace.  If so, advance forward.
@@ -544,7 +484,10 @@
 					(looking-at "struct \\|union \\|class ")
 					(setq middle (point)))
 				   (buffer-substring middle end)))))))))
-		((memq major-mode add-log-tex-like-modes)
+		((memq major-mode
+		       '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
+				  plain-tex-mode latex-mode;; cmutex.el
+				  ))
 		 (if (re-search-backward
 		      "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
 		     (progn