annotate lisp/progmodes/make-mode.el @ 14049:d35edcfdefc1

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