annotate lisp/progmodes/make-mode.el @ 79615:c70a8429c7d8

(copy-face): Create the new face explicitly if it does not exist already.
author Richard M. Stallman <rms@gnu.org>
date Sun, 23 Dec 2007 18:08:38 +0000
parents c1ec1c8a8d2e
children a1342e6e097a f55f9811f5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13402
1f9832fe9e44 (makefile-define-space-face): Don't make face if non-X.
Karl Heuer <kwzh@gnu.org>
parents: 13333
diff changeset
1 ;;; make-mode.el --- makefile editing commands for Emacs
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 73157
diff changeset
3 ;; Copyright (C) 1992, 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
64699
629afbe74e61 Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents: 64085
diff changeset
4 ;; Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
5
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6 ;; Author: Thomas Neumann <tom@smart.bo.open.de>
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
7 ;; Eric S. Raymond <esr@snark.thyrsus.com>
17976
852464ce5d6a Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17240
diff changeset
8 ;; Maintainer: FSF
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 ;; Adapted-By: ESR
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 809
diff changeset
10 ;; Keywords: unix, tools
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
78234
c1ec1c8a8d2e Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
16 ;; the Free Software Foundation; either version 3, or (at your option)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; any later version.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; GNU General Public License for more details.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14117
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63474
diff changeset
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63474
diff changeset
27 ;; Boston, MA 02110-1301, USA.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 841
diff changeset
29 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 841
diff changeset
30
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
31 ;; A major mode for editing makefiles. The mode knows about Makefile
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
32 ;; syntax and defines M-n and M-p to move to next and previous productions.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
33 ;;
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
34 ;; The keys $, =, : and . are electric; they try to help you fill in a
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
35 ;; macro reference, macro definition, ordinary target name, or special
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
36 ;; target name, respectively. Such names are completed using a list of
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
37 ;; targets and macro names parsed out of the makefile. This list is
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
38 ;; automatically updated, if necessary, whenever you invoke one of
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
39 ;; these commands. You can force it to be updated with C-c C-p.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
40 ;;
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
41 ;; The command C-c C-f adds certain filenames in the current directory
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
42 ;; as targets. You can filter out filenames by setting the variable
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
43 ;; makefile-ignored-files-in-pickup-regex.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
44 ;;
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
45 ;; The command C-c C-u grinds for a bit, then pops up a report buffer
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
46 ;; showing which target names are up-to-date with respect to their
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
47 ;; prerequisites, which targets are out-of-date, and which have no
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
48 ;; prerequisites.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
49 ;;
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
50 ;; The command C-c C-b pops up a browser window listing all target and
62082
2805978983d8 (makefile-font-lock-keywords): Use font-lock-negation-char-face.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 57158
diff changeset
51 ;; macro names. You can mark or unmark items with C-c SPC, and insert
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
52 ;; all marked items back in the Makefile with C-c TAB.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
53 ;;
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
54 ;; The command C-c TAB in the makefile buffer inserts a GNU make builtin.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
55 ;; You will be prompted for the builtin's args.
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
56 ;;
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
57 ;; There are numerous other customization variables.
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 841
diff changeset
58
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
59 ;;
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
60 ;; To Do:
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
61 ;;
56503
8bbd2323fbf2 Fix comments.
Kim F. Storm <storm@cua.dk>
parents: 53477
diff changeset
62 ;; * Add missing doc strings, improve terse doc strings.
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
63 ;; * Eliminate electric stuff entirely.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
64 ;; * It might be nice to highlight targets differently depending on
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
65 ;; whether they are up-to-date or not. Not sure how this would
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
66 ;; interact with font-lock.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
67 ;; * Would be nice to edit the commands in ksh-mode and have
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
68 ;; indentation and slashification done automatically. Hard.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
69 ;; * Consider removing browser mode. It seems useless.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
70 ;; * ":" should notice when a new target is made and add it to the
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
71 ;; list (or at least set makefile-need-target-pickup).
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
72 ;; * Make browser into a major mode.
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
73 ;; * Clean up macro insertion stuff. It is a mess.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
74 ;; * Browser entry and exit is weird. Normalize.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
75 ;; * Browser needs to be rewritten. Right now it is kind of a crock.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
76 ;; Should at least:
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
77 ;; * Act more like dired/buffer menu/whatever.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
78 ;; * Highlight as mouse traverses.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
79 ;; * B2 inserts.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
80 ;; * Update documentation above.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
81 ;; * Update texinfo manual.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
82 ;; * Update files.el.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
83
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
84
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
85
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 ;;; Code:
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
88 ;; Sadly we need this for a macro.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
89 (eval-when-compile
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
90 (require 'imenu)
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
91 (require 'dabbrev)
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
92 (require 'add-log))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
93
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
94 ;;; ------------------------------------------------------------
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2671
diff changeset
95 ;;; Configurable stuff
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
96 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
97
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
98 (defgroup makefile nil
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
99 "Makefile editing commands for Emacs."
66963
a11fdee52c05 Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents: 66114
diff changeset
100 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
101 :group 'tools
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
102 :prefix "makefile-")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
104 (defface makefile-space
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
105 '((((class color)) (:background "hotpink"))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
106 (t (:reverse-video t)))
19028
f2458ec72074 (makefile-space-face): Add defface.
Richard M. Stallman <rms@gnu.org>
parents: 19008
diff changeset
107 "Face to use for highlighting leading spaces in Font-Lock mode."
48377
7f3cb336821a (makefile-space-face): Fix typo in group name.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48037
diff changeset
108 :group 'makefile)
63474
7e5dd206d539 (put 'makefile-space-face 'face-alias 'makefile-space)
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63444
diff changeset
109 (put 'makefile-space-face 'face-alias 'makefile-space)
19028
f2458ec72074 (makefile-space-face): Add defface.
Richard M. Stallman <rms@gnu.org>
parents: 19008
diff changeset
110
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
111 (defface makefile-targets
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
112 ;; This needs to go along both with foreground and background colors (i.e. shell)
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
113 '((t (:inherit font-lock-function-name-face)))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
114 "Face to use for additionally highlighting rule targets in Font-Lock mode."
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
115 :group 'makefile
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
116 :version "22.1")
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
117
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
118 (defface makefile-shell
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
119 ()
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
120 ;;'((((class color) (min-colors 88) (background light)) (:background "seashell1"))
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
121 ;; (((class color) (min-colors 88) (background dark)) (:background "seashell4")))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
122 "Face to use for additionally highlighting Shell commands in Font-Lock mode."
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
123 :group 'makefile
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
124 :version "22.1")
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
125
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
126 (defface makefile-makepp-perl
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
127 '((((class color) (background light)) (:background "LightBlue1")) ; Camel Book
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
128 (((class color) (background dark)) (:background "DarkBlue"))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
129 (t (:reverse-video t)))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
130 "Face to use for additionally highlighting Perl code in Font-Lock mode."
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
131 :group 'makefile
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
132 :version "22.1")
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
133
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
134 (defcustom makefile-browser-buffer-name "*Macros and Targets*"
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
135 "*Name of the macro- and target browser buffer."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
136 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
137 :group 'makefile)
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
138
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
139 (defcustom makefile-target-colon ":"
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
140 "*String to append to all target names inserted by `makefile-insert-target'.
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
141 \":\" or \"::\" are common values."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
142 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
143 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
144
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
145 (defcustom makefile-macro-assign " = "
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
146 "*String to append to all macro names inserted by `makefile-insert-macro'.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 The normal value should be \" = \", since this is what
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
148 standard make expects. However, newer makes such as dmake
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149 allow a larger variety of different macro assignments, so you
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
150 might prefer to use \" += \" or \" := \" ."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
151 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
152 :group 'makefile)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
153
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
154 (defcustom makefile-electric-keys nil
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
155 "*If non-nil, Makefile mode should install electric keybindings.
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
156 Default is nil."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
157 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
158 :group 'makefile)
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
159
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
160 (defcustom makefile-use-curly-braces-for-macros-p nil
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
161 "*Controls the style of generated macro references.
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
162 Non-nil means macro references should use curly braces, like `${this}'.
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
163 nil means use parentheses, like `$(this)'."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
164 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
165 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
166
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
167 (defcustom makefile-tab-after-target-colon t
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
168 "*If non-nil, insert a TAB after a target colon.
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
169 Otherwise, a space is inserted.
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
170 The default is t."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
171 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
172 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
173
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
174 (defcustom makefile-browser-leftmost-column 10
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
175 "*Number of blanks to the left of the browser selection mark."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
176 :type 'integer
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
177 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
178
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
179 (defcustom makefile-browser-cursor-column 10
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
180 "*Column the cursor goes to when it moves up or down in the Makefile browser."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
181 :type 'integer
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
182 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
183
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
184 (defcustom makefile-backslash-column 48
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
185 "*Column in which `makefile-backslash-region' inserts backslashes."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
186 :type 'integer
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
187 :group 'makefile)
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
188
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
189 (defcustom makefile-backslash-align t
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
190 "*If non-nil, `makefile-backslash-region' will align backslashes."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
191 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
192 :group 'makefile)
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
193
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
194 (defcustom makefile-browser-selected-mark "+ "
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
195 "*String used to mark selected entries in the Makefile browser."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
196 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
197 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
198
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
199 (defcustom makefile-browser-unselected-mark " "
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
200 "*String used to mark unselected entries in the Makefile browser."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
201 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
202 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
203
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
204 (defcustom makefile-browser-auto-advance-after-selection-p t
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
205 "*If non-nil, cursor will move after item is selected in Makefile browser."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
206 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
207 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
208
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
209 (defcustom makefile-pickup-everything-picks-up-filenames-p nil
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
210 "*If non-nil, `makefile-pickup-everything' picks up filenames as targets.
19896
b27fcef497c1 (makefile-pickup-everything-picks-up-filenames-p): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 19028
diff changeset
211 This means it calls `makefile-pickup-filenames-as-targets'.
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
212 Otherwise filenames are omitted."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
213 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
214 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
215
48018
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
216 (defcustom makefile-cleanup-continuations nil
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
217 "*If non-nil, automatically clean up continuation lines when saving.
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
218 A line is cleaned up by removing all whitespace following a trailing
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
219 backslash. This is done silently.
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
220 IMPORTANT: Please note that enabling this option causes Makefile mode
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
221 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\"."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
222 :type 'boolean
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
223 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
224
26621
5df1b3f7ed3a (makefile-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents: 26136
diff changeset
225 (defcustom makefile-mode-hook nil
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
226 "*Normal hook run by `makefile-mode'."
26621
5df1b3f7ed3a (makefile-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents: 26136
diff changeset
227 :type 'hook
5df1b3f7ed3a (makefile-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents: 26136
diff changeset
228 :group 'makefile)
5df1b3f7ed3a (makefile-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents: 26136
diff changeset
229
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
230 (defvar makefile-browser-hook '())
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
231
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
232 ;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
233 ;; Special targets for DMake, Sun's make ...
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48980
diff changeset
234 ;;
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
235 (defcustom makefile-special-targets-list
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236 '(("DEFAULT") ("DONE") ("ERROR") ("EXPORT")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237 ("FAILED") ("GROUPEPILOG") ("GROUPPROLOG") ("IGNORE")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
238 ("IMPORT") ("INCLUDE") ("INCLUDEDIRS") ("INIT")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
239 ("KEEP_STATE") ("MAKEFILES") ("MAKE_VERSION") ("NO_PARALLEL")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
240 ("PARALLEL") ("PHONY") ("PRECIOUS") ("REMOVE")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
241 ("SCCS_GET") ("SILENT") ("SOURCE") ("SUFFIXES")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
242 ("WAIT") ("c.o") ("C.o") ("m.o")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
243 ("el.elc") ("y.c") ("s.o"))
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
244 "*List of special targets.
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
245 You will be offered to complete on one of those in the minibuffer whenever
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
246 you enter a \".\" at the beginning of a line in `makefile-mode'."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
247 :type '(repeat (list string))
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
248 :group 'makefile)
70810
d464ed82246a (makefile-special-targets-list)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70780
diff changeset
249 (put 'makefile-special-targets-list 'risky-local-variable t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
250
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
251 (defcustom makefile-runtime-macros-list
14688
217222b416f7 (makefile-runtime-macros-list): Add + to the list.
Richard M. Stallman <rms@gnu.org>
parents: 14375
diff changeset
252 '(("@") ("&") (">") ("<") ("*") ("^") ("+") ("?") ("%") ("$"))
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
253 "*List of macros that are resolved by make at runtime.
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
254 If you insert a macro reference using `makefile-insert-macro-ref', the name
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
255 of the macro is checked against this list. If it can be found its name will
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
256 not be enclosed in { } or ( )."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
257 :type '(repeat (list string))
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
258 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
259
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
260 ;; Note that the first big subexpression is used by font lock. Note
24271
bab606b16c3c Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 24248
diff changeset
261 ;; that if you change this regexp you might have to fix the imenu
bab606b16c3c Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 24248
diff changeset
262 ;; index in makefile-imenu-generic-expression.
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
263 (defvar makefile-dependency-regex
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
264 ;; Allow for two nested levels $(v1:$(v2:$(v3:a=b)=c)=d)
63138
2a347143dae3 (makefile-shell-face): Make this a no-op
Richard M. Stallman <rms@gnu.org>
parents: 63067
diff changeset
265 "^\\(\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#:=]\\)+?\\)\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)"
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
266 "Regex used to find dependency lines in a makefile.")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
267
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
268 (defconst makefile-bsdmake-dependency-regex
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
269 (progn (string-match (regexp-quote "\\(:\\)") makefile-dependency-regex)
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
270 (replace-match "\\([:!]\\)" t t makefile-dependency-regex))
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
271 "Regex used to find dependency lines in a BSD makefile.")
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
272
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
273 (defvar makefile-dependency-skip "^:"
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
274 "Characters to skip to find a line that might be a dependency.")
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
275
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
276 (defvar makefile-rule-action-regex
62849
dbba3c92fc76 (makefile-rule-action-regex, makefile-macroassign-regex): Continuation lines may be empty. Reported by Joshua Varner.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62569
diff changeset
277 "^\t[ \t]*\\([-@]*\\)[ \t]*\\(\\(?:.*\\\\\n\\)*.*\\)"
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
278 "Regex used to highlight rule action lines in font lock mode.")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
279
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
280 (defconst makefile-makepp-rule-action-regex
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
281 ;; Don't care about initial tab, but I don't know how to font-lock correctly without.
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
282 "^\t[ \t]*\\(\\(?:\\(?:noecho\\|ignore[-_]error\\|[-@]+\\)[ \t]*\\)*\\)\\(\\(&\\S +\\)?\\(?:.*\\\\\n\\)*.*\\)"
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
283 "Regex used to highlight makepp rule action lines in font lock mode.")
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
284
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
285 (defconst makefile-bsdmake-rule-action-regex
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
286 (progn (string-match "-@" makefile-rule-action-regex)
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
287 (replace-match "-+@" t t makefile-rule-action-regex))
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
288 "Regex used to highlight BSD rule action lines in font lock mode.")
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
289
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
290 ;; Note that the first and second subexpression is used by font lock. Note
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
291 ;; that if you change this regexp you might have to fix the imenu index in
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
292 ;; makefile-imenu-generic-expression.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
293 (defconst makefile-macroassign-regex
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
294 ;; We used to match not just the varname but also the whole value
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
295 ;; (spanning potentially several lines).
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
296 ;; "^ *\\([^ \n\t][^:#= \t\n]*\\)[ \t]*\\(?:!=[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)\\|[*:+]?[:?]?=[ \t]*\\(\\(?:.*\\\\\n\\)*.*\\)\\)"
71559
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
297 ;; What about the define statement? What about differentiating this for makepp?
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
298 "\\(?:^\\|^export\\|^override\\|:\\|: *override\\) *\\([^ \n\t][^:#= \t\n]*\\)[ \t]*\\(?:!=\\|[*:+]?[:?]?=\\)"
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
299 "Regex used to find macro assignment lines in a makefile.")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
300
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
301 (defconst makefile-var-use-regex
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
302 "[^$]\\$[({]\\([-a-zA-Z0-9_.]+\\|[@%<?^+*][FD]?\\)"
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
303 "Regex used to find $(macro) uses in a makefile.")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
304
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
305 (defconst makefile-ignored-files-in-pickup-regex
5312
aad805608eec (makefile-ignored-files-in-pickup-regex): Supply missing \\.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
306 "\\(^\\..*\\)\\|\\(.*~$\\)\\|\\(.*,v$\\)\\|\\(\\.[chy]\\)"
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
307 "Regex for filenames that will NOT be included in the target list.")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
308
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
309 (defvar makefile-space 'makefile-space
12912
e519963ce31a (makefile-space-face): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12373
diff changeset
310 "Face to use for highlighting leading spaces in Font-Lock mode.")
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
311
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
312 ;; These lists were inspired by the old solution. But they are silly, because
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
313 ;; you can't differentiate what follows. They need to be split up.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
314 (defconst makefile-statements '("include")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
315 "List of keywords understood by standard make.")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
316
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
317 (defconst makefile-automake-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
318 `("if" "else" "endif" ,@makefile-statements)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
319 "List of keywords understood by automake.")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
320
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
321 (defconst makefile-gmake-statements
71559
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
322 `("-sinclude" "sinclude" "vpath" ; makefile-makepp-statements takes rest
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
323 "ifdef" "ifndef" "ifeq" "ifneq" "-include" "define" "endef" "export"
71559
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
324 "override define" "override" "unexport"
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
325 ,@(cdr makefile-automake-statements))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
326 "List of keywords understood by gmake.")
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
327
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
328 ;; These are even more silly, because you can have more spaces in between.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
329 (defconst makefile-makepp-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
330 `("and ifdef" "and ifndef" "and ifeq" "and ifneq" "and ifperl"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
331 "and ifmakeperl" "and ifsys" "and ifnsys" "build_cache" "build_check"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
332 "else ifdef" "else ifndef" "else ifeq" "else ifneq" "else ifperl"
71559
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
333 "else ifmakeperl" "else ifsys" "else ifnsys" "enddef" "global"
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
334 "load_makefile" "ifperl" "ifmakeperl" "ifsys" "ifnsys" "_include"
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
335 "makeperl" "makesub" "no_implicit_load" "perl" "perl-begin" "perl_begin"
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
336 "perl-end" "perl_end" "prebuild" "or ifdef" "or ifndef" "or ifeq"
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
337 "or ifneq" "or ifperl" "or ifmakeperl" "or ifsys" "or ifnsys"
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
338 "override export" "override global" "register_command_parser"
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
339 "register_scanner" "repository" "runtime" "signature" "sub"
71559
e0adef75745f (makefile-macroassign-regex): Accept preceding keyword.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 71293
diff changeset
340 ,@(nthcdr 3 makefile-gmake-statements))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
341 "List of keywords understood by gmake.")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
342
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
343 (defconst makefile-bsdmake-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
344 `(".elif" ".elifdef" ".elifmake" ".elifndef" ".elifnmake" ".else" ".endfor"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
345 ".endif" ".for" ".if" ".ifdef" ".ifmake" ".ifndef" ".ifnmake" ".undef")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
346 "List of keywords understood by BSD make.")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
347
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
348 (defun makefile-make-font-lock-keywords (var keywords space
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
349 &optional negation
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
350 &rest font-lock-keywords)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
351 `(;; Do macro assignments. These get the "variable-name" face.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
352 (,makefile-macroassign-regex
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
353 (1 font-lock-variable-name-face)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
354 ;; This is for after !=
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
355 (2 'makefile-shell prepend t)
62446
c03004f09a28 (makefile-macroassign-regex, makefile-make-font-lock-keywords): Also fontify plain strings assigned to variables, mostly so that a colon has a face and is thus not taken as a dependency separator.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62444
diff changeset
356 ;; This is for after normal assignment
c03004f09a28 (makefile-macroassign-regex, makefile-make-font-lock-keywords): Also fontify plain strings assigned to variables, mostly so that a colon has a face and is thus not taken as a dependency separator.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62444
diff changeset
357 (3 'font-lock-string-face prepend t))
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
358
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
359 ;; Rule actions.
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
360 (makefile-match-action
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
361 (1 font-lock-type-face)
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
362 (2 'makefile-shell prepend)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
363 ;; Only makepp has builtin commands.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
364 (3 font-lock-builtin-face prepend t))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
365
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
366 ;; Variable references even in targets/strings/comments.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
367 (,var 1 font-lock-variable-name-face prepend)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
368
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
369 ;; Automatic variable references and single character variable references,
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
370 ;; but not shell variables references.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
371 ("[^$]\\$\\([@%<?^+*_]\\|[a-zA-Z0-9]\\>\\)"
49754
77c84ccd18b9 (makefile-font-lock-keywords): Simplify last change.
Juanma Barranquero <lekktu@gmail.com>
parents: 49739
diff changeset
372 1 font-lock-constant-face prepend)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
373 ("[^$]\\(\\$[@%*]\\)"
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
374 1 'makefile-targets append)
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
375
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
376 ;; Fontify conditionals and includes.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
377 (,(concat "^\\(?: [ \t]*\\)?"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
378 (regexp-opt keywords t)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
379 "\\>[ \t]*\\([^: \t\n#]*\\)")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
380 (1 font-lock-keyword-face) (2 font-lock-variable-name-face))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
381
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
382 ,@(if negation
62491
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
383 `((,negation (1 font-lock-negation-char-face prepend)
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
384 (2 font-lock-negation-char-face prepend t))))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
385
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
386 ,@(if space
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
387 '(;; Highlight lines that contain just whitespace.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
388 ;; They can cause trouble, especially if they start with a tab.
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
389 ("^[ \t]+$" . makefile-space)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
390
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
391 ;; Highlight shell comments that Make treats as commands,
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
392 ;; since these can fool people.
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
393 ("^\t+#" 0 makefile-space t)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
394
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
395 ;; Highlight spaces that precede tabs.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
396 ;; They can make a tab fail to be effective.
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
397 ("^\\( +\\)\t" 1 makefile-space)))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
398
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
399 ,@font-lock-keywords
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
400
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
401 ;; Do dependencies.
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
402 (makefile-match-dependency
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
403 (1 'makefile-targets prepend)
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
404 (3 'makefile-shell prepend t))))
49739
7e5f5bd11b07 (makefile-font-lock-keywords): Fontify single character variable references, but
Juanma Barranquero <lekktu@gmail.com>
parents: 49598
diff changeset
405
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
406 (defconst makefile-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
407 (makefile-make-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
408 makefile-var-use-regex
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
409 makefile-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
410 t))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
411
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
412 (defconst makefile-automake-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
413 (makefile-make-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
414 makefile-var-use-regex
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
415 makefile-automake-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
416 t))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
417
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
418 (defconst makefile-gmake-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
419 (makefile-make-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
420 makefile-var-use-regex
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
421 makefile-gmake-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
422 t
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
423 "^\\(?: [ \t]*\\)?if\\(n\\)\\(?:def\\|eq\\)\\>"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
424
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
425 '("[^$]\\(\\$[({][@%*][DF][})]\\)"
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
426 1 'makefile-targets append)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
427
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
428 ;; $(function ...) ${function ...}
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
429 '("[^$]\\$[({]\\([-a-zA-Z0-9_.]+\\s \\)"
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
430 1 font-lock-function-name-face prepend)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
431
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
432 ;; $(shell ...) ${shell ...}
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
433 '("[^$]\\$\\([({]\\)shell[ \t]+"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
434 makefile-match-function-end nil nil
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
435 (1 'makefile-shell prepend t))))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
436
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
437 (defconst makefile-makepp-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
438 (makefile-make-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
439 makefile-var-use-regex
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
440 makefile-makepp-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
441 nil
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
442 "^\\(?: [ \t]*\\)?\\(?:and[ \t]+\\|else[ \t]+\\|or[ \t]+\\)?if\\(n\\)\\(?:def\\|eq\\|sys\\)\\>"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
443
62849
dbba3c92fc76 (makefile-rule-action-regex, makefile-macroassign-regex): Continuation lines may be empty. Reported by Joshua Varner.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62569
diff changeset
444 '("[^$]\\(\\$[({]\\(?:output\\|stem\\|target\\)s?\\_>.*?[})]\\)"
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
445 1 'makefile-targets append)
28802
f7eed599c0df (makefile-mode-abbrev-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28503
diff changeset
446
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
447 ;; Colon modifier keywords.
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
448 '("\\(:\\s *\\)\\(build_c\\(?:ache\\|heck\\)\\|env\\(?:ironment\\)?\\|foreach\\|signature\\|scanner\\|quickscan\\|smartscan\\)\\>\\([^:\n]*\\)"
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
449 (1 font-lock-type-face t)
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
450 (2 font-lock-keyword-face t)
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
451 (3 font-lock-variable-name-face t))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
452
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
453 ;; $(function ...) $((function ...)) ${function ...} ${{function ...}}
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
454 '("[^$]\\$\\(?:((?\\|{{?\\)\\([-a-zA-Z0-9_.]+\\s \\)"
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
455 1 font-lock-function-name-face prepend)
62082
2805978983d8 (makefile-font-lock-keywords): Use font-lock-negation-char-face.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 57158
diff changeset
456
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
457 ;; $(shell ...) $((shell ...)) ${shell ...} ${{shell ...}}
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
458 '("[^$]\\$\\(((?\\|{{?\\)shell\\(?:[-_]\\(?:global[-_]\\)?once\\)?[ \t]+"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
459 makefile-match-function-end nil nil
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
460 (1 'makefile-shell prepend t))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
461
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
462 ;; $(perl ...) $((perl ...)) ${perl ...} ${{perl ...}}
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
463 '("[^$]\\$\\(((?\\|{{?\\)makeperl[ \t]+"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
464 makefile-match-function-end nil nil
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
465 (1 'makefile-makepp-perl prepend t))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
466 '("[^$]\\$\\(((?\\|{{?\\)perl[ \t]+"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
467 makefile-match-function-end nil nil
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
468 (1 'makefile-makepp-perl t t))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
469
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
470 ;; Can we unify these with (if (match-end 1) 'prepend t)?
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
471 '("ifmakeperl\\s +\\(.*\\)" 1 'makefile-makepp-perl prepend)
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
472 '("ifperl\\s +\\(.*\\)" 1 'makefile-makepp-perl t)
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
473
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
474 ;; Perl block single- or multiline, as statement or rule action.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
475 ;; Don't know why the initial newline in 2nd variant of group 2 doesn't get skipped.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
476 '("\\<make\\(?:perl\\|sub\\s +\\S +\\)\\s *\n?\\s *{\\(?:{\\s *\n?\\(\\(?:.*\n\\)+?\\)\\s *}\\|\\s *\\(\\(?:.*?\\|\n?\\(?:.*\n\\)+?\\)\\)\\)}"
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
477 (1 'makefile-makepp-perl prepend t)
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
478 (2 'makefile-makepp-perl prepend t))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
479 '("\\<\\(?:perl\\|sub\\s +\\S +\\)\\s *\n?\\s *{\\(?:{\\s *\n?\\(\\(?:.*\n\\)+?\\)\\s *}\\|\\s *\\(\\(?:.*?\\|\n?\\(?:.*\n\\)+?\\)\\)\\)}"
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
480 (1 'makefile-makepp-perl t t)
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
481 (2 'makefile-makepp-perl t t))
12961
e8028ecec7ea (makefile-font-lock-keywords): Highlight lines with
Richard M. Stallman <rms@gnu.org>
parents: 12938
diff changeset
482
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
483 ;; Statement style perl block.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
484 '("perl[-_]begin\\s *\\(?:\\s #.*\\)?\n\\(\\(?:.*\n\\)+?\\)\\s *perl[-_]end\\>"
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
485 1 'makefile-makepp-perl t)))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
486
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
487 (defconst makefile-bsdmake-font-lock-keywords
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
488 (makefile-make-font-lock-keywords
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
489 ;; A lot more could be done for variables here:
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
490 makefile-var-use-regex
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
491 makefile-bsdmake-statements
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
492 t
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
493 "^\\(?: [ \t]*\\)?\\.\\(?:el\\)?if\\(n?\\)\\(?:def\\|make\\)?\\>[ \t]*\\(!?\\)"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
494 '("^[ \t]*\\.for[ \t].+[ \t]\\(in\\)\\>" 1 font-lock-keyword-face)))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
495
68239
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
496 (defconst makefile-imake-font-lock-keywords
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
497 (append
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
498 (makefile-make-font-lock-keywords
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
499 makefile-var-use-regex
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
500 makefile-statements
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
501 t
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
502 nil
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
503 '("^XCOMM.*$" . font-lock-comment-face)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
504 '("XVAR\\(?:use\\|def\\)[0-9]" 0 font-lock-keyword-face prepend)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
505 '("@@" . font-lock-preprocessor-face)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
506 )
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
507 cpp-font-lock-keywords))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
508
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
509
50205
63bfe3825510 (makefile-font-lock-syntactic-keywords): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 49970
diff changeset
510 (defconst makefile-font-lock-syntactic-keywords
53170
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
511 ;; From sh-script.el.
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
512 ;; A `#' begins a comment in sh when it is unquoted and at the beginning
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
513 ;; of a word. In the shell, words are separated by metacharacters.
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
514 ;; The list of special chars is taken from the single-unix spec of the
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
515 ;; shell command language (under `quoting') but with `$' removed.
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
516 '(("[^|&;<>()`\\\"' \t\n]\\(#+\\)" 1 "_")
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
517 ;; Change the syntax of a quoted newline so that it does not end a comment.
67eeb641d52a (makefile-font-lock-syntactic-keywords): Don't use `space' for \\\n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
518 ("\\\\\n" 0 ".")))
50205
63bfe3825510 (makefile-font-lock-syntactic-keywords): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 49970
diff changeset
519
24248
fd94cf07b4cc (makefile-imenu-generic-expression): New var.
Richard M. Stallman <rms@gnu.org>
parents: 22837
diff changeset
520 (defvar makefile-imenu-generic-expression
62569
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
521 `(("Dependencies" makefile-previous-dependency 1)
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
522 ("Macro Assignment" ,makefile-macroassign-regex 1))
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
523 "Imenu generic expression for Makefile mode. See `imenu-generic-expression'.")
24248
fd94cf07b4cc (makefile-imenu-generic-expression): New var.
Richard M. Stallman <rms@gnu.org>
parents: 22837
diff changeset
524
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
525 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
526 ;;; The following configurable variables are used in the
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
527 ;;; up-to-date overview .
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2671
diff changeset
528 ;;; The standard configuration assumes that your `make' program
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
529 ;;; can be run in question/query mode using the `-q' option, this
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
530 ;;; means that the command
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
531 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
532 ;;; make -q foo
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
533 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
534 ;;; should return an exit status of zero if the target `foo' is
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
535 ;;; up to date and a nonzero exit status otherwise.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
536 ;;; Many makes can do this although the docs/manpages do not mention
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
537 ;;; it. Try it with your favourite one. GNU make, System V make, and
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
538 ;;; Dennis Vadura's DMake have no problems.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
539 ;;; Set the variable `makefile-brave-make' to the name of the
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
540 ;;; make utility that does this on your system.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2671
diff changeset
541 ;;; To understand what this is all about see the function definition
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
542 ;;; of `makefile-query-by-make-minus-q' .
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
543 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
544
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
545 (defcustom makefile-brave-make "make"
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
546 "*How to invoke make, for `makefile-query-targets'.
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
547 This should identify a `make' command that can handle the `-q' option."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
548 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
549 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
550
70812
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
551 (defcustom makefile-query-one-target-method-function
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
552 'makefile-query-by-make-minus-q
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
553 "*Function to call to determine whether a make target is up to date.
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
554 The function must satisfy this calling convention:
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
555
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
556 * As its first argument, it must accept the name of the target to
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
557 be checked, as a string.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
558
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
559 * As its second argument, it may accept the name of a makefile
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
560 as a string. Depending on what you're going to do you may
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
561 not need this.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
562
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
563 * It must return the integer value 0 (zero) if the given target
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
564 should be considered up-to-date in the context of the given
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
565 makefile, any nonzero integer value otherwise."
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
566 :type 'function
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
567 :group 'makefile)
70812
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
568 (defvaralias 'makefile-query-one-target-method
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
569 'makefile-query-one-target-method-function)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
570
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
571 (defcustom makefile-up-to-date-buffer-name "*Makefile Up-to-date overview*"
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
572 "*Name of the Up-to-date overview buffer."
19008
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
573 :type 'string
12eb62604fa7 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 17976
diff changeset
574 :group 'makefile)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
575
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
576 ;;; --- end of up-to-date-overview configuration ------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
577
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
578 (defvar makefile-mode-abbrev-table nil
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
579 "Abbrev table in use in Makefile buffers.")
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
580 (if makefile-mode-abbrev-table
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
581 ()
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
582 (define-abbrev-table 'makefile-mode-abbrev-table ()))
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
583
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
584 (defvar makefile-mode-map
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
585 (let ((map (make-sparse-keymap)))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
586 ;; set up the keymap
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
587 (define-key map "\C-c:" 'makefile-insert-target-ref)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
588 (if makefile-electric-keys
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
589 (progn
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
590 (define-key map "$" 'makefile-insert-macro-ref)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
591 (define-key map ":" 'makefile-electric-colon)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
592 (define-key map "=" 'makefile-electric-equal)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
593 (define-key map "." 'makefile-electric-dot)))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
594 (define-key map "\C-c\C-f" 'makefile-pickup-filenames-as-targets)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
595 (define-key map "\C-c\C-b" 'makefile-switch-to-browser)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
596 (define-key map "\C-c\C-c" 'comment-region)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
597 (define-key map "\C-c\C-p" 'makefile-pickup-everything)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
598 (define-key map "\C-c\C-u" 'makefile-create-up-to-date-overview)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
599 (define-key map "\C-c\C-i" 'makefile-insert-gmake-function)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
600 (define-key map "\C-c\C-\\" 'makefile-backslash-region)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
601 (define-key map "\C-c\C-m\C-a" 'makefile-automake-mode)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
602 (define-key map "\C-c\C-m\C-b" 'makefile-bsdmake-mode)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
603 (define-key map "\C-c\C-m\C-g" 'makefile-gmake-mode)
68239
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
604 (define-key map "\C-c\C-m\C-i" 'makefile-imake-mode)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
605 (define-key map "\C-c\C-m\C-m" 'makefile-mode)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
606 (define-key map "\C-c\C-m\C-p" 'makefile-makepp-mode)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
607 (define-key map "\M-p" 'makefile-previous-dependency)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
608 (define-key map "\M-n" 'makefile-next-dependency)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
609 (define-key map "\e\t" 'makefile-complete)
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
610
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
611 ;; Make menus.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
612 (define-key map [menu-bar makefile-mode]
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
613 (cons "Makefile" (make-sparse-keymap "Makefile")))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
614
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
615 (define-key map [menu-bar makefile-mode browse]
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
616 '("Pop up Makefile Browser" . makefile-switch-to-browser))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
617 (define-key map [menu-bar makefile-mode complete]
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
618 '("Complete Target or Macro" . makefile-complete))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
619 (define-key map [menu-bar makefile-mode pickup]
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
620 '("Find Targets and Macros" . makefile-pickup-everything))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
621
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
622 (define-key map [menu-bar makefile-mode prev]
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
623 '("Move to Previous Dependency" . makefile-previous-dependency))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
624 (define-key map [menu-bar makefile-mode next]
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
625 '("Move to Next Dependency" . makefile-next-dependency))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
626 map)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
627 "The keymap that is used in Makefile mode.")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
628
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
629
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
630 (defvar makefile-browser-map
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
631 (let ((map (make-sparse-keymap)))
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
632 (define-key map "n" 'makefile-browser-next-line)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
633 (define-key map "\C-n" 'makefile-browser-next-line)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
634 (define-key map "p" 'makefile-browser-previous-line)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
635 (define-key map "\C-p" 'makefile-browser-previous-line)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
636 (define-key map " " 'makefile-browser-toggle)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
637 (define-key map "i" 'makefile-browser-insert-selection)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
638 (define-key map "I" 'makefile-browser-insert-selection-and-quit)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
639 (define-key map "\C-c\C-m" 'makefile-browser-insert-continuation)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
640 (define-key map "q" 'makefile-browser-quit)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
641 ;; disable horizontal movement
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
642 (define-key map "\C-b" 'undefined)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
643 (define-key map "\C-f" 'undefined)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
644 map)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
645 "The keymap that is used in the macro- and target browser.")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
646
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
647
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
648 (defvar makefile-mode-syntax-table
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
649 (let ((st (make-syntax-table)))
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
650 (modify-syntax-entry ?\( "() " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
651 (modify-syntax-entry ?\) ")( " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
652 (modify-syntax-entry ?\[ "(] " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
653 (modify-syntax-entry ?\] ")[ " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
654 (modify-syntax-entry ?\{ "(} " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
655 (modify-syntax-entry ?\} "){ " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
656 (modify-syntax-entry ?\' "\" " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
657 (modify-syntax-entry ?\` "\" " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
658 (modify-syntax-entry ?# "< " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
659 (modify-syntax-entry ?\n "> " st)
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
660 st))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
661
68239
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
662 (defvar makefile-imake-mode-syntax-table (copy-syntax-table
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
663 makefile-mode-syntax-table))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
664 (if makefile-imake-mode-syntax-table
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
665 ()
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
666 (modify-syntax-entry ?/ ". 14" makefile-imake-mode-syntax-table)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
667 (modify-syntax-entry ?* ". 23" makefile-imake-mode-syntax-table)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
668 (modify-syntax-entry ?# "'" makefile-imake-mode-syntax-table)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
669 (modify-syntax-entry ?\n ". b" makefile-imake-mode-syntax-table))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
670
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
671
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
672 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
673 ;;; Internal variables.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
674 ;;; You don't need to configure below this line.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
675 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
676
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
677 (defvar makefile-target-table nil
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
678 "Table of all target names known for this buffer.")
70810
d464ed82246a (makefile-special-targets-list)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70780
diff changeset
679 (put 'makefile-target-table 'risky-local-variable t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
680
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
681 (defvar makefile-macro-table nil
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
682 "Table of all macro names known for this buffer.")
70810
d464ed82246a (makefile-special-targets-list)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70780
diff changeset
683 (put 'makefile-macro-table 'risky-local-variable t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
684
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
685 (defvar makefile-browser-client
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
686 "A buffer in Makefile mode that is currently using the browser.")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
687
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
688 (defvar makefile-browser-selection-vector nil)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
689 (defvar makefile-has-prereqs nil)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
690 (defvar makefile-need-target-pickup t)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
691 (defvar makefile-need-macro-pickup t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
692
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
693 (defvar makefile-mode-hook '())
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
694
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
695 ;; Each element looks like '("GNU MAKE FUNCTION" "ARG" "ARG" ... )
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
696 ;; Each "ARG" is used as a prompt for a required argument.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
697 (defconst makefile-gnumake-functions-alist
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
698 '(
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
699 ;; Text functions
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
700 ("subst" "From" "To" "In")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
701 ("patsubst" "Pattern" "Replacement" "In")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
702 ("strip" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
703 ("findstring" "Find what" "In")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
704 ("filter" "Pattern" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
705 ("filter-out" "Pattern" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
706 ("sort" "List")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
707 ;; Filename functions
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
708 ("dir" "Names")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
709 ("notdir" "Names")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
710 ("suffix" "Names")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
711 ("basename" "Names")
15523
682a3d405c49 (makefile-gnumake-functions-alist): Add `addprefix'.
Richard M. Stallman <rms@gnu.org>
parents: 14688
diff changeset
712 ("addprefix" "Prefix" "Names")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
713 ("addsuffix" "Suffix" "Names")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
714 ("join" "List 1" "List 2")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
715 ("word" "Index" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
716 ("words" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
717 ("firstword" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
718 ("wildcard" "Pattern")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
719 ;; Misc functions
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
720 ("foreach" "Variable" "List" "Text")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
721 ("origin" "Variable")
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
722 ("shell" "Command")))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
723
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
724
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
725 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
726 ;;; The mode function itself.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
727 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
728
2534
0099d6be2b11 (makefile-mode): Fix typo in autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 2400
diff changeset
729 ;;;###autoload
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
730 (defun makefile-mode ()
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
731 "Major mode for editing standard Makefiles.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
732
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
733 If you are editing a file for a different make, try one of the
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
734 variants `makefile-automake-mode', `makefile-gmake-mode',
70780
1921a3870365 (makefile-mode): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 68773
diff changeset
735 `makefile-makepp-mode', `makefile-bsdmake-mode' or,
1921a3870365 (makefile-mode): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 68773
diff changeset
736 `makefile-imake-mode'. All but the last should be correctly
1921a3870365 (makefile-mode): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 68773
diff changeset
737 chosen based on the file name, except if it is *.mk. This
1921a3870365 (makefile-mode): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 68773
diff changeset
738 function ends by invoking the function(s) `makefile-mode-hook'.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
739
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
740 It is strongly recommended to use `font-lock-mode', because that
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
741 provides additional parsing information. This is used for
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
742 example to see that a rule action `echo foo: bar' is a not rule
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
743 dependency, despite the colon.
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
744
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
745 \\{makefile-mode-map}
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
746
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
747 In the browser, use the following keys:
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
748
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
749 \\{makefile-browser-map}
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
750
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
751 Makefile mode can be configured by modifying the following variables:
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
752
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
753 `makefile-browser-buffer-name':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
754 Name of the macro- and target browser buffer.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
755
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
756 `makefile-target-colon':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
757 The string that gets appended to all target names
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
758 inserted by `makefile-insert-target'.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
759 \":\" or \"::\" are quite common values.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
760
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
761 `makefile-macro-assign':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
762 The string that gets appended to all macro names
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
763 inserted by `makefile-insert-macro'.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
764 The normal value should be \" = \", since this is what
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
765 standard make expects. However, newer makes such as dmake
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
766 allow a larger variety of different macro assignments, so you
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
767 might prefer to use \" += \" or \" := \" .
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
768
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
769 `makefile-tab-after-target-colon':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
770 If you want a TAB (instead of a space) to be appended after the
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
771 target colon, then set this to a non-nil value.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
772
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
773 `makefile-browser-leftmost-column':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
774 Number of blanks to the left of the browser selection mark.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
775
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
776 `makefile-browser-cursor-column':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
777 Column in which the cursor is positioned when it moves
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
778 up or down in the browser.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
779
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
780 `makefile-browser-selected-mark':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
781 String used to mark selected entries in the browser.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
782
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
783 `makefile-browser-unselected-mark':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
784 String used to mark unselected entries in the browser.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
785
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
786 `makefile-browser-auto-advance-after-selection-p':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
787 If this variable is set to a non-nil value the cursor
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
788 will automagically advance to the next line after an item
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
789 has been selected in the browser.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
790
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
791 `makefile-pickup-everything-picks-up-filenames-p':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
792 If this variable is set to a non-nil value then
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
793 `makefile-pickup-everything' also picks up filenames as targets
19896
b27fcef497c1 (makefile-pickup-everything-picks-up-filenames-p): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 19028
diff changeset
794 (i.e. it calls `makefile-pickup-filenames-as-targets'), otherwise
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
795 filenames are omitted.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
796
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
797 `makefile-cleanup-continuations':
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
798 If this variable is set to a non-nil value then Makefile mode
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
799 will assure that no line in the file ends with a backslash
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
800 (the continuation character) followed by any whitespace.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
801 This is done by silently removing the trailing whitespace, leaving
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
802 the backslash itself intact.
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
803 IMPORTANT: Please note that enabling this option causes Makefile mode
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
804 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\".
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
805
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
806 `makefile-browser-hook':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
807 A function or list of functions to be called just before the
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
808 browser is entered. This is executed in the makefile buffer.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
809
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
810 `makefile-special-targets-list':
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
811 List of special targets. You will be offered to complete
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
812 on one of those in the minibuffer whenever you enter a `.'.
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
813 at the beginning of a line in Makefile mode."
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
814
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
815 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
816 (kill-all-local-variables)
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
817 (add-hook 'write-file-functions
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
818 'makefile-warn-suspicious-lines nil t)
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
819 (add-hook 'write-file-functions
48018
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
820 'makefile-warn-continuations nil t)
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
821 (add-hook 'write-file-functions
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
822 'makefile-cleanup-continuations nil t)
6146
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
823 (make-local-variable 'makefile-target-table)
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
824 (make-local-variable 'makefile-macro-table)
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
825 (make-local-variable 'makefile-has-prereqs)
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
826 (make-local-variable 'makefile-need-target-pickup)
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
827 (make-local-variable 'makefile-need-macro-pickup)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
828
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
829 ;; Font lock.
9477
7a8a379513e4 * makefile.el: (makefile-mode-syntax-table): Made `'' and ``' be
Simon Marshall <simon@gnu.org>
parents: 9454
diff changeset
830 (make-local-variable 'font-lock-defaults)
35932
2b3447fcf42b (makefile-mode): Set SYNTAX-BEGIN member
Eli Zaretskii <eliz@gnu.org>
parents: 30468
diff changeset
831 (setq font-lock-defaults
2b3447fcf42b (makefile-mode): Set SYNTAX-BEGIN member
Eli Zaretskii <eliz@gnu.org>
parents: 30468
diff changeset
832 ;; SYNTAX-BEGIN set to backward-paragraph to avoid slow-down
2b3447fcf42b (makefile-mode): Set SYNTAX-BEGIN member
Eli Zaretskii <eliz@gnu.org>
parents: 30468
diff changeset
833 ;; near the end of a large buffer, due to parse-partial-sexp's
2b3447fcf42b (makefile-mode): Set SYNTAX-BEGIN member
Eli Zaretskii <eliz@gnu.org>
parents: 30468
diff changeset
834 ;; trying to parse all the way till the beginning of buffer.
50205
63bfe3825510 (makefile-font-lock-syntactic-keywords): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 49970
diff changeset
835 '(makefile-font-lock-keywords
63bfe3825510 (makefile-font-lock-syntactic-keywords): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 49970
diff changeset
836 nil nil
63bfe3825510 (makefile-font-lock-syntactic-keywords): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 49970
diff changeset
837 ((?$ . "."))
63bfe3825510 (makefile-font-lock-syntactic-keywords): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 49970
diff changeset
838 backward-paragraph
73157
66c756c90e7b (makefile-mode): Don't disable jit-lock.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71569
diff changeset
839 (font-lock-syntactic-keywords
66c756c90e7b (makefile-mode): Don't disable jit-lock.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71569
diff changeset
840 . makefile-font-lock-syntactic-keywords)))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
841
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
842 ;; Add-log.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
843 (make-local-variable 'add-log-current-defun-function)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
844 (setq add-log-current-defun-function 'makefile-add-log-defun)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
845
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
846 ;; Imenu.
24248
fd94cf07b4cc (makefile-imenu-generic-expression): New var.
Richard M. Stallman <rms@gnu.org>
parents: 22837
diff changeset
847 (make-local-variable 'imenu-generic-expression)
fd94cf07b4cc (makefile-imenu-generic-expression): New var.
Richard M. Stallman <rms@gnu.org>
parents: 22837
diff changeset
848 (setq imenu-generic-expression makefile-imenu-generic-expression)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
849
11638
2b1d5f2e99cc (makefile-mode): Set dabbrev-abbrev-skip-leading-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 9758
diff changeset
850 ;; Dabbrev.
2b1d5f2e99cc (makefile-mode): Set dabbrev-abbrev-skip-leading-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 9758
diff changeset
851 (make-local-variable 'dabbrev-abbrev-skip-leading-regexp)
2b1d5f2e99cc (makefile-mode): Set dabbrev-abbrev-skip-leading-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 9758
diff changeset
852 (setq dabbrev-abbrev-skip-leading-regexp "\\$")
2b1d5f2e99cc (makefile-mode): Set dabbrev-abbrev-skip-leading-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 9758
diff changeset
853
28503
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
854 ;; Other abbrevs.
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
855 (setq local-abbrev-table makefile-mode-abbrev-table)
a8184f890df4 Some doc fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 28277
diff changeset
856
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
857 ;; Filling.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
858 (make-local-variable 'fill-paragraph-function)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
859 (setq fill-paragraph-function 'makefile-fill-paragraph)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
860
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
861 ;; Comment stuff.
5464
4823e14b1314 (makefile-mode): Make comment-start, comment-end,
Richard M. Stallman <rms@gnu.org>
parents: 5312
diff changeset
862 (make-local-variable 'comment-start)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
863 (setq comment-start "#")
5464
4823e14b1314 (makefile-mode): Make comment-start, comment-end,
Richard M. Stallman <rms@gnu.org>
parents: 5312
diff changeset
864 (make-local-variable 'comment-end)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
865 (setq comment-end "")
5464
4823e14b1314 (makefile-mode): Make comment-start, comment-end,
Richard M. Stallman <rms@gnu.org>
parents: 5312
diff changeset
866 (make-local-variable 'comment-start-skip)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
867 (setq comment-start-skip "#+[ \t]*")
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
868
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
869 ;; Make sure TAB really inserts \t.
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
870 (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
871
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
872 ;; become the current major mode
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
873 (setq major-mode 'makefile-mode)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
874 (setq mode-name "Makefile")
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
875
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
876 ;; Activate keymap and syntax table.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
877 (use-local-map makefile-mode-map)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
878 (set-syntax-table makefile-mode-syntax-table)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
879
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
880 ;; Real TABs are important in makefiles
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
881 (setq indent-tabs-mode t)
62525
10a127a02c08 (makefile-mode): Use run-mode-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 62503
diff changeset
882 (run-mode-hooks 'makefile-mode-hook))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
883
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
884 ;; These should do more than just differentiate font-lock.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
885 ;;;###autoload
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
886 (define-derived-mode makefile-automake-mode makefile-mode "Makefile.am"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
887 "An adapted `makefile-mode' that knows about automake."
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
888 (setq font-lock-defaults
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
889 `(makefile-automake-font-lock-keywords ,@(cdr font-lock-defaults))))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
890
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
891 ;;;###autoload
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
892 (define-derived-mode makefile-gmake-mode makefile-mode "GNUmakefile"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
893 "An adapted `makefile-mode' that knows about gmake."
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
894 (setq font-lock-defaults
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
895 `(makefile-gmake-font-lock-keywords ,@(cdr font-lock-defaults))))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
896
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
897 ;;;###autoload
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
898 (define-derived-mode makefile-makepp-mode makefile-mode "Makeppfile"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
899 "An adapted `makefile-mode' that knows about makepp."
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
900 (set (make-local-variable 'makefile-rule-action-regex)
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
901 makefile-makepp-rule-action-regex)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
902 (setq font-lock-defaults
62569
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
903 `(makefile-makepp-font-lock-keywords ,@(cdr font-lock-defaults))
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
904 imenu-generic-expression
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
905 `(("Functions" "^[ \t]*\\(?:make\\)?sub[ \t]+\\([A-Za-z0-9_]+\\)" 1)
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
906 ,@imenu-generic-expression)))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
907
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
908 ;;;###autoload
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
909 (define-derived-mode makefile-bsdmake-mode makefile-mode "BSDmakefile"
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
910 "An adapted `makefile-mode' that knows about BSD make."
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
911 (set (make-local-variable 'makefile-dependency-regex)
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
912 makefile-bsdmake-dependency-regex)
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
913 (set (make-local-variable 'makefile-dependency-skip) "^:!")
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
914 (set (make-local-variable 'makefile-rule-action-regex)
62965
a078bb7e3d21 (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): Add :version.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62851
diff changeset
915 makefile-bsdmake-rule-action-regex)
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
916 (setq font-lock-defaults
62569
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
917 `(makefile-bsdmake-font-lock-keywords ,@(cdr font-lock-defaults))))
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
918
68239
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
919 ;;;###autoload
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
920 (define-derived-mode makefile-imake-mode makefile-mode "Imakefile"
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
921 "An adapted `makefile-mode' that knows about imake."
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
922 :syntax-table makefile-imake-mode-syntax-table
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
923 (let ((base `(makefile-imake-font-lock-keywords ,@(cdr font-lock-defaults)))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
924 new)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
925 ;; Remove `font-lock-syntactic-keywords' entry from font-lock-defaults.
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
926 (mapc (lambda (elt)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
927 (unless (and (consp elt)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
928 (eq (car elt) 'font-lock-syntactic-keywords))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
929 (setq new (cons elt new))))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
930 base)
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
931 (setq font-lock-defaults (nreverse new))))
e08826f8b714 Added makefile-imake-mode.
Masatake YAMATO <jet@gyve.org>
parents: 67835
diff changeset
932
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
933
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
934
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
935 ;;; Motion code.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
936
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
937 (defun makefile-next-dependency ()
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
938 "Move point to the beginning of the next dependency line."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
939 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
940 (let ((here (point)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
941 (end-of-line)
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
942 (if (makefile-match-dependency nil)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
943 (progn (beginning-of-line) t) ; indicate success
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
944 (goto-char here) nil)))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
945
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
946 (defun makefile-previous-dependency ()
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
947 "Move point to the beginning of the previous dependency line."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
948 (interactive)
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
949 (let ((pt (point)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
950 (beginning-of-line)
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
951 ;; makefile-match-dependency done backwards:
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
952 (catch 'found
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
953 (while (progn (skip-chars-backward makefile-dependency-skip)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
954 (not (bobp)))
62491
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
955 (or (prog1 (eq (char-after) ?=)
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
956 (backward-char))
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
957 (get-text-property (point) 'face)
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
958 (beginning-of-line)
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
959 (if (> (point) (+ (point-min) 2))
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
960 (eq (char-before (1- (point))) ?\\))
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
961 (if (looking-at makefile-dependency-regex)
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
962 (throw 'found t))))
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
963 (goto-char pt)
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
964 nil)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
965
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
966
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
967
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
968 ;;; Electric keys. Blech.
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
969
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
970 (defun makefile-electric-dot (arg)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
971 "Prompt for the name of a special target to insert.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
972 Only does electric insertion at beginning of line.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
973 Anywhere else just self-inserts."
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
974 (interactive "p")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
975 (if (bolp)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
976 (makefile-insert-special-target)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
977 (self-insert-command arg)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
978
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
979 (defun makefile-insert-special-target ()
13995
33b51573611f (makefile-insert-special-target,
Karl Heuer <kwzh@gnu.org>
parents: 13847
diff changeset
980 "Prompt for and insert a special target name.
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
981 Uses `makefile-special-targets' list."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
982 (interactive)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
983 (makefile-pickup-targets)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
984 (let ((special-target
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
985 (completing-read "Special target: "
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
986 makefile-special-targets-list nil nil nil)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
987 (if (zerop (length special-target))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
988 ()
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
989 (insert "." special-target ":")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
990 (makefile-forward-after-target-colon))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
991
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
992 (defun makefile-electric-equal (arg)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
993 "Prompt for name of a macro to insert.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
994 Only does prompting if point is at beginning of line.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
995 Anywhere else just self-inserts."
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
996 (interactive "p")
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
997 (makefile-pickup-macros)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
998 (if (bolp)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
999 (call-interactively 'makefile-insert-macro)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1000 (self-insert-command arg)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1001
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1002 (defun makefile-insert-macro (macro-name)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1003 "Prepare definition of a new macro."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1004 (interactive "sMacro Name: ")
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1005 (makefile-pickup-macros)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1006 (if (not (zerop (length macro-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1007 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1008 (beginning-of-line)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1009 (insert macro-name makefile-macro-assign)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1010 (setq makefile-need-macro-pickup t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1011 (makefile-remember-macro macro-name))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1012
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1013 (defun makefile-insert-macro-ref (macro-name)
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
1014 "Complete on a list of known macros, then insert complete ref at point."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1015 (interactive
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1016 (list
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1017 (progn
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1018 (makefile-pickup-macros)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1019 (completing-read "Refer to macro: " makefile-macro-table nil nil nil))))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1020 (makefile-do-macro-insertion macro-name))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1021
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1022 (defun makefile-insert-target (target-name)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1023 "Prepare definition of a new target (dependency line)."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1024 (interactive "sTarget: ")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1025 (if (not (zerop (length target-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1026 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1027 (beginning-of-line)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1028 (insert target-name makefile-target-colon)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1029 (makefile-forward-after-target-colon)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1030 (end-of-line)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1031 (setq makefile-need-target-pickup t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1032 (makefile-remember-target target-name))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1033
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1034 (defun makefile-insert-target-ref (target-name)
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
1035 "Complete on a list of known targets, then insert TARGET-NAME at point."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1036 (interactive
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1037 (list
5312
aad805608eec (makefile-ignored-files-in-pickup-regex): Supply missing \\.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1038 (progn
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1039 (makefile-pickup-targets)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1040 (completing-read "Refer to target: " makefile-target-table nil nil nil))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1041 (if (not (zerop (length target-name)))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1042 (insert target-name " ")))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1043
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1044 (defun makefile-electric-colon (arg)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1045 "Prompt for name of new target.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1046 Prompting only happens at beginning of line.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1047 Anywhere else just self-inserts."
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1048 (interactive "p")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1049 (if (bolp)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1050 (call-interactively 'makefile-insert-target)
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1051 (self-insert-command arg)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1052
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1053
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1054
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1055 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1056 ;;; Extracting targets and macros from an existing makefile
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1057 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1058
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1059 (defun makefile-pickup-targets ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1060 "Notice names of all target definitions in Makefile."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1061 (interactive)
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1062 (when makefile-need-target-pickup
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1063 (setq makefile-need-target-pickup nil
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1064 makefile-target-table nil
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1065 makefile-has-prereqs nil)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1066 (save-excursion
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1067 (goto-char (point-min))
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1068 (while (makefile-match-dependency nil)
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1069 (goto-char (match-beginning 1))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1070 (while (let ((target-name
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1071 (buffer-substring-no-properties (point)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1072 (progn
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1073 (skip-chars-forward "^ \t:#")
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1074 (point))))
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1075 (has-prereqs
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1076 (not (looking-at ":[ \t]*$"))))
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1077 (if (makefile-remember-target target-name has-prereqs)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1078 (message "Picked up target \"%s\" from line %d"
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1079 target-name (line-number-at-pos)))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1080 (skip-chars-forward " \t")
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1081 (not (or (eolp) (eq (char-after) ?:)))))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1082 (forward-line)))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1083 (message "Read targets OK.")))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1084
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1085 (defun makefile-pickup-macros ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1086 "Notice names of all macro definitions in Makefile."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1087 (interactive)
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1088 (when makefile-need-macro-pickup
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1089 (setq makefile-need-macro-pickup nil
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1090 makefile-macro-table nil)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1091 (save-excursion
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1092 (goto-char (point-min))
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1093 (while (re-search-forward makefile-macroassign-regex nil t)
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1094 (goto-char (match-beginning 1))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1095 (let ((macro-name (buffer-substring-no-properties (point)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1096 (progn
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1097 (skip-chars-forward "^ \t:#=*")
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1098 (point)))))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1099 (if (makefile-remember-macro macro-name)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1100 (message "Picked up macro \"%s\" from line %d"
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1101 macro-name (line-number-at-pos))))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1102 (forward-line)))
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1103 (message "Read macros OK.")))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1104
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1105 (defun makefile-pickup-everything (arg)
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1106 "Notice names of all macros and targets in Makefile.
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1107 Prefix arg means force pickups to be redone."
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1108 (interactive "P")
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1109 (if arg
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1110 (setq makefile-need-target-pickup t
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1111 makefile-need-macro-pickup t))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1112 (makefile-pickup-macros)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1113 (makefile-pickup-targets)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1114 (if makefile-pickup-everything-picks-up-filenames-p
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1115 (makefile-pickup-filenames-as-targets)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1116
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1117 (defun makefile-pickup-filenames-as-targets ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1118 "Scan the current directory for filenames to use as targets.
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1119 Checks each filename against `makefile-ignored-files-in-pickup-regex'
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1120 and adds all qualifying names to the list of known targets."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1121 (interactive)
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1122 (mapc (lambda (name)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1123 (or (file-directory-p name)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1124 (string-match makefile-ignored-files-in-pickup-regex name)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1125 (if (makefile-remember-target name)
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1126 (message "Picked up file \"%s\" as target" name))))
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1127 (file-name-all-completions "" (or (file-name-directory (buffer-file-name)) ""))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1128
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1129
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1130
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1131 ;;; Completion.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1132
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1133 (defun makefile-complete ()
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1134 "Perform completion on Makefile construct preceding point.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1135 Can complete variable and target names.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1136 The context determines which are considered."
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1137 (interactive)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1138 (let* ((beg (save-excursion
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1139 (skip-chars-backward "^$(){}:#= \t\n")
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1140 (point)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1141 (try (buffer-substring beg (point)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1142 (do-macros nil)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1143 (paren nil))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1144
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1145 (save-excursion
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1146 (goto-char beg)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1147 (let ((pc (preceding-char)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1148 (cond
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1149 ;; Beginning of line means anything.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1150 ((bolp)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1151 ())
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1152
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1153 ;; Preceding "$" means macros only.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1154 ((= pc ?$)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1155 (setq do-macros t))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1156
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1157 ;; Preceding "$(" or "${" means macros only.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1158 ((and (or (= pc ?{)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1159 (= pc ?\())
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1160 (progn
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1161 (setq paren pc)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1162 (backward-char)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1163 (and (not (bolp))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1164 (= (preceding-char) ?$))))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1165 (setq do-macros t)))))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1166
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1167 ;; Try completion.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1168 (let* ((table (append (if do-macros
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1169 '()
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1170 makefile-target-table)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1171 makefile-macro-table))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1172 (completion (try-completion try table)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1173 (cond
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1174 ;; Exact match, so insert closing paren or colon.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1175 ((eq completion t)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1176 (insert (if do-macros
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1177 (if (eq paren ?{)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1178 ?}
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1179 ?\))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1180 (if (save-excursion
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1181 (goto-char beg)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1182 (bolp))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1183 ":"
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1184 " "))))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1185
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1186 ;; No match.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1187 ((null completion)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1188 (message "Can't find completion for \"%s\"" try)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1189 (ding))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1190
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1191 ;; Partial completion.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1192 ((not (string= try completion))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1193 ;; FIXME it would be nice to supply the closing paren if an
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1194 ;; exact, unambiguous match were found. That is not possible
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1195 ;; right now. Ditto closing ":" for targets.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1196 (delete-region beg (point))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1197
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1198 ;; DO-MACROS means doing macros only. If not that, then check
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1199 ;; to see if this completion is a macro. Special insertion
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1200 ;; must be done for macros.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1201 (if (or do-macros
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1202 (assoc completion makefile-macro-table))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1203 (let ((makefile-use-curly-braces-for-macros-p
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1204 (or (eq paren ?{)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1205 makefile-use-curly-braces-for-macros-p)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1206 (delete-backward-char 2)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1207 (makefile-do-macro-insertion completion)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1208 (delete-backward-char 1))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1209
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1210 ;; Just insert targets.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1211 (insert completion)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1212
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1213 ;; Can't complete any more, so make completion list. FIXME
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1214 ;; this doesn't do the right thing when the completion is
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1215 ;; actually inserted. I don't think there is an easy way to do
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1216 ;; that.
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1217 (t
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1218 (message "Making completion list...")
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1219 (let ((list (all-completions try table)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1220 (with-output-to-temp-buffer "*Completions*"
66114
13abee3a9bc6 * message.el (message-expand-group): Pass the common
Masatake YAMATO <jet@gyve.org>
parents: 65383
diff changeset
1221 (display-completion-list list try)))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1222 (message "Making completion list...done"))))))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1223
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1224
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1225
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1226 ;; Backslashification. Stolen from cc-mode.el.
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1227
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1228 (defun makefile-backslash-region (from to delete-flag)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1229 "Insert, align, or delete end-of-line backslashes on the lines in the region.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1230 With no argument, inserts backslashes and aligns existing backslashes.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1231 With an argument, deletes the backslashes.
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1232
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
1233 This function does not modify the last line of the region if the region ends
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1234 right at the start of the following line; it does not modify blank lines
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1235 at the start of the region. So you can put the region around an entire macro
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1236 definition and conveniently use this command."
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1237 (interactive "r\nP")
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1238 (save-excursion
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1239 (goto-char from)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1240 (let ((column makefile-backslash-column)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1241 (endmark (make-marker)))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1242 (move-marker endmark to)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1243 ;; Compute the smallest column number past the ends of all the lines.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1244 (if makefile-backslash-align
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1245 (progn
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1246 (if (not delete-flag)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1247 (while (< (point) to)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1248 (end-of-line)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1249 (if (= (preceding-char) ?\\)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1250 (progn (forward-char -1)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1251 (skip-chars-backward " \t")))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1252 (setq column (max column (1+ (current-column))))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1253 (forward-line 1)))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1254 ;; Adjust upward to a tab column, if that doesn't push
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1255 ;; past the margin.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1256 (if (> (% column tab-width) 0)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1257 (let ((adjusted (* (/ (+ column tab-width -1) tab-width)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1258 tab-width)))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1259 (if (< adjusted (window-width))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1260 (setq column adjusted))))))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1261 ;; Don't modify blank lines at start of region.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1262 (goto-char from)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1263 (while (and (< (point) endmark) (eolp))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1264 (forward-line 1))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1265 ;; Add or remove backslashes on all the lines.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1266 (while (and (< (point) endmark)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1267 ;; Don't backslashify the last line
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1268 ;; if the region ends right at the start of the next line.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1269 (save-excursion
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1270 (forward-line 1)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1271 (< (point) endmark)))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1272 (if (not delete-flag)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1273 (makefile-append-backslash column)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1274 (makefile-delete-backslash))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1275 (forward-line 1))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1276 (move-marker endmark nil))))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1277
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1278 (defun makefile-append-backslash (column)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1279 (end-of-line)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1280 ;; Note that "\\\\" is needed to get one backslash.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1281 (if (= (preceding-char) ?\\)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1282 (progn (forward-char -1)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1283 (delete-horizontal-space)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1284 (indent-to column (if makefile-backslash-align nil 1)))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1285 (indent-to column (if makefile-backslash-align nil 1))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1286 (insert "\\")))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1287
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1288 (defun makefile-delete-backslash ()
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1289 (end-of-line)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1290 (or (bolp)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1291 (progn
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1292 (forward-char -1)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1293 (if (looking-at "\\\\")
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1294 (delete-region (1+ (point))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1295 (progn (skip-chars-backward " \t") (point)))))))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1296
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1297
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1298
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1299 ;; Filling
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1300
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1301 (defun makefile-fill-paragraph (arg)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1302 ;; Fill comments, backslashed lines, and variable definitions
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1303 ;; specially.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1304 (save-excursion
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1305 (beginning-of-line)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1306 (cond
71293
e09c0037f795 (makefile-fill-paragraph): Don't remove spaces after the comment start.
Eli Zaretskii <eliz@gnu.org>
parents: 71030
diff changeset
1307 ((looking-at "^#+\\s-*")
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1308 ;; Found a comment. Return nil to let normal filling take place.
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1309 nil)
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1310
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1311 ;; Must look for backslashed-region before looking for variable
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1312 ;; assignment.
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1313 ((or (eq (char-before (line-end-position 1)) ?\\)
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1314 (eq (char-before (line-end-position 0)) ?\\))
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1315 ;; A backslash region. Find beginning and end, remove
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1316 ;; backslashes, fill, and then reapply backslahes.
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1317 (end-of-line)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1318 (let ((beginning
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1319 (save-excursion
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1320 (end-of-line 0)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1321 (while (= (preceding-char) ?\\)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1322 (end-of-line 0))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1323 (forward-char)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1324 (point)))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1325 (end
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1326 (save-excursion
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1327 (while (= (preceding-char) ?\\)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1328 (end-of-line 2))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1329 (point))))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1330 (save-restriction
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1331 (narrow-to-region beginning end)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1332 (makefile-backslash-region (point-min) (point-max) t)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1333 (let ((fill-paragraph-function nil))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1334 (fill-paragraph nil))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1335 (makefile-backslash-region (point-min) (point-max) nil)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1336 (goto-char (point-max))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1337 (if (< (skip-chars-backward "\n") 0)
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1338 (delete-region (point) (point-max)))))
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1339 ;; Return non-nil to indicate it's been filled.
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1340 t)
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1341
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1342 ((looking-at makefile-macroassign-regex)
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1343 ;; Have a macro assign. Fill just this line, and then backslash
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1344 ;; resulting region.
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1345 (save-restriction
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1346 (narrow-to-region (point) (line-beginning-position 2))
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1347 (let ((fill-paragraph-function nil))
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1348 (fill-paragraph nil))
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1349 (makefile-backslash-region (point-min) (point-max) nil))
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1350 ;; Return non-nil to indicate it's been filled.
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1351 t)
17240
9e236e540a59 (makefile-backslash-align): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 17142
diff changeset
1352
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1353 (t
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1354 ;; Return non-nil so we don't fill anything else.
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1355 t))))
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1356
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1357
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1358
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1359 ;;; ------------------------------------------------------------
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1360 ;;; Browser mode.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1361 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1362
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1363 (defun makefile-browser-format-target-line (target selected)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1364 (format
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1365 (concat (make-string makefile-browser-leftmost-column ?\ )
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1366 (if selected
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1367 makefile-browser-selected-mark
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1368 makefile-browser-unselected-mark)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1369 "%s%s")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1370 target makefile-target-colon))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1371
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1372 (defun makefile-browser-format-macro-line (macro selected)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1373 (format
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1374 (concat (make-string makefile-browser-leftmost-column ?\ )
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1375 (if selected
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1376 makefile-browser-selected-mark
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1377 makefile-browser-unselected-mark)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1378 (makefile-format-macro-ref macro))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1379
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1380 (defun makefile-browser-fill (targets macros)
5820
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1381 (let ((inhibit-read-only t))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1382 (goto-char (point-min))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1383 (erase-buffer)
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1384 (mapconcat
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1385 (function
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1386 (lambda (item) (insert (makefile-browser-format-target-line (car item) nil) "\n")))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1387 targets
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1388 "")
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1389 (mapconcat
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1390 (function
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1391 (lambda (item) (insert (makefile-browser-format-macro-line (car item) nil) "\n")))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1392 macros
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1393 "")
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1394 (sort-lines nil (point-min) (point-max))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1395 (goto-char (1- (point-max)))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1396 (delete-char 1) ; remove unnecessary newline at eob
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1397 (goto-char (point-min))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1398 (forward-char makefile-browser-cursor-column)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1399
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1400 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1401 ;;; Moving up and down in the browser
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1402 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1403
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1404 (defun makefile-browser-next-line ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1405 "Move the browser selection cursor to the next line."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1406 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1407 (if (not (makefile-last-line-p))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1408 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1409 (forward-line 1)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1410 (forward-char makefile-browser-cursor-column))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1411
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1412 (defun makefile-browser-previous-line ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1413 "Move the browser selection cursor to the previous line."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1414 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1415 (if (not (makefile-first-line-p))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1416 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1417 (forward-line -1)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1418 (forward-char makefile-browser-cursor-column))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1419
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1420 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1421 ;;; Quitting the browser (returns to client buffer)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1422 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1423
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1424 (defun makefile-browser-quit ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1425 "Leave the browser and return to the makefile buffer."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1426 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1427 (let ((my-client makefile-browser-client))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1428 (setq makefile-browser-client nil) ; we quitted, so NO client!
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1429 (set-buffer-modified-p nil)
21096
712fd7860b32 (makefile-browser-quit): Use quit-window.
Richard M. Stallman <rms@gnu.org>
parents: 21000
diff changeset
1430 (quit-window t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1431 (pop-to-buffer my-client)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1432
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1433 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1434 ;;; Toggle state of a browser item
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1435 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1436
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1437 (defun makefile-browser-toggle ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1438 "Toggle the selection state of the browser item at the cursor position."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1439 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1440 (let ((this-line (count-lines (point-min) (point))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1441 (setq this-line (max 1 this-line))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1442 (makefile-browser-toggle-state-for-line this-line)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1443 (goto-line this-line)
5820
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1444 (let ((inhibit-read-only t))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1445 (beginning-of-line)
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1446 (if (makefile-browser-on-macro-line-p)
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1447 (let ((macro-name (makefile-browser-this-line-macro-name)))
14277
f0d30883b329 (makefile-browser-toggle): Use delete-region, not kill-line.
Richard M. Stallman <rms@gnu.org>
parents: 14209
diff changeset
1448 (delete-region (point) (progn (end-of-line) (point)))
5820
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1449 (insert
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1450 (makefile-browser-format-macro-line
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1451 macro-name
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1452 (makefile-browser-get-state-for-line this-line))))
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1453 (let ((target-name (makefile-browser-this-line-target-name)))
14277
f0d30883b329 (makefile-browser-toggle): Use delete-region, not kill-line.
Richard M. Stallman <rms@gnu.org>
parents: 14209
diff changeset
1454 (delete-region (point) (progn (end-of-line) (point)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1455 (insert
5820
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1456 (makefile-browser-format-target-line
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1457 target-name
3443820118a0 (makefile-browser-fill, makefile-browser-toggle):
Richard M. Stallman <rms@gnu.org>
parents: 5464
diff changeset
1458 (makefile-browser-get-state-for-line this-line))))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1459 (beginning-of-line)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1460 (forward-char makefile-browser-cursor-column)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1461 (if makefile-browser-auto-advance-after-selection-p
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1462 (makefile-browser-next-line))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1463
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1464 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1465 ;;; Making insertions into the client buffer
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1466 ;;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1467
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1468 (defun makefile-browser-insert-continuation ()
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1469 "Insert a makefile continuation.
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1470 In the makefile buffer, go to (end-of-line), insert a \'\\\'
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1471 character, insert a new blank line, go to that line and indent by one TAB.
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1472 This is most useful in the process of creating continued lines when copying
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1473 large dependencies from the browser to the client buffer.
7639
67b7d1ea7b2e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7024
diff changeset
1474 \(point) advances accordingly in the client buffer."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1475 (interactive)
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1476 (with-current-buffer makefile-browser-client
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1477 (end-of-line)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1478 (insert "\\\n\t")))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1479
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1480 (defun makefile-browser-insert-selection ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1481 "Insert all selected targets and/or macros in the makefile buffer.
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
1482 Insertion takes place at point."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1483 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1484 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1485 (goto-line 1)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1486 (let ((current-line 1))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1487 (while (not (eobp))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1488 (if (makefile-browser-get-state-for-line current-line)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1489 (makefile-browser-send-this-line-item))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1490 (forward-line 1)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1491 (setq current-line (1+ current-line))))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1492
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1493 (defun makefile-browser-insert-selection-and-quit ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1494 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1495 (makefile-browser-insert-selection)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1496 (makefile-browser-quit))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1497
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1498 (defun makefile-browser-send-this-line-item ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1499 (if (makefile-browser-on-macro-line-p)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1500 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1501 (let ((macro-name (makefile-browser-this-line-macro-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1502 (set-buffer makefile-browser-client)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1503 (insert (makefile-format-macro-ref macro-name) " ")))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1504 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1505 (let ((target-name (makefile-browser-this-line-target-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1506 (set-buffer makefile-browser-client)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1507 (insert target-name " ")))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1508
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1509 (defun makefile-browser-start-interaction ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1510 (use-local-map makefile-browser-map)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1511 (setq buffer-read-only t))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1512
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1513 (defun makefile-browse (targets macros)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1514 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1515 (if (zerop (+ (length targets) (length macros)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1516 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1517 (beep)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1518 (message "No macros or targets to browse! Consider running 'makefile-pickup-everything\'"))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1519 (let ((browser-buffer (get-buffer-create makefile-browser-buffer-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1520 (pop-to-buffer browser-buffer)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1521 (makefile-browser-fill targets macros)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1522 (shrink-window-if-larger-than-buffer)
38418
336177767929 (makefile-browse): Use make-local-variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37469
diff changeset
1523 (set (make-local-variable 'makefile-browser-selection-vector)
336177767929 (makefile-browse): Use make-local-variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37469
diff changeset
1524 (make-vector (+ (length targets) (length macros)) nil))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1525 (makefile-browser-start-interaction))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1526
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1527 (defun makefile-switch-to-browser ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1528 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1529 (run-hooks 'makefile-browser-hook)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1530 (setq makefile-browser-client (current-buffer))
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1531 (makefile-pickup-targets)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1532 (makefile-pickup-macros)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1533 (makefile-browse makefile-target-table makefile-macro-table))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1534
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1535
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1536
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1537 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1538 ;;; Up-to-date overview buffer
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1539 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1540
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1541 (defun makefile-create-up-to-date-overview ()
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1542 "Create a buffer containing an overview of the state of all known targets.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1543 Known targets are targets that are explicitly defined in that makefile;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1544 in other words, all targets that appear on the left hand side of a
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1545 dependency in the makefile."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1546 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1547 (if (y-or-n-p "Are you sure that the makefile being edited is consistent? ")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1548 ;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1549 ;; The rest of this function operates on a temporary makefile, created by
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1550 ;; writing the current contents of the makefile buffer.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1551 ;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1552 (let ((saved-target-table makefile-target-table)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1553 (this-buffer (current-buffer))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1554 (makefile-up-to-date-buffer
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1555 (get-buffer-create makefile-up-to-date-buffer-name))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1556 (filename (makefile-save-temporary))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1557 ;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1558 ;; Forget the target table because it may contain picked-up filenames
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1559 ;; that are not really targets in the current makefile.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1560 ;; We don't want to query these, so get a new target-table with just the
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1561 ;; targets that can be found in the makefile buffer.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1562 ;; The 'old' target table will be restored later.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1563 ;;
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1564 (real-targets (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1565 (makefile-pickup-targets)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1566 makefile-target-table))
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1567 (prereqs makefile-has-prereqs)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1568 )
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1569
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1570 (set-buffer makefile-up-to-date-buffer)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1571 (setq buffer-read-only nil)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1572 (erase-buffer)
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1573 (makefile-query-targets filename real-targets prereqs)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1574 (if (zerop (buffer-size)) ; if it did not get us anything
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1575 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1576 (kill-buffer (current-buffer))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1577 (message "No overview created!")))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1578 (set-buffer this-buffer)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1579 (setq makefile-target-table saved-target-table)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1580 (if (get-buffer makefile-up-to-date-buffer-name)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1581 (progn
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1582 (pop-to-buffer (get-buffer makefile-up-to-date-buffer-name))
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1583 (shrink-window-if-larger-than-buffer)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1584 (sort-lines nil (point-min) (point-max))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1585 (setq buffer-read-only t))))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1586
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1587 (defun makefile-save-temporary ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1588 "Create a temporary file from the current makefile buffer."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1589 (let ((filename (makefile-generate-temporary-filename)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1590 (write-region (point-min) (point-max) filename nil 0)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1591 filename)) ; return the filename
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1592
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1593 (defun makefile-generate-temporary-filename ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1594 "Create a filename suitable for use in `makefile-save-temporary'.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1595 Be careful to allow brain-dead file systems (DOS, SYSV ...) to cope
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1596 with the generated name!"
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1597 (let ((my-name (user-login-name))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1598 (my-uid (int-to-string (user-uid))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1599 (concat "mktmp"
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1600 (if (> (length my-name) 3)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1601 (substring my-name 0 3)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1602 my-name)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1603 "."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1604 (if (> (length my-uid) 3)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1605 (substring my-uid 0 3)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1606 my-uid))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1607
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1608 (defun makefile-query-targets (filename target-table prereq-list)
12936
1548eeb34926 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12912
diff changeset
1609 "Fill the up-to-date overview buffer.
70812
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
1610 Checks each target in TARGET-TABLE using
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
1611 `makefile-query-one-target-method-function'
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1612 and generates the overview, one line per target name."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1613 (insert
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1614 (mapconcat
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1615 (function (lambda (item)
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1616 (let* ((target-name (car item))
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1617 (no-prereqs (not (member target-name prereq-list)))
26136
6e87dd221598 Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 24271
diff changeset
1618 (needs-rebuild (or no-prereqs
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1619 (funcall
70812
5244bd9a8bac (makefile-query-one-target-method): Make this the alias for the
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70810
diff changeset
1620 makefile-query-one-target-method-function
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1621 target-name
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1622 filename))))
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1623 (format "\t%s%s"
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1624 target-name
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1625 (cond (no-prereqs " .. has no prerequisites")
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1626 (needs-rebuild " .. NEEDS REBUILD")
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1627 (t " .. is up to date"))))
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1628 ))
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1629 target-table "\n"))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1630 (goto-char (point-min))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1631 (delete-file filename)) ; remove the tmpfile
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1632
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1633 (defun makefile-query-by-make-minus-q (target &optional filename)
53477
79093b308520 * progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53170
diff changeset
1634 (not (eq 0
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1635 (call-process makefile-brave-make nil nil nil
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1636 "-f" filename "-q" target))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1637
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1638
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1639
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1640 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1641 ;;; Continuation cleanup
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1642 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1643
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1644 (defun makefile-cleanup-continuations ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1645 (if (eq major-mode 'makefile-mode)
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1646 (if (and makefile-cleanup-continuations
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1647 (not buffer-read-only))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1648 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1649 (goto-char (point-min))
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1650 (while (re-search-forward "\\\\[ \t]+$" nil t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1651 (replace-match "\\" t t))))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1652
6146
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1653
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1654 ;;; ------------------------------------------------------------
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1655 ;;; Warn of suspicious lines
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1656 ;;; ------------------------------------------------------------
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1657
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1658 (defun makefile-warn-suspicious-lines ()
28277
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1659 ;; Returning non-nil cancels the save operation
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1660 (if (eq major-mode 'makefile-mode)
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1661 (save-excursion
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1662 (goto-char (point-min))
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1663 (if (re-search-forward "^\\(\t+$\\| +\t\\)" nil t)
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1664 (not (y-or-n-p
48018
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1665 (format "Suspicious line %d. Save anyway? "
28277
18aaefd4bc8f (makefile-warn-suspicious-lines): clean
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26621
diff changeset
1666 (count-lines (point-min) (point)))))))))
48018
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1667
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1668 (defun makefile-warn-continuations ()
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1669 (if (eq major-mode 'makefile-mode)
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1670 (save-excursion
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1671 (goto-char (point-min))
48037
1e646259d1b2 (makefile-warn-continuations): Don't barf when there _aren't_ any
Miles Bader <miles@gnu.org>
parents: 48018
diff changeset
1672 (if (re-search-forward "\\\\[ \t]+$" nil t)
48018
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1673 (not (y-or-n-p
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1674 (format "Suspicious continuation in line %d. Save anyway? "
1117d26eaae0 (makefile-cleanup-continuations): Default for variable is nil.
Richard M. Stallman <rms@gnu.org>
parents: 47546
diff changeset
1675 (count-lines (point-min) (point)))))))))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1676
6146
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1677
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1678 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1679 ;;; GNU make function support
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1680 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1681
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1682 (defun makefile-insert-gmake-function ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1683 "Insert a GNU make function call.
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1684 Asks for the name of the function to use (with completion).
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1685 Then prompts for all required parameters."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1686 (interactive)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1687 (let* ((gm-function-name (completing-read
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1688 "Function: "
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1689 makefile-gnumake-functions-alist
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1690 nil t nil))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1691 (gm-function-prompts
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1692 (cdr (assoc gm-function-name makefile-gnumake-functions-alist))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1693 (if (not (zerop (length gm-function-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1694 (insert (makefile-format-macro-ref
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1695 (concat gm-function-name " "
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1696 (makefile-prompt-for-gmake-funargs
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1697 gm-function-name gm-function-prompts)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1698 " "))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1699
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1700 (defun makefile-prompt-for-gmake-funargs (function-name prompt-list)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1701 (mapconcat
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1702 (function (lambda (one-prompt)
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1703 (read-string (format "[%s] %s: " function-name one-prompt)
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1704 nil)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1705 prompt-list
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1706 ","))
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1707
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1708
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1709
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1710 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1711 ;;; Utility functions
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1712 ;;; ------------------------------------------------------------
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1713
62276
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1714 (defun makefile-match-function-end (end)
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1715 "To be called as an anchored matcher by font-lock.
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1716 The anchor must have matched the opening parens in the first group."
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1717 (let ((s (match-string-no-properties 1)))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1718 (setq s (cond ((string= s "(") "\\(.*?\\)[ \t]*)")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1719 ((string= s "{") "\\(.*?\\)[ \t]*}")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1720 ((string= s "((") "\\(.*?\\)[ \t]*))")
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1721 ((string= s "{{") "\\(.*?\\)[ \t]*}}")))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1722 (if s (looking-at s))))
c1e4bf9803aa (makefile-targets-face, makefile-shell-face, makefile-makepp-perl-face): New faces.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62082
diff changeset
1723
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1724 (defun makefile-match-dependency (bound)
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1725 "Search for `makefile-dependency-regex' up to BOUND.
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1726 Checks that the colon has not already been fontified, else we
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1727 matched in a rule action."
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1728 (catch 'found
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1729 (let ((pt (point)))
62503
c50200e8e7e8 (makefile-add-this-line-targets): Simplify and integrate into `makefile-pickup-targets'.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62491
diff changeset
1730 (while (progn (skip-chars-forward makefile-dependency-skip bound)
62569
f09fbe52c543 (makefile-imenu-generic-expression): Use function to find dependencies, because regexp alone is so complex, it easily goes into an endless loop.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62525
diff changeset
1731 (< (point) (or bound (point-max))))
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1732 (forward-char)
62491
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
1733 (or (eq (char-after) ?=)
2acb3a2dd842 (makefile-previous-dependency, makefile-match-dependency): Check for := (and in bsd mode also !=) to give a better result, even when font-lock is not on.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62446
diff changeset
1734 (get-text-property (1- (point)) 'face)
63444
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
1735 (if (> (line-beginning-position) (+ (point-min) 2))
cc4a71461921 (makefile-space, makefile-makepp-perl): Eliminate "-face" suffix.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 63138
diff changeset
1736 (eq (char-before (line-end-position 0)) ?\\))
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1737 (when (save-excursion
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1738 (beginning-of-line)
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1739 (looking-at makefile-dependency-regex))
63067
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1740 (save-excursion
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1741 (let ((deps-end (match-end 1))
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1742 (match-data (match-data)))
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1743 (goto-char deps-end)
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1744 (skip-chars-backward " \t")
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1745 (setq deps-end (point))
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1746 (beginning-of-line)
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1747 (skip-chars-forward " \t")
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1748 ;; Alter the bounds recorded for subexp 1,
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1749 ;; which is what is supposed to match the targets.
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1750 (setcar (nthcdr 2 match-data) (point))
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1751 (setcar (nthcdr 3 match-data) deps-end)
7738d9700f66 (makefile-dependency-regex): Handle whitespace
Richard M. Stallman <rms@gnu.org>
parents: 62965
diff changeset
1752 (store-match-data match-data)))
62444
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1753 (end-of-line)
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1754 (throw 'found (point)))))
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1755 (goto-char pt))
24bf25fa47db (makefile-dependency-skip): New variable.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62412
diff changeset
1756 nil))
62412
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1757
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1758 (defun makefile-match-action (bound)
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1759 (catch 'found
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1760 (while (re-search-forward makefile-rule-action-regex bound t)
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1761 (or (eq ?\\ (char-after (- (match-beginning 0) 2)))
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1762 (throw 'found t)))))
6ac7ed8e212b (makefile-dependency-regex): Turn it into a var, and refine it to mask one more level of nested vars.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62276
diff changeset
1763
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1764 (defun makefile-do-macro-insertion (macro-name)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1765 "Insert a macro reference."
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1766 (if (not (zerop (length macro-name)))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1767 (if (assoc macro-name makefile-runtime-macros-list)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1768 (insert "$" macro-name)
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1769 (insert (makefile-format-macro-ref macro-name)))))
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1770
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1771 (defun makefile-remember-target (target-name &optional has-prereqs)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1772 "Remember a given target if it is not already remembered for this buffer."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1773 (if (not (zerop (length target-name)))
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1774 (progn
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1775 (if (not (assoc target-name makefile-target-table))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1776 (setq makefile-target-table
2559
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1777 (cons (list target-name) makefile-target-table)))
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1778 (if has-prereqs
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1779 (setq makefile-has-prereqs
5f2c2994cbca Rewritten and simplified, commentary added. It now will usually
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2534
diff changeset
1780 (cons target-name makefile-has-prereqs))))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1781
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1782 (defun makefile-remember-macro (macro-name)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1783 "Remember a given macro if it is not already remembered for this buffer."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1784 (if (not (zerop (length macro-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1785 (if (not (assoc macro-name makefile-macro-table))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1786 (setq makefile-macro-table
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1787 (cons (list macro-name) makefile-macro-table)))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1788
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1789 (defun makefile-forward-after-target-colon ()
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1790 "Move point forward after inserting the terminating colon of a target.
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1791 This acts according to the value of `makefile-tab-after-target-colon'."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1792 (if makefile-tab-after-target-colon
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1793 (insert "\t")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1794 (insert " ")))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1795
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1796 (defun makefile-browser-on-macro-line-p ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1797 "Determine if point is on a macro line in the browser."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1798 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1799 (beginning-of-line)
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1800 (re-search-forward "\\$[{(]" (line-end-position) t)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1801
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1802 (defun makefile-browser-this-line-target-name ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1803 "Extract the target name from a line in the browser."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1804 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1805 (end-of-line)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1806 (skip-chars-backward "^ \t")
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1807 (buffer-substring (point) (1- (line-end-position)))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1808
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1809 (defun makefile-browser-this-line-macro-name ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1810 "Extract the macro name from a line in the browser."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1811 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1812 (beginning-of-line)
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1813 (re-search-forward "\\$[{(]" (line-end-position) t)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1814 (let ((macro-start (point)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1815 (skip-chars-forward "^})")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1816 (buffer-substring macro-start (point)))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1817
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1818 (defun makefile-format-macro-ref (macro-name)
9758
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1819 "Format a macro reference.
b9084912762f Changed almost every doc string.
Richard M. Stallman <rms@gnu.org>
parents: 9477
diff changeset
1820 Uses `makefile-use-curly-braces-for-macros-p'."
6146
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1821 (if (or (char-equal ?\( (string-to-char macro-name))
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1822 (char-equal ?\{ (string-to-char macro-name)))
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1823 (format "$%s" macro-name)
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1824 (if makefile-use-curly-braces-for-macros-p
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1825 (format "${%s}" macro-name)
1a2a8ef9b4af (makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents: 5820
diff changeset
1826 (format "$(%s)" macro-name))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1827
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1828 (defun makefile-browser-get-state-for-line (n)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1829 (aref makefile-browser-selection-vector (1- n)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1830
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1831 (defun makefile-browser-set-state-for-line (n to-state)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1832 (aset makefile-browser-selection-vector (1- n) to-state))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1833
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1834 (defun makefile-browser-toggle-state-for-line (n)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1835 (makefile-browser-set-state-for-line n (not (makefile-browser-get-state-for-line n))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1836
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1837 (defun makefile-last-line-p ()
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1838 (= (line-end-position) (point-max)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1839
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1840 (defun makefile-first-line-p ()
41641
66c7637cbf17 Use line-(end|beginning)-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38600
diff changeset
1841 (= (line-beginning-position) (point-min)))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1842
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1843
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1844
24271
bab606b16c3c Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 24248
diff changeset
1845 ;;; Support for other packages, like add-log.
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1846
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1847 (defun makefile-add-log-defun ()
13847
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1848 "Return name of target or variable assignment that point is in.
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1849 If it isn't in one, return nil."
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1850 (save-excursion
13847
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1851 (let (found)
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1852 (beginning-of-line)
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1853 ;; Scan back line by line, noticing when we come to a
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1854 ;; variable or rule definition, and giving up when we see
36556403b62b (makefile-add-log-defun): Rewrite to scan back
Richard M. Stallman <rms@gnu.org>
parents: 13804
diff changeset
1855 ;; a line that is not part of either of those.
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1856 (while (not (or (setq found
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1857 (when (or (looking-at makefile-macroassign-regex)
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1858 (looking-at makefile-dependency-regex))
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1859 (match-string-no-properties 1)))
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1860 ;; Don't keep looking across a blank line or comment.
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1861 (looking-at "$\\|#")
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1862 (not (zerop (forward-line -1))))))
65383
4dadc0d80d76 (makefile-add-log-defun): Trim the result.
Richard M. Stallman <rms@gnu.org>
parents: 64699
diff changeset
1863 ;; Remove leading and trailing whitespace.
4dadc0d80d76 (makefile-add-log-defun): Trim the result.
Richard M. Stallman <rms@gnu.org>
parents: 64699
diff changeset
1864 (when found
4dadc0d80d76 (makefile-add-log-defun): Trim the result.
Richard M. Stallman <rms@gnu.org>
parents: 64699
diff changeset
1865 (setq found (replace-regexp-in-string "[ \t]+\\'" "" found))
4dadc0d80d76 (makefile-add-log-defun): Trim the result.
Richard M. Stallman <rms@gnu.org>
parents: 64699
diff changeset
1866 (setq found (replace-regexp-in-string "\\`[ \t]+" "" found)))
47546
2c7b4003c5ad (makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47527
diff changeset
1867 found)))
9454
40340d39257d (makefile-mode-name): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1868
41642
d00b43e2316c Move `provide' to the end.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41641
diff changeset
1869 (provide 'make-mode)
d00b43e2316c Move `provide' to the end.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41641
diff changeset
1870
71030
6e1192ac395f (makefile-browser-map, makefile-mode-syntax-table): Move init inside decl.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70812
diff changeset
1871 ;; arch-tag: bd23545a-de91-44fb-b1b2-feafbb2635a0
13402
1f9832fe9e44 (makefile-define-space-face): Don't make face if non-X.
Karl Heuer <kwzh@gnu.org>
parents: 13333
diff changeset
1872 ;;; make-mode.el ends here