From: hayashi Date: Thu, 12 Aug 1999 01:17:22 +0000 (+0000) Subject: Add suffix to Texinfo file when formatting. X-Git-Tag: t-gnus-6_13_0-01~2 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87d1ec3870f2b71dd92fc005221204fbcd6f9452;p=elisp%2Fgnus.git- Add suffix to Texinfo file when formatting. --- diff --git a/Makefile.in b/Makefile.in index 42944e3..0dbddc4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -20,17 +20,17 @@ install: cd texi && $(MAKE) EMACS="$(EMACS)" install # Rule for XEmacs package. -package: xlick add-info-suffix xinfo remove-info-suffix +package: xlick xinfo cd lisp && $(MAKE) EMACS="$(XEMACS)" package -install-package: add-info-suffix xinfo xinfo remove-info-suffix +install-package: xinfo cd lisp && $(MAKE) EMACS="$(XEMACS)" PACKAGEDIR="$(PACKAGEDIR)" \ install-package -package-ja: xlick add-info-suffix xinfo xinfo-ja remove-info-suffix +package-ja: xlick xinfo xinfo-ja cd lisp && $(MAKE) EMACS="$(XEMACS)" package -install-package-ja: add-info-suffix xinfo xinfo-ja remove-info-suffix +install-package-ja: xinfo xinfo-ja cd lisp && $(MAKE) EMACS="$(XEMACS)" PACKAGEDIR="$(PACKAGEDIR)" \ install-package @@ -38,16 +38,10 @@ xlick: cd lisp && $(MAKE) EMACS="$(XEMACS)" lispdir="$(lispdir)" all xinfo: - cd texi && $(MAKE) EMACS="$(XEMACS)" all + cd texi && $(MAKE) EMACS="$(XEMACS)" all-info xinfo-ja: - cd texi && $(MAKE) EMACS="$(XEMACS)" MAKEINFO=no ja - -add-info-suffix: - cd texi && $(MAKE) EMACS="$(XEMACS)" add-info-suffix - -remove-info-suffix: - cd texi && $(MAKE) remove-info-suffix + cd texi && $(MAKE) EMACS="$(XEMACS)" MAKEINFO=no ja-info # Rule for Lars and nobody else. some: diff --git a/lisp/dgnushack.el b/lisp/dgnushack.el index ba704c1..bec11bb 100644 --- a/lisp/dgnushack.el +++ b/lisp/dgnushack.el @@ -113,10 +113,12 @@ (unless (boundp 'buffer-file-coding-system) (defvar buffer-file-coding-system (symbol-value 'file-coding-system))) (autoload 'font-lock-set-defaults "font-lock") -(defalias 'coding-system-get 'ignore) +(unless (fboundp 'coding-system-get) + (defalias 'coding-system-get 'ignore)) (when (boundp 'MULE) (defalias 'find-coding-system 'ignore)) -(defalias 'get-charset-property 'ignore) +(unless (fboundp 'get-charset-property) + (defalias 'get-charset-property 'ignore)) (unless (featurep 'xemacs) (defalias 'Custom-make-dependencies 'ignore) (defalias 'toolbar-gnus 'ignore) @@ -174,7 +176,7 @@ Modify to suit your needs.")) (when (or (not (file-exists-p (setq elc (concat file "c")))) (file-newer-than-file-p file elc)) (ignore-errors - (byte-compile-file file))))))) + (byte-compile-file file))))))) (defun dgnushack-recompile () (require 'gnus) @@ -319,21 +321,93 @@ You must specify the name of the package path as follows: (message "Done"))) -(defun dgnushack-add-info-suffix-maybe () - ;; This function must be invoked from lisp directory. - (setq default-directory "../texi/") - (let ((coding-system-for-read 'raw-text) - (coding-system-for-write 'raw-text) - (files (directory-files "." nil dgnushack-texi-file-regexp)) - file make-backup-files) - (while (setq file (pop files)) - (find-file file) - (when (and (re-search-forward - "^@setfilename[\t ]+\\([^\t\n ]+\\)" nil t) - (not (string-match "\\.info$" (match-string 1)))) - (copy-file file (concat file "_") nil t) - (insert ".info") - (save-buffer)) - (kill-buffer (current-buffer))))) +(defun dgnushack-texi-add-suffix-and-format () + (dgnushack-texi-format t)) + +(defun dgnushack-texi-format (&optional addsuffix) + (if (not noninteractive) + (error "batch-texinfo-format may only be used -batch.")) + (require 'texinfmt) + (let ((auto-save-default nil) + (find-file-run-dired nil) + coding-system-for-write) + (let ((error 0) + file + (files ())) + (while command-line-args-left + (setq file (expand-file-name (car command-line-args-left))) + (cond ((not (file-exists-p file)) + (message ">> %s does not exist!" file) + (setq error 1 + command-line-args-left (cdr command-line-args-left))) + ((file-directory-p file) + (setq command-line-args-left + (nconc (directory-files file) + (cdr command-line-args-left)))) + (t + (setq files (cons file files) + command-line-args-left (cdr command-line-args-left))))) + (while files + (setq file (car files) + files (cdr files)) + (condition-case err + (progn + (if buffer-file-name (kill-buffer (current-buffer))) + (find-file file) + (setq coding-system-for-write buffer-file-coding-system) + (when (and addsuffix + (re-search-forward + "^@setfilename[\t ]+\\([^\t\n ]+\\)" nil t) + (not (string-match "\\.info$" (match-string 1)))) + (insert ".info")) + (buffer-disable-undo (current-buffer)) + ;; process @include before updating node + ;; This might produce some problem if we use @lowersection or such. + (let ((input-directory default-directory) + (texinfo-command-end)) + (while (re-search-forward "^@include" nil t) + (setq texinfo-command-end (point)) + (let ((filename (concat input-directory + (texinfo-parse-line-arg)))) + (re-search-backward "^@include") + (delete-region (point) (save-excursion (forward-line 1) (point))) + (message "Reading included file: %s" filename) + (save-excursion + (save-restriction + (narrow-to-region + (point) + (+ (point) (car (cdr (insert-file-contents filename))))) + (goto-char (point-min)) + ;; Remove `@setfilename' line from included file, if any, + ;; so @setfilename command not duplicated. + (if (re-search-forward + "^@setfilename" (save-excursion (forward-line 100) (point)) t) + (progn + (beginning-of-line) + (delete-region + (point) (save-excursion (forward-line 1) (point)))))))))) + (texinfo-mode) + (texinfo-every-node-update) + (set-buffer-modified-p nil) + (message "texinfo formatting %s..." file) + (texinfo-format-buffer nil) + (if (buffer-modified-p) + (progn (message "Saving modified %s" (buffer-file-name)) + (save-buffer)))) + (error + (message ">> Error: %s" (prin1-to-string err)) + (message ">> point at") + (let ((s (buffer-substring (point) + (min (+ (point) 100) + (point-max)))) + (tem 0)) + (while (setq tem (string-match "\n+" s tem)) + (setq s (concat (substring s 0 (match-beginning 0)) + "\n>> " + (substring s (match-end 0))) + tem (1+ tem))) + (message ">> %s" s)) + (setq error 1)))) + (kill-emacs error)))) ;;; dgnushack.el ends here diff --git a/texi/Makefile.in b/texi/Makefile.in index 1790a78..047fa0c 100644 --- a/texi/Makefile.in +++ b/texi/Makefile.in @@ -8,9 +8,9 @@ top_srcdir = @top_srcdir@ TEXI2DVI=texi2dvi EMACS=emacs MAKEINFO=@MAKEINFO@ -EMACSINFO=$(EMACS) -batch -q -no-site-file -INFOSWI=-l texinfmt -f texinfo-every-node-update -f texinfo-format-buffer -f save-buffer -XINFOSWI=-l texinfmt -f texinfo-every-node-update -f texinfo-format-buffer -f save-buffer +FLAGS=-batch -q -no-site-file +INFOSWI=-l ./dgnushack.el -f dgnushack-texi-format +XINFOSWI=-l ./dgnushack.el -f dgnushack-texi-add-suffix-and-format LATEX=latex DVIPS=dvips PERL=perl @@ -20,28 +20,32 @@ SHELL = /bin/sh PAPERTYPE=a4 all: gnus message emacs-mime +all-info: gnus.info message.info emacs-mime.info -ja: gnus-ja message-ja +gnus.info: gnus.texi gnus-faq.texi +message.info: message.texi +emacs-mime.info: emacs-mime.texi -# Rule for XEmacs package. -add-info-suffix: - cd ../lisp && $(EMACS) -batch -q -no-site-file \ - -l dgnushack.el -f dgnushack-add-info-suffix-maybe +ja: gnus-ja message-ja +ja-info: gnus-ja.info message-ja.info -remove-info-suffix: - for file in gnus message emacs-mime gnus-ja message-ja; do \ - if test -f $$file.texi_; then \ - mv $$file.texi_ $$file.texi; \ - fi; \ - done +gnus-ja.info: gnus-ja.texi gnus-faq-ja.texi +message-ja.info: message-ja.texi most: texi2latex.elc latex latexps +%.info: %.texi + if test $(MAKEINFO) = no; then \ + cd ../lisp && $(EMACS) $(FLAGS) $(XINFOSWI) ../texi/$<; \ + else \ + makeinfo -o $@ $<; \ + fi + .SUFFIXES: .texi .dvi .ps .texi: if test $(MAKEINFO) = no; then \ - $(EMACSINFO) $< $(XINFOSWI); \ + cd ../lisp && $(EMACS) $(FLAGS) $(INFOSWI) ../texi/$<; \ else \ makeinfo $<; \ fi @@ -64,7 +68,7 @@ clean: gnus.tmptexi *.tmplatexi gnus.tmplatexi1 texput.log *.orig *.rej \ gnus.latexi*~* tmp/*.ps xface.tex picons.tex smiley.tex *.latexi \ gnus.info* gnus-ja.info* message.info* message-ja.info* \ - *.texi_ emacs-mime.info + emacs-mime.info makeinfo: makeinfo -o gnus gnus.texi @@ -128,6 +132,8 @@ distclean: clean rm -f *.orig *.rej *.elc *~ gnus gnus-[0-9] gnus-[0-9][0-9] Makefile rm -f message message-[0-9] rm -f emacs-mime + rm -f gnus-ja gnus-ja-[0-9] gnus-ja-[0-9][0-9] + rm -f message-ja message-ja-[0-9] install: $(SHELL) $(top_srcdir)/mkinstalldirs $(infodir)