summaryrefslogtreecommitdiff
path: root/lisp/cedet/semantic/grammar.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-05-05 22:18:19 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-05-05 22:18:19 -0400
commita7d630eb4895a392bcc0d9986d1ca5382a4f7b96 (patch)
treea7dba5dd168029652d5640cac86e5c97444c0563 /lisp/cedet/semantic/grammar.el
parent0ed044dc1b524370f02f531b3b6fcc1ef45c395d (diff)
downloademacs-a7d630eb4895a392bcc0d9986d1ca5382a4f7b96.tar.gz
* lisp/cedet/semantic/grammar.el: Fix compiler warnings (bug#20505)
(semantic-grammar--template-expand): New function. (semantic-grammar-header, semantic-grammar-footer): Use it. (semantic-grammar--lex-block-specs): Remove unused var `block-spec'. (semantic-grammar-file-regexp): Refine regexp. (semantic-grammar-eldoc-get-macro-docstring): Use elisp-get-fnsym-args-string when available. (semantic-idle-summary-current-symbol-info): Use new elisp-* names instead of the old eldoc-* names. * lisp/emacs-lisp/eldoc.el (eldoc-docstring-format-sym-doc): Move back from elisp-mode.el. Tweak calling convention. * lisp/progmodes/elisp-mode.el (package-user-dir): Declare. (elisp-get-fnsym-args-string): Add `prefix' argument. Rename from elisp--get-fnsym-args-string. (elisp--highlight-function-argument): Add `prefix' arg. (elisp-get-var-docstring): Rename from elisp--get-var-docstring. (elisp--docstring-format-sym-doc): Move back to eldoc.el.
Diffstat (limited to 'lisp/cedet/semantic/grammar.el')
-rw-r--r--lisp/cedet/semantic/grammar.el84
1 files changed, 49 insertions, 35 deletions
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index 15ad9872446..fc7e9e61a16 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -628,39 +628,38 @@ The symbols in the list are local variables in
t)
(match-string 0))))
+(defun semantic-grammar--template-expand (template env)
+ (mapconcat (lambda (S)
+ (if (stringp S) S
+ (let ((x (assq S env)))
+ (cond
+ (x (cdr x))
+ ((symbolp S) (symbol-value S))))))
+ template ""))
+
(defun semantic-grammar-header ()
"Return text of a generated standard header."
- (let ((file (semantic-grammar-buffer-file
+ (semantic-grammar--template-expand
+ semantic-grammar-header-template
+ `((file . ,(semantic-grammar-buffer-file
semantic--grammar-output-buffer))
- (gram (semantic-grammar-buffer-file))
- (date (format-time-string "%Y-%m-%d %T%z"))
- (vcid (concat "$" "Id" "$")) ;; Avoid expansion
- ;; Try to get the copyright from the input grammar, or
- ;; generate a new one if not found.
- (copy (or (semantic-grammar-copyright-line)
+ (gram . ,(semantic-grammar-buffer-file))
+ (date . ,(format-time-string "%Y-%m-%d %T%z"))
+ (vcid . ,(concat "$" "Id" "$")) ;; Avoid expansion
+ ;; Try to get the copyright from the input grammar, or
+ ;; generate a new one if not found.
+ (copy . ,(or (semantic-grammar-copyright-line)
(concat (format-time-string ";; Copyright (C) %Y ")
- user-full-name)))
- (out ""))
- (dolist (S semantic-grammar-header-template)
- (cond ((stringp S)
- (setq out (concat out S)))
- ((symbolp S)
- (setq out (concat out (symbol-value S))))))
- out))
+ user-full-name))))))
(defun semantic-grammar-footer ()
"Return text of a generated standard footer."
- (let* ((file (semantic-grammar-buffer-file
- semantic--grammar-output-buffer))
- (libr (or semantic--grammar-provide
- semantic--grammar-package))
- (out ""))
- (dolist (S semantic-grammar-footer-template)
- (cond ((stringp S)
- (setq out (concat out S)))
- ((symbolp S)
- (setq out (concat out (symbol-value S))))))
- out))
+ (semantic-grammar--template-expand
+ semantic-grammar-footer-template
+ `((file . ,(semantic-grammar-buffer-file
+ semantic--grammar-output-buffer))
+ (libr . ,(or semantic--grammar-provide
+ semantic--grammar-package)))))
(defun semantic-grammar-token-data ()
"Return the string value of the table of lexical tokens."
@@ -714,7 +713,7 @@ Block definitions are read from the current table of lexical types."
(let* ((blocks (cdr (semantic-lex-type-value "block" t)))
(open-delims (cdr (semantic-lex-type-value "open-paren" t)))
(close-delims (cdr (semantic-lex-type-value "close-paren" t)))
- olist clist block-spec delim-spec open-spec close-spec)
+ olist clist delim-spec open-spec close-spec)
(dolist (block-spec blocks)
(setq delim-spec (semantic-grammar--lex-delim-spec block-spec)
open-spec (assq (car delim-spec) open-delims)
@@ -818,7 +817,7 @@ Block definitions are read from the current table of lexical types."
;;; Generation of the grammar support file.
;;
-(defcustom semantic-grammar-file-regexp "\\.[wb]y$"
+(defcustom semantic-grammar-file-regexp "\\.[wb]y\\'"
"Regexp which matches grammar source files."
:group 'semantic
:type 'regexp)
@@ -1073,7 +1072,7 @@ See also the variable `semantic-grammar-file-regexp'."
(defvar semantic--grammar-macros-regexp-2 nil)
(make-variable-buffer-local 'semantic--grammar-macros-regexp-2)
-(defun semantic--grammar-clear-macros-regexp-2 (&rest ignore)
+(defun semantic--grammar-clear-macros-regexp-2 (&rest _)
"Clear the cached regexp that match macros local in this grammar.
IGNORE arguments.
Added to `before-change-functions' hooks to be run before each text
@@ -1665,9 +1664,11 @@ Select the buffer containing the tag's definition, and move point there."
"Return a one-line docstring for the given grammar MACRO.
EXPANDER is the name of the function that expands MACRO."
(require 'eldoc)
- (if (eq expander (car semantic-grammar-eldoc-last-data))
- (cdr semantic-grammar-eldoc-last-data)
- (let ((doc (help-split-fundoc (documentation expander t) expander)))
+ (cond
+ ((eq expander (car semantic-grammar-eldoc-last-data))
+ (cdr semantic-grammar-eldoc-last-data))
+ ((fboundp 'eldoc-function-argstring) ;; Emacs<25
+ (let* ((doc (help-split-fundoc (documentation expander t) expander)))
(cond
(doc
(setq doc (car doc))
@@ -1680,7 +1681,16 @@ EXPANDER is the name of the function that expands MACRO."
(eldoc-docstring-format-sym-doc
macro (format "==> %s %s" expander doc) 'default))
(setq semantic-grammar-eldoc-last-data (cons expander doc)))
- doc)))
+ doc))
+ ((fboundp 'elisp-get-fnsym-args-string) ;; Emacsā‰„25
+ (elisp-get-fnsym-args-string
+ expander nil
+ (concat (propertize (symbol-name macro)
+ 'face 'font-lock-keyword-face)
+ " ==> "
+ (propertize (symbol-name macro)
+ 'face 'font-lock-function-name-face)
+ ": ")))))
(define-mode-local-override semantic-idle-summary-current-symbol-info
semantic-grammar-mode ()
@@ -1711,10 +1721,14 @@ Otherwise return nil."
(setq val (semantic-grammar-eldoc-get-macro-docstring elt val)))
;; Function
((and elt (fboundp elt))
- (setq val (eldoc-get-fnsym-args-string elt)))
+ (setq val (if (fboundp 'eldoc-get-fnsym-args-string)
+ (eldoc-get-fnsym-args-string elt)
+ (elisp-get-fnsym-args-string elt))))
;; Variable
((and elt (boundp elt))
- (setq val (eldoc-get-var-docstring elt)))
+ (setq val (if (fboundp 'eldoc-get-var-docstring)
+ (eldoc-get-var-docstring elt)
+ (elisp-get-var-docstring elt))))
(t nil)))
(or val (semantic-idle-summary-current-symbol-info-default))))