Mercurial > emacs
comparison lisp/add-log.el @ 1369:e5cb5060bb51
(add-log-current-defun): In normal C case,
start with beginning-of-line.
In last (fallback) case, start with end-of-line.
(add-log-current-defun-header-regexp): In first alternative
within the parens, don't allow space as last character.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 08 Oct 1992 08:35:26 +0000 |
parents | e7bc20e1b2b9 |
children | 75fa9ad982a5 |
comparison
equal
deleted
inserted
replaced
1368:35a17cd4ae62 | 1369:e5cb5060bb51 |
---|---|
201 (set (make-local-variable 'version-control) 'never) | 201 (set (make-local-variable 'version-control) 'never) |
202 (set (make-local-variable 'adaptive-fill-regexp) "\\s *") | 202 (set (make-local-variable 'adaptive-fill-regexp) "\\s *") |
203 (run-hooks 'change-log-mode-hook)) | 203 (run-hooks 'change-log-mode-hook)) |
204 | 204 |
205 (defvar add-log-current-defun-header-regexp | 205 (defvar add-log-current-defun-header-regexp |
206 "^\\([A-Z][A-Z_ ]+\\|[a-z_---A-Z]+\\)[ \t]*[:=]" | 206 "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[a-z_---A-Z]+\\)[ \t]*[:=]" |
207 "*Heuristic regexp used by `add-log-current-defun' for unknown major modes.") | 207 "*Heuristic regexp used by `add-log-current-defun' for unknown major modes.") |
208 | 208 |
209 (defun add-log-current-defun () | 209 (defun add-log-current-defun () |
210 "Return name of function definition point is in, or nil. | 210 "Return name of function definition point is in, or nil. |
211 | 211 |
251 (search-forward "define") | 251 (search-forward "define") |
252 (skip-chars-forward " \t") | 252 (skip-chars-forward " \t") |
253 (buffer-substring (point) | 253 (buffer-substring (point) |
254 (progn (forward-sexp 1) (point)))) | 254 (progn (forward-sexp 1) (point)))) |
255 ((memq major-mode '(c-mode 'c++-mode)) | 255 ((memq major-mode '(c-mode 'c++-mode)) |
256 (beginning-of-line) | |
256 ;; See if we are in the beginning part of a function, | 257 ;; See if we are in the beginning part of a function, |
257 ;; before the open brace. If so, advance forward. | 258 ;; before the open brace. If so, advance forward. |
258 (while (not (looking-at "{\\|\\(\\s *$\\)")) | 259 (while (not (looking-at "{\\|\\(\\s *$\\)")) |
259 (forward-line 1)) | 260 (forward-line 1)) |
260 (or (eobp) | 261 (or (eobp) |
338 (buffer-substring (match-beginning 1) | 339 (buffer-substring (match-beginning 1) |
339 (match-end 1)))) | 340 (match-end 1)))) |
340 (t | 341 (t |
341 ;; If all else fails, try heuristics | 342 ;; If all else fails, try heuristics |
342 (let (case-fold-search) | 343 (let (case-fold-search) |
344 (end-of-line) | |
343 (if (re-search-backward add-log-current-defun-header-regexp | 345 (if (re-search-backward add-log-current-defun-header-regexp |
344 (- (point) 10000) | 346 (- (point) 10000) |
345 t) | 347 t) |
346 (buffer-substring (match-beginning 1) | 348 (buffer-substring (match-beginning 1) |
347 (match-end 1))))))))) | 349 (match-end 1))))))))) |