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