comparison lisp/add-log.el @ 27277:9fdcfef41c64

(add-log-current-defun): Call `add-log-current-defun-function'. Try matches at level 0 and level 1. Strip whitespace from defun found.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 11 Jan 2000 15:05:58 +0000
parents d7748c3e79ad
children 300415d17473
comparison
equal deleted inserted replaced
27276:61772f3ab92f 27277:9fdcfef41c64
579 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...), 579 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...),
580 Texinfo (@node titles), Perl, and Fortran. 580 Texinfo (@node titles), Perl, and Fortran.
581 581
582 Other modes are handled by a heuristic that looks in the 10K before 582 Other modes are handled by a heuristic that looks in the 10K before
583 point for uppercase headings starting in the first column or 583 point for uppercase headings starting in the first column or
584 identifiers followed by `:' or `=', see variable 584 identifiers followed by `:' or `=', see variables
585 `add-log-current-defun-header-regexp'. 585 `add-log-current-defun-header-regexp' and
586 `add-log-current-defun-function'
586 587
587 Has a preference of looking backwards." 588 Has a preference of looking backwards."
588 (condition-case nil 589 (condition-case nil
589 (save-excursion 590 (save-excursion
590 (let ((location (point))) 591 (let ((location (point)))
591 (cond ((memq major-mode add-log-lisp-like-modes) 592 (cond ((functionp add-log-current-defun-function)
593 (funcall add-log-current-defun-function))
594 ((memq major-mode add-log-lisp-like-modes)
592 ;; If we are now precisely at the beginning of a defun, 595 ;; If we are now precisely at the beginning of a defun,
593 ;; make sure beginning-of-defun finds that one 596 ;; make sure beginning-of-defun finds that one
594 ;; rather than the previous one. 597 ;; rather than the previous one.
595 (or (eobp) (forward-char 1)) 598 (or (eobp) (forward-char 1))
596 (beginning-of-defun) 599 (beginning-of-defun)
769 (progn (backward-sexp) 772 (progn (backward-sexp)
770 (point))))) 773 (point)))))
771 "main"))) 774 "main")))
772 (t 775 (t
773 ;; If all else fails, try heuristics 776 ;; If all else fails, try heuristics
774 (let (case-fold-search) 777 (let (case-fold-search
778 result)
775 (end-of-line) 779 (end-of-line)
776 (if (re-search-backward add-log-current-defun-header-regexp 780 (when (re-search-backward
777 (- (point) 10000) 781 add-log-current-defun-header-regexp
778 t) 782 (- (point) 10000)
779 (buffer-substring (match-beginning 1) 783 t)
780 (match-end 1)))))))) 784 (setq result (or (buffer-substring (match-beginning 1)
785 (match-end 1))
786 (buffer-substring (match-beginning 0)
787 (match-end 0))))
788 ;; Strip whitespace away
789 (when (string-match "\\([^ \t\n\r\f].*[^ \t\n\r\f]\\)"
790 result)
791 (setq result (match-string 1 result)))
792 result))))))
781 (error nil))) 793 (error nil)))
782 794
783 (defvar change-log-get-method-definition-md) 795 (defvar change-log-get-method-definition-md)
784 796
785 ;; Subroutine used within change-log-get-method-definition. 797 ;; Subroutine used within change-log-get-method-definition.