Mercurial > emacs
comparison lisp/progmodes/make-mode.el @ 13847:36556403b62b
(makefile-add-log-defun): Rewrite to scan back
checking one line at a time. Notice blank lines and comments.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 25 Dec 1995 01:43:07 +0000 |
parents | da3a679bbfac |
children | 33b51573611f |
comparison
equal
deleted
inserted
replaced
13846:398b490f2df2 | 13847:36556403b62b |
---|---|
1326 | 1326 |
1327 | 1327 |
1328 ;;; Support for other packages, like add-log and imenu. | 1328 ;;; Support for other packages, like add-log and imenu. |
1329 | 1329 |
1330 (defun makefile-add-log-defun () | 1330 (defun makefile-add-log-defun () |
1331 ;; "Return name of target or macro point is in, or nil." | 1331 "Return name of target or variable assignment that point is in. |
1332 If it isn't in one, return nil." | |
1332 (save-excursion | 1333 (save-excursion |
1333 (beginning-of-line) | 1334 (let (found) |
1334 (cond | 1335 (beginning-of-line) |
1335 ((looking-at makefile-macroassign-regex) | 1336 ;; Scan back line by line, noticing when we come to a |
1336 (buffer-substring (match-beginning 1) | 1337 ;; variable or rule definition, and giving up when we see |
1337 (match-end 1))) | 1338 ;; a line that is not part of either of those. |
1338 ((progn | 1339 (while (not found) |
1339 (or (eobp) (forward-char)) | 1340 (cond |
1340 (re-search-backward makefile-dependency-regex nil t)) | 1341 ((looking-at makefile-macroassign-regex) |
1341 (buffer-substring (match-beginning 1) | 1342 (setq found (buffer-substring-no-properties (match-beginning 1) |
1342 (match-end 1))) | 1343 (match-end 1)))) |
1343 (t nil)))) | 1344 ((looking-at makefile-dependency-regex) |
1345 (setq found (buffer-substring-no-properties (match-beginning 1) | |
1346 (match-end 1)))) | |
1347 ;; Don't keep looking across a blank line or comment. Give up. | |
1348 ((looking-at "$\\|#") | |
1349 (setq found 'bobp)) | |
1350 ((bobp) | |
1351 (setq found 'bobp))) | |
1352 (or found | |
1353 (forward-line -1))) | |
1354 (if (stringp found) found)))) | |
1344 | 1355 |
1345 ;; FIXME it might be nice to have them separated by macro vs target. | 1356 ;; FIXME it might be nice to have them separated by macro vs target. |
1346 (defun makefile-menu-index-function () | 1357 (defun makefile-menu-index-function () |
1347 ;; "Generate alist of indices for imenu." | 1358 ;; "Generate alist of indices for imenu." |
1348 (let (alist | 1359 (let (alist |