aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2001-10-06 02:32:54 +0000
committerRichard M. Stallman2001-10-06 02:32:54 +0000
commitd882f144e7b70465bc9e5fdd7a572637a3411d4a (patch)
tree496664b77e3b79d7fa2cd2f66075f182d5755879
parent857e81db0f2cfe658ff88f1af5767c1d9318f206 (diff)
downloademacs-d882f144e7b70465bc9e5fdd7a572637a3411d4a.tar.gz
emacs-d882f144e7b70465bc9e5fdd7a572637a3411d4a.zip
(add-change-log-entry): Skip copyright notice
and copying permission notice at start of file, if any. Make use of terms "entry" and "item" accord with Emacs manual. Simplify the logic for moving point while entering or creating an entry and then an item. (add-change-log-entry-other-window): Doc fix.
-rw-r--r--lisp/add-log.el65
1 files changed, 39 insertions, 26 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el
index 61a29beda84..1d175ffe4a3 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -402,16 +402,23 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'."
402 402
403;;;###autoload 403;;;###autoload
404(defun add-change-log-entry (&optional whoami file-name other-window new-entry) 404(defun add-change-log-entry (&optional whoami file-name other-window new-entry)
405 "Find change log file and add an entry for today. 405 "Find change log file, and add an entry for today and an item for this file.
406Optional arg WHOAMI (interactive prefix) non-nil means prompt for user 406Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
407name and site. 407name and site.
408 408
409Second arg is FILE-NAME of change log. If nil, uses `change-log-default-name'. 409Second arg FILE-NAME is file name of the change log.
410If nil, use the value of `change-log-default-name'.
411
410Third arg OTHER-WINDOW non-nil means visit in other window. 412Third arg OTHER-WINDOW non-nil means visit in other window.
413
411Fourth arg NEW-ENTRY non-nil means always create a new entry at the front; 414Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
412never append to an existing entry. Option `add-log-keep-changes-together' 415never append to an existing entry. Option `add-log-keep-changes-together'
413otherwise affects whether a new entry is created. 416otherwise affects whether a new entry is created.
414 417
418The change log file can start with a copyright notice and a copying
419permission notice. The first blank line indicates the end of these
420notices.
421
415Today's date is calculated according to `change-log-time-zone-rule' if 422Today's date is calculated according to `change-log-time-zone-rule' if
416non-nil, otherwise in local time." 423non-nil, otherwise in local time."
417 (interactive (list current-prefix-arg 424 (interactive (list current-prefix-arg
@@ -439,8 +446,8 @@ non-nil, otherwise in local time."
439 (buffer-file (if buf-file-name (expand-file-name buf-file-name))) 446 (buffer-file (if buf-file-name (expand-file-name buf-file-name)))
440 (file-name (expand-file-name 447 (file-name (expand-file-name
441 (or file-name (find-change-log file-name buffer-file)))) 448 (or file-name (find-change-log file-name buffer-file))))
442 ;; Set ENTRY to the file name to use in the new entry. 449 ;; Set ITEM to the file name to use in the new item.
443 (entry (add-log-file-name buffer-file file-name)) 450 (item (add-log-file-name buffer-file file-name))
444 bound) 451 bound)
445 452
446 (if (or (and other-window (not (equal file-name buffer-file-name))) 453 (if (or (and other-window (not (equal file-name buffer-file-name)))
@@ -451,36 +458,47 @@ non-nil, otherwise in local time."
451 (change-log-mode)) 458 (change-log-mode))
452 (undo-boundary) 459 (undo-boundary)
453 (goto-char (point-min)) 460 (goto-char (point-min))
461
462 ;; If file starts with a copyright and permission notice, skip them.
463 ;; Assume they end at first blank line.
464 (when (looking-at "Copyright")
465 (search-forward "\n\n")
466 (skip-chars-forward "\n"))
467
468 ;; Advance into first entry if it is usable; else make new one.
454 (let ((new-entry (concat (funcall add-log-time-format) 469 (let ((new-entry (concat (funcall add-log-time-format)
455 " " add-log-full-name 470 " " add-log-full-name
456 " <" add-log-mailing-address ">"))) 471 " <" add-log-mailing-address ">")))
457 (if (looking-at (regexp-quote new-entry)) 472 (if (looking-at (regexp-quote new-entry))
458 (forward-line 1) 473 (forward-line 1)
459 (insert new-entry "\n\n"))) 474 (insert new-entry "\n\n")
475 (forward-line -1)))
460 476
477 ;; Determine where we should stop searching for a usable
478 ;; item to add to, within this entry.
461 (setq bound 479 (setq bound
462 (progn 480 (save-excursion
463 (if (looking-at "\n*[^\n* \t]") 481 (if (looking-at "\n*[^\n* \t]")
464 (skip-chars-forward "\n") 482 (skip-chars-forward "\n")
465 (if add-log-keep-changes-together 483 (if add-log-keep-changes-together
466 (forward-page) ; page delimits entries for date 484 (forward-page) ; page delimits entries for date
467 (forward-paragraph))) ; paragraph delimits entries for file 485 (forward-paragraph))) ; paragraph delimits entries for file
468 (point))) 486 (point)))
469 (goto-char (point-min)) 487
470 ;; Now insert the new line for this entry. 488 ;; Now insert the new line for this item.
471 (cond ((re-search-forward "^\\s *\\*\\s *$" bound t) 489 (cond ((re-search-forward "^\\s *\\*\\s *$" bound t)
472 ;; Put this file name into the existing empty entry. 490 ;; Put this file name into the existing empty item.
473 (if entry 491 (if item
474 (insert entry))) 492 (insert item)))
475 ((and (not new-entry) 493 ((and (not new-entry)
476 (let (case-fold-search) 494 (let (case-fold-search)
477 (re-search-forward 495 (re-search-forward
478 (concat (regexp-quote (concat "* " entry)) 496 (concat (regexp-quote (concat "* " item))
479 ;; Don't accept `foo.bar' when 497 ;; Don't accept `foo.bar' when
480 ;; looking for `foo': 498 ;; looking for `foo':
481 "\\(\\s \\|[(),:]\\)") 499 "\\(\\s \\|[(),:]\\)")
482 bound t))) 500 bound t)))
483 ;; Add to the existing entry for the same file. 501 ;; Add to the existing item for the same file.
484 (re-search-forward "^\\s *$\\|^\\s \\*") 502 (re-search-forward "^\\s *$\\|^\\s \\*")
485 (goto-char (match-beginning 0)) 503 (goto-char (match-beginning 0))
486 ;; Delete excess empty lines; make just 2. 504 ;; Delete excess empty lines; make just 2.
@@ -490,8 +508,7 @@ non-nil, otherwise in local time."
490 (forward-line -2) 508 (forward-line -2)
491 (indent-relative-maybe)) 509 (indent-relative-maybe))
492 (t 510 (t
493 ;; Make a new entry. 511 ;; Make a new item.
494 (forward-line 1)
495 (while (looking-at "\\sW") 512 (while (looking-at "\\sW")
496 (forward-line 1)) 513 (forward-line 1))
497 (while (and (not (eobp)) (looking-at "^\\s *$")) 514 (while (and (not (eobp)) (looking-at "^\\s *$"))
@@ -500,9 +517,9 @@ non-nil, otherwise in local time."
500 (forward-line -2) 517 (forward-line -2)
501 (indent-to left-margin) 518 (indent-to left-margin)
502 (insert "* ") 519 (insert "* ")
503 (if entry (insert entry)))) 520 (if item (insert item))))
504 ;; Now insert the function name, if we have one. 521 ;; Now insert the function name, if we have one.
505 ;; Point is at the entry for this file, 522 ;; Point is at the item for this file,
506 ;; either at the end of the line or at the first blank line. 523 ;; either at the end of the line or at the first blank line.
507 (if defun 524 (if defun
508 (progn 525 (progn
@@ -512,8 +529,8 @@ non-nil, otherwise in local time."
512 (beginning-of-line 1) 529 (beginning-of-line 1)
513 (looking-at "\\s *$")) 530 (looking-at "\\s *$"))
514 (insert ?\ )) 531 (insert ?\ ))
515 ;; See if the prev function name has a message yet or not 532 ;; See if the prev function name has a message yet or not.
516 ;; If not, merge the two entries. 533 ;; If not, merge the two items.
517 (let ((pos (point-marker))) 534 (let ((pos (point-marker)))
518 (if (and (skip-syntax-backward " ") 535 (if (and (skip-syntax-backward " ")
519 (skip-chars-backward "):") 536 (skip-chars-backward "):")
@@ -537,13 +554,9 @@ non-nil, otherwise in local time."
537 554
538;;;###autoload 555;;;###autoload
539(defun add-change-log-entry-other-window (&optional whoami file-name) 556(defun add-change-log-entry-other-window (&optional whoami file-name)
540 "Find change log file in other window and add an entry for today. 557 "Find change log file in other window and add entry and item.
541Optional arg WHOAMI (interactive prefix) non-nil means prompt for user 558This is just like `add-change-log-entry' except that it displays
542name and site. 559the change log file in another window."
543Second optional arg FILE-NAME is file name of change log.
544If nil, use `change-log-default-name'.
545
546Affected by the same options as `add-change-log-entry'."
547 (interactive (if current-prefix-arg 560 (interactive (if current-prefix-arg
548 (list current-prefix-arg 561 (list current-prefix-arg
549 (prompt-for-change-log-name)))) 562 (prompt-for-change-log-name))))