aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1998-04-17 20:27:32 +0000
committerDave Love1998-04-17 20:27:32 +0000
commit3697b8070ef045292eb77cbcc38a56b64f6c6e0c (patch)
tree65a36db8bca79015214cdbff07eff6d6e1f89dc0
parent786b07e8f5df204d579b2ec4ac6a8bbd99854ccd (diff)
downloademacs-3697b8070ef045292eb77cbcc38a56b64f6c6e0c.tar.gz
emacs-3697b8070ef045292eb77cbcc38a56b64f6c6e0c.zip
(change-log-mode): Revert 1997-12-03 doc change.
(add-change-log-entry): Replace 1997-12-03 changes with simple implementation of add-log-keep-changes-together. Doc fix. (change-log-add-make-room): Function deleted. (add-change-log-entry-other-window, change-log-mode, add-log-keep-changes-together): Doc fix. (add-log-lisp-like-modes): Add dsssl-mode. (add-log-current-defun): Generalize Fortran case.
-rw-r--r--lisp/add-log.el148
1 files changed, 68 insertions, 80 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el
index aa8e005b540..cb3873750c0 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -1,6 +1,6 @@
1;;; add-log.el --- change log maintenance commands for Emacs 1;;; add-log.el --- change log maintenance commands for Emacs
2 2
3;; Copyright (C) 1985, 86, 88, 93, 94, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1985, 86, 88, 93, 94, 97, 1998 Free Software Foundation, Inc.
4 4
5;; Keywords: tools 5;; Keywords: tools
6 6
@@ -27,9 +27,12 @@
27 27
28;;; Code: 28;;; Code:
29 29
30(eval-when-compile (require 'fortran))
31
30(defgroup change-log nil 32(defgroup change-log nil
31 "Change log maintenance" 33 "Change log maintenance"
32 :group 'tools 34 :group 'tools
35 :link '(custom-manual "(emacs)Change Log")
33 :prefix "change-log-" 36 :prefix "change-log-"
34 :prefix "add-log-") 37 :prefix "add-log-")
35 38
@@ -77,26 +80,34 @@ and `current-time-string' are two valid values."
77 :group 'change-log) 80 :group 'change-log)
78 81
79(defcustom add-log-keep-changes-together nil 82(defcustom add-log-keep-changes-together nil
80 "*If non-nil, then keep changes to the same file together. 83 "*If non-nil, normally keep day's log entries for one file together.
81If this variable is nil and you add log for (e.g.) two files, 84
82the change log entries are added cumulatively to the beginning of log. 85Log entries for a given file made with \\[add-change-log-entry] or
83This is the old behaviour: 86\\[add-change-log-entry-other-window] will only be added to others \
87for that file made
88today if this variable is non-nil or that file comes first in today's
89entries. Otherwise another entry for that file will be started. An
90original log:
91
92 * foo (...): ...
93 * bar (...): change 1
84 94
85 Wday Mon DD TIME YYYY 95in the latter case, \\[add-change-log-entry-other-window] in a \
96buffer visiting `bar', yields:
86 97
87 file A log2 << added this later 98 * bar (...): -!-
88 file B log1 99 * foo (...): ...
89 File A log1 100 * bar (...): change 1
90 101
91But if this variable is non-nil, then same file's changes are always kept 102and in the former:
92together. Notice that Log2 has been appended and it is the most recent
93for file A.
94 103
95 Wday Mon DD TIME YYYY 104 * foo (...): ...
105 * bar (...): change 1
106 (...): -!-
96 107
97 file B log1 108The NEW-ENTRY arg to `add-change-log-entry' can override the effect of
98 File A log1 109this variable."
99 file A log2 << Added this later" 110 :version "20.3"
100 :type 'boolean 111 :type 'boolean
101 :group 'change-log) 112 :group 'change-log)
102 113
@@ -248,19 +259,6 @@ current buffer to the complete file name."
248 (set (make-local-variable 'change-log-default-name) file-name) 259 (set (make-local-variable 'change-log-default-name) file-name)
249 file-name) 260 file-name)
250 261
251
252
253(defun change-log-add-make-room ()
254 "Begin a new empty change log entry at point."
255 ;; Delete excess empty lines; make just 2.
256 ;;
257 (while (and (not (eobp)) (looking-at "^\\s *$"))
258 (delete-region (point) (save-excursion (forward-line 1) (point))))
259 (insert "\n\n")
260 (forward-line -2)
261 (indent-relative-maybe)
262 )
263
264;;;###autoload 262;;;###autoload
265(defun add-change-log-entry (&optional whoami file-name other-window new-entry) 263(defun add-change-log-entry (&optional whoami file-name other-window new-entry)
266 "Find change log file and add an entry for today. 264 "Find change log file and add an entry for today.
@@ -270,8 +268,11 @@ name and site.
270Second arg is FILE-NAME of change log. If nil, uses `change-log-default-name'. 268Second arg is FILE-NAME of change log. If nil, uses `change-log-default-name'.
271Third arg OTHER-WINDOW non-nil means visit in other window. 269Third arg OTHER-WINDOW non-nil means visit in other window.
272Fourth arg NEW-ENTRY non-nil means always create a new entry at the front; 270Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
273never append to an existing entry. Today's date is calculated according to 271never append to an existing entry. Option `add-log-keep-changes-together'
274`change-log-time-zone-rule' if non-nil, otherwise in local time." 272otherwise affects whether a new entry is created.
273
274Today's date is calculated according to `change-log-time-zone-rule' if
275non-nil, otherwise in local time."
275 (interactive (list current-prefix-arg 276 (interactive (list current-prefix-arg
276 (prompt-for-change-log-name))) 277 (prompt-for-change-log-name)))
277 (or add-log-full-name 278 (or add-log-full-name
@@ -289,11 +290,8 @@ never append to an existing entry. Today's date is calculated according to
289 (read-input "Mailing address: " add-log-mailing-address)))) 290 (read-input "Mailing address: " add-log-mailing-address))))
290 (let ((defun (funcall (or add-log-current-defun-function 291 (let ((defun (funcall (or add-log-current-defun-function
291 'add-log-current-defun))) 292 'add-log-current-defun)))
292 today-end 293 bound entry)
293 paragraph-end
294 entry
295 294
296 )
297 (setq file-name (expand-file-name (find-change-log file-name))) 295 (setq file-name (expand-file-name (find-change-log file-name)))
298 296
299 ;; Set ENTRY to the file name to use in the new entry. 297 ;; Set ENTRY to the file name to use in the new entry.
@@ -321,30 +319,20 @@ never append to an existing entry. Today's date is calculated according to
321 (forward-line 1) 319 (forward-line 1)
322 (insert new-entry "\n\n"))) 320 (insert new-entry "\n\n")))
323 321
324 ;; Search only within the first paragraph. 322 (setq bound
325 (if (looking-at "\n*[^\n* \t]") 323 (progn
326 (skip-chars-forward "\n") 324 (if (looking-at "\n*[^\n* \t]")
327 (forward-paragraph 1)) 325 (skip-chars-forward "\n")
328 (setq paragraph-end (point)) 326 (if add-log-keep-changes-together
327 (forward-page) ; page delimits entries for date
328 (forward-paragraph))) ; paragraph delimits entries for file
329 (point)))
329 (goto-char (point-min)) 330 (goto-char (point-min))
330
331 ;; Today page's end point. Used in search boundary
332
333 (save-excursion
334 (goto-char (point-min)) ;Latest change log day
335 (forward-line 1)
336 (setq today-end
337 (if (re-search-forward "^[^ \t\n]" nil t) ;Seek to next day's hdr
338 (match-beginning 0)
339 (point-max)))) ;No next day, use point max
340
341 ;; Now insert the new line for this entry. 331 ;; Now insert the new line for this entry.
342 (cond ((re-search-forward "^\\s *\\*\\s *$" paragraph-end t) 332 (cond ((re-search-forward "^\\s *\\*\\s *$" bound t)
343 ;; Put this file name into the existing empty entry. 333 ;; Put this file name into the existing empty entry.
344 (if entry 334 (if entry
345 (insert entry)) 335 (insert entry)))
346 )
347
348 ((and (not new-entry) 336 ((and (not new-entry)
349 (let (case-fold-search) 337 (let (case-fold-search)
350 (re-search-forward 338 (re-search-forward
@@ -352,24 +340,16 @@ never append to an existing entry. Today's date is calculated according to
352 ;; Don't accept `foo.bar' when 340 ;; Don't accept `foo.bar' when
353 ;; looking for `foo': 341 ;; looking for `foo':
354 "\\(\\s \\|[(),:]\\)") 342 "\\(\\s \\|[(),:]\\)")
355 paragraph-end t))) 343 bound t)))
356 ;; Add to the existing entry for the same file. 344 ;; Add to the existing entry for the same file.
357 (re-search-forward "^\\s *$\\|^\\s \\*") 345 (re-search-forward "^\\s *$\\|^\\s \\*")
358 (goto-char (match-beginning 0)) 346 (goto-char (match-beginning 0))
359 (change-log-add-make-room) 347 ;; Delete excess empty lines; make just 2.
360 ) 348 (while (and (not (eobp)) (looking-at "^\\s *$"))
361 349 (delete-region (point) (save-excursion (forward-line 1) (point))))
362 ;; See if there is existing entry and append to it. 350 (insert "\n\n")
363 ;; * file.txt: 351 (forward-line -2)
364 ;; 352 (indent-relative-maybe))
365 ((and add-log-keep-changes-together ;enabled ?
366 (re-search-forward (regexp-quote (concat "* " entry))
367 today-end t))
368 (re-search-forward "^\\s *$\\|^\\s \\*")
369 (goto-char (match-beginning 0))
370 (change-log-add-make-room)
371 )
372
373 (t 353 (t
374 ;; Make a new entry. 354 ;; Make a new entry.
375 (forward-line 1) 355 (forward-line 1)
@@ -405,8 +385,10 @@ never append to an existing entry. Today's date is calculated according to
405 "Find change log file in other window and add an entry for today. 385 "Find change log file in other window and add an entry for today.
406Optional arg WHOAMI (interactive prefix) non-nil means prompt for user 386Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
407name and site. 387name and site.
408Second arg is file name of change log. \ 388Second optional arg FILE-NAME is file name of change log.
409If nil, uses `change-log-default-name'." 389If nil, use `change-log-default-name'.
390
391Affected by the same options as `add-change-log-entry'."
410 (interactive (if current-prefix-arg 392 (interactive (if current-prefix-arg
411 (list current-prefix-arg 393 (list current-prefix-arg
412 (prompt-for-change-log-name)))) 394 (prompt-for-change-log-name))))
@@ -417,7 +399,7 @@ If nil, uses `change-log-default-name'."
417(defun change-log-mode () 399(defun change-log-mode ()
418 "Major mode for editing change logs; like Indented Text Mode. 400 "Major mode for editing change logs; like Indented Text Mode.
419Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74. 401Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74.
420New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-before-other-window]. 402New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window].
421Each entry behaves as a paragraph, and the entries for one day as a page. 403Each entry behaves as a paragraph, and the entries for one day as a page.
422Runs `change-log-mode-hook'." 404Runs `change-log-mode-hook'."
423 (interactive) 405 (interactive)
@@ -469,7 +451,7 @@ Prefix arg means justify as well."
469 451
470;;;###autoload 452;;;###autoload
471(defvar add-log-lisp-like-modes 453(defvar add-log-lisp-like-modes
472 '(emacs-lisp-mode lisp-mode scheme-mode lisp-interaction-mode) 454 '(emacs-lisp-mode lisp-mode scheme-mode dsssl-mode lisp-interaction-mode)
473 "*Modes that look like Lisp to `add-log-current-defun'.") 455 "*Modes that look like Lisp to `add-log-current-defun'.")
474 456
475;;;###autoload 457;;;###autoload
@@ -646,25 +628,31 @@ Has a preference of looking backwards."
646 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t) 628 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t)
647 (buffer-substring (match-beginning 1) 629 (buffer-substring (match-beginning 1)
648 (match-end 1)))) 630 (match-end 1))))
649 ((eq major-mode 'fortran-mode) 631 ((or (eq major-mode 'fortran-mode)
632 ;; Needs work for f90, but better than nothing.
633 (eq major-mode 'f90-mode))
650 ;; must be inside function body for this to work 634 ;; must be inside function body for this to work
651 (beginning-of-fortran-subprogram) 635 (beginning-of-fortran-subprogram)
652 (let ((case-fold-search t)) ; case-insensitive 636 (let ((case-fold-search t)) ; case-insensitive
653 ;; search for fortran subprogram start 637 ;; search for fortran subprogram start
654 (if (re-search-forward 638 (if (re-search-forward
655 "^[ \t]*\\(program\\|subroutine\\|function\ 639 "^[ \t]*\\(program\\|subroutine\\|function\
656\\|[ \ta-z0-9*]*[ \t]+function\\)" 640\\|[ \ta-z0-9*()]*[ \t]+function\\|\\(block[ \t]*data\\)\\)"
657 nil t) 641 (progn (end-of-fortran-subprogram)
642 (point))
643 t)
644 (or (match-string 2)
658 (progn 645 (progn
659 ;; move to EOL or before first left paren 646 ;; move to EOL or before first left paren
660 (if (re-search-forward "[(\n]" nil t) 647 (if (re-search-forward "[(\n]" nil t)
661 (progn (forward-char -1) 648 (progn (backward-char)
662 (skip-chars-backward " \t")) 649 (skip-chars-backward " \t"))
663 (end-of-line)) 650 (end-of-line))
664 ;; Use the name preceding that. 651 ;; Use the name preceding that.
665 (buffer-substring (point) 652 (buffer-substring (point)
666 (progn (forward-sexp -1) 653 (progn (backward-sexp)
667 (point))))))) 654 (point)))))
655 "main")))
668 (t 656 (t
669 ;; If all else fails, try heuristics 657 ;; If all else fails, try heuristics
670 (let (case-fold-search) 658 (let (case-fold-search)