]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/grammar.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / grammar.el
index ce658cd5d544a998d57603f9a9705621d2d0faa4..fc62b221665dbb876f762f27ef3533d706593724 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/grammar.el --- Major mode framework for Semantic grammars
 
-;; Copyright (C) 2002-2005, 2007-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2005, 2007-2015 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Maintainer: David Ponce <david@dponce.com>
@@ -33,6 +33,8 @@
 (require 'semantic/wisent)
 (require 'semantic/ctxt)
 (require 'semantic/format)
+;; FIXME this is a generated file, but we need to load this file to
+;; generate it!
 (require 'semantic/grammar-wy)
 (require 'semantic/idle)
 (require 'help-fns)
@@ -605,6 +607,11 @@ The symbols in the template are local variables in
 
 \(provide '" libr ")
 
+;; Local Variables:
+;; version-control: never
+;; no-update-autoloads: t
+;; End:
+
 ;;; " file " ends here
 ")
   "Generated footer template.
@@ -822,9 +829,10 @@ Block definitions are read from the current table of lexical types."
       (noninteractive)
     noninteractive))
 
-(defun semantic-grammar-create-package (&optional force)
+(defun semantic-grammar-create-package (&optional force uptodate)
   "Create package Lisp code from grammar in current buffer.
-Does nothing if the Lisp code seems up to date.
+If the Lisp code seems up to date, do nothing (if UPTODATE
+is non-nil, return nil in such cases).
 If optional argument FORCE is non-nil, unconditionally re-generate the
 Lisp code."
   (interactive "P")
@@ -854,13 +862,18 @@ Lisp code."
              (file-newer-than-file-p
               (buffer-file-name semantic--grammar-output-buffer)
               (buffer-file-name semantic--grammar-input-buffer)))
-        (message "Package `%s' is up to date." semantic--grammar-package)
+       (progn
+         (message "Package `%s' is up to date." semantic--grammar-package)
+         ;; It would be better if this were always the case, IMO,
+         ;; but the (unspecified) return value of this function is
+         ;; assumed to be non-nil in some places, it seems.
+         (if uptodate (setq output nil)))
       ;; Create the package
       (set-buffer semantic--grammar-output-buffer)
       ;; Use Unix EOLs, so that the file is portable to all platforms.
       (setq buffer-file-coding-system 'raw-text-unix)
       (erase-buffer)
-      (unless (eq major-mode 'emacs-lisp-mode)
+      (unless (derived-mode-p 'emacs-lisp-mode)
         (emacs-lisp-mode))
 
 ;;;; Header + Prologue
@@ -1102,7 +1115,9 @@ END is the limit of the search."
 ;;;; Define major mode
 ;;;;
 
-(defvar semantic-grammar-syntax-table
+(define-obsolete-variable-alias 'semantic-grammar-syntax-table
+  'semantic-grammar-mode-syntax-table "24.1")
+(defvar semantic-grammar-mode-syntax-table
   (let ((table (make-syntax-table (standard-syntax-table))))
     (modify-syntax-entry ?\: "."     table) ;; COLON
     (modify-syntax-entry ?\> "."     table) ;; GT
@@ -1158,19 +1173,25 @@ END is the limit of the search."
 
 (defvar semantic-grammar-mode-keywords-2
   (append semantic-grammar-mode-keywords-1
-          lisp-font-lock-keywords-1)
+         (if (boundp 'lisp-font-lock-keywords-1)
+             lisp-font-lock-keywords-1
+           lisp-el-font-lock-keywords-1))
   "Font Lock keywords used to highlight Semantic grammar buffers.")
 
 (defvar semantic-grammar-mode-keywords-3
   (append semantic-grammar-mode-keywords-1
-          lisp-font-lock-keywords-2)
+         (if (boundp 'lisp-font-lock-keywords-2)
+             lisp-font-lock-keywords-2
+           lisp-el-font-lock-keywords-2))
   "Font Lock keywords used to highlight Semantic grammar buffers.")
 
 (defvar semantic-grammar-mode-keywords
   semantic-grammar-mode-keywords-1
   "Font Lock keywords used to highlight Semantic grammar buffers.")
 
-(defvar semantic-grammar-map
+(define-obsolete-variable-alias 'semantic-grammar-map
+  'semantic-grammar-mode-map "24.1")
+(defvar semantic-grammar-mode-map
   (let ((km (make-sparse-keymap)))
 
     (define-key km "|" 'semantic-grammar-electric-punctuation)
@@ -1271,22 +1292,17 @@ the change bounds to encompass the whole nonterminal tag."
                                (semantic-tag-start outer)
                                (semantic-tag-end outer)))))
 
-(defun semantic-grammar-mode ()
+(define-derived-mode semantic-grammar-mode
+  fundamental-mode "Semantic Grammar Framework"
   "Initialize a buffer for editing Semantic grammars.
 
-\\{semantic-grammar-map}"
-  (interactive)
-  (kill-all-local-variables)
-  (setq major-mode 'semantic-grammar-mode
-        mode-name "Semantic Grammar Framework")
+\\{semantic-grammar-mode-map}"
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
   (set (make-local-variable 'comment-start) ";;")
   ;; Look within the line for a ; following an even number of backslashes
   ;; after either a non-backslash or the line beginning.
   (set (make-local-variable 'comment-start-skip)
        "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
-  (set-syntax-table semantic-grammar-syntax-table)
-  (use-local-map semantic-grammar-map)
   (set (make-local-variable 'indent-line-function)
        'semantic-grammar-indent)
   (set (make-local-variable 'fill-paragraph-function)
@@ -1335,15 +1351,14 @@ the change bounds to encompass the whole nonterminal tag."
   (semantic-make-local-hook 'semantic-edits-new-change-functions)
   (add-hook 'semantic-edits-new-change-functions
             'semantic-grammar-edits-new-change-hook-fcn
-            nil t)
-  (semantic-run-mode-hooks 'semantic-grammar-mode-hook))
+            nil t))
 \f
 ;;;;
 ;;;; Useful commands
 ;;;;
 
 (defvar semantic-grammar-skip-quoted-syntax-table
-  (let ((st (copy-syntax-table semantic-grammar-syntax-table)))
+  (let ((st (copy-syntax-table semantic-grammar-mode-syntax-table)))
     (modify-syntax-entry ?\' "$" st)
     st)
   "Syntax table to skip a whole quoted expression in grammar code.
@@ -1912,6 +1927,7 @@ Optional argument COLOR determines if color is added to the text."
 
 (provide 'semantic/grammar)
 
+\f
 ;; Local variables:
 ;; generated-autoload-load-name: "semantic/grammar"
 ;; End: