annotate lisp/progmodes/make-mode.el @ 48254:0012ec6b9866

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