X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/362b9d483c714a8fd87966ddbd8686850f870e34..230dcbaf2ff0615d72c5d2ca41edb999b6bc1b87:/lisp/progmodes/antlr-mode.el diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el index f704eec2c0..56680f23a8 100644 --- a/lisp/progmodes/antlr-mode.el +++ b/lisp/progmodes/antlr-mode.el @@ -1,7 +1,6 @@ ;;; 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-2013 Free Software Foundation, Inc. ;; Author: Christoph.Wedler@sap.com ;; Keywords: languages, ANTLR, code generator @@ -70,7 +69,7 @@ ;; This file requires Emacs-20.3, XEmacs-20.4 or higher and package cc-mode. ;; If antlr-mode is not part of your distribution, put this file into your -;; load-path and the following into your ~/.emacs: +;; load-path and the following into your init file: ;; (autoload 'antlr-mode "antlr-mode" nil t) ;; (setq auto-mode-alist (cons '("\\.g\\'" . antlr-mode) auto-mode-alist)) ;; (add-hook 'speedbar-load-hook ; would be too late in antlr-mode.el @@ -83,7 +82,7 @@ ;;; Code: -(eval-when-compile +(eval-when-compile (require 'cl)) (require 'easymenu) @@ -94,7 +93,7 @@ (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")) @@ -236,11 +235,11 @@ MAJOR-MODE, the major mode of the code in the grammar's actions, is the value of `antlr-language' if the first group in the string matched by REGEXP in `antlr-language-limit-n-regexp' is one of the OPTION-VALUEs. An OPTION-VALUE of nil denotes the fallback element. MODELINE-STRING is -also displayed in the modeline next to \"Antlr\"." +also displayed in the mode line next to \"Antlr\"." :group 'antlr :type '(repeat (group :value (java-mode "") (function :tag "Major mode") - (string :tag "Modeline string") + (string :tag "Mode line string") (repeat :tag "ANTLR language option" :inline t (choice (const :tag "Default" nil) string ))))) @@ -270,7 +269,7 @@ greater than this number." (integer :tag "Hidden if longer than" :value 3))) (defcustom antlr-indent-comment 'tab - "*Non-nil, if the indentation should touch lines in block comments. + "Non-nil, if the indentation should touch lines in block comments. If nil, no continuation line of a block comment is changed. If t, they are changed according to `c-indentation-line'. When not nil and not t, they are only changed by \\[antlr-indent-command]." @@ -297,7 +296,7 @@ ANTLR's and Java's indentation styles. Used by `antlr-set-tabs'." (boolean :tag "Indent-tabs-mode")))) (defcustom antlr-indent-style "java" - "*If non-nil, cc-mode indentation style used for `antlr-mode'. + "If non-nil, cc-mode indentation style used for `antlr-mode'. See `c-set-style' and for details, where the most interesting part in `c-style-alist' is the value of `c-basic-offset'." :group 'antlr @@ -340,14 +339,14 @@ to the normal rules of `antlr-indent-line'." ;;;=========================================================================== (defcustom antlr-options-use-submenus t - "*Non-nil, if the major mode menu should include option submenus. + "Non-nil, if the major mode menu should include option submenus. If nil, the menu just includes a command to insert options. Otherwise, it includes four submenus to insert file/grammar/rule/subrule options." :group 'antlr :type 'boolean) (defcustom antlr-tool-version 20701 - "*The version number of the Antlr tool. + "The version number of the Antlr tool. The value is an integer of the form XYYZZ which stands for vX.YY.ZZ. This variable is used to warn about non-supported options and to supply version correct option values when using \\[antlr-insert-option]. @@ -359,7 +358,7 @@ can make this variable buffer-local." :type 'integer) (defcustom antlr-options-auto-colon t - "*Non-nil, if `:' is inserted with a rule or subrule options section. + "Non-nil, if `:' is inserted with a rule or subrule options section. A `:' is only inserted if this value is non-nil, if a rule or subrule option is inserted with \\[antlr-insert-option], if there was no rule or subrule options section before, and if a `:' is not already present @@ -379,7 +378,7 @@ is `language-as-string'. See also `antlr-read-value'." :type '(repeat (symbol :tag "Style symbol"))) (defcustom antlr-options-push-mark t - "*Non-nil, if inserting an option should set & push mark. + "Non-nil, if inserting an option should set & push mark. If nil, never set mark when inserting an option with command \\[antlr-insert-option]. If t, always set mark via `push-mark'. If a number, only set mark if point was outside the options area before and @@ -393,7 +392,7 @@ options area before." (sexp :tag "If outside options" :format "%t" :value outside))) (defcustom antlr-options-assign-string " = " - "*String containing `=' to use between option name and value. + "String containing `=' to use between option name and value. This string is only used if the option to insert did not exist before or if there was no `=' after it. In other words, the spacing around an existing `=' won't be changed when changing an option value." @@ -579,21 +578,21 @@ AS-STRING is non-nil and is either t or a symbol which is a member of ;;;=========================================================================== (defcustom antlr-tool-command "java antlr.Tool" - "*Command used in \\[antlr-run-tool] to run the Antlr tool. + "Command used in \\[antlr-run-tool] to run the Antlr tool. This variable should include all options passed to Antlr except the option \"-glib\" which is automatically suggested if necessary." :group 'antlr :type 'string) (defcustom antlr-ask-about-save t - "*If not nil, \\[antlr-run-tool] asks which buffers to save. + "If not nil, \\[antlr-run-tool] asks which buffers to save. Otherwise, it saves all modified buffers before running without asking." :group 'antlr :type 'boolean) (defcustom antlr-makefile-specification '("\n" ("GENS" "GENS%d" " \\\n\t") "$(ANTLR)") - "*Variable to specify the appearance of the generated makefile rules. + "Variable to specify the appearance of the generated makefile rules. This variable influences the output of \\[antlr-show-makefile-rules]. It looks like \(RULE-SEP GEN-VAR-SPEC COMMAND). @@ -651,7 +650,7 @@ See variable `antlr-file-formats-alist' for language dependent formats.") (defvar antlr-unknown-file-formats '("?%s?.g" "?%s?") - "*Formats which specify the names of unknown files. + "Formats which specify the names of unknown files. The value looks like \(SUPER-GRAMMAR-FILE-FORMAT SUPER-EVOCAB-FORMAT). SUPER-GRAMMAR-FORMAT is a format string, it specifies with substitution @@ -686,7 +685,7 @@ DIRECTORY is the name of the current directory.") ;;;=========================================================================== (defcustom antlr-imenu-name t ; (featurep 'xemacs) ; TODO: Emacs-21 bug? - "*Non-nil, if a \"Index\" menu should be added to the menubar. + "Non-nil, if a \"Index\" menu should be added to the menubar. If it is a string, it is used instead \"Index\". Requires package imenu." :group 'antlr @@ -775,7 +774,7 @@ imenu." ;;;=========================================================================== (defcustom antlr-font-lock-maximum-decoration 'inherit - "*The maximum decoration level for fontifying actions. + "The maximum decoration level for fontifying actions. Value `none' means, do not fontify actions, just normal grammar code according to `antlr-font-lock-additional-keywords'. Value `inherit' means, use value of `font-lock-maximum-decoration'. Any other value is @@ -962,7 +961,7 @@ group. The string matched by the first group is highlighted with (antlr-re-search-forward "^\\(private\\|public\\|protected\\)\\>[ \t]*\\(\\(\\sw+[ \t]*\\(:\\)?\\)\\)?" limit)) - (1 font-lock-type-face) ; not XEmacs' java level-3 fruit salad + (1 font-lock-type-face) ; not XEmacs's java level-3 fruit salad (3 (if (antlr-upcase-p (char-after (match-beginning 3))) antlr-tokendef-face antlr-ruledef-face) nil t) @@ -1031,7 +1030,7 @@ not to confuse their context_cache.") (define-abbrev-table 'antlr-mode-abbrev-table ()) (defvar antlr-slow-cache-enabling-symbol 'loudly -;; Emacs' font-lock changes buffer's tick counter, therefore this value should +;; Emacs's font-lock changes buffer's tick counter, therefore this value should ;; be a parameter of a font-lock function, but not any other variable of ;; functions which call `antlr-slow-syntactic-context'. "If value is a bound symbol, cache will be used even with text changes. @@ -1074,7 +1073,7 @@ Used for `antlr-slow-syntactic-context'.") (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*" @@ -1093,7 +1092,7 @@ Used for `antlr-slow-syntactic-context'.") ;;;(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 @@ -1114,7 +1113,7 @@ WARNING: this may alter `match-data'." (or (buffer-syntactic-context) (buffer-syntactic-context-depth)) :EMACS (let ((orig (point)) diff state - ;; Arg, Emacs' (buffer-modified-tick) changes with font-lock. Use + ;; Arg, Emacs's (buffer-modified-tick) changes with font-lock. Use ;; hack that `loudly' is bound during font-locking => cache use will ;; increase from 7% to 99.99% during font-locking. (tick (or (boundp antlr-slow-cache-enabling-symbol) @@ -1671,7 +1670,7 @@ Return \(LEVEL OPTION LOCATION)." 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 @@ -2073,7 +2072,7 @@ Used inside `antlr-options-alists'." 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 @@ -2089,7 +2088,7 @@ Called in PHASE `after-insertion', see `antlr-options-alists'." (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 @@ -2182,36 +2181,32 @@ grammar file in which CLASS is defined and EVOCAB is the name of the 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)))))) @@ -2265,7 +2260,7 @@ called interactively, the buffers are always saved, see also variable (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 @@ -2597,7 +2592,7 @@ the default language." ;; 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 @@ -2667,5 +2662,4 @@ Used in `antlr-mode'. Also a useful function in `java-mode-hook'." ;;; Local IspellPersDict: .ispell_antlr -;; arch-tag: 5de2be79-3d13-4560-8fbc-f7d0234dcb5c ;;; antlr-mode.el ends here