Add plugin periodic function elisp skeleton
[vpp.git] / extras / emacs / plugin.el
1 ;;; Copyright (c) 2016 Cisco and/or its affiliates.
2 ;;; Licensed under the Apache License, Version 2.0 (the "License");
3 ;;; you may not use this file except in compliance with the License.
4 ;;; You may obtain a copy of the License at:
5 ;;;
6 ;;;     http://www.apache.org/licenses/LICENSE-2.0
7 ;;;
8 ;;; Unless required by applicable law or agreed to in writing, software
9 ;;; distributed under the License is distributed on an "AS IS" BASIS,
10 ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 ;;; See the License for the specific language governing permissions and
12 ;;; limitations under the License.
13
14 (defun make-plugin ()
15   "Create a plugin"
16   (interactive)
17   (save-excursion
18     (let (cd-args cmd-args start-dir)
19       (setq start-dir default-directory)
20       (makunbound 'plugin-name)
21       (makunbound 'PLUGIN-NAME)
22       (setq plugin-name (read-string "Plugin name: "))
23       (setq PLUGIN-NAME (upcase plugin-name))
24       (find-file (concat plugin-name ".am"))
25       (skel-plugin-makefile-am-fragment)
26       (setq cmd-args (concat "mkdir -p " plugin-name))
27       (shell-command cmd-args)
28       (setq cd-args (concat start-dir "/" plugin-name))
29       (setq default-directory cd-args)
30       (find-file (concat plugin-name ".api"))
31       (skel-plugin-api)
32       (find-file (concat plugin-name "_all_api_h.h"))
33       (skel-plugin-all-apih)
34       (find-file (concat plugin-name ".h"))
35       (skel-plugin-h)
36       (find-file (concat plugin-name ".c"))
37       (skel-plugin-main)
38       (find-file (concat plugin-name "_msg_enum.h"))
39       (skel-plugin-msg-enum)
40       (find-file "node.c")
41       (skel-plugin-node)
42       (find-file (concat plugin-name "_test.c"))
43       (skel-plugin-test)
44       (find-file (concat plugin-name "_periodic.c"))
45       (skel-plugin-periodic)
46       (cd start-dir))))
47