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