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