;;; antlr-mode.el --- major mode for ANTLR grammar files
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;; 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
;; Author: Christoph.Wedler@sap.com
;; Keywords: languages, ANTLR, code generator
;;; Code:
-(eval-when-compile
+(eval-when-compile
(require 'cl))
(require 'easymenu)
(declare-function cond-emacs-xemacs-macfn "antlr-mode" (args &optional msg))
;; General Emacs/XEmacs-compatibility compile-time macros
-(eval-when-compile
+(eval-when-compile
(defmacro cond-emacs-xemacs (&rest args)
(cond-emacs-xemacs-macfn
args "`cond-emacs-xemacs' must return exactly one element"))
(read-from-minibuffer prompt initial-input nil nil
(or history 'shell-command-history)))
-(defunx antlr-with-displaying-help-buffer (thunk &optional name)
+(defunx antlr-with-displaying-help-buffer (thunk &optional _name)
:xemacs-and-try with-displaying-help-buffer
"Make a help buffer and call `thunk' there."
(with-output-to-temp-buffer "*Help*"
;;;(defvar antlr-statistics-cache 0)
;;;(defvar antlr-statistics-inval 0)
-(defunx antlr-invalidate-context-cache (&rest dummies)
+(defunx antlr-invalidate-context-cache (&rest _dummies)
;; checkdoc-params: (dummies)
"Invalidate context cache for syntactical context information."
:XEMACS ; XEmacs bug workaround
table)))
(list level input (cdr kind))))))
-(defun antlr-options-menu-filter (level menu-items)
+(defun antlr-options-menu-filter (level _menu-items)
"Return items for options submenu of level LEVEL."
;; checkdoc-params: (menu-items)
(let ((active (if buffer-read-only
nil
table '(("false") ("true"))))
-(defun antlr-language-option-extra (phase &rest dummies)
+(defun antlr-language-option-extra (phase &rest _dummies)
;; checkdoc-params: (dummies)
"Change language according to the new value of the \"language\" option.
Call `antlr-mode' if the new language would be different from the value
(antlr-mode)
(and font-lock (null font-lock-mode) (font-lock-mode 1)))))))
-(defun antlr-c++-mode-extra (phase option &rest dummies)
+(defun antlr-c++-mode-extra (phase option &rest _dummies)
;; checkdoc-params: (option dummies)
"Warn if C++ option is used with the wrong language.
Ask user \(\"y or n\"), if a C++ only option is going to be inserted but
export vocabulary specified in that file."
(let ((grammar (directory-files dirname t "\\.g\\'")))
(when grammar
- (let ((temp-buffer (get-buffer-create
- (generate-new-buffer-name " *temp*")))
- (antlr-imenu-name nil) ; dynamic-let: no imenu
- (expanded-regexp (concat (format (regexp-quote
- (cadr antlr-special-file-formats))
- ".+")
- "\\'"))
+ (let ((antlr-imenu-name nil) ; dynamic-let: no imenu
+ (expanded-regexp
+ (concat (format (regexp-quote
+ (cadr antlr-special-file-formats))
+ ".+")
+ "\\'"))
classes dependencies)
- (unwind-protect
- (with-current-buffer temp-buffer
- (widen) ; just in case...
- (dolist (file grammar)
- (when (and (file-regular-p file)
- (null (string-match expanded-regexp file)))
- (insert-file-contents file t nil nil t)
- (normal-mode t) ; necessary for major-mode, syntax
+ (with-temp-buffer
+ (dolist (file grammar)
+ (when (and (file-regular-p file)
+ (null (string-match expanded-regexp file)))
+ (insert-file-contents file t nil nil t)
+ (normal-mode t) ; necessary for major-mode, syntax
; table and `antlr-language'
- (when (derived-mode-p 'antlr-mode)
- (let* ((file-deps (antlr-file-dependencies))
- (file (car file-deps)))
- (when file-deps
- (dolist (class-def (caadr file-deps))
- (let ((file-evocab (cons file (cdr class-def)))
- (class-spec (assoc (car class-def) classes)))
- (if class-spec
- (nconc (cdr class-spec) (list file-evocab))
- (push (list (car class-def) file-evocab)
- classes))))
- (push file-deps dependencies)))))))
- (kill-buffer temp-buffer))
+ (when (derived-mode-p 'antlr-mode)
+ (let* ((file-deps (antlr-file-dependencies))
+ (file (car file-deps)))
+ (when file-deps
+ (dolist (class-def (caadr file-deps))
+ (let ((file-evocab (cons file (cdr class-def)))
+ (class-spec (assoc (car class-def) classes)))
+ (if class-spec
+ (nconc (cdr class-spec) (list file-evocab))
+ (push (list (car class-def) file-evocab)
+ classes))))
+ (push file-deps dependencies)))))))
(cons (nreverse classes) (nreverse dependencies))))))
(or saved (save-some-buffers (not antlr-ask-about-save)))
(let ((default-directory (file-name-directory file)))
(compilation-start (concat command " " (file-name-nondirectory file))
- nil #'(lambda (mode-name) "*Antlr-Run*"))))
+ nil (lambda (_mode-name) "*Antlr-Run*"))))
(defun antlr-run-tool-interactive ()
;; code in `interactive' is not compiled
;; FIXME: Since it uses cc-mode, it bumps into c-update-modeline's
;; limitation to mode-name being a string.
;; '("Antlr." (:eval (cadr (assq antlr-language antlr-language-alist))))
- "Antlr"
+ "Antlr"
"Major mode for editing ANTLR grammar files."
:abbrev-table antlr-mode-abbrev-table
(c-initialize-cc-mode) ; cc-mode is required