Commits

Anonymous committed e10304c

package standards update

  • Participants
  • Parent commits 9eb86d9

Comments (0)

Files changed (4)

+1999-07-15  Karl M. Hegbloom  <karlheg@debian.org>
+
+	* make-mode.el: Better highlighting and imenu support.
+
 1999-06-05  Karl M. Hegbloom  <karlheg@debian.org>
 
 	* sql.el (sql-mode): autoload
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.20
+VERSION = 1.21
 AUTHOR_VERSION =
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = prog-modes

File make-mode.el

   "If non-nil, automatically clean up continuation lines when saving.
 A line is cleaned up by removing all whitespace following a trailing
 backslash.  This is done silently.
-IMPORTANT: Please note that enabling this option causes makefile-mode
+IMPORTANT: Please note that enabling this option causes `makefile-mode'
 to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \'it seems necessary\'."
   :type 'boolean
   :group 'makefile-mode)
 of the macro is checked against this list. If it can be found its name will
 not be enclosed in { } or ( ).")
 
-;; Note that the first big subexpression is used by font lock.  Note
-;; that if you change this regexp you must fix the imenu index
-;; function defined at the end of the file.
+;;; Some sample lines from one of the glibc makefiles:
+;;
+;; $(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: $(common-objpfx)libc.so
+;; $(objpfx)libnss_compat.so: $(objpfx)libnsl.so$(libnsl.so-version)
+;; subdir-dirs = $(services:%=nss_%) ---> mustn't match.
+;; ordinary: blah blah
+;;
+;; Note that the first big subexpression (the only match capturing
+;; one) is used by font lock, imenu, and makefile-mode.
 (defconst makefile-dependency-regex
-  "^\\([^ \n\t#:]+\\([ \t]+[^ \t\n#:]+\\)*\\)[ \t]*:\\([ \t]*$\\|\\([^=\n].*$\\)\\)" 
+  (purecopy
+   (concat
+    "^"
+;;;   "\\(?:vpath[ \t]\\)\\{0,0\\}" ; doesn't work as intended
+;;; I want it to NOT highlight lines like:
+;;;vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
+;;;				      $(+sysdep_dirs) $(..)))
+;;; ... where the colon between the two commas makes it look like a
+;;; target.  The workaround is to write the line like:
+;;;colon := :
+;;;vpath %.h $(subst $(empty) ,$(colon),$(strip $(common-objpfx) $(objpfx) \
+;;;				      $(+sysdep_dirs) $(..)))
+;;; ... putting a space before vpath works too, but I highlight vpath later,
+;;; and that expects it to be anchored left.
+;;; I wonder if the "zero length negative assertion" (the \\{0,0\\} is
+;;; moving the scan cursor forward?  Bet that's it.  I should look
+;;; into the regexp engine at some point and see if I can fix it.
+;;; The libpcre is not too shabby.  Dunno if it's right for an Emacs.
+    "\\("
+      "\\(?:"
+            "\\$([^\)]+)[^ \n\t#=:]+"
+        "\\|"
+            "[^ \n\t#=:]+"
+       "\\)"
+       "\\(?:"
+             "[ \t]+"
+	     "\\(?:"
+	           "\\$([^\)]+)[^ \n\t#=:]+"
+	       "\\|"
+	           "[^ \n\t#=:]+"
+	      "\\)"
+       "\\)*"
+   "\\)" ; end match-string 1 (the only one we use.)
+   "[ \t]*:"
+   "\\(?:"
+          "[ \t]*$"
+     "\\|"
+          "[^=\n].*$"
+   "\\)"))
   "Regex used to find dependency lines in a makefile.")
 
-;; Note that the first subexpression is used by font lock.  Note that
-;; if you change this regexp you must fix the imenu index function
-;; defined at the end of the file.
+;; Note that the first match capturing subexpression is used by font
+;; lock, Imenu, and makefile-mode.
 (defconst makefile-macroassign-regex
-  "^\\([^ \n\t][^:#= \t\n]*\\)[ \t]*[*:+]?:?="
+  (purecopy
+   "^\\(?:export[ \t]+\\)?\\([^ \n\t][^:#= \t\n]*\\)[ \t]*[*:+]?:?=")
   "Regex used to find macro assignment lines in a makefile.")
 
+(defconst makefile-imenu-generic-expression
+  ;; Not purecopied; users may like to add to it perhaps, I guess.
+  `(("Targets" ,makefile-dependency-regex 1)
+    ("Macros" ,makefile-macroassign-regex 1)
+    ("Defines" "^define[ \t]+\\([-.a-zA-Z0-9_+]+\\)" 1)
+    )
+  "See: `imenu-generic-expression'")
+
 (defconst makefile-ignored-files-in-pickup-regex
+  ;; no purecopy; users may often change this one, I believe.
   "\\(^\\..*\\)\\|\\(.*~$\\)\\|\\(.*,v$\\)\\|\\(\\.[chy]\\)"
   "Regex for filenames that will NOT be included in the target list.")
 
 
 (defconst makefile-font-lock-keywords (purecopy
   (list
+   ;; conditionals, vpath & include
+   (list
+    (concat "^\\("
+	    (regexp-opt
+	     (mapcar #'symbol-name
+		     '(ifeq ifneq else endif endef include)))
+	    "\\|-include\\)[ \t\n]+")
+    1 font-lock-preprocessor-face)
+
+   '("^\\(ifn?def\\)[ \t]+\\(.*$\\)"
+     (1 font-lock-preprocessor-face) (2 font-lock-reference-face nil t))
+
+   ;; define
+   '("^\\(define\\)[ \t]+\\(.*$\\)"
+     (1 font-lock-preprocessor-face) (2 font-lock-variable-name-face nil t))
+
+   ;; vpath export
+   '("^\\(vpath\\|export\\)[ \t]+" (1 font-lock-keyword-face prepend))
+
+   ;; Do dependencies.  These get the function name face.
+   (list makefile-dependency-regex 1 'font-lock-function-name-face 'prepend)
+
    ;; Do macro assignments.  These get the "variable-name" face rather
    ;; arbitrarily.
-   (list makefile-macroassign-regex 1 'font-lock-variable-name-face)
-   ;;
+   (list makefile-macroassign-regex 1 'font-lock-variable-name-face t)
+
    ;; Variable references even in targets/strings/comments:
-   '("\\$[({]\\([a-zA-Z0-9_]+\\)[})]" 1 font-lock-reference-face prepend)
-   ;;
-   ;; Do dependencies.  These get the function name face.
-   (list makefile-dependency-regex 1 'font-lock-function-name-face 'prepend)
+   (list
+    (concat "\\$[\(\{][ \t]*"
+;;	    "\\(?:" "\\$[\(\{]" "[^\)\}]+" "[\)\}]" "\\)*" ; $($(var)-ext) doesn't work.
+	    "\\(" "[-<@.a-zA-Z0-9+_]+" "\\)" ; match-string 1
+	    "\\(?:"
+	           "[^-.a-zA-Z0-9+_]\\{0,0\\}"
+	      "\\|"
+	           "[ \t]*[:\$].*?"
+	    "\\)"
+	    "[ \t]*[\}\)]")
+     1 'font-lock-reference-face 'prepend)
+
+   ;; and builtin special variable names
+   (list
+    (concat "\\$" (regexp-opt (mapcar #'car makefile-runtime-macros-list)))
+    '(0 font-lock-reference-face t))
+
+   ;; Make $(functions ...)
+   (list
+    (concat
+     "\\$[\(\{][ \t]*\\("
+     (regexp-opt
+      (mapcar #'symbol-name
+	      '(subst patsubst strip findstring filter filter-out sort
+		dir notdir suffix basename addsuffix addprefix join
+		word wordlist words firstword wildcard foreach origin shell)))
+     "\\)[ \t]+:\\{0,0\\}")
+    1 'font-lock-keyword-face 'prepend)
+
+   ;; Todo: and ### through ###### in comments.
+   '("#.*?[ \t]+\\([Tt][Oo][Dd][Oo]:?\\)" (1 font-lock-warning-face t))
+   '("#.*?[ \t]+\\(#\\{3,6\\}\\)[ \t\n]+" (1 font-lock-warning-face t))
 
    ;; Highlight lines that contain just whitespace.
    ;; They can cause trouble, especially if they start with a tab.
   (setq add-log-current-defun-function 'makefile-add-log-defun)
 
   ;; Imenu.
-  (unless (featurep 'xemacs)
-    (make-local-variable 'imenu-create-index-function)
-    (setq imenu-create-index-function 'makefile-menu-index-function))
+  (make-local-variable 'imenu-generic-expression)
+  (setq imenu-generic-expression makefile-imenu-generic-expression)
 
   ;; Dabbrev.
   (make-local-variable 'dabbrev-abbrev-skip-leading-regexp)
 	    (forward-line -1)))
       (if (stringp found) found))))
 
-;; FIXME it might be nice to have them separated by macro vs target.
-(defun makefile-menu-index-function ()
-  ;; "Generate alist of indices for imenu."
-  (let (alist
-	stupid
-	(re (concat makefile-dependency-regex
-		    "\\|"
-		    makefile-macroassign-regex)))
-    (imenu-progress-message stupid 0)
-    (goto-char (point-min))
-    (while (re-search-forward re nil t)
-      (imenu-progress-message stupid)
-      (let ((n (if (match-beginning 1) 1 5)))
-	(setq alist (cons
-		     (cons (buffer-substring (match-beginning n)
-					     (match-end n))
-			   (match-beginning n))
-		     alist))))
-    (imenu-progress-message stupid 100)
-    (nreverse alist)))
-
 ;;; make-mode.el ends here

File package-info.in

 (prog-modes
-  (standards-version 1.0
+  (standards-version 1.1
    version VERSION
    author-version AUTHOR_VERSION
    date DATE
    build-date BUILD_DATE
    maintainer MAINTAINER
-   distribution stable
+   distribution xemacs
    priority medium
    category CATEGORY
    dump nil