;;; make-mode.el --- makefile editing commands for Emacs
;; Copyright (C) 1992, 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; Author: Thomas Neumann <tom@smart.bo.open.de>
;; Eric S. Raymond <esr@snark.thyrsus.com>
(t (:reverse-video t)))
"Face to use for highlighting leading spaces in Font-Lock mode."
:group 'makefile)
-(put 'makefile-space-face 'face-alias 'makefile-space)
+(define-obsolete-face-alias 'makefile-space-face 'makefile-space "22.1")
(defface makefile-targets
;; This needs to go along both with foreground and background colors (i.e. shell)
;; Special targets for DMake, Sun's make ...
;;
(defcustom makefile-special-targets-list
- '(("DEFAULT") ("DONE") ("ERROR") ("EXPORT")
- ("FAILED") ("GROUPEPILOG") ("GROUPPROLOG") ("IGNORE")
- ("IMPORT") ("INCLUDE") ("INCLUDEDIRS") ("INIT")
- ("KEEP_STATE") ("MAKEFILES") ("MAKE_VERSION") ("NO_PARALLEL")
- ("PARALLEL") ("PHONY") ("PRECIOUS") ("REMOVE")
- ("SCCS_GET") ("SILENT") ("SOURCE") ("SUFFIXES")
- ("WAIT") ("c.o") ("C.o") ("m.o")
- ("el.elc") ("y.c") ("s.o"))
- "*List of special targets.
+ '("DEFAULT" "DONE" "ERROR" "EXPORT"
+ "FAILED" "GROUPEPILOG" "GROUPPROLOG" "IGNORE"
+ "IMPORT" "INCLUDE" "INCLUDEDIRS" "INIT"
+ "KEEP_STATE" "MAKEFILES" "MAKE_VERSION" "NO_PARALLEL"
+ "PARALLEL" "PHONY" "PRECIOUS" "REMOVE"
+ "SCCS_GET" "SILENT" "SOURCE" "SUFFIXES"
+ "WAIT" "c.o" "C.o" "m.o"
+ "el.elc" "y.c" "s.o")
+ "List of special targets.
You will be offered to complete on one of those in the minibuffer whenever
you enter a \".\" at the beginning of a line in `makefile-mode'."
:type '(repeat (list string))
"Characters to skip to find a line that might be a dependency.")
(defvar makefile-rule-action-regex
- "^\t[ \t]*\\([-@]*\\)[ \t]*\\(\\(?:.*\\\\\n\\)*.*\\)"
+ "^\t[ \t]*\\(?:\\([-@]+\\)[ \t]*\\)\\(.*\\(?:\\\\\n.*\\)*\\)"
"Regex used to highlight rule action lines in font lock mode.")
(defconst makefile-makepp-rule-action-regex
(3 'font-lock-string-face prepend t))
;; Rule actions.
+ ;; FIXME: When this spans multiple lines we need font-lock-multiline.
(makefile-match-action
- (1 font-lock-type-face)
+ (1 font-lock-type-face nil t)
(2 'makefile-shell prepend)
;; Only makepp has builtin commands.
(3 font-lock-builtin-face prepend t))
(skip-chars-backward "^$(){}:#= \t\n")
(point)))
(try (buffer-substring beg (point)))
- (do-macros nil)
- (paren nil))
-
- (save-excursion
- (goto-char beg)
- (let ((pc (preceding-char)))
- (cond
- ;; Beginning of line means anything.
- ((bolp)
- ())
-
- ;; Preceding "$" means macros only.
- ((= pc ?$)
- (setq do-macros t))
-
- ;; Preceding "$(" or "${" means macros only.
- ((and (or (= pc ?{)
- (= pc ?\())
- (progn
- (setq paren pc)
- (backward-char)
- (and (not (bolp))
- (= (preceding-char) ?$))))
- (setq do-macros t)))))
-
- ;; Try completion.
- (let* ((table (append (if do-macros
- '()
- makefile-target-table)
- makefile-macro-table))
- (completion (try-completion try table)))
- (cond
- ;; Exact match, so insert closing paren or colon.
- ((eq completion t)
- (insert (if do-macros
- (if (eq paren ?{)
- ?}
- ?\))
- (if (save-excursion
- (goto-char beg)
- (bolp))
- ":"
- " "))))
-
- ;; No match.
- ((null completion)
- (message "Can't find completion for \"%s\"" try)
- (ding))
-
- ;; Partial completion.
- ((not (string= try completion))
- ;; FIXME it would be nice to supply the closing paren if an
- ;; exact, unambiguous match were found. That is not possible
- ;; right now. Ditto closing ":" for targets.
- (delete-region beg (point))
-
- ;; DO-MACROS means doing macros only. If not that, then check
- ;; to see if this completion is a macro. Special insertion
- ;; must be done for macros.
- (if (or do-macros
- (assoc completion makefile-macro-table))
- (let ((makefile-use-curly-braces-for-macros-p
- (or (eq paren ?{)
- makefile-use-curly-braces-for-macros-p)))
- (delete-backward-char 2)
- (makefile-do-macro-insertion completion)
- (delete-backward-char 1))
-
- ;; Just insert targets.
- (insert completion)))
-
- ;; Can't complete any more, so make completion list. FIXME
- ;; this doesn't do the right thing when the completion is
- ;; actually inserted. I don't think there is an easy way to do
- ;; that.
- (t
- (message "Making completion list...")
- (let ((list (all-completions try table)))
- (with-output-to-temp-buffer "*Completions*"
- (display-completion-list list try)))
- (message "Making completion list...done"))))))
+ (paren nil)
+ (do-macros
+ (save-excursion
+ (goto-char beg)
+ (let ((pc (preceding-char)))
+ (cond
+ ;; Preceding "$" means macros only.
+ ((= pc ?$)
+ t)
+
+ ;; Preceding "$(" or "${" means macros only.
+ ((and (memq pc '(?\{ ?\())
+ (progn
+ (setq paren (if (eq paren ?\{) ?\} ?\)))
+ (backward-char)
+ (= (preceding-char) ?$)))
+ t)))))
+
+ (table (apply-partially 'completion-table-with-terminator
+ (cond
+ (do-macros (or paren ""))
+ ((save-excursion (goto-char beg) (bolp)) ":")
+ (t " "))
+ (append (if do-macros
+ '()
+ makefile-target-table)
+ makefile-macro-table))))
+ (completion-in-region beg (point) table)))
\f
(save-restriction
(narrow-to-region beginning end)
(makefile-backslash-region (point-min) (point-max) t)
- (let ((fill-paragraph-function nil))
+ (let ((fill-paragraph-function nil)
+ ;; Adjust fill-column to allow space for the backslash.
+ (fill-column (- fill-column 1)))
(fill-paragraph nil))
(makefile-backslash-region (point-min) (point-max) nil)
(goto-char (point-max))
;; resulting region.
(save-restriction
(narrow-to-region (point) (line-beginning-position 2))
- (let ((fill-paragraph-function nil))
+ (let ((fill-paragraph-function nil)
+ ;; Adjust fill-column to allow space for the backslash.
+ (fill-column (- fill-column 1)))
(fill-paragraph nil))
(makefile-backslash-region (point-min) (point-max) nil))
;; Return non-nil to indicate it's been filled.