comparison lisp/progmodes/make-mode.el @ 41641:66c7637cbf17

Use line-(end|beginning)-position. (makefile-mode): Set indent-line-function. (makefile-browser-insert-continuation): Use with-current-buffer. (makefile-beginning-of-line-point, makefile-end-of-line-point): Remove.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 28 Nov 2001 20:40:36 +0000
parents 1d8c9639b73c
children d00b43e2316c
comparison
equal deleted inserted replaced
41640:963149bd6f3e 41641:66c7637cbf17
501 501
502 \\{makefile-browser-map} 502 \\{makefile-browser-map}
503 503
504 Makefile mode can be configured by modifying the following variables: 504 Makefile mode can be configured by modifying the following variables:
505 505
506 makefile-browser-buffer-name: 506 `makefile-browser-buffer-name':
507 Name of the macro- and target browser buffer. 507 Name of the macro- and target browser buffer.
508 508
509 makefile-target-colon: 509 `makefile-target-colon':
510 The string that gets appended to all target names 510 The string that gets appended to all target names
511 inserted by `makefile-insert-target'. 511 inserted by `makefile-insert-target'.
512 \":\" or \"::\" are quite common values. 512 \":\" or \"::\" are quite common values.
513 513
514 makefile-macro-assign: 514 `makefile-macro-assign':
515 The string that gets appended to all macro names 515 The string that gets appended to all macro names
516 inserted by `makefile-insert-macro'. 516 inserted by `makefile-insert-macro'.
517 The normal value should be \" = \", since this is what 517 The normal value should be \" = \", since this is what
518 standard make expects. However, newer makes such as dmake 518 standard make expects. However, newer makes such as dmake
519 allow a larger variety of different macro assignments, so you 519 allow a larger variety of different macro assignments, so you
520 might prefer to use \" += \" or \" := \" . 520 might prefer to use \" += \" or \" := \" .
521 521
522 makefile-tab-after-target-colon: 522 `makefile-tab-after-target-colon':
523 If you want a TAB (instead of a space) to be appended after the 523 If you want a TAB (instead of a space) to be appended after the
524 target colon, then set this to a non-nil value. 524 target colon, then set this to a non-nil value.
525 525
526 makefile-browser-leftmost-column: 526 `makefile-browser-leftmost-column':
527 Number of blanks to the left of the browser selection mark. 527 Number of blanks to the left of the browser selection mark.
528 528
529 makefile-browser-cursor-column: 529 `makefile-browser-cursor-column':
530 Column in which the cursor is positioned when it moves 530 Column in which the cursor is positioned when it moves
531 up or down in the browser. 531 up or down in the browser.
532 532
533 makefile-browser-selected-mark: 533 `makefile-browser-selected-mark':
534 String used to mark selected entries in the browser. 534 String used to mark selected entries in the browser.
535 535
536 makefile-browser-unselected-mark: 536 `makefile-browser-unselected-mark':
537 String used to mark unselected entries in the browser. 537 String used to mark unselected entries in the browser.
538 538
539 makefile-browser-auto-advance-after-selection-p: 539 `makefile-browser-auto-advance-after-selection-p':
540 If this variable is set to a non-nil value the cursor 540 If this variable is set to a non-nil value the cursor
541 will automagically advance to the next line after an item 541 will automagically advance to the next line after an item
542 has been selected in the browser. 542 has been selected in the browser.
543 543
544 makefile-pickup-everything-picks-up-filenames-p: 544 `makefile-pickup-everything-picks-up-filenames-p':
545 If this variable is set to a non-nil value then 545 If this variable is set to a non-nil value then
546 `makefile-pickup-everything' also picks up filenames as targets 546 `makefile-pickup-everything' also picks up filenames as targets
547 (i.e. it calls `makefile-pickup-filenames-as-targets'), otherwise 547 (i.e. it calls `makefile-pickup-filenames-as-targets'), otherwise
548 filenames are omitted. 548 filenames are omitted.
549 549
550 makefile-cleanup-continuations-p: 550 `makefile-cleanup-continuations-p':
551 If this variable is set to a non-nil value then Makefile mode 551 If this variable is set to a non-nil value then Makefile mode
552 will assure that no line in the file ends with a backslash 552 will assure that no line in the file ends with a backslash
553 (the continuation character) followed by any whitespace. 553 (the continuation character) followed by any whitespace.
554 This is done by silently removing the trailing whitespace, leaving 554 This is done by silently removing the trailing whitespace, leaving
555 the backslash itself intact. 555 the backslash itself intact.
556 IMPORTANT: Please note that enabling this option causes Makefile mode 556 IMPORTANT: Please note that enabling this option causes Makefile mode
557 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\". 557 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\".
558 558
559 makefile-browser-hook: 559 `makefile-browser-hook':
560 A function or list of functions to be called just before the 560 A function or list of functions to be called just before the
561 browser is entered. This is executed in the makefile buffer. 561 browser is entered. This is executed in the makefile buffer.
562 562
563 makefile-special-targets-list: 563 `makefile-special-targets-list':
564 List of special targets. You will be offered to complete 564 List of special targets. You will be offered to complete
565 on one of those in the minibuffer whenever you enter a `.'. 565 on one of those in the minibuffer whenever you enter a `.'.
566 at the beginning of a line in Makefile mode." 566 at the beginning of a line in Makefile mode."
567 567
568 (interactive) 568 (interactive)
608 (setq comment-start "#") 608 (setq comment-start "#")
609 (make-local-variable 'comment-end) 609 (make-local-variable 'comment-end)
610 (setq comment-end "") 610 (setq comment-end "")
611 (make-local-variable 'comment-start-skip) 611 (make-local-variable 'comment-start-skip)
612 (setq comment-start-skip "#+[ \t]*") 612 (setq comment-start-skip "#+[ \t]*")
613
614 ;; Make sure TAB really inserts \t.
615 (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
613 616
614 ;; become the current major mode 617 ;; become the current major mode
615 (setq major-mode 'makefile-mode) 618 (setq major-mode 'makefile-mode)
616 (setq mode-name "Makefile") 619 (setq mode-name "Makefile")
617 620
1053 1056
1054 ((looking-at makefile-macroassign-regex) 1057 ((looking-at makefile-macroassign-regex)
1055 ;; Have a macro assign. Fill just this line, and then backslash 1058 ;; Have a macro assign. Fill just this line, and then backslash
1056 ;; resulting region. 1059 ;; resulting region.
1057 (save-restriction 1060 (save-restriction
1058 (narrow-to-region (point) (save-excursion 1061 (narrow-to-region (point) (line-beginning-position 2))
1059 (end-of-line)
1060 (forward-char)
1061 (point)))
1062 (let ((fill-paragraph-function nil)) 1062 (let ((fill-paragraph-function nil))
1063 (fill-paragraph nil)) 1063 (fill-paragraph nil))
1064 (makefile-backslash-region (point-min) (point-max) nil))))) 1064 (makefile-backslash-region (point-min) (point-max) nil)))))
1065 1065
1066 ;; Always return non-nil so we don't fill anything else. 1066 ;; Always return non-nil so we don't fill anything else.
1183 character, insert a new blank line, go to that line and indent by one TAB. 1183 character, insert a new blank line, go to that line and indent by one TAB.
1184 This is most useful in the process of creating continued lines when copying 1184 This is most useful in the process of creating continued lines when copying
1185 large dependencies from the browser to the client buffer. 1185 large dependencies from the browser to the client buffer.
1186 \(point) advances accordingly in the client buffer." 1186 \(point) advances accordingly in the client buffer."
1187 (interactive) 1187 (interactive)
1188 (save-excursion 1188 (with-current-buffer makefile-browser-client
1189 (set-buffer makefile-browser-client)
1190 (end-of-line) 1189 (end-of-line)
1191 (insert "\\\n\t"))) 1190 (insert "\\\n\t")))
1192 1191
1193 (defun makefile-browser-insert-selection () 1192 (defun makefile-browser-insert-selection ()
1194 "Insert all selected targets and/or macros in the makefile buffer. 1193 "Insert all selected targets and/or macros in the makefile buffer.
1449 1448
1450 (defun makefile-browser-on-macro-line-p () 1449 (defun makefile-browser-on-macro-line-p ()
1451 "Determine if point is on a macro line in the browser." 1450 "Determine if point is on a macro line in the browser."
1452 (save-excursion 1451 (save-excursion
1453 (beginning-of-line) 1452 (beginning-of-line)
1454 (re-search-forward "\\$[{(]" (makefile-end-of-line-point) t))) 1453 (re-search-forward "\\$[{(]" (line-end-position) t)))
1455 1454
1456 (defun makefile-browser-this-line-target-name () 1455 (defun makefile-browser-this-line-target-name ()
1457 "Extract the target name from a line in the browser." 1456 "Extract the target name from a line in the browser."
1458 (save-excursion 1457 (save-excursion
1459 (end-of-line) 1458 (end-of-line)
1460 (skip-chars-backward "^ \t") 1459 (skip-chars-backward "^ \t")
1461 (buffer-substring (point) (1- (makefile-end-of-line-point))))) 1460 (buffer-substring (point) (1- (line-end-position)))))
1462 1461
1463 (defun makefile-browser-this-line-macro-name () 1462 (defun makefile-browser-this-line-macro-name ()
1464 "Extract the macro name from a line in the browser." 1463 "Extract the macro name from a line in the browser."
1465 (save-excursion 1464 (save-excursion
1466 (beginning-of-line) 1465 (beginning-of-line)
1467 (re-search-forward "\\$[{(]" (makefile-end-of-line-point) t) 1466 (re-search-forward "\\$[{(]" (line-end-position) t)
1468 (let ((macro-start (point))) 1467 (let ((macro-start (point)))
1469 (skip-chars-forward "^})") 1468 (skip-chars-forward "^})")
1470 (buffer-substring macro-start (point))))) 1469 (buffer-substring macro-start (point)))))
1471 1470
1472 (defun makefile-format-macro-ref (macro-name) 1471 (defun makefile-format-macro-ref (macro-name)
1486 (aset makefile-browser-selection-vector (1- n) to-state)) 1485 (aset makefile-browser-selection-vector (1- n) to-state))
1487 1486
1488 (defun makefile-browser-toggle-state-for-line (n) 1487 (defun makefile-browser-toggle-state-for-line (n)
1489 (makefile-browser-set-state-for-line n (not (makefile-browser-get-state-for-line n)))) 1488 (makefile-browser-set-state-for-line n (not (makefile-browser-get-state-for-line n))))
1490 1489
1491 (defun makefile-beginning-of-line-point ()
1492 (save-excursion
1493 (beginning-of-line)
1494 (point)))
1495
1496 (defun makefile-end-of-line-point ()
1497 (save-excursion
1498 (end-of-line)
1499 (point)))
1500
1501 (defun makefile-last-line-p () 1490 (defun makefile-last-line-p ()
1502 (= (makefile-end-of-line-point) (point-max))) 1491 (= (line-end-position) (point-max)))
1503 1492
1504 (defun makefile-first-line-p () 1493 (defun makefile-first-line-p ()
1505 (= (makefile-beginning-of-line-point) (point-min))) 1494 (= (line-beginning-position) (point-min)))
1506 1495
1507 1496
1508 1497
1509 ;;; Support for other packages, like add-log. 1498 ;;; Support for other packages, like add-log.
1510 1499