1 ;;; ede-proj-info.el --- EDE Generic Project texinfo support
3 ;;; Copyright (C) 1998-2001, 2004, 2007-2012 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; Handle texinfo in and EDE Project file.
30 (defclass ede-proj-target-makefile-info
(ede-proj-target-makefile)
32 (keybindings :initform nil
)
33 (availablecompilers :initform
'(ede-makeinfo-compiler
34 ede-texi2html-compiler
))
35 (sourcetype :initform
'(ede-makeinfo-source))
36 (mainmenu :initarg
:mainmenu
40 :documentation
"The main menu resides in this file.
41 All other sources should be included independently."))
42 "Target for a single info file.")
44 (defvar ede-makeinfo-source
45 (ede-sourcecode "ede-makeinfo-source"
47 :sourcepattern
"\\.texi?$"
48 :garbagepattern
'("*.info*" "*.html"))
49 "Texinfo source code definition.")
51 (defvar ede-makeinfo-compiler
53 "ede-makeinfo-compiler"
55 :variables
'(("MAKEINFO" .
"makeinfo"))
56 :commands
'("$(MAKEINFO) $<")
57 :autoconf
'(("AC_CHECK_PROG" .
"MAKEINFO, makeinfo"))
58 :sourcetype
'(ede-makeinfo-source)
60 "Compile texinfo files into info files.")
62 (defvar ede-texi2html-compiler
64 "ede-texi2html-compiler"
66 :variables
'(("TEXI2HTML" .
"makeinfo -html"))
67 :commands
'("makeinfo -o $@ $<")
68 :sourcetype
'(ede-makeinfo-source)
70 "Compile texinfo files into html files.")
72 ;;; Makefile generation
74 (defmethod ede-proj-configure-add-missing
75 ((this ede-proj-target-makefile-info
))
76 "Query if any files needed by THIS provided by automake are missing.
77 Results in --add-missing being passed to automake."
78 (not (ede-expand-filename (ede-toplevel) "texinfo.tex")))
80 (defmethod ede-proj-makefile-sourcevar ((this ede-proj-target-makefile-info
))
81 "Return the variable name for THIS's sources."
82 (concat (ede-pmake-varname this
) "_TEXINFOS"))
84 (defmethod ede-proj-makefile-insert-source-variables
85 ((this ede-proj-target-makefile-info
) &optional moresource
)
86 "Insert the source variables needed by THIS info target.
87 Optional argument MORESOURCE is a list of additional sources to add to the
89 Does the usual for Makefile mode, but splits source into two variables
90 when working in Automake mode."
91 (if (not (ede-proj-automake-p))
93 (let* ((sv (ede-proj-makefile-sourcevar this
))
94 (src (copy-sequence (oref this source
)))
95 (menu (or (oref this menu
) (car src
))))
96 (setq src
(delq menu src
))
97 ;; the info_TEXINFOS variable is probably shared
98 (ede-pmake-insert-variable-shared "info_TEXINFOS"
100 ;; Now insert the rest of the source elsewhere
101 (ede-pmake-insert-variable-shared sv
102 (insert (mapconcat 'identity src
" ")))
104 (error "Texinfo files should not have moresource")))))
106 (defun ede-makeinfo-find-info-filename (source)
107 "Find the info filename produced by SOURCE texinfo file."
108 (let ((opened (get-file-buffer source
))
109 (buffer (or (get-file-buffer source
)
110 (find-file-noselect source nil t
)))
112 (with-current-buffer buffer
114 (goto-char (point-min))
115 (and (re-search-forward "^@setfilename\\s-+\\([^.]+\\).info$" nil t
)
116 (setq info
(match-string 1)))))
117 (unless (eq buffer opened
)
118 (kill-buffer buffer
))
121 (defmethod ede-proj-makefile-target-name ((this ede-proj-target-makefile-info
))
122 "Return the name of the main target for THIS target."
123 ;; The target should be the main-menu file name translated to .info.
124 (let* ((source (if (not (string= (oref this mainmenu
) ""))
126 (car (oref this source
))))
127 (info (ede-makeinfo-find-info-filename source
)))
128 (concat (or info
(file-name-sans-extension source
)) ".info")))
130 (defmethod ede-proj-makefile-insert-dist-dependencies ((this ede-proj-target-makefile-info
))
131 "Insert any symbols that the DIST rule should depend on.
132 Texinfo files want to insert generated `.info' files.
133 Argument THIS is the target which needs to insert an info file."
134 ;; In some cases, this is ONLY the index file. That should generally
136 (insert " " (ede-proj-makefile-target-name this
))
139 (defmethod ede-proj-makefile-insert-dist-filepatterns ((this ede-proj-target-makefile-info
))
140 "Insert any symbols that the DIST rule should depend on.
141 Texinfo files want to insert generated `.info' files.
142 Argument THIS is the target which needs to insert an info file."
143 ;; In some cases, this is ONLY the index file. That should generally
145 (insert " " (ede-proj-makefile-target-name this
) "*")
148 ; (let ((n (ede-name this)))
149 ; (if (string-match "\\.info$" n)
151 ; (concat n ".info"))))
153 (defmethod object-write ((this ede-proj-target-makefile-info
))
154 "Before committing any change to THIS, make sure the mainmenu is first."
155 (let ((mm (oref this mainmenu
))
156 (s (oref this source
))
158 (if (or (string= mm
"") (not mm
) (string= mm
(car s
)))
160 ;; Make sure that MM is first in the list of items.
161 (setq nl
(cons mm
(delq mm s
)))
162 (oset this source nl
)))
165 (defmethod ede-documentation ((this ede-proj-target-makefile-info
))
166 "Return a list of files that provides documentation.
167 Documentation is not for object THIS, but is provided by THIS for other
168 files in the project."
169 (let* ((src (oref this source
))
170 (proj (ede-target-parent this
))
171 (dir (oref proj directory
))
174 ;; convert src to full file names.
177 (expand-file-name (car src
) dir
)
179 (setq src
(cdr src
)))
183 (provide 'ede
/proj-info
)
185 ;;; ede/proj-info.el ends here