1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
;;; ebuild-mode.el --- a mode for editing Portage .ebuild, .eclass and .eselect files.
;; Copyright (C) 2003-2006 Gentoo Foundation
;; Author: Matthew Kennedy <mkennedy@gentoo.org>
;; Author: Diego Pettenò <flameeyes@gentoo.org>
;; Keywords: convenience
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
(defvar ebuild-mode-hook nil
"List of functions to call when entering ebuild-mode")
;;; Commentary:
;; The commands have been grouped into lists of rough similarity. If
;; you can think of a better way to arrange these, please let us know.
;; We map each set of keywords to the basic faces: font-lock-*-face.
;;; Code:
(defvar ebuild-mode-commands-0
'("use" "has_version" "best_version" "use_with" "use_enable" "check_KV" "keepdir" "econf" "die" "einstall" "elog" "einfo" "ewarn" "eerror" "diropts" "dobin" "docinto" "dodoc" "doexe" "dohard" "dohtml" "doinfo" "doins" "dolib" "dolib.a" "dolib.so" "doman" "dosbin" "dosym" "emake" "exeinto" "exeopts" "fowners" "fperms" "insinto" "insopts" "into" "libopts" "newbin" "newexe" "newins" "newman" "newsbin" "prepall" "prepalldocs" "prepallinfo" "prepallman" "prepallstrip" "has" "unpack" "dopython" "dosed" "into" "doinitd" "doconfd" "doenvd" "dojar" "domo" "dodir" "ebegin" "eend" "newconfd" "newdoc" "newenvd" "newinitd" "newlib.a" "newlib.so" "hasq" "hasv" "useq" "usev"))
(defvar ebuild-mode-commands-1
'("addread" "addwrite" "adddeny" "addpredict"))
(defvar ebuild-mode-commands-2
'("inherit"))
(defun ebuild-mode-make-keywords-list (keywords-list face &optional prefix suffix)
;; based on `make-generic-keywords-list' from generic.el
(unless (listp keywords-list)
(error "Keywords argument must be a list of strings"))
(cons (concat prefix "\\<"
(regexp-opt keywords-list t)
"\\>" suffix)
face))
(defun ebuild-mode-tabify ()
(save-excursion
(tabify (point-min) (point-max))))
(define-derived-mode ebuild-mode shell-script-mode "Ebuild"
"Major mode for Portage .ebuild and .eclass files."
(font-lock-add-keywords 'ebuild-mode
(list (ebuild-mode-make-keywords-list ebuild-mode-commands-0 'font-lock-type-face)
(ebuild-mode-make-keywords-list ebuild-mode-commands-1 'font-lock-warning-face)
(ebuild-mode-make-keywords-list ebuild-mode-commands-2 'font-lock-type-face)))
(add-hook 'write-file-functions 'delete-trailing-whitespace t t)
(add-hook 'write-file-functions 'ebuild-mode-tabify t t)
(setq tab-width 4
indent-tabs-mode t)
;; run user-defined hooks
(run-hooks 'ebuild-mode-hook))
(defvar eselect-mode-commands-0
'("die" "is_function" "has"))
(defvar eselect-mode-commands-1
'("store_config" "load_config" "add_config"))
(defvar eselect-mode-commands-2
'("svn_date_to_version"))
(defvar eselect-mode-commands-3
'("list_libdirs"))
(defvar eselect-mode-commands-4
'("write_error_msg" "write_list_start" "write_kv_list_entry" "write_numbered_list_entry" "write_numbered_list" "highlight" "highlight_warning" "space"))
(defvar eselect-mode-commands-5
'("is_number"))
(define-derived-mode eselect-mode shell-script-mode "Eselect"
"Major mode for Portage .eselect files."
(font-lock-add-keywords 'eselect-mode
(list (ebuild-mode-make-keywords-list eselect-mode-commands-0 'font-lock-type-face)
(ebuild-mode-make-keywords-list eselect-mode-commands-1 'font-lock-type-face)
(ebuild-mode-make-keywords-list eselect-mode-commands-2 'font-lock-type-face)
(ebuild-mode-make-keywords-list eselect-mode-commands-3 'font-lock-warning-face)
(ebuild-mode-make-keywords-list eselect-mode-commands-4 'font-lock-type-face)
(ebuild-mode-make-keywords-list eselect-mode-commands-5 'font-lock-type-face)))
(add-hook 'write-file-functions 'delete-trailing-whitespace t t)
(add-hook 'write-file-functions 'ebuild-mode-tabify t t)
(setq tab-width 4
indent-tabs-mode t))
(defun ebuild-mode-run-command (command)
(let ((process-connection-type "t")
(buffer (format "*ebuild %s*" command)))
(start-process "ebuild-digest" buffer "env" "NOCOLOR=yes" "ebuild" (buffer-file-name) command)
(pop-to-buffer buffer)))
(defmacro define-ebuild-mode-command (key command)
(let ((name (intern (format "ebuild-mode-command-%s" command))))
`(progn
(defun ,name ()
,(format "Runs the ebuild %s command for the ebuild in the current buffer" command)
(interactive)
(ebuild-mode-run-command ,command))
(define-key ebuild-mode-map ,key ',name))))
(define-ebuild-mode-command "\C-ced" "digest")
(define-ebuild-mode-command "\C-cef" "fetch")
(define-ebuild-mode-command "\C-ceu" "unpack")
;; (add-to-list 'auto-mode-alist '("\\.ebuild\\'" . ebuild-mode))
;; (add-to-list 'auto-mode-alist '("\\.eclass\\'" . ebuild-mode))
;; (add-to-list 'auto-mode-alist '("\\.eselect\\'" . eselect-mode))
(provide 'ebuild-mode)
;;; ebuild-mode.el ends here
|