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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
###
# Purpose: this script generates Emacs major mode elisp file for
# requested Quantum ESPRESSO mode
##
# directories
set basedir [file normalize [file dirname [info script]]]
set topdir [file normalize [file join $basedir ..]]
set qe_modes_template_dir [file join $topdir GUI QE-modes qe-modes.templates]
set helpdocdir [file join $basedir helpdoc.d]
source [file join $helpdocdir modules.tcl]; # load which modules do we support
set usage "
Usage:
either: $argv0 \[OPTIONS\] module1 \[module2 module3 ...\]
or: $argv0 \[OPTIONS\] INPUT_*.def \[INPUT_*.def INPUT_*.def ...\]
Where possible values for modules are:
[::helpdoc::get_supported_modules]
While INPUT_*.def are what the name suggests.
OPTIONS are:
-mode value
The \"mode\" stands for the short name of the mode, i.e., the
generated name of the major mode file will be \${mode}-mode.el
(default value is the same as the name of the command-line
specified either module or the lowercase spelled PROG part of the
INPUT_PROG.def file).
-modename value
The \"modename\" is the textual name of mode; for example if
mode = pw, then modename can be set to QE-pw.x
(default value = QE-\${mode}.x).
-nmlprefix value
The \"nmlprefix\" is the prefix character of the fortran namelists
(default value = '&').
-funcs
If this option is specified then the function \$mode-funcs.el file is generated.
-masteronly
If this option is specified then only the master \$mode-modes.el file is generated.
The $argv0 generates an emacs major-mode elisp file for easier editing
of input files of specified Quantum ESPRESSO package.
"
# parse command-line
if { $argc < 1 } {
puts stderr $usage
exit 1
}
package require cmdline
set options {
{funcs "generate $mode-funcs.el file"}
{masteronly "generate $mode-modes.el master file"}
{mode.arg {} "short name of mode; the corresponding mode file will be named $mode-mode.el"}
{modename.arg {} "textual name of mode"}
{nmlprefix.arg & "symbol used for fortran namelist prefix"}
}
set argv_orig $argv
namespace eval ::helpdoc {
variable opt
array set opt [::cmdline::getoptions ::argv $options $usage]
if { [llength $::argv] == 0 } {
puts stderr "
### no module specified on the command line: [concat $::argv0 $::argv_orig]
"
exit 1
}
puts "
Input specs:
-----------"
parray opt
foreach module $argv {
puts "module([incr i]) = $module"
}
puts ""
}
# load the helpdoc package
source [file join $helpdocdir helpdoc.tcl]
# source the gen-emacs-mode.tcl
source [file join $basedir gen-emacs-mode.tcl]
namespace eval ::helpdoc {
# for -masteronly generates only the master mode file
if { $opt(masteronly) } {
qe_master_generate $argv
exit 0
}
# initialize the qe-mode generation
qe_mode_init
# parse each module file ...
variable module
foreach module $argv {
# find whether module is a name of the name of INPUT_*.def file
set deffile $module
if { ! [file exists $module] } {
# seems $module is a module name
puts -nonewline "
trying the $module as a module name ... "
set deffile [get_def_filename $module]
puts "\[OK\]"
} else {
# extract module name from INPUT_*.def as:
set module [modulename_from_defname $deffile]
}
lappend module_list $module
if { $opt(mode) eq {} } {
set opt(mode) $module
}
if { $opt(modename) eq {} } {
set opt(modename) QE-$opt(mode).x
}
# process this def file
qe_mode_process_def $deffile
}
# generate a $opt(mode)-mode.el file
qe_mode_generate $module_list
}
|