aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-12-25 01:43:07 +0000
committerRichard M. Stallman1995-12-25 01:43:07 +0000
commit32b558fad310ed852405b77e1b2db6730c444e58 (patch)
tree75c36d7d41db27ebb254e1f633694078d98c3222
parent46c0ddcfe2aa28333cae3ce67f7f3e2bcafdf684 (diff)
downloademacs-32b558fad310ed852405b77e1b2db6730c444e58.tar.gz
emacs-32b558fad310ed852405b77e1b2db6730c444e58.zip
(makefile-add-log-defun): Rewrite to scan back
checking one line at a time. Notice blank lines and comments.
-rw-r--r--lisp/progmodes/make-mode.el35
1 files changed, 23 insertions, 12 deletions
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index ecda1c89744..659a2adb6a8 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -1328,19 +1328,30 @@ Uses `makefile-use-curly-braces-for-macros-p'."
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.
1332If 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 ()