# HG changeset patch # User Richard M. Stallman # Date 1102032285 0 # Node ID a67575cbdd93a45d5347ca3a9396e78b538a4e2c # Parent 311652551ce26a187f6d11a2b7eeedc979768957 (add-log-current-defun): Handle the case where point is in the header part of a DEFUN construct. diff -r 311652551ce2 -r a67575cbdd93 lisp/add-log.el --- a/lisp/add-log.el Thu Dec 02 23:43:51 2004 +0000 +++ b/lisp/add-log.el Fri Dec 03 00:04:45 2004 +0000 @@ -779,9 +779,28 @@ (forward-line 1)) (or (eobp) (forward-char 1)) - (beginning-of-defun) - (when (progn (end-of-defun) - (< location (point))) + (let (maybe-beg) + ;; Try to find the containing defun. + (beginning-of-defun) + (end-of-defun) + ;; If the defun we found ends before the desired position, + ;; see if there's a DEFUN construct + ;; between that end and the desired position. + (when (save-excursion + (and (> location (point)) + (re-search-forward "^DEFUN" + (save-excursion + (goto-char location) + (line-end-position)) + t) + (re-search-forward "^{" nil t) + (setq maybe-beg (point)))) + ;; If so, go to the end of that instead. + (goto-char maybe-beg) + (end-of-defun))) + ;; If the desired position is within the defun we found, + ;; find the function name. + (when (< location (point)) (backward-sexp 1) (let (beg tem)