comparison lisp/add-log.el @ 28446:28009885f082

Don't require cl, fortran. (add-log-current-defun-function): Doc fix. (change-log-version-number-regexp-list): Remove SCCS stuff. Doc fix. (change-log-mode-map): Defvar directly. (change-log-version-rcs): Function deleted. (change-log-version-number-search): Doc fix.
author Dave Love <fx@gnu.org>
date Fri, 31 Mar 2000 16:00:08 +0000
parents c11a0bbb5c88
children e5643646a988
comparison
equal deleted inserted replaced
28445:765d0ff9037d 28446:28009885f082
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, 97, 1998, 2000 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985, 86, 88, 93, 94, 97, 98, 2000 Free Software Foundation, Inc.
4 4
5 ;; Keywords: tools 5 ;; Keywords: tools
6 6
7 ;; This file is part of GNU Emacs. 7 ;; This file is part of GNU Emacs.
8 8
26 ;; This facility is documented in the Emacs Manual. 26 ;; This facility is documented in the Emacs Manual.
27 27
28 ;;; Code: 28 ;;; Code:
29 29
30 (eval-when-compile 30 (eval-when-compile
31 (require 'fortran) 31 (require 'timezone))
32 (require 'timezone)
33 (require 'cl))
34 32
35 (defgroup change-log nil 33 (defgroup change-log nil
36 "Change log maintenance" 34 "Change log maintenance"
37 :group 'tools 35 :group 'tools
38 :link '(custom-manual "(emacs)Change Log") 36 :link '(custom-manual "(emacs)Change Log")
50 "Normal hook run by `change-log-mode'." 48 "Normal hook run by `change-log-mode'."
51 :type 'hook 49 :type 'hook
52 :group 'change-log) 50 :group 'change-log)
53 51
54 (defcustom add-log-current-defun-function nil 52 (defcustom add-log-current-defun-function nil
55 "\ 53 "*If non-nil, function to guess name of surrounding function.
56 *If non-nil, function to guess name of current function from surrounding text. 54 It is used by `add-log-current-defun' in preference to built-in rules.
57 \\[add-change-log-entry] calls this function (if nil, `add-log-current-defun' 55 Returns function's name as a string, or nil if outside a function."
58 instead) with no arguments. It returns a string or nil if it cannot guess."
59 :type 'function 56 :type 'function
60 :group 'change-log) 57 :group 'change-log)
61 58
62 ;;;###autoload 59 ;;;###autoload
63 (defcustom add-log-full-name nil 60 (defcustom add-log-full-name nil
138 (let ((re "\\([0-9]+\.[0-9.]+\\)")) 135 (let ((re "\\([0-9]+\.[0-9.]+\\)"))
139 (list 136 (list
140 ;; (defconst ad-version "2.15" 137 ;; (defconst ad-version "2.15"
141 (concat "^(def[^ \t\n]+[ \t]+[^ \t\n][ \t]\"" re) 138 (concat "^(def[^ \t\n]+[ \t]+[^ \t\n][ \t]\"" re)
142 ;; Revision: pcl-cvs.el,v 1.72 1999/09/05 20:21:54 monnier Exp 139 ;; Revision: pcl-cvs.el,v 1.72 1999/09/05 20:21:54 monnier Exp
143 (concat "^;+ *Revision: +[^ \t\n]+[ \t]+" re) 140 (concat "^;+ *Revision: +[^ \t\n]+[ \t]+" re)))
144 ;; SCCS @(#)igrep.el 2.83
145 (concat "SCCS[ \t]+@(#).*[ \t]+" re)
146 ))
147 "*List of regexps to search for version number. 141 "*List of regexps to search for version number.
142 The version number must be in group 1.
148 Note: The search is conducted only within 10%, at the beginning of the file." 143 Note: The search is conducted only within 10%, at the beginning of the file."
149 :version "21.1" 144 :version "21.1"
150 :type '(repeat regexp) 145 :type '(repeat regexp)
151 :group 'change-log) 146 :group 'change-log)
152 147
183 1 font-lock-comment-face) 178 1 font-lock-comment-face)
184 (" \\(From\\|Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)" 179 (" \\(From\\|Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)"
185 1 font-lock-comment-face)) 180 1 font-lock-comment-face))
186 "Additional expressions to highlight in Change Log mode.") 181 "Additional expressions to highlight in Change Log mode.")
187 182
188 (defvar change-log-mode-map nil 183 (defvar change-log-mode-map (make-sparse-keymap)
189 "Keymap for Change Log major mode.") 184 "Keymap for Change Log major mode.")
190 (if change-log-mode-map
191 nil
192 (setq change-log-mode-map (make-sparse-keymap)))
193 185
194 (defvar change-log-time-zone-rule nil 186 (defvar change-log-time-zone-rule nil
195 "Time zone used for calculating change log time stamps. 187 "Time zone used for calculating change log time stamps.
196 It takes the same format as the TZ argument of `set-time-zone-rule'. 188 It takes the same format as the TZ argument of `set-time-zone-rule'.
197 If nil, use local time.") 189 If nil, use local time.")
246 (if (file-directory-p name) 238 (if (file-directory-p name)
247 (expand-file-name (file-name-nondirectory default) 239 (expand-file-name (file-name-nondirectory default)
248 (file-name-as-directory name)) 240 (file-name-as-directory name))
249 name)))) 241 name))))
250 242
251 (defun change-log-version-rcs (rcs-string &optional end)
252 "Search for plain RCS-STRING from whole buffer up till END.
253 The surrounding $ characters fro RCS-STRING are added in this function;
254 provide argument e.g. as \"Id\"."
255 (let (str)
256 (save-excursion
257 (goto-char (point-min))
258 (when (re-search-forward
259 (concat "[$]" rcs-string ":[^\n$]+[$]")
260 end t)
261 (setq str (match-string 0))
262 (when (string-match "[0-9]+\.[0-9.]+" str)
263 (match-string 0 str))))))
264
265 (defun change-log-version-number-search () 243 (defun change-log-version-number-search ()
266 "Return version number for the file by searchin version control tags." 244 "Return version number of current buffer's file.
245 This is the value returned by `vc-workfile-version' or, if that is
246 nil, by matching `change-log-version-number-regexp-list'."
267 (let* ((size (buffer-size)) 247 (let* ((size (buffer-size))
268 (end 248 (end
269 ;; The version number can be anywhere in the file, but restrict 249 ;; The version number can be anywhere in the file, but
270 ;; search to the file beginning: 10% should be enough to prevent 250 ;; restrict search to the file beginning: 10% should be
271 ;; some mishits. 251 ;; enough to prevent some mishits.
272 ;; 252 ;;
273 ;; Apply percentage only if buffer size is bigger than approx 100 lines 253 ;; Apply percentage only if buffer size is bigger than
254 ;; approx 100 lines.
274 (if (> size (* 100 80)) 255 (if (> size (* 100 80))
275 (/ (* (buffer-size) 10) 100) 256 (/ size 10)
276 size)) 257 size))
277 version) 258 version)
278 259 (or (and buffer-file-name
279 ;; Search RCS, CVS version strings 260 (vc-workfile-version buffer-file-name))
280 261 (save-restriction
281 (dolist (choice '("Revision" "Id")) 262 (widen)
282 (when (setq version (change-log-version-rcs choice end)) 263 (let ((regexps change-log-version-number-regexp-list))
283 (return))) 264 (while regexps
284 265 (save-excursion
285 (unless version 266 (goto-char (point-min))
286 (dolist (regexp change-log-version-number-regexp-list) 267 (when (re-search-forward (pop regexps) end t)
287 (save-excursion 268 (setq version (match-string 1)
288 (goto-char (point-min)) 269 regexps nil)))))))))
289 (when (re-search-forward regexp end t)
290 (setq version (match-string 1))
291 (return)))))
292
293 version
294 ))
295 270
296 271
297 ;;;###autoload 272 ;;;###autoload
298 (defun find-change-log (&optional file-name) 273 (defun find-change-log (&optional file-name)
299 "Find a change log file for \\[add-change-log-entry] and return the name. 274 "Find a change log file for \\[add-change-log-entry] and return the name.
378 ;; full name which look silly when inserted. Rather than do 353 ;; full name which look silly when inserted. Rather than do
379 ;; anything about that here, let user give prefix argument so that 354 ;; anything about that here, let user give prefix argument so that
380 ;; s/he can edit the full name field in prompter if s/he wants. 355 ;; s/he can edit the full name field in prompter if s/he wants.
381 (setq add-log-mailing-address 356 (setq add-log-mailing-address
382 (read-input "Mailing address: " add-log-mailing-address)))) 357 (read-input "Mailing address: " add-log-mailing-address))))
383 (let ((defun (funcall (or add-log-current-defun-function 358 (let ((defun (add-log-current-defun))
384 'add-log-current-defun)))
385 (version (and change-log-version-info-enabled 359 (version (and change-log-version-info-enabled
386 (change-log-version-number-search))) 360 (change-log-version-number-search)))
387 bound 361 bound entry)
388 entry)
389 362
390 (setq file-name (expand-file-name (find-change-log file-name))) 363 (setq file-name (expand-file-name (find-change-log file-name)))
391 364
392 ;; Set ENTRY to the file name to use in the new entry. 365 ;; Set ENTRY to the file name to use in the new entry.
393 (and buffer-file-name 366 (and buffer-file-name
448 ;; Add to the existing entry for the same file. 421 ;; Add to the existing entry for the same file.
449 (re-search-forward "^\\s *$\\|^\\s \\*") 422 (re-search-forward "^\\s *$\\|^\\s \\*")
450 (goto-char (match-beginning 0)) 423 (goto-char (match-beginning 0))
451 ;; Delete excess empty lines; make just 2. 424 ;; Delete excess empty lines; make just 2.
452 (while (and (not (eobp)) (looking-at "^\\s *$")) 425 (while (and (not (eobp)) (looking-at "^\\s *$"))
453 (delete-region (point) (save-excursion (forward-line 1) (point)))) 426 (delete-region (point) (line-beginning-position 2)))
454 (insert "\n\n") 427 (insert "\n\n")
455 (forward-line -2) 428 (forward-line -2)
456 (indent-relative-maybe)) 429 (indent-relative-maybe))
457 (t 430 (t
458 ;; Make a new entry. 431 ;; Make a new entry.
459 (forward-line 1) 432 (forward-line 1)
460 (while (looking-at "\\sW") 433 (while (looking-at "\\sW")
461 (forward-line 1)) 434 (forward-line 1))
462 (while (and (not (eobp)) (looking-at "^\\s *$")) 435 (while (and (not (eobp)) (looking-at "^\\s *$"))
463 (delete-region (point) (save-excursion (forward-line 1) (point)))) 436 (delete-region (point) (line-beginning-position 2)))
464 (insert "\n\n\n") 437 (insert "\n\n\n")
465 (forward-line -2) 438 (forward-line -2)
466 (indent-to left-margin) 439 (indent-to left-margin)
467 (insert "* " (or entry "")) 440 (insert "* " (or entry ""))))
468 ))
469 ;; Now insert the function name, if we have one. 441 ;; Now insert the function name, if we have one.
470 ;; Point is at the entry for this file, 442 ;; Point is at the entry for this file,
471 ;; either at the end of the line or at the first blank line. 443 ;; either at the end of the line or at the first blank line.
472 (if defun 444 (if defun
473 (progn 445 (progn
474 ;; Make it easy to get rid of the function name. 446 ;; Make it easy to get rid of the function name.
475 (undo-boundary) 447 (undo-boundary)
476 (insert (if (save-excursion 448 (unless (save-excursion
477 (beginning-of-line 1) 449 (beginning-of-line 1)
478 (looking-at "\\s *$")) 450 (looking-at "\\s *$"))
479 "" 451 (insert ?\ ))
480 " ") 452 (insert "(" defun "): ")
481 "(" defun "): " 453 (if version
482 (if version 454 (insert version ?\ )))
483 (concat version " ")
484 "")))
485 ;; No function name, so put in a colon unless we have just a star. 455 ;; No function name, so put in a colon unless we have just a star.
486 (if (not (save-excursion 456 (unless (save-excursion
487 (beginning-of-line 1) 457 (beginning-of-line 1)
488 (looking-at "\\s *\\(\\*\\s *\\)?$"))) 458 (looking-at "\\s *\\(\\*\\s *\\)?$"))
489 (insert ": " 459 (insert ": ")
490 (if version 460 (if version (insert version ?\ ))))))
491 (concat version " ") ""))))))
492 461
493 ;;;###autoload 462 ;;;###autoload
494 (defun add-change-log-entry-other-window (&optional whoami file-name) 463 (defun add-change-log-entry-other-window (&optional whoami file-name)
495 "Find change log file in other window and add an entry for today. 464 "Find change log file in other window and add an entry for today.
496 Optional arg WHOAMI (interactive prefix) non-nil means prompt for user 465 Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
577 ;;;###autoload 546 ;;;###autoload
578 (defun add-log-current-defun () 547 (defun add-log-current-defun ()
579 "Return name of function definition point is in, or nil. 548 "Return name of function definition point is in, or nil.
580 549
581 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...), 550 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...),
582 Texinfo (@node titles), Perl, and Fortran. 551 Texinfo (@node titles) and Perl.
583 552
584 Other modes are handled by a heuristic that looks in the 10K before 553 Other modes are handled by a heuristic that looks in the 10K before
585 point for uppercase headings starting in the first column or 554 point for uppercase headings starting in the first column or
586 identifiers followed by `:' or `=', see variables 555 identifiers followed by `:' or `='. See variables
587 `add-log-current-defun-header-regexp' and 556 `add-log-current-defun-header-regexp' and
588 `add-log-current-defun-function' 557 `add-log-current-defun-function'
589 558
590 Has a preference of looking backwards." 559 Has a preference of looking backwards."
591 (condition-case nil 560 (condition-case nil
592 (save-excursion 561 (save-excursion
593 (let ((location (point))) 562 (let ((location (point)))
594 (cond ((and (functionp add-log-current-defun-function) 563 (cond (add-log-current-defun-function
595 (funcall add-log-current-defun-function))) 564 (funcall add-log-current-defun-function))
596 ((memq major-mode add-log-lisp-like-modes) 565 ((memq major-mode add-log-lisp-like-modes)
597 ;; If we are now precisely at the beginning of a defun, 566 ;; If we are now precisely at the beginning of a defun,
598 ;; make sure beginning-of-defun finds that one 567 ;; make sure beginning-of-defun finds that one
599 ;; rather than the previous one. 568 ;; rather than the previous one.
600 (or (eobp) (forward-char 1)) 569 (or (eobp) (forward-char 1))
601 (beginning-of-defun) 570 (beginning-of-defun)
602 ;; Make sure we are really inside the defun found, not after it. 571 ;; Make sure we are really inside the defun found,
572 ;; not after it.
603 (when (and (looking-at "\\s(") 573 (when (and (looking-at "\\s(")
604 (progn (end-of-defun) 574 (progn (end-of-defun)
605 (< location (point))) 575 (< location (point)))
606 (progn (forward-sexp -1) 576 (progn (forward-sexp -1)
607 (>= location (point)))) 577 (>= location (point))))
611 ;; or "defvar". 581 ;; or "defvar".
612 (forward-sexp 1) 582 (forward-sexp 1)
613 ;; The second element is usually a symbol being defined. 583 ;; The second element is usually a symbol being defined.
614 ;; If it is not, use the first symbol in it. 584 ;; If it is not, use the first symbol in it.
615 (skip-chars-forward " \t\n'(") 585 (skip-chars-forward " \t\n'(")
616 (buffer-substring (point) 586 (buffer-substring-no-properties (point)
617 (progn (forward-sexp 1) 587 (progn (forward-sexp 1)
618 (point))))) 588 (point)))))
619 ((and (memq major-mode add-log-c-like-modes) 589 ((and (memq major-mode add-log-c-like-modes)
620 (save-excursion 590 (save-excursion
621 (beginning-of-line) 591 (beginning-of-line)
622 ;; Use eq instead of = here to avoid 592 ;; Use eq instead of = here to avoid
623 ;; error when at bob and char-after 593 ;; error when at bob and char-after
629 (beginning-of-line) 599 (beginning-of-line)
630 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above 600 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
631 (forward-line -1)) 601 (forward-line -1))
632 (search-forward "define") 602 (search-forward "define")
633 (skip-chars-forward " \t") 603 (skip-chars-forward " \t")
634 (buffer-substring (point) 604 (buffer-substring-no-properties (point)
635 (progn (forward-sexp 1) (point)))) 605 (progn (forward-sexp 1)
606 (point))))
636 ((memq major-mode add-log-c-like-modes) 607 ((memq major-mode add-log-c-like-modes)
637 (beginning-of-line) 608 (beginning-of-line)
638 ;; See if we are in the beginning part of a function, 609 ;; See if we are in the beginning part of a function,
639 ;; before the open brace. If so, advance forward. 610 ;; before the open brace. If so, advance forward.
640 (while (not (looking-at "{\\|\\(\\s *$\\)")) 611 (while (not (looking-at "{\\|\\(\\s *$\\)"))
641 (forward-line 1)) 612 (forward-line 1))
642 (or (eobp) 613 (or (eobp)
643 (forward-char 1)) 614 (forward-char 1))
644 (beginning-of-defun) 615 (beginning-of-defun)
645 (if (progn (end-of-defun) 616 (when (progn (end-of-defun)
646 (< location (point))) 617 (< location (point)))
647 (progn 618 (backward-sexp 1)
648 (backward-sexp 1) 619 (let (beg tem)
649 (let (beg tem) 620
650 621 (forward-line -1)
651 (forward-line -1) 622 ;; Skip back over typedefs of arglist.
652 ;; Skip back over typedefs of arglist. 623 (while (and (not (bobp))
653 (while (and (not (bobp)) 624 (looking-at "[ \t\n]"))
654 (looking-at "[ \t\n]")) 625 (forward-line -1))
655 (forward-line -1)) 626 ;; See if this is using the DEFUN macro used in Emacs,
656 ;; See if this is using the DEFUN macro used in Emacs, 627 ;; or the DEFUN macro used by the C library.
657 ;; or the DEFUN macro used by the C library. 628 (if (condition-case nil
658 (if (condition-case nil 629 (and (save-excursion
659 (and (save-excursion 630 (end-of-line)
660 (end-of-line) 631 (while (= (preceding-char) ?\\)
661 (while (= (preceding-char) ?\\) 632 (end-of-line 2))
662 (end-of-line 2)) 633 (backward-sexp 1)
663 (backward-sexp 1) 634 (beginning-of-line)
664 (beginning-of-line) 635 (setq tem (point))
665 (setq tem (point)) 636 (looking-at "DEFUN\\b"))
666 (looking-at "DEFUN\\b")) 637 (>= location tem))
667 (>= location tem)) 638 (error nil))
668 (error nil)) 639 (progn
669 (progn 640 (goto-char tem)
670 (goto-char tem) 641 (down-list 1)
671 (down-list 1) 642 (if (= (char-after (point)) ?\")
672 (if (= (char-after (point)) ?\") 643 (progn
673 (progn 644 (forward-sexp 1)
674 (forward-sexp 1) 645 (skip-chars-forward " ,")))
675 (skip-chars-forward " ,"))) 646 (buffer-substring-no-properties
676 (buffer-substring (point) 647 (point)
677 (progn (forward-sexp 1) (point)))) 648 (progn (forward-sexp 1)
678 (if (looking-at "^[+-]") 649 (point))))
679 (change-log-get-method-definition) 650 (if (looking-at "^[+-]")
680 ;; Ordinary C function syntax. 651 (change-log-get-method-definition)
681 (setq beg (point)) 652 ;; Ordinary C function syntax.
682 (if (and (condition-case nil 653 (setq beg (point))
683 ;; Protect against "Unbalanced parens" error. 654 (if (and
684 (progn 655 ;; Protect against "Unbalanced parens" error.
685 (down-list 1) ; into arglist 656 (condition-case nil
686 (backward-up-list 1) 657 (progn
687 (skip-chars-backward " \t") 658 (down-list 1) ; into arglist
688 t) 659 (backward-up-list 1)
689 (error nil)) 660 (skip-chars-backward " \t")
690 ;; Verify initial pos was after 661 t)
691 ;; real start of function. 662 (error nil))
692 (save-excursion 663 ;; Verify initial pos was after
693 (goto-char beg) 664 ;; real start of function.
694 ;; For this purpose, include the line 665 (save-excursion
695 ;; that has the decl keywords. This 666 (goto-char beg)
696 ;; may also include some of the 667 ;; For this purpose, include the line
697 ;; comments before the function. 668 ;; that has the decl keywords. This
698 (while (and (not (bobp)) 669 ;; may also include some of the
699 (save-excursion 670 ;; comments before the function.
700 (forward-line -1) 671 (while (and (not (bobp))
701 (looking-at "[^\n\f]"))) 672 (save-excursion
702 (forward-line -1)) 673 (forward-line -1)
703 (>= location (point))) 674 (looking-at "[^\n\f]")))
704 ;; Consistency check: going down and up 675 (forward-line -1))
705 ;; shouldn't take us back before BEG. 676 (>= location (point)))
706 (> (point) beg)) 677 ;; Consistency check: going down and up
707 (let (end middle) 678 ;; shouldn't take us back before BEG.
708 ;; Don't include any final whitespace 679 (> (point) beg))
709 ;; in the name we use. 680 (let (end middle)
710 (skip-chars-backward " \t\n") 681 ;; Don't include any final whitespace
711 (setq end (point)) 682 ;; in the name we use.
712 (backward-sexp 1) 683 (skip-chars-backward " \t\n")
713 ;; Now find the right beginning of the name. 684 (setq end (point))
714 ;; Include certain keywords if they 685 (backward-sexp 1)
715 ;; precede the name. 686 ;; Now find the right beginning of the name.
716 (setq middle (point)) 687 ;; Include certain keywords if they
717 (forward-word -1) 688 ;; precede the name.
718 ;; Ignore these subparts of a class decl 689 (setq middle (point))
719 ;; and move back to the class name itself. 690 (forward-word -1)
720 (while (looking-at "public \\|private ") 691 ;; Ignore these subparts of a class decl
721 (skip-chars-backward " \t:") 692 ;; and move back to the class name itself.
722 (setq end (point)) 693 (while (looking-at "public \\|private ")
723 (backward-sexp 1) 694 (skip-chars-backward " \t:")
724 (setq middle (point)) 695 (setq end (point))
725 (forward-word -1)) 696 (backward-sexp 1)
726 (and (bolp) 697 (setq middle (point))
727 (looking-at "enum \\|struct \\|union \\|class ") 698 (forward-word -1))
728 (setq middle (point))) 699 (and (bolp)
729 (goto-char end) 700 (looking-at
730 (when (eq (preceding-char) ?=) 701 "enum \\|struct \\|union \\|class ")
731 (forward-char -1) 702 (setq middle (point)))
732 (skip-chars-backward " \t") 703 (goto-char end)
733 (setq end (point))) 704 (when (eq (preceding-char) ?=)
734 (buffer-substring middle end))))))))) 705 (forward-char -1)
706 (skip-chars-backward " \t")
707 (setq end (point)))
708 (buffer-substring-no-properties
709 middle end))))))))
735 ((memq major-mode add-log-tex-like-modes) 710 ((memq major-mode add-log-tex-like-modes)
736 (if (re-search-backward 711 (if (re-search-backward
737 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t) 712 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)"
713 nil t)
738 (progn 714 (progn
739 (goto-char (match-beginning 0)) 715 (goto-char (match-beginning 0))
740 (buffer-substring (1+ (point));; without initial backslash 716 (buffer-substring-no-properties
741 (progn 717 (1+ (point)) ; without initial backslash
742 (end-of-line) 718 (line-end-position)))))
743 (point))))))
744 ((eq major-mode 'texinfo-mode) 719 ((eq major-mode 'texinfo-mode)
745 (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t) 720 (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
746 (buffer-substring (match-beginning 1) 721 (match-string-no-properties 1)))
747 (match-end 1))))
748 ((eq major-mode 'perl-mode) 722 ((eq major-mode 'perl-mode)
749 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t) 723 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t)
750 (buffer-substring (match-beginning 1) 724 (match-string-no-properties 1)))
751 (match-end 1)))) 725 ;; Emacs's autoconf-mode installs its own
726 ;; `add-log-current-defun-function'. This applies to
727 ;; a different mode apparently for editing .m4
728 ;; autoconf source.
752 ((eq major-mode 'autoconf-mode) 729 ((eq major-mode 'autoconf-mode)
753 (if (re-search-backward "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t) 730 (if (re-search-backward
754 (buffer-substring (match-beginning 3) 731 "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t)
755 (match-end 3)))) 732 (match-string-no-properties 3)))
756 ((or (eq major-mode 'fortran-mode)
757 ;; Needs work for f90, but better than nothing.
758 (eq major-mode 'f90-mode))
759 ;; must be inside function body for this to work
760 (fortran-beginning-of-subprogram)
761 (let ((case-fold-search t)) ; case-insensitive
762 ;; search for fortran subprogram start
763 (if (re-search-forward
764 "^[ \t]*\\(program\\|subroutine\\|function\
765 \\|[ \ta-z0-9*()]*[ \t]+function\\|\\(block[ \t]*data\\)\\)"
766 (save-excursion (fortran-end-of-subprogram)
767 (point))
768 t)
769 (or (match-string 2)
770 (progn
771 ;; move to EOL or before first left paren
772 (if (re-search-forward "[(\n]" nil t)
773 (progn (backward-char)
774 (skip-chars-backward " \t"))
775 (end-of-line))
776 ;; Use the name preceding that.
777 (buffer-substring (point)
778 (progn (backward-sexp)
779 (point)))))
780 "main")))
781 (t 733 (t
782 ;; If all else fails, try heuristics 734 ;; If all else fails, try heuristics
783 (let (case-fold-search 735 (let (case-fold-search
784 result) 736 result)
785 (end-of-line) 737 (end-of-line)
786 (when (re-search-backward 738 (when (re-search-backward
787 add-log-current-defun-header-regexp 739 add-log-current-defun-header-regexp
788 (- (point) 10000) 740 (- (point) 10000)
789 t) 741 t)
790 (setq result (or (buffer-substring (match-beginning 1) 742 (setq result (or (match-string-no-properties 1)
791 (match-end 1)) 743 (match-string-no-properties 0)))
792 (buffer-substring (match-beginning 0)
793 (match-end 0))))
794 ;; Strip whitespace away 744 ;; Strip whitespace away
795 (when (string-match "\\([^ \t\n\r\f].*[^ \t\n\r\f]\\)" 745 (when (string-match "\\([^ \t\n\r\f].*[^ \t\n\r\f]\\)"
796 result) 746 result)
797 (setq result (match-string 1 result))) 747 (setq result (match-string-no-properties 1 result)))
798 result)))))) 748 result))))))
799 (error nil))) 749 (error nil)))
800 750
801 (defvar change-log-get-method-definition-md) 751 (defvar change-log-get-method-definition-md)
802 752
804 ;; Add the last match in the buffer to the end of `md', 754 ;; Add the last match in the buffer to the end of `md',
805 ;; followed by the string END; move to the end of that match. 755 ;; followed by the string END; move to the end of that match.
806 (defun change-log-get-method-definition-1 (end) 756 (defun change-log-get-method-definition-1 (end)
807 (setq change-log-get-method-definition-md 757 (setq change-log-get-method-definition-md
808 (concat change-log-get-method-definition-md 758 (concat change-log-get-method-definition-md
809 (buffer-substring (match-beginning 1) (match-end 1)) 759 (match-string 1)
810 end)) 760 end))
811 (goto-char (match-end 0))) 761 (goto-char (match-end 0)))
812 762
813 (defun change-log-get-method-definition () 763 (defun change-log-get-method-definition ()
814 "For objective C, return the method name if we are in a method." 764 "For objective C, return the method name if we are in a method."