annotate lisp/modes/make-mode.el @ 120:cca96a509cfe r20-1b12

Import from CVS: tag r20-1b12
author cvs
date Mon, 13 Aug 2007 09:25:29 +0200
parents 1040fe1366ac
children 9b50b4588a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; make-mode.el --- makefile editing commands for Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Thomas Neumann <tom@smart.bo.open.de>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Eric S. Raymond <esr@snark.thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Adapted-By: ESR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: unix, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; RMS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This needs work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; Also, the doc strings need fixing: the first line doesn't stand alone,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; and other usage is not high quality. Symbol names don't have `...'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
29 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
30 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
32 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; A major mode for editing makefiles. The mode knows about Makefile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; syntax and defines M-n and M-p to move to next and previous productions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; The keys $, =, : and . are electric; they try to help you fill in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; macro reference, macro definition, ordinary target name, or special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; target name, respectively. Such names are completed using a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; targets and macro names parsed out of the makefile. This list is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; automatically updated, if necessary, whenever you invoke one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; these commands. You can force it to be updated with C-c C-p.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; The command C-c C-f adds certain filenames in the current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; as targets. You can filter out filenames by setting the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; makefile-ignored-files-in-pickup-regex.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; The command C-c C-u grinds for a bit, then pops up a report buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; showing which target names are up-to-date with respect to their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; prerequisites, which targets are out-of-date, and which have no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; prerequisites.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; The command C-c C-b pops up a browser window listing all target and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; macro names. You can mark or unmark items wit C-c SPC, and insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; all marked items back in the Makefile with C-c TAB.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; The command C-c TAB in the makefile buffer inserts a GNU make builtin.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; You will be prompted for the builtin's args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; There are numerous other customization variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; To Do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; * makefile-backslash-region should be given better behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; * Consider binding C-c C-c to comment-region (like cc-mode).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; * Eliminate electric stuff entirely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; * It might be nice to highlight targets differently depending on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; whether they are up-to-date or not. Not sure how this would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; interact with font-lock.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; * Would be nice to edit the commands in ksh-mode and have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; indentation and slashification done automatically. Hard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; * Consider removing browser mode. It seems useless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; * ":" should notice when a new target is made and add it to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; list (or at least set makefile-need-target-pickup).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; * Make browser into a major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; * Clean up macro insertion stuff. It is a mess.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; * Browser entry and exit is weird. Normalize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; * Browser needs to be rewritten. Right now it is kind of a crock.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Should at least:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; * Act more like dired/buffer menu/whatever.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; * Highlight as mouse traverses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; * B2 inserts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; * Update documentation above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; * Update texinfo manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; * Update files.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (provide 'makefile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
96 (defgroup makefile-mode nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
97 "Makefile mode customizations"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
98 :group 'tools
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
99 :prefix "makefile-")
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
100
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
101
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; Sadly we need this for a macro.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
103 (eval-when-compile
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
104 (require 'imenu))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; Configurable stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
110 (defcustom makefile-browser-buffer-name "*Macros and Targets*"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
111 "Name of the macro- and target browser buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
112 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
113 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
115 (defcustom makefile-target-colon ":"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 "String to append to all target names inserted by `makefile-insert-target'.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
117 \":\" or \"::\" are common values."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
118 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
119 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
121 (defcustom makefile-macro-assign " = "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "String to append to all macro names inserted by `makefile-insert-macro'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 The normal value should be \" = \", since this is what
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 standard make expects. However, newer makes such as dmake
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 allow a larger variety of different macro assignments, so you
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
126 might prefer to use \" += \" or \" := \" ."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
127 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
128 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
130 (defcustom makefile-electric-keys nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "If non-nil, install electric keybindings.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
132 Default is nil."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
133 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
134 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
136 (defcustom makefile-use-curly-braces-for-macros-p nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "Controls the style of generated macro references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 t (actually non-nil) means macro references should use curly braces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 like `${this}'.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
140 nil means use parentheses, like `$(this)'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
141 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
142 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
144 (defcustom makefile-tab-after-target-colon t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "If non-nil, insert a TAB after a target colon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Otherwise, a space is inserted.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
147 The default is t."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
148 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
149 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
151 (defcustom makefile-browser-leftmost-column 10
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
152 "Number of blanks to the left of the browser selection mark."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
153 :type 'integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
154 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
156 (defcustom makefile-browser-cursor-column 10
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "Column in which the cursor is positioned when it moves
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
158 up or down in the browser."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
159 :type 'integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
160 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
162 (defcustom makefile-backslash-column 48
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
163 "*Column in which `makefile-backslash-region' inserts backslashes."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
164 :type 'integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
165 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
167 (defcustom makefile-browser-selected-mark "+ "
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
168 "String used to mark selected entries in the browser."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
169 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
170 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
172 (defcustom makefile-browser-unselected-mark " "
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
173 "String used to mark unselected entries in the browser."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
174 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
175 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
177 (defcustom makefile-browser-auto-advance-after-selection-p t
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
178 "If non-nil, cursor will move after item is selected in browser."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
179 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
180 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
182 (defcustom makefile-pickup-everything-picks-up-filenames-p nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "If non-nil, `makefile-pickup-everything' picks up filenames as targets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 \(i.e. it calls `makefile-find-filenames-as-targets').
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
185 Otherwise filenames are omitted."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
186 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
187 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
189 (defcustom makefile-cleanup-continuations-p t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "If non-nil, automatically clean up continuation lines when saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 A line is cleaned up by removing all whitespace following a trailing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 backslash. This is done silently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 IMPORTANT: Please note that enabling this option causes makefile-mode
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
194 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \'it seems necessary\'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
195 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
196 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
198 ;;; those suspicious line warnings are really annoying and
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
199 ;;; seem to be generated for every makefile I've ever seen.
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
200 ;;; add a simple mechanism to disable them. -gk
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
201 (defcustom makefile-warn-suspicious-lines-p t
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
202 "In non-nil, warn about suspicious lines when saving the makefile"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
203 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
204 :group 'makefile-mode)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
205
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
206 (defcustom makefile-browser-hook '()
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
207 "The hook to run when entering makefile browser."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
208 :type 'hook
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
209 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;; Special targets for DMake, Sun's make ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar makefile-special-targets-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 '(("DEFAULT") ("DONE") ("ERROR") ("EXPORT")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ("FAILED") ("GROUPEPILOG") ("GROUPPROLOG") ("IGNORE")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ("IMPORT") ("INCLUDE") ("INCLUDEDIRS") ("INIT")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ("KEEP_STATE") ("MAKEFILES") ("MAKE_VERSION") ("NO_PARALLEL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ("PARALLEL") ("PHONY") ("PRECIOUS") ("REMOVE")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ("SCCS_GET") ("SILENT") ("SOURCE") ("SUFFIXES")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ("WAIT") ("c.o") ("C.o") ("m.o")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ("el.elc") ("y.c") ("s.o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "List of special targets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 You will be offered to complete on one of those in the minibuffer whenever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 you enter a \".\" at the beginning of a line in makefile-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defvar makefile-runtime-macros-list
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
228 '(("@") ("&") (">") ("<") ("*") ("^") ("+") ("?") ("%") ("$"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "List of macros that are resolved by make at runtime.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 If you insert a macro reference using makefile-insert-macro-ref, the name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 of the macro is checked against this list. If it can be found its name will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 not be enclosed in { } or ( ).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; Note that the first big subexpression is used by font lock. Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; that if you change this regexp you must fix the imenu index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; function defined at the end of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (defconst makefile-dependency-regex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "^\\([^ \n\t#:]+\\([ \t]+[^ \t\n#:]+\\)*\\)[ \t]*:\\([ \t]*$\\|\\([^=\n].*$\\)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Regex used to find dependency lines in a makefile.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; Note that the first subexpression is used by font lock. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;; if you change this regexp you must fix the imenu index function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; defined at the end of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defconst makefile-macroassign-regex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "^\\([^ \n\t][^:#= \t\n]*\\)[ \t]*[*:+]?:?="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "Regex used to find macro assignment lines in a makefile.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defconst makefile-ignored-files-in-pickup-regex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "\\(^\\..*\\)\\|\\(.*~$\\)\\|\\(.*,v$\\)\\|\\(\\.[chy]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "Regex for filenames that will NOT be included in the target list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;####
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;(add-to-list 'facemenu-unlisted-faces 'makefile-space-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ; Bogus FSFmacs crap.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
255 (defface makefile-space-face
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
256 '((((class color))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
257 (:background "hotpink")) ; uhm
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
258 (((class grayscale)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
259 (background light))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
260 (:background "black"))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
261 (((class grayscale)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
262 (background black))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
263 (:background "white"))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
264 (((class mono)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
265 (background light))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
266 (:background "white"))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
267 (((class mono)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
268 (background dark))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
269 (:background "black")))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
270 "Face to use for highlighting leading spaces in Font-Lock mode."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
271 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;Older version of same.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;(defconst makefile-font-lock-keywords (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ; (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ; '("^#.*$" . font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ; '("[^$]#.*$" . font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ; ;; rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ; '("^\\([^ \t\n]*%?[^ \t\n]*[ \t]*::?\\)[ \t]" 1 font-lock-type-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ; '("^\\(\\.[A-Za-z][A-Za-z]?\\..[ \t]*::?\\)" 1 font-lock-type-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ; '("^[^ \t\n]+[ \t]*:;?\\(.*\\)$" 1 font-lock-doc-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ; ;; variable definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ; '("^[_A-Za-z0-9]+[ \t]*\+?=" . font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ; '("\\( \\|:=\\)[_A-Za-z0-9]+[ \t]*\\+=" . font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ; ;; variable references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ; '("\\(\\$\\$?\\([^ \t\n{(]\\|[{(][^ \t\n)}]+[)}]\\)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ; 1 font-lock-keyword-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ; '("^include " . font-lock-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ; ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (defconst makefile-font-lock-keywords (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; Do macro assignments. These get the "variable-name" face rather
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; arbitrarily.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (list makefile-macroassign-regex 1 'font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; Variable references even in targets/strings/comments:
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
298 '("\\$[({]\\([a-zA-Z0-9_]+\\)[})]" 1 font-lock-reference-face prepend)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; Do dependencies. These get the function name face.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
301 (list makefile-dependency-regex 1 'font-lock-function-name-face 'prepend)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; Highlight lines that contain just whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; They can cause trouble, especially if they start with a tab.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
305 '("^[ \t]+$" . 'makefile-space-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; Highlight shell comments that Make treats as commands,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; since these can fool people.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
309 '("^\t+#" 0 'makefile-space-face t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; Highlight spaces that precede tabs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; They can make a tab fail to be effective.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
313 '("^\\( +\\)\t" 1 'makefile-space-face)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Additional expressions to highlight in makefiles")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (put 'makefile-mode 'font-lock-defaults '(makefile-font-lock-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;;; The following configurable variables are used in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;;; up-to-date overview .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;;; The standard configuration assumes that your `make' program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;;; can be run in question/query mode using the `-q' option, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;;; means that the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;;; make -q foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;;; should return an exit status of zero if the target `foo' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;;; up to date and a nonzero exit status otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;;; Many makes can do this although the docs/manpages do not mention
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;;; it. Try it with your favourite one. GNU make, System V make, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;;; Dennis Vadura's DMake have no problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;;; Set the variable `makefile-brave-make' to the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;; make utility that does this on your system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;; To understand what this is all about see the function definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;;; of `makefile-query-by-make-minus-q' .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
338 (defcustom makefile-brave-make "make"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
339 "A make that can handle the `-q' option."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
340 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
341 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
343 (defcustom makefile-query-one-target-method 'makefile-query-by-make-minus-q
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "Function to call to determine whether a make target is up to date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 The function must satisfy this calling convention:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 * As its first argument, it must accept the name of the target to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 be checked, as a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 * As its second argument, it may accept the name of a makefile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 as a string. Depending on what you're going to do you may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 not need this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 * It must return the integer value 0 (zero) if the given target
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 should be considered up-to-date in the context of the given
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
356 makefile, any nonzero integer value otherwise."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
357 :type 'function
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
358 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
360 (defcustom makefile-up-to-date-buffer-name "*Makefile Up-to-date overview*"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
361 "Name of the Up-to-date overview buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
362 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 94
diff changeset
363 :group 'makefile-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;;; --- end of up-to-date-overview configuration ------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defvar makefile-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "The keymap that is used in Makefile mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if makefile-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq makefile-mode-map (make-sparse-keymap 'makefile-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; set up the keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (define-key makefile-mode-map "\C-c:" 'makefile-insert-target-ref)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if makefile-electric-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (define-key makefile-mode-map "$" 'makefile-insert-macro-ref)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (define-key makefile-mode-map ":" 'makefile-electric-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (define-key makefile-mode-map "=" 'makefile-electric-equal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (define-key makefile-mode-map "." 'makefile-electric-dot)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (define-key makefile-mode-map "\C-c\C-f" 'makefile-pickup-filenames-as-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (define-key makefile-mode-map "\C-c\C-b" 'makefile-switch-to-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (define-key makefile-mode-map "\C-c\C-p" 'makefile-pickup-everything)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (define-key makefile-mode-map "\C-c\C-u" 'makefile-create-up-to-date-overview)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (define-key makefile-mode-map "\C-c\C-i" 'makefile-insert-gmake-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (define-key makefile-mode-map "\C-c\C-\\" 'makefile-backslash-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (define-key makefile-mode-map "\M-p" 'makefile-previous-dependency)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (define-key makefile-mode-map "\M-n" 'makefile-next-dependency)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (define-key makefile-mode-map "\e\t" 'makefile-complete))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
391 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defconst makefile-menubar-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 '("Makefile"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ["Move to Next Dependency" makefile-next-dependency t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ["Move to Previous Dependency" makefile-previous-dependency t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ["Find Targets and Macros" makefile-pickup-everything t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ["Complete Target or Macro" makefile-complete t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ["Pop up Makefile Browser" makefile-switch-to-browser t])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
402 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defconst makefile-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (cons "Makefile Mode Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (cdr makefile-menubar-menu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defvar makefile-browser-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "The keymap that is used in the macro- and target browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (if makefile-browser-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq makefile-browser-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (define-key makefile-browser-map "n" 'makefile-browser-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (define-key makefile-browser-map "\C-n" 'makefile-browser-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (define-key makefile-browser-map "p" 'makefile-browser-previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (define-key makefile-browser-map "\C-p" 'makefile-browser-previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (define-key makefile-browser-map " " 'makefile-browser-toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (define-key makefile-browser-map "i" 'makefile-browser-insert-selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (define-key makefile-browser-map "I" 'makefile-browser-insert-selection-and-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (define-key makefile-browser-map "\C-c\C-m" 'makefile-browser-insert-continuation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (define-key makefile-browser-map "q" 'makefile-browser-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;; disable horizontal movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (define-key makefile-browser-map "\C-b" 'undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (define-key makefile-browser-map "\C-f" 'undefined))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defvar makefile-mode-syntax-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if makefile-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (setq makefile-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (modify-syntax-entry ?\( "() " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (modify-syntax-entry ?\) ")( " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (modify-syntax-entry ?\[ "(] " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (modify-syntax-entry ?\] ")[ " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (modify-syntax-entry ?\{ "(} " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (modify-syntax-entry ?\} "){ " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (modify-syntax-entry ?\' "\" " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (modify-syntax-entry ?\` "\" " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (modify-syntax-entry ?# "< " makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (modify-syntax-entry ?\n "> " makefile-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;;; You don't need to configure below this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defvar makefile-target-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "Table of all target names known for this buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (defvar makefile-macro-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 "Table of all macro names known for this buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defvar makefile-browser-client
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "A buffer in Makefile mode that is currently using the browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defvar makefile-browser-selection-vector nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defvar makefile-has-prereqs nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defvar makefile-need-target-pickup t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (defvar makefile-need-macro-pickup t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defvar makefile-mode-hook '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; Each element looks like '("GNU MAKE FUNCTION" "ARG" "ARG" ... )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;; Each "ARG" is used as a prompt for a required argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defconst makefile-gnumake-functions-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; Text functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ("subst" "From" "To" "In")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ("patsubst" "Pattern" "Replacement" "In")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ("strip" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ("findstring" "Find what" "In")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ("filter" "Pattern" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ("filter-out" "Pattern" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ("sort" "List")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; Filename functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ("dir" "Names")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ("notdir" "Names")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ("suffix" "Names")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ("basename" "Names")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
481 ("addprefix" "Prefix" "Names")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ("addsuffix" "Suffix" "Names")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ("join" "List 1" "List 2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ("word" "Index" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ("words" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ("firstword" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ("wildcard" "Pattern")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; Misc functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ("foreach" "Variable" "List" "Text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ("origin" "Variable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ("shell" "Command")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;;; The mode function itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (defun makefile-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 "Major mode for editing Makefiles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 This function ends by invoking the function(s) `makefile-mode-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 \\{makefile-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 In the browser, use the following keys:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 \\{makefile-browser-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 Makefile mode can be configured by modifying the following variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 makefile-browser-buffer-name:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 Name of the macro- and target browser buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 makefile-target-colon:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 The string that gets appended to all target names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 inserted by `makefile-insert-target'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 \":\" or \"::\" are quite common values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 makefile-macro-assign:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 The string that gets appended to all macro names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 inserted by `makefile-insert-macro'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 The normal value should be \" = \", since this is what
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 standard make expects. However, newer makes such as dmake
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 allow a larger variety of different macro assignments, so you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 might prefer to use \" += \" or \" := \" .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 makefile-tab-after-target-colon:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 If you want a TAB (instead of a space) to be appended after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 target colon, then set this to a non-nil value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 makefile-browser-leftmost-column:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 Number of blanks to the left of the browser selection mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 makefile-browser-cursor-column:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 Column in which the cursor is positioned when it moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 up or down in the browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 makefile-browser-selected-mark:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 String used to mark selected entries in the browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 makefile-browser-unselected-mark:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 String used to mark unselected entries in the browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 makefile-browser-auto-advance-after-selection-p:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 If this variable is set to a non-nil value the cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 will automagically advance to the next line after an item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 has been selected in the browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 makefile-pickup-everything-picks-up-filenames-p:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 If this variable is set to a non-nil value then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 `makefile-pickup-everything' also picks up filenames as targets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (i.e. it calls `makefile-find-filenames-as-targets'), otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 filenames are omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 makefile-cleanup-continuations-p:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 If this variable is set to a non-nil value then makefile-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 will assure that no line in the file ends with a backslash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (the continuation character) followed by any whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 This is done by silently removing the trailing whitespace, leaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 the backslash itself intact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 IMPORTANT: Please note that enabling this option causes makefile-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 makefile-browser-hook:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 A function or list of functions to be called just before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 browser is entered. This is executed in the makefile buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 makefile-special-targets-list:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 List of special targets. You will be offered to complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 on one of those in the minibuffer whenever you enter a `.'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 at the beginning of a line in Makefile mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (make-local-variable 'local-write-file-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (setq local-write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 '(makefile-cleanup-continuations makefile-warn-suspicious-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (make-local-variable 'makefile-target-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (make-local-variable 'makefile-macro-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (make-local-variable 'makefile-has-prereqs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (make-local-variable 'makefile-need-target-pickup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (make-local-variable 'makefile-need-macro-pickup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;; Font lock.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
585 (make-local-variable 'font-lock-defaults)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
586 (setq font-lock-defaults '(makefile-font-lock-keywords))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; Add-log.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (make-local-variable 'add-log-current-defun-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (setq add-log-current-defun-function 'makefile-add-log-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
592 ;; Imenu.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
593 (make-local-variable 'imenu-create-index-function)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
594 (setq imenu-create-index-function 'makefile-menu-index-function)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; Dabbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (make-local-variable 'dabbrev-abbrev-skip-leading-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (setq dabbrev-abbrev-skip-leading-regexp "\\$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; Comment stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq comment-start "#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (make-local-variable 'comment-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (setq comment-end "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (make-local-variable 'comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq comment-start-skip "#+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; become the current major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (setq major-mode 'makefile-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setq mode-name "Makefile")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; Activate keymap and syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (use-local-map makefile-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (set-syntax-table makefile-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;; Set menu
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
617 ;; XEmacs addition
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (setq mode-popup-menu makefile-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (if (featurep 'menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; make a local copy of the menubar, so our modes don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; change the global menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (set-buffer-menubar current-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (add-submenu nil makefile-menubar-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; Real TABs are important in makefiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq indent-tabs-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (run-hooks 'makefile-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;; Motion code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (defun makefile-next-dependency ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 "Move point to the beginning of the next dependency line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if (re-search-forward makefile-dependency-regex (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (progn (beginning-of-line) t) ; indicate success
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (goto-char here) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (defun makefile-previous-dependency ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 "Move point to the beginning of the previous dependency line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (if (re-search-backward makefile-dependency-regex (point-min) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (progn (beginning-of-line) t) ; indicate success
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (goto-char here) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;;; Electric keys. Blech.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defun makefile-electric-dot (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 "Prompt for the name of a special target to insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 Only does electric insertion at beginning of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 Anywhere else just self-inserts."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (makefile-insert-special-target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (self-insert-command arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (defun makefile-insert-special-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 "Propmt for and insert a special target name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 Uses `makefile-special-targets' list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (makefile-pickup-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (let ((special-target
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (completing-read "Special target: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 makefile-special-targets-list nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (if (zerop (length special-target))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (insert "." special-target ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (makefile-forward-after-target-colon))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (defun makefile-electric-equal (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 "Prompt for name of a macro to insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 Only does prompting if point is at beginning of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 Anywhere else just self-inserts."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (makefile-pickup-macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (call-interactively 'makefile-insert-macro)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
686 (self-insert-command arg)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
687 ;; from here down is new -- if they inserted a macro without using
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
688 ;; the electric behavior, pick it up anyway -gk
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
689 (save-excursion
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
690 (beginning-of-line)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
691 (if (looking-at makefile-macroassign-regex)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
692 (makefile-add-this-line-macro)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (defun makefile-insert-macro (macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 "Prepare definition of a new macro."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (interactive "sMacro Name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (makefile-pickup-macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (if (not (zerop (length macro-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (insert macro-name makefile-macro-assign)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (setq makefile-need-macro-pickup t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (makefile-remember-macro macro-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (defun makefile-insert-macro-ref (macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 "Complete on a list of known macros, then insert complete ref at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (makefile-pickup-macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (completing-read "Refer to macro: " makefile-macro-table nil nil nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (makefile-do-macro-insertion macro-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (defun makefile-insert-target (target-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 "Prepare definition of a new target (dependency line)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (interactive "sTarget: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (if (not (zerop (length target-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (insert target-name makefile-target-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (makefile-forward-after-target-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq makefile-need-target-pickup t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (makefile-remember-target target-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (defun makefile-insert-target-ref (target-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 "Complete on a list of known targets, then insert target-ref at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (makefile-pickup-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (completing-read "Refer to target: " makefile-target-table nil nil nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (if (not (zerop (length target-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (insert target-name " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun makefile-electric-colon (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 "Prompt for name of new target.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 Prompting only happens at beginning of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 Anywhere else just self-inserts."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (call-interactively 'makefile-insert-target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (self-insert-command arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ;;; Extracting targets and macros from an existing makefile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defun makefile-pickup-targets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Notice names of all target definitions in Makefile."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (if (not makefile-need-target-pickup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (setq makefile-need-target-pickup nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (setq makefile-target-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (setq makefile-has-prereqs nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (while (re-search-forward makefile-dependency-regex (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (makefile-add-this-line-targets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (message "Read targets OK.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (defun makefile-add-this-line-targets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (let ((done-with-line nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (line-number (1+ (count-lines (point-min) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (while (not done-with-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (if (not (setq done-with-line (or (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (char-equal (char-after (point)) ?:))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (let* ((start-of-target-name (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (target-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (skip-chars-forward "^ \t:#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (buffer-substring start-of-target-name (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (has-prereqs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (not (looking-at ":[ \t]*$"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if (makefile-remember-target target-name has-prereqs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (message "Picked up target \"%s\" from line %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 target-name line-number)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (defun makefile-pickup-macros ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 "Notice names of all macro definitions in Makefile."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (if (not makefile-need-macro-pickup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (setq makefile-need-macro-pickup nil)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
792 ;; changed the nil in the next line to makefile-runtime-macros-list
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
793 ;; so you don't have to confirm on every runtime macro entered... -gk
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
794 (setq makefile-macro-table makefile-runtime-macros-list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (while (re-search-forward makefile-macroassign-regex (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (makefile-add-this-line-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (message "Read macros OK.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (defun makefile-add-this-line-macro ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (if (not (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (let* ((start-of-macro-name (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (line-number (1+ (count-lines (point-min) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (macro-name (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (skip-chars-forward "^ \t:#=*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (buffer-substring start-of-macro-name (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (if (makefile-remember-macro macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (message "Picked up macro \"%s\" from line %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 macro-name line-number))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (defun makefile-pickup-everything (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 "Notice names of all macros and targets in Makefile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Prefix arg means force pickups to be redone."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (setq makefile-need-target-pickup t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (setq makefile-need-macro-pickup t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (makefile-pickup-macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (makefile-pickup-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (if makefile-pickup-everything-picks-up-filenames-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (makefile-pickup-filenames-as-targets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (defun makefile-pickup-filenames-as-targets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 "Scan the current directory for filenames to use as targets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 Checks each filename against `makefile-ignored-files-in-pickup-regex'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 and adds all qualifying names to the list of known targets."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (let* ((dir (file-name-directory (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (raw-filename-list (if dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (file-name-all-completions "" dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (file-name-all-completions "" ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (mapcar '(lambda (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (if (and (not (file-directory-p name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (not (string-match makefile-ignored-files-in-pickup-regex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (if (makefile-remember-target name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (message "Picked up file \"%s\" as target" name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 raw-filename-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;;; Completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (defun makefile-complete ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 "Perform completion on Makefile construct preceding point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 Can complete variable and target names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 The context determines which are considered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (let* ((beg (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (skip-chars-backward "^$(){}:#= \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (try (buffer-substring beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (do-macros nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (paren nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (let ((pc (preceding-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ;; Beginning of line means anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ((bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ;; Preceding "$" means macros only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ((= pc ?$)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (setq do-macros t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; Preceding "$(" or "${" means macros only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ((and (or (= pc ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (= pc ?\())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (setq paren pc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (and (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (= (preceding-char) ?$))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (setq do-macros t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ;; Try completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (let* ((table (append (if do-macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 '()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 makefile-target-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 makefile-macro-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (completion (try-completion try table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;; Exact match, so insert closing paren or colon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ((eq completion t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (insert (if do-macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (if (eq paren ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 " "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; No match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ((null completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (message "Can't find completion for \"%s\"" try)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (ding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;; Partial completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 ((not (string= try completion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 ;; FIXME it would be nice to supply the closing paren if an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 ;; exact, unambiguous match were found. That is not possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 ;; right now. Ditto closing ":" for targets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; DO-MACROS means doing macros only. If not that, then check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;; to see if this completion is a macro. Special insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; must be done for macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (if (or do-macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (assoc completion makefile-macro-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (let ((makefile-use-curly-braces-for-macros-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (or (eq paren ?{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 makefile-use-curly-braces-for-macros-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (delete-backward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (makefile-do-macro-insertion completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (delete-backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; Just insert targets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (insert completion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; Can't complete any more, so make completion list. FIXME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; this doesn't do the right thing when the completion is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; actually inserted. I don't think there is an easy way to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (message "Making completion list...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (let ((list (all-completions try table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (with-output-to-temp-buffer "*Completions*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (display-completion-list list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (message "Making completion list...done"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; Backslashification. Stolen from cc-mode.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (defun makefile-backslashify-current-line (doit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (if doit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (if (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (eq (char-after (point)) ?\\ )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (if (>= (current-column) makefile-backslash-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (insert " \\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (while (<= (current-column) makefile-backslash-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (insert "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (while (< (current-column) makefile-backslash-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (insert "\\"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (if (eq (char-after (point)) ?\\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (let ((saved (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (delete-region (point) saved)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (defun makefile-backslash-region (beg end arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "Insert backslashes at end of every line in region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 Useful for defining multi-line rules.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
975 If called with a prefix argument, trailing backslashes are removed."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (interactive "r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (let ((do-lastline-p (progn (goto-char end) (not (bolp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (narrow-to-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (while (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (makefile-backslashify-current-line (null arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (and do-lastline-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (progn (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (makefile-backslashify-current-line (null arg)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;;; Browser mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (defun makefile-browser-format-target-line (target selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (concat (make-string makefile-browser-leftmost-column ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (if selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 makefile-browser-selected-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 makefile-browser-unselected-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 "%s%s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 target makefile-target-colon))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (defun makefile-browser-format-macro-line (macro selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (concat (make-string makefile-browser-leftmost-column ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (if selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 makefile-browser-selected-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 makefile-browser-unselected-mark)
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 80
diff changeset
1011 (makefile-format-macro-ref macro)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (defun makefile-browser-fill (targets macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (lambda (item) (insert (makefile-browser-format-target-line (car item) nil) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 targets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (lambda (item) (insert (makefile-browser-format-macro-line (car item) nil) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (sort-lines nil (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (goto-char (1- (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (delete-char 1) ; remove unnecessary newline at eob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (forward-char makefile-browser-cursor-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ;;; Moving up and down in the browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (defun makefile-browser-next-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 "Move the browser selection cursor to the next line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (if (not (makefile-last-line-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (forward-char makefile-browser-cursor-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (defun makefile-browser-previous-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 "Move the browser selection cursor to the previous line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (if (not (makefile-first-line-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (forward-char makefile-browser-cursor-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;;; Quitting the browser (returns to client buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (defun makefile-browser-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 "Leave the browser and return to the makefile buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (let ((my-client makefile-browser-client))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (setq makefile-browser-client nil) ; we quitted, so NO client!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (pop-to-buffer my-client)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;;; Toggle state of a browser item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (defun makefile-browser-toggle ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 "Toggle the selection state of the browser item at the cursor position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (let ((this-line (count-lines (point-min) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (setq this-line (max 1 this-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (makefile-browser-toggle-state-for-line this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (goto-line this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (if (makefile-browser-on-macro-line-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (let ((macro-name (makefile-browser-this-line-macro-name)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1081 (delete-region (point) (progn (end-of-line) (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (makefile-browser-format-macro-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 macro-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (makefile-browser-get-state-for-line this-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (let ((target-name (makefile-browser-this-line-target-name)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1087 (delete-region (point) (progn (end-of-line) (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (makefile-browser-format-target-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 target-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (makefile-browser-get-state-for-line this-line))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (forward-char makefile-browser-cursor-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (if makefile-browser-auto-advance-after-selection-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (makefile-browser-next-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;;; Making insertions into the client buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (defun makefile-browser-insert-continuation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 "Insert a makefile continuation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 In the makefile buffer, go to (end-of-line), insert a \'\\\'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 character, insert a new blank line, go to that line and indent by one TAB.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 This is most useful in the process of creating continued lines when copying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 large dependencies from the browser to the client buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 \(point) advances accordingly in the client buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (set-buffer makefile-browser-client)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (insert "\\\n\t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (defun makefile-browser-insert-selection ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 "Insert all selected targets and/or macros in the makefile buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 Insertion takes place at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (goto-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (let ((current-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (if (makefile-browser-get-state-for-line current-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (makefile-browser-send-this-line-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (setq current-line (1+ current-line))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (defun makefile-browser-insert-selection-and-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (makefile-browser-insert-selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (makefile-browser-quit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (defun makefile-browser-send-this-line-item ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (if (makefile-browser-on-macro-line-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (let ((macro-name (makefile-browser-this-line-macro-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (set-buffer makefile-browser-client)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (insert (makefile-format-macro-ref macro-name) " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (let ((target-name (makefile-browser-this-line-target-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (set-buffer makefile-browser-client)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (insert target-name " ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (defun makefile-browser-start-interaction ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (use-local-map makefile-browser-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (setq buffer-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (defun makefile-browse (targets macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (if (zerop (+ (length targets) (length macros)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (message "No macros or targets to browse! Consider running 'makefile-pickup-everything\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (let ((browser-buffer (get-buffer-create makefile-browser-buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (pop-to-buffer browser-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (make-variable-buffer-local 'makefile-browser-selection-vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (makefile-browser-fill targets macros)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (shrink-window-if-larger-than-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (setq makefile-browser-selection-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (make-vector (+ (length targets) (length macros)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (makefile-browser-start-interaction))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (defun makefile-switch-to-browser ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (run-hooks 'makefile-browser-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (setq makefile-browser-client (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (makefile-pickup-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (makefile-pickup-macros)
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 80
diff changeset
1168 (makefile-browse makefile-target-table
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 80
diff changeset
1169 ;; take out the runtime macros which were added for completion sake -gk
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 80
diff changeset
1170 (set-difference makefile-macro-table makefile-runtime-macros-list)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;;; Up-to-date overview buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (defun makefile-create-up-to-date-overview ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 "Create a buffer containing an overview of the state of all known targets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 Known targets are targets that are explicitly defined in that makefile;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 in other words, all targets that appear on the left hand side of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 dependency in the makefile."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (if (y-or-n-p "Are you sure that the makefile being edited is consistent? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; The rest of this function operates on a temporary makefile, created by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;; writing the current contents of the makefile buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (let ((saved-target-table makefile-target-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (this-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (makefile-up-to-date-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (get-buffer-create makefile-up-to-date-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (filename (makefile-save-temporary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; Forget the target table because it may contain picked-up filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; that are not really targets in the current makefile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;; We don't want to query these, so get a new target-table with just the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 ;; targets that can be found in the makefile buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ;; The 'old' target table will be restored later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (real-targets (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (makefile-pickup-targets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 makefile-target-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (prereqs makefile-has-prereqs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (set-buffer makefile-up-to-date-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (makefile-query-targets filename real-targets prereqs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (if (zerop (buffer-size)) ; if it did not get us anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (message "No overview created!")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (set-buffer this-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (setq makefile-target-table saved-target-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (if (get-buffer makefile-up-to-date-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (pop-to-buffer (get-buffer makefile-up-to-date-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (shrink-window-if-larger-than-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (sort-lines nil (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (setq buffer-read-only t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (defun makefile-save-temporary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 "Create a temporary file from the current makefile buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (let ((filename (makefile-generate-temporary-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (write-region (point-min) (point-max) filename nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 filename)) ; return the filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (defun makefile-generate-temporary-filename ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 "Create a filename suitable for use in `makefile-save-temporary'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 Be careful to allow brain-dead file systems (DOS, SYSV ...) to cope
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 with the generated name!"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (let ((my-name (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (my-uid (int-to-string (user-uid))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (concat "mktmp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (if (> (length my-name) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (substring my-name 0 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 my-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 "."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (if (> (length my-uid) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (substring my-uid 0 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 my-uid))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (defun makefile-query-targets (filename target-table prereq-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 "Fill the up-to-date overview buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 Checks each target in TARGET-TABLE using `makefile-query-one-target-method'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 and generates the overview, one line per target name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (function (lambda (item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (let* ((target-name (car item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (no-prereqs (not (member target-name prereq-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (needs-rebuild (or no-prereqs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 makefile-query-one-target-method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 target-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (format "\t%s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 target-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (cond (no-prereqs " .. has no prerequisites")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (needs-rebuild " .. NEEDS REBUILD")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (t " .. is up to date"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 target-table "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (delete-file filename)) ; remove the tmpfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (defun makefile-query-by-make-minus-q (target &optional filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (not (zerop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (call-process makefile-brave-make nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 "-f" filename "-q" target))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ;;; Continuation cleanup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (defun makefile-cleanup-continuations ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (if (eq major-mode 'makefile-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (if (and makefile-cleanup-continuations-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (not buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (while (re-search-forward "\\\\[ \t]+$" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (replace-match "\\" t t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 ;;; Warn of suspicious lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (defun makefile-warn-suspicious-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (let ((dont-save nil))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1296 (if (and (eq major-mode 'makefile-mode)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1297 makefile-warn-suspicious-lines-p) ; -gk
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (let ((suspicious
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 "\\(^[\t]+$\\)\\|\\(^[ ]+[\t]\\)" (point-max) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (if suspicious
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (let ((line-nr (count-lines (point-min) suspicious)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (setq dont-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (not (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (format "Suspicious line %d. Save anyway "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 line-nr))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 dont-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ;;; GNU make function support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (defun makefile-insert-gmake-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 "Insert a GNU make function call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 Asks for the name of the function to use (with completion).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 Then prompts for all required parameters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (let* ((gm-function-name (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 "Function: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 makefile-gnumake-functions-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 nil t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (gm-function-prompts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (cdr (assoc gm-function-name makefile-gnumake-functions-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (if (not (zerop (length gm-function-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (insert (makefile-format-macro-ref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (concat gm-function-name " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (makefile-prompt-for-gmake-funargs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 gm-function-name gm-function-prompts)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 " "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (defun makefile-prompt-for-gmake-funargs (function-name prompt-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (function (lambda (one-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (read-string (format "[%s] %s: " function-name one-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 prompt-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;;; Utility functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ;;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (defun makefile-do-macro-insertion (macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 "Insert a macro reference."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (if (not (zerop (length macro-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (if (assoc macro-name makefile-runtime-macros-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (insert "$" macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (insert (makefile-format-macro-ref macro-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (defun makefile-remember-target (target-name &optional has-prereqs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 "Remember a given target if it is not already remembered for this buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (if (not (zerop (length target-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (if (not (assoc target-name makefile-target-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (setq makefile-target-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (cons (list target-name) makefile-target-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (if has-prereqs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (setq makefile-has-prereqs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (cons target-name makefile-has-prereqs))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (defun makefile-remember-macro (macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 "Remember a given macro if it is not already remembered for this buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (if (not (zerop (length macro-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (if (not (assoc macro-name makefile-macro-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (setq makefile-macro-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (cons (list macro-name) makefile-macro-table)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (defun makefile-forward-after-target-colon ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 "Move point forward after inserting the terminating colon of a target.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 This acts according to the value of `makefile-tab-after-target-colon'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (if makefile-tab-after-target-colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (insert "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (defun makefile-browser-on-macro-line-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 "Determine if point is on a macro line in the browser."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (re-search-forward "\\$[{(]" (makefile-end-of-line-point) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (defun makefile-browser-this-line-target-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 "Extract the target name from a line in the browser."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (skip-chars-backward "^ \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (buffer-substring (point) (1- (makefile-end-of-line-point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (defun makefile-browser-this-line-macro-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 "Extract the macro name from a line in the browser."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (re-search-forward "\\$[{(]" (makefile-end-of-line-point) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (let ((macro-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (skip-chars-forward "^})")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (buffer-substring macro-start (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (defun makefile-format-macro-ref (macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 "Format a macro reference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 Uses `makefile-use-curly-braces-for-macros-p'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (if (or (char-equal ?\( (string-to-char macro-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (char-equal ?\{ (string-to-char macro-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (format "$%s" macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (if makefile-use-curly-braces-for-macros-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (format "${%s}" macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (format "$(%s)" macro-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (defun makefile-browser-get-state-for-line (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (aref makefile-browser-selection-vector (1- n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (defun makefile-browser-set-state-for-line (n to-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (aset makefile-browser-selection-vector (1- n) to-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (defun makefile-browser-toggle-state-for-line (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (makefile-browser-set-state-for-line n (not (makefile-browser-get-state-for-line n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (defun makefile-beginning-of-line-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (defun makefile-end-of-line-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (defun makefile-last-line-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (= (makefile-end-of-line-point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (defun makefile-first-line-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (= (makefile-beginning-of-line-point) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;;; Support for other packages, like add-log and imenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (defun makefile-add-log-defun ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1443 "Return name of target or variable assignment that point is in.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1444 If it isn't in one, return nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (save-excursion
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1446 (let (found)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1447 (beginning-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1448 ;; Scan back line by line, noticing when we come to a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1449 ;; variable or rule definition, and giving up when we see
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1450 ;; a line that is not part of either of those.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1451 (while (not found)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1452 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1453 ((looking-at makefile-macroassign-regex)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1454 (setq found (buffer-substring-no-properties (match-beginning 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1455 (match-end 1))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1456 ((looking-at makefile-dependency-regex)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1457 (setq found (buffer-substring-no-properties (match-beginning 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1458 (match-end 1))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1459 ;; Don't keep looking across a blank line or comment. Give up.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1460 ((looking-at "$\\|#")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1461 (setq found 'bobp))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1462 ((bobp)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1463 (setq found 'bobp)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1464 (or found
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1465 (forward-line -1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1466 (if (stringp found) found))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1468 ;; FIXME it might be nice to have them separated by macro vs target.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1469 (defun makefile-menu-index-function ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1470 ;; "Generate alist of indices for imenu."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1471 (let (alist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1472 stupid
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1473 (re (concat makefile-dependency-regex
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1474 "\\|"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1475 makefile-macroassign-regex)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1476 (imenu-progress-message stupid 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1477 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1478 (while (re-search-forward re nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1479 (imenu-progress-message stupid)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1480 (let ((n (if (match-beginning 1) 1 5)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1481 (setq alist (cons
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1482 (cons (buffer-substring (match-beginning n)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1483 (match-end n))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1484 (match-beginning n))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1485 alist))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1486 (imenu-progress-message stupid 100)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1487 (nreverse alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;;; make-mode.el ends here