1# Produce dotzile.sample 2# 3# Copyright (c) 2010 Free Software Foundation, Inc. 4# 5# This file is part of GNU Zile. 6# 7# GNU Zile is free software; you can redistribute it and/or modify it 8# under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 3, or (at your option) 10# any later version. 11# 12# GNU Zile is distributed in the hope that it will be useful, but 13# WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with GNU Zile; see the file COPYING. If not, write to the 19# Free Software Foundation, Fifth Floor, 51 Franklin Street, Boston, 20# MA 02111-1301, USA. 21 22use Zile; 23 24open VARS, ">src/tbl_vars.h" or die; 25open SAMPLE, ">src/dotzile.sample" or die; 26 27print SAMPLE <<EOF; 28;;;; .$ENV{PACKAGE} configuration 29 30;; Rebind keys with: 31;; (global-set-key "key" 'func) 32 33EOF 34 35# Don't note where the contents of this file comes from or that it's 36# auto-generated, because it's ugly in a user configuration file. 37 38sub escape_for_C { 39 my ($s) = @_; 40 $s =~ s/\n/\\n/g; 41 $s =~ s/\"/\\\"/g; 42 return $s; 43} 44 45sub comment_for_lisp { 46 my ($s) = @_; 47 $s =~ s/\n/\n; /g; 48 return $s; 49} 50 51open IN, "<$ARGV[0]"; 52while (<IN>) { 53 if (/^X \(/) { 54 eval $_ or die "Error evaluating:\n$_\n"; 55 my ($name, $defval, $local_when_set, $doc) = @xarg; 56 $doc = texi($doc); 57 58 print VARS "X (\"$name\", \"$defval\", " . 59 ($local_when_set ? "true" : "false") . ", \"" . 60 escape_for_C($doc) . "\")\n"; 61 62 print SAMPLE "; " . comment_for_lisp($doc) . "\n" . 63 "; Default value is $defval.\n" . 64 "(setq $name $defval)\n\n"; 65 } 66} 67