annotate lisp/progmodes/make-mode.el @ 26201:097072728e80

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