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