Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / cedet / srecode / el.el
blob25ed45e5dfe5c1fea775d0368e40090b30f8e602
1 ;;; srecode/el.el --- Emacs Lisp specific arguments
3 ;; Copyright (C) 2008-2014 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; Emacs Lisp specific handlers. To use these handlers in your
25 ;; template, add the :name part to your template argument list.
27 ;; Error if not in a Emacs Lisp mode
29 ;;; Code:
31 (require 'srecode)
32 (require 'srecode/semantic)
34 (declare-function semanticdb-brute-find-tags-by-class "semantic/db-find")
36 ;;;###autoload
37 (defun srecode-semantic-handle-:el (dict)
38 "Add macros into the dictionary DICT based on the current Emacs Lisp file.
39 Adds the following:
40 PRENAME - The common name prefix of this file."
41 (let* ((names (append (semantic-find-tags-by-class 'function (current-buffer))
42 (semantic-find-tags-by-class 'variable (current-buffer)))
44 (common (try-completion "" names)))
46 (srecode-dictionary-set-value dict "PRENAME" common)
49 ;;;###autoload
50 (defun srecode-semantic-handle-:el-custom (dict)
51 "Add macros into the dictionary DICT based on the current Emacs Lisp file.
52 Adds the following:
53 GROUP - The 'defgroup' name we guess you want for variables.
54 FACEGROUP - The `defgroup' name you might want for faces."
55 (require 'semantic/db-find)
56 (let ((groups (semanticdb-strip-find-results
57 (semanticdb-brute-find-tags-by-class 'customgroup)))
58 (varg nil)
59 (faceg nil)
62 ;; Pick the best group
63 (while groups
64 (cond ((string-match "face" (semantic-tag-name (car groups)))
65 (setq faceg (car groups)))
66 ((not varg)
67 (setq varg (car groups)))
69 ;; What about other groups?
71 (setq groups (cdr groups)))
73 ;; Double check the facegroup.
74 (setq faceg (or faceg varg))
76 ;; Setup some variables
77 (srecode-dictionary-set-value dict "GROUP" (semantic-tag-name varg))
78 (srecode-dictionary-set-value dict "FACEGROUP" (semantic-tag-name faceg))
82 (define-mode-local-override srecode-semantic-apply-tag-to-dict
83 emacs-lisp-mode (tagobj dict)
84 "Apply Emacs Lisp specific features from TAGOBJ into DICT.
85 Calls `srecode-semantic-apply-tag-to-dict-default' first."
86 (srecode-semantic-apply-tag-to-dict-default tagobj dict)
88 ;; Pull out the tag for the individual pieces.
89 (let* ((tag (oref tagobj :prime))
90 (doc (semantic-tag-docstring tag)))
92 ;; It is much more common to have doc on ELisp.
93 (srecode-dictionary-set-value dict "DOC" doc)
95 (cond
97 ;; FUNCTION
99 ((eq (semantic-tag-class tag) 'function)
100 (if (semantic-tag-get-attribute tag :user-visible-flag)
101 (srecode-dictionary-set-value dict "INTERACTIVE" " (interactive)\n ")
102 (srecode-dictionary-set-value dict "INTERACTIVE" ""))))))
105 (provide 'srecode/el)
107 ;; Local variables:
108 ;; generated-autoload-file: "loaddefs.el"
109 ;; generated-autoload-load-name: "srecode/el"
110 ;; End:
112 ;;; srecode/el.el ends here