On this page I am collecting some ideas I have for user level customization of EASE. Have fun.
Contents of this page:
One of the really tedious things about using EASE is setting paths for the FEFF, data, and output files every time a new `feffit.inp' file is created. When I start a new bit of EXAFS analysis, I usually create a new directory to hold my work, then create subdirectories called `feff/', `data/', and `fits/'. This imposes some level of order on the files involved in data analysis and I am usually very consistent about choosing those directory names. Here is a snippet of elisp code that you can put in your `~/.ease' file that will set the data paths to those default values for a new file, but will not change them for an old file:
(add-hook 'Feffit-mode-hook
'(lambda ()
(if input-feff-path ()
(setq input-feff-path "feff/"))
(if input-data-path ()
(setq input-data-path "data/"))
(if input-out-path ()
(setq input-out-path "fits/")) ))
Since this is a mode-hook, it will be evaluated when the feffit input file is first visited. The if functions check to see if the values of the data paths were set from the auto-configuration line. If they were, nothing happens. If not, they are set to my user-chosen defaults. Note that (add-hook...) is used rather than (setq...). You should always set hooks in emacs using (add-hook...) to avoid accidentally overwriting any functions already in the hook.
The auto-configuration values, i.e. the stuff that looks like this
!!&& input-program-name: "feffit"
!!&& input-data-path: "data/"
!!&& input-feff-path: "feff/"
!!&& input-out-path: "fits/"
can be edited on screen by changing the values inserted between the double quotes, then doing M-x input-set-configuration, C-c C-b a, or selecting Reset autoconfiguration variables from the Input->Miscellaneous menu.
Two possibly annoying features of EASE are the Local Variables list that gets written to the end of every file and the fact that you have to answer a question about what kind of file you are editing when you start a new input file. That EASE writes the Local Variables list can be quite convenient for the user, but it is wrting something to the file that the user might not have chosen to write. The question is simply annoying if you just want to make a quick change and hurry along.
There are several variables that you can set in your `.ease' file that might be helpful if either of these features irks you. Each of these is a logical flag, thus should be set to t or nil.
ease-always-start-generic-flag:
When
non-nil this tells EASE to always start editing a file in
generic minor mode whenever it cannot otherwise determine
the file type. Generic minor mode lacks most of the
functionality of EASE, but it load slightly quicker than
the other minor modes and it avoids the question about the
file type. You can always select
Switch Programs from the
Input:Miscellaneous menu
(C-c C-b s) to set the file type
interactively.
ease-hide-autoconfig-flag:
When non-nil this tells EASE to narrow to the region
between the beginning of the file and the beginning of
the Local Variables list. This has the effect of hiding
the Local Variables list from sight. It is still used
by EASE, but it is out of sight.
input-prohibit-autoconfig-flag:
When non-nil this tells EASE to never write the Local
Variable list. Using this in conjunction with ease-always-start-generic-flag is
sensible.
input-time-stamp-flag:
When
non-nil this tells EASE to never write a time stamp to
the input file.
ease-mouse-overlays-default-flag:
When nil (note that this behaves opposite to all the
others in this section) this tells EASE to not set the
mouse-faces. Thus, when nil the color over a filename
will not flash when the mouse moves near it. This
doesn't have to do with the Local Variables list, but if
someone dislikes the list then he probably doesn't like
the mouse-faces either.
Here is some code for your `.ease' file implementing everything in this section. Note that what I have listed here is the opposite to the default behavior.
(setq ease-always-start-generic-flag t ease-hide-autoconfig-flag t ease-prohibit-autoconfig-flag t ease-time-stamp-flag t ease-mouse-overlays-default-flag nil)
EASE has a facility for performing user-specified chores when it is done running a program. The following code is an example of this. This example will cause EASE to display the result of a fit from FEFFIT in R space immediately after completing the fit.
(add-hook 'input-after-run-hook '(lambda () (if (string= input-program-name "feffit") (Feffit-plot-r))))
Note that this will attempt to plot the fit regardless of whether FEFFIT ran correctly. Thus, this might be something that you put into your `.ease' file, but comment out until you have an input file that know is free of mistakes.
This example is for having EASE open the `feff.inp' generated by an ATOMS run immediately upon finishing the ATOMS run.
(add-hook 'input-after-run-hook
'(lambda ()
(if (string= input-program-name "atoms")
(input-jump-to-log-file))))
To use both of these, you can either put both expressions in your `.ease' file or do something like the following
(add-hook 'input-after-run-hook
'(lambda ()
(cond ((string= input-program-name "atoms")
(input-jump-to-log-file))
((string= input-program-name "feffit")
(Feffit-plot-r)))))
You can then string together special after-run instructions for each of the different programs.
Just as there is a hook that is run after program execution finishes, there is one that run before program execution starts. I find it convenient to have EASE make sure that evaluation lines in an `atoms.inp' file are expanded before running ATOMS. Putting this in the `.ease' file accomplishes that:
(add-hook 'input-before-run-hook
'(lambda () (and (string= "atoms" input-program-name)
(Atoms-evaluate-buffer)
(save-buffer))))
Evaluation line expansion is a nifty feature of EASE. You can define atoms coodinates using a line like this:
!+ Mn 0.0 3/4 1/8 mn1
and it will be expanded to this
!+ Mn 0.0 3/4 1/8 mn1
Mn 0.0000 0.7500 0.1250 mn1
Similarly you can define an atom coordinate using variables and math expressions. This
!+ Ti 0.5 0.5 (0.5 + q*ti)
expands to this
!+ Ti 0.5 0.5 (0.5 + q*ti)
Ti 0.5000 0.5000 0.5377
assuming that the following definition line is found somewhere in the input file:
!- ti = 0.0377 q = 1
Note that the evaluation and definition lines are comments and will be ignored by ATOMS. The evaluation functions require the calc package.
You can use imenu rules in FEFFIT, AUTOBK, and phit minor modes. M-x imenu and M-x imenu-add-to-menubar now do interesting things in input mode. This is particularly handy for use with speedbar. Put the following in your `~/.ease' file to enable input file support in speedbar.
(if (featurep 'speedbar)
(speedbar-add-supported-extension ".inp"))