diff --git a/lisp/org-babel-init.el b/lisp/org-babel-init.el index 2e6823ed7..72c27f29e 100644 --- a/lisp/org-babel-init.el +++ b/lisp/org-babel-init.el @@ -49,7 +49,10 @@ ;; other versions of htmlize can cause export problems (load (expand-file-name "htmlize.el" util-dir)) ;; the newest version of inf-ruby.el is required by org-babel-ruby.el - (load (expand-file-name "inf-ruby.el" util-dir))) + (load (expand-file-name "inf-ruby.el" util-dir)) + ;; gnuplot mode + (load (expand-file-name "gnuplot.el" + (expand-file-name "gnuplot-mode.0.6.0" util-dir)))) ;; language specific files (add-to-list 'load-path (expand-file-name "langs" (file-name-directory (or load-file-name buffer-file-name)))) diff --git a/util/gnuplot-mode.0.6.0/COPYING b/util/gnuplot-mode.0.6.0/COPYING new file mode 100644 index 000000000..eeb586b39 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/util/gnuplot-mode.0.6.0/ChangeLog b/util/gnuplot-mode.0.6.0/ChangeLog new file mode 100644 index 000000000..4d77cfd61 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/ChangeLog @@ -0,0 +1,224 @@ + +May 17 2002 Bruce Ravel + * gnuplot.el: Version 0.5r + * handle continuation lines better + * C-c C-c now for comment region, C-c C-o for GUI + * trim gnuplot buffer + customize vble controlling max buffer + length + * Altered Makefile.in to install .el files along with .elc + files + +May 30 2001 Bruce Ravel + * gnuplot.el: Version 0.5q + * added font-lock bindings for words associated with plotting + +Apr 15 2001 Bruce Ravel + * gnuplot.el: Version 0.5p + * fixed the fix for the serious bug in how speedbar and + gnuplot-mode interact. In the words of Bullwinkle, "This + time for sure!" + +Jan 4 2001 Bruce Ravel + * gnuplot.el: Version 0.5n + * fixed a serious bug in how speedbar and gnuplot-mode + interact + +Nov 29 2000 Bruce Ravel + * gnuplot.el: Version 0.5m + * much better algorithm for determining gnuplot version number + * add colorization and gui support for new commands in 3.8. + * gui support for emf term. + * gui support for new "set style" syntax. + +Nov 16 2000 Bruce Ravel + * gnuplot.el: Version 0.5l + * support for pm3d in gnuplot-gui and in plot options + insertions menu. + * mentioned pm3d in gpelcard. + * `gnuplot-negate-option' works with new syntax + +Sep 22 1999 Bruce Ravel + * gnuplot.el: Version 0.5k + * make `gnuplot-send-line-and-forward' skip over blank and + comment lines as suggested by . + * Jan 10 2000 Bound C-c C-j to `gnuplot-forward-script-line'. + +Sep 9 1999 Bruce Ravel + * gnuplot.el: Version 0.5j + * Do a more robust check for the gnuplot process before + killing the gnuplot buffer, as suggested by . + +Sep 2 1999 Bruce Ravel + * gnuplot.el: Version 0.5i + * Once again changed how `comint-process-echos' gets set. + Maybe I got it right this time? + * Also fixed certain situations where the info file did not + get properly loaded (insertion with info toggle on and info + button in GUI). + +Aug 15 1999 Bruce Ravel + * gnuplot.el: Version 0.5h + * Added `gnuplot-determine-gnuplot-version' so that the + gnuplot version number and `comint-process-echos' actually + get set correctly. Actually, the first time something is + plotted, the echoing might not work, but the second time it + will. + +May 27 1999 Bruce Ravel + * gnuplot.el: Version 0.5g + * fixed a bug in XEmacs in the font-locking rules for comments + and strings + * figure out what version of gnuplot is being run by reading + the Gnuplot start-up message and set + gnuplot-echo-command-line-flag appropriately + * fixed a bug which made gnuplot-mode fail when font-lock was + not a feature + +May 15 1999 Bruce Ravel + * gnuplot.el: Version 0.5f + * include pgnuplot.c and installation instructions for Windows + 95 and 98 + * allow user to defer parsing info file so that gnuplot-mode + starts up faster + +Apr 6 1999 Bruce Ravel + * gnuplot.el: Version 0.5e + * drop gnuplot-which-highlight variable but still make sure + colorization works under emacs, xemacs, font-lock, and + hilit19 + * insert a space at the end of a unique completion + * fixed completion in file widget in GUI + * primitive support for plot, splot, fit in gui. + * rewrote a lot of GUI code + +Mar 21 1999 Bruce Ravel + * gnuplot.el: Version 0.5d + * use installation materials provided by Lars Hecking, + maintainer of gnuplot itself + * added some GUI support for hidden3d + * various improvements to the types alists used by the GUI + * improved various document strings and the bug reporter function + +Feb 15 1999 Bruce Ravel + * gnuplot.el: Version 0.5c + * update copyright information and gpelcard.tex + +Jan 28 1999 Bruce Ravel + * gnuplot.el: Version 0.5b + * fixed a bug in gnuplot-kill-gnuplot-buffer + * fixed a bug in gnuplot-plot-from-comint + * fixed the description of the gnuplot-faces customization group + +Jan 23 1999 Bruce Ravel + * gnuplot.el: Version 0.5a + * send file to gnuplot now uses the "load" command + * can plot scripts from the comint buffer using + gnuplot-plot-from-comint or + gnuplot-save-and-plot-from-comint. + * C-d in comint buffer is more graceful + +Dec 27 1998 Bruce Ravel + + * gnuplot.el: Version 0.5 + * preliminary version of interactive graphical system for + setting command arguments + * make changes to insertion menu and to gnuplot-insert + function to accomodate GUI system + * made gnuplot-negate-option function and bound it to C-c C-n + * replace kw-compl with a simple completion function + * transparent icons in toolbar + * move toolbar code into gnuplot.el + +Dec 15 1998 Bruce Ravel + + * gnuplot.el: Version 0.4f + * defcustom all the insertion submenus + * added gnuplot-insertion-menu-flag + * Makefile now knows how to determine which version of + info-look to compile + +Dec 13 1998 Bruce Ravel + + * gnuplot.el: Version 0.4e + * deal with the many versions of info-look in the Makefile + * drop install-gnuplot + * break insertions menu up into several variables and put + menubar initialization into a function + +Dec 9 1998 Bruce Ravel + + * gnuplot.el: Version 0.4d + * added function gnuplot-setup-info-look and hook variable + gnuplot-info-hook to handle situation of different versions + of the info file. + +Nov 30 1998 Bruce Ravel + + * gnuplot.el: Version 0.4c + * fixed frame behavior + * fixed comint highlighting behavior + * added :link to defgroup. added "[:]" to range insertions + * fixed behavior of filename insertion function + * added more :link's to the defgroup + * edited Makefile and README file in the distribution, added + dot.el to the distribution to suppress compile-time + warnings + +Nov 21 1998 Bruce Ravel + + * gnuplot.el: Version 0.4b + * Fix bug in line plotting function when line is empty + * Add toolbar for XEmacs and file gnuplot-toolbar.el + * Allow display of gnuplot process in a separate frame + +Nov 18 1998 Bruce Ravel + + * gnuplot.el: Version 0.4a + * clean up useless buffers left lying around by info-look + * Fix font-lock rules so that quoted words and the text + surrounding them are correctly highlighted + * Fix font-lock rules for plot and splot + * Added function `gnuplot-send-line-and-forward' and bound it to + C-c C-v. Mention this in gpelcard + +Nov 14 1998 Bruce Ravel + + * gnuplot.el: Version 0.4 + * Added info-look to distribution. It was taken from the emacs + 20.2 installation and one small change was made to allow + it compile under XEmacs. + * Use info-look for info interface. With this the gnuplot-mode + user interface to the gnuplot info file does not change + but the interior code is much cleaner and I get to use an + already invented wheel. One nice feature is that the help + function is completely independent of the version number of + gnuplot as long as the index in the gnuplot.info file is + called "General Index". Also `gnuplot-keywords' (which is + used for help, keyword-completion, and hilit19 highlighting) + is now generated automatically the first time gnuplot mode + is invoked. + * Changed default of `gnuplot-show-help-flag' to nil. + + +Earlier versions (taken from gnuplot.el file) + + 0.1 Jun 25 1998 Finished with initial release. + 0.2 Sep 4 1998 Added filename insertion, indentation, and + colorization/completion in comint buffer.
+ 0.2a Sep 11 1998 made `indent-line-function' buffer-local (whoops!) + and fixed some stuff in the installation script
+ 0.3 Sep 12 1998 include insertions menu
+ 0.3a Sep 14 1998 fixed bug finding info file if missing, fixed bug + starting font-lock, fixed bug re overwriting files in + installation script
+ 0.3b Sep 15 1998 Added (require 'info) to `(eval-and-compile' clause, + Added (kill-all-local-variables) to `gnuplot-mode', altered order + of:- + (provide 'gnuplot) + ;; any final chores before leaving + (run-hooks 'gnuplot-load-hook) + at the end of the file in case something in the load hook + requires gnuplot (oh not that old one again...), added + `gnuplot-comint-setup-hook', corrected `gnuplot-mark-active' + which caused an error to be raised by (mark) when the mark + was inactive Some changes to font-lock rules &
diff --git a/util/gnuplot-mode.0.6.0/INSTALL b/util/gnuplot-mode.0.6.0/INSTALL new file mode 100644 index 000000000..adbc4ba49 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/INSTALL @@ -0,0 +1,45 @@ + +To install gnuplot-mode: + +1. At the command line: + + > configure + > make + + If you use XEmacs, do "make EMACS=xemacs" (or change the EMACS + variable to "xemacs" in the Makefile, the run "make"). + + If "configure" doesn't work for you, the file "Makefile.dst" can be + used. In that case do, "make -f Makefile.dst". + +2. Move the .elc files to a place where emacs can find them, for + example /usr/share/emacs/site-lisp or your personal emacs + directory. + +3. Insert the contents of the `dotemacs' file into your .emacs file + or system start-up file to enable gnuplot mode. + +4. The function `gnuplot-info-lookup-symbol' looks at the Gnuplot + info file that comes with this package or that can be made from + the Gnuplot distribution. For that function to work, the file + gnuplot.info must be placed somewhere where info can find it, for + example /usr/info. A line like this in your .emacs allows you to + put gnuplot.info any place convenient: + (add-to-list 'Info-default-directory-list "/path/to/file") + + + +The "configure; make" sequence may not work on all systems, +particularly Win32 systems. The long-winded way of making the .elc +gpelcard.ps files is to edit each of the .el files with emacs and do +`M-x byte-compile-file'. Then "latex gpelcard.tex" and +"dvips gpelcard.dvi". + +You will need to follow the instructions contained in the file +Win9x/INSTALL.Win9x to get gnuplot working with Emacs on a Windows 95 +or 98 machine. + + + +Problems? Contact gnuplot-mode's author Bruce Ravel + diff --git a/util/gnuplot-mode.0.6.0/Makefile.dst b/util/gnuplot-mode.0.6.0/Makefile.dst new file mode 100644 index 000000000..c9d8c83b4 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/Makefile.dst @@ -0,0 +1,83 @@ + +## set this variable to "xemacs" if you use XEmacs +EMACS = emacs + +## You will probably not need to change anything below this line + +BYTE = $(EMACS) -batch -q -no-site-file -l dot.el -f batch-byte-compile + +.PHONY: all default clean + +default: + $(MAKE) info-look.elc gnuplot.elc gnuplot-gui.elc + +gnuplot.elc: gnuplot.el + $(BYTE) gnuplot.el + +gnuplot-gui.elc: gnuplot-gui.el + $(BYTE) gnuplot-gui.el + +## There are many possibilities for info-look: +## +## EMACS version use +## ----------------------------------------- +## Emacs or XEmacs 19 info-look.20.2.el +## Emacs 20.2 or less info-look.20.2.el +## Emacs 20.3 nothing +## XEmacs 20+ info-look.20.3.el +## +## want to use my modified version even if 20.2 is installed because a +## bug is fixed +## +## the first 6 lines attempt to ascertain the version number of +## $(EMACS), then multiply by 100 to convert it to an integer for the +## sake of the integer comparisons in the following lines. Is this a +## hassle, or what?! +## +MESSAGE = compiling info-look for $(EMACS) $$vnum +info-look.elc: info-look.20.2.el info-look.20.3.el + @if [ $(EMACS) = "emacs" ]; \ + then vnum=`emacs --version | grep 'Emacs [12]' | awk '{print $$3}'`; \ + else vnum=`xemacs --version | grep 'Emacs [12]' | awk '{print $$2}'`; \ + fi; \ + vn=`echo "$$vnum" | awk 'BEGIN{FS="."}{print $$1 "." $$2}'`; \ + version=`echo "$$vn" | awk '{print 100*$$1}'`; \ + if [ $(EMACS) = "emacs" -a $$version -ge 2030 ]; \ + then echo "no need to compile info-look for $(EMACS) $$vnum"; \ + else echo "$(MESSAGE)"; \ + fi; \ + if [ $(EMACS) = "emacs" -a $$version -lt 2030 ]; \ + then cp -v info-look.20.2.el info-look.el; \ + elif [ $(EMACS) = "xemacs" -a $$version -ge 2000 ]; \ + then cp -v info-look.20.3.el info-look.el; \ + elif [ $(EMACS) = "xemacs" -a $$version -lt 2000 ]; \ + then cp -v info-look.20.2.el info-look.el; \ + fi ;\ + if [ ! \( $(EMACS) = "emacs" -a $$version -ge 2030 \) ]; \ + then $(BYTE) info-look.el; fi; + +gpelcard.ps: gpelcard.dvi + dvips -o gpelcard.ps gpelcard.dvi + +gpelcard.dvi: gpelcard.tex + latex gpelcard.tex + +all: + $(MAKE) gnuplot.elc info-look.elc gnuplot-gui.elc gpelcard.ps + +clean: + rm -f *.elc info-look.el gpelcard.dvi gpelcard.log gpelcard.aux + + +##---------------------------------------------------------------------- +## old stuff: + +## from the `all' and `default' targets: +# gnuplot-toolbar.elc kw-compl.elc + +#kw-compl.elc: kw-compl.el +# $(BYTE) kw-compl.el + +## only make this for XEmacs +#gnuplot-toolbar.elc: gnuplot-toolbar.el +# if [ $(EMACS) = "xemacs" ]; then $(BYTE) gnuplot-toolbar.el; fi diff --git a/util/gnuplot-mode.0.6.0/Makefile.in b/util/gnuplot-mode.0.6.0/Makefile.in new file mode 100644 index 000000000..b7aa28e63 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/Makefile.in @@ -0,0 +1,151 @@ +# +# Makefile.in for gnuplot-mode +# +# Based on original Makefile +# by Lars Hecking 1999-02-25 +# +# Modified to install .el files along with .elc files +# BR May 17 2002 + +SHELL = /bin/sh + +prefix = @prefix@ +datadir = @datadir@ +lispdir = @lispdir@ +srcdir = @srcdir@ +subdir = lisp +top_builddir = . +top_srcdir = @top_srcdir@ + +@SET_MAKE@ +EMACS = @EMACS@ +MAKEINFO = @MAKEINFO@ +LATEX = latex +DVIPS = dvips +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +VPATH = @srcdir@ + +# Command to byte-compile +BYTEC = $(EMACS) -batch -q -no-site-file -l $(srcdir)/dot.el -f batch-byte-compile + +ELCS = info-look.elc gnuplot.elc gnuplot-gui.elc + +DIST_COMMON = ChangeLog Makefile.dst Makefile.in README aclocal.m4 configure \ +configure.in + +EXTRA_DIST = dot.el dotemacs gnuplot-gui.el gnuplot.el gnuplot.el.old \ +gpelcard.tex info-look.20.2.el info-look.20.3.el + +DISTFILES = $(DIST_COMMON) $(EXTRA_DIST) + +default: $(ELCS) + +gnuplot.elc: gnuplot.el + test "$(srcdir)" = "$(top_builddir)" || cp $(srcdir)/gnuplot.el . + $(BYTEC) gnuplot.el + +gnuplot-gui.elc: gnuplot.elc gnuplot-gui.el + test "$(srcdir)" = "$(top_builddir)" || cp $(srcdir)/gnuplot-gui.el . + $(BYTEC) gnuplot-gui.el + +## There are many possibilities for info-look: +## +## EMACS version use +## ----------------------------------------- +## Emacs or XEmacs 19 info-look.20.2.el +## Emacs 20.2 or less info-look.20.2.el +## Emacs 20.3 nothing +## XEmacs 20+ info-look.20.3.el +## +## want to use my modified version even if 20.2 is installed because a +## bug is fixed +## +## the first 6 lines attempt to ascertain the version number of +## $(EMACS), then multiply by 100 to convert it to an integer for the +## sake of the integer comparisons in the following lines. Is this a +## hassle, or what?! +## +MESSAGE = compiling info-look for $(EMACS) $$vnum +info-look.elc: info-look.20.2.el info-look.20.3.el + @if [ $(EMACS) = "emacs" ]; \ + then vnum=`emacs --version | grep 'Emacs [12]' | awk '{print $$3}'`; \ + else vnum=`xemacs --version | grep 'Emacs [12]' | awk '{print $$2}'`; \ + fi; \ + vn=`echo "$$vnum" | awk 'BEGIN{FS="."}{print $$1 "." $$2}'`; \ + version=`echo "$$vn" | awk '{print 100*$$1}'`; \ + if [ $(EMACS) = "emacs" -a $$version -ge 2030 ]; \ + then echo "no need to compile info-look for $(EMACS) $$vnum"; \ + else echo "$(MESSAGE)"; \ + fi; \ + if [ $(EMACS) = "emacs" -a $$version -lt 2030 ]; \ + then echo Using info-look.20.2.el; \ + cp $(srcdir)/info-look.20.2.el info-look.el; \ + elif [ $(EMACS) = "xemacs" -a $$version -ge 2000 ]; \ + then echo Using info-look.20.3.el; \ + cp $(srcdir)/info-look.20.3.el info-look.el; \ + elif [ $(EMACS) = "xemacs" -a $$version -lt 2000 ]; \ + then echo Using info-look.20.2.el; \ + cp $(srcdir)/info-look.20.2.el info-look.el; \ + fi ;\ + if [ ! \( $(EMACS) = "emacs" -a $$version -ge 2030 \) ]; \ + then $(BYTEC) info-look.el; fi; + +ps: gpelcard.ps + +gpelcard.ps: gpelcard.dvi + $(DVIPS) -o gpelcard.ps gpelcard.dvi + +gpelcard.dvi: gpelcard.tex + $(LATEX) $(srcdir)/gpelcard.tex + +all: gnuplot.elc info-look.elc gnuplot-gui.elc + +install: + mkinstalldirs $(lispdir) + @for p in *.el *.elc; do \ + echo " $(INSTALL_DATA) $$p $(lispdir)/$$p"; \ + $(INSTALL_DATA) $$p $(lispdir)/$$p; \ + done + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = lisp + +distdir: $(DISTFILES) + distdir=`cd $(distdir) && pwd` + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + +clean: + -rm -f *.elc info-look.el gpelcard.ps gpelcard.dvi gpelcard.log \ + gpelcard.aux + test "$(srcdir)" = "$(top_builddir)" || rm -f gnuplot.el gnuplot-gui.el + +distclean: clean + rm -f Makefile config.status config.log config.cache + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/util/gnuplot-mode.0.6.0/README b/util/gnuplot-mode.0.6.0/README new file mode 100644 index 000000000..429201041 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/README @@ -0,0 +1,127 @@ + +This directory contains files for running Gnuplot from within emacs. +This package was assembled by Bruce Ravel . +See http://feff.phys.washington.edu/~ravel/gnuplot/ for the latest. + + + Contents + ======== + +README this file +INSTALL thorough installation instructions +ChangeLog a log of changes by version number +gnuplot.el gnuplot mode for emacs +gnuplot-gui.el a GUI for setting command arguments interactively +info-look.20.2.el programmer's interface to info files, old version +info-look.20.3.el programmer's interface to info files, new version +dot.el a short lisp file used by the Makefile +gnuplot.info info version of gnuplot 3.6 help +gpelcard.tex quick reference card for gnuplot mode (latex) +gpelcard.ps +dotemacs example .emacs lines for enabling gnuplot mode +Makefile.in \ +Makefile.dst \ +aclocal.m4 \ files inherited from the gnuplot distribution +configure } for making gnuplot-mode +configure.in / +install-sh / +mkinstalldirs / +Win9x/INSTALL.Win9x Extra installation instructions for Windows 95/98 +Win9x/pgnuplot.c Program required to run gnuplot from Emacs + +Soon gnuplot-mode will be included with the gnuplot 3.7 distribution. +The installation instructions for the free-standing distribution have +been modified to be consistent with that. + + + Installation + ============ + +1. Unpack the gnuplot.tar.gz and cd to the gnuplot directory. + +2. Type "configure". If configure doesn't work for you, see note 7 + below. + +3. Run "make". If you use XEmacs, run "make EMACS=xemacs" (or change + the EMACS variable to "xemacs" in the Makefile, the run "make"). + +4. Move the lisp files to the system site_lisp directory if you are + installing as root. If you are installing as a normal user move + the .elc files to a place where emacs, i.e. your personal emacs + directory. + +5. Insert the contents of the `dotemacs' file into your .emacs file + or into the system's emacs start-up file to enable gnuplot mode. + +6. The function `gnuplot-info-lookup-symbol' looks at the Gnuplot + info file that comes with this package or that can be made from + the Gnuplot distribution. For that function to work, the file + gnuplot.info must be placed somewhere where info can find it, for + example /usr/info. A line like this in your .emacs allows you to + put gnuplot.info any place convenient: + (add-to-list 'Info-default-directory-list "/path/to/file") + + +Wouldn't it be //great// if Emacs had some kind of systematized package +installing facility? I think so, too! Oh well.... + + + + NOTES + ===== + +1. gnuplot-mode is designed for use with version 3.7 of gnuplot. It + should work very well with any of the 3.6 beta versions. Only some + of the specialized features will not work with version 3.5 -- the + GUI interface to setting command arguments is an example. + +2. To use gnuplot-mode with Emacs on Windows 95 or 98 see the + instructions in the directory Win9x. + +3. The installation materials used by gnuplot-mode come from the + gnuplot distribution. + +4. If "configure" doesn't work for you, the file "Makefile.dst" can be + used. In that case do, "make -f Makefile.dst" and carry on from + there. + +5. If you do not have the custom library installed, you will get + several harmless warnings when compiling gnuplot.el. Most of + gnuplot-mode will work even without the custom library installed. + +6. The file info-look.el provides the on-line help functionality. + Without it, things like on-line help and keyword completion will + not work. Using a tool that is a standard part of Emacs is a good + idea, but this one gets complicated. This file became part of + Emacs with version 20. It changed between 20.2 and 20.3. And it + does not come with XEmacs. What's more, the version from 20.2 has + a bug and the newer version does not work with Emacs 19. So, this + distribution comes with two versions of info-look.el, the version + from Emacs 20.2 patched to work correctly and the version from + Emacs 20.3. Here's what happens when you run make: + + a. If you use Emacs 19 or XEmacs 19, then the Makefile will + compile the 20.2 version. + b. If you use Emacs 20.2 or lower, the Makefile will compile the + 20.2 version. + c. If you use XEmacs 20 or higher, the Makefile will compile the + 20.3 version. + d. If you use Emacs 20.3 or higher, the Makefile won't compile any + version. + +7. The gnuplot-mode distribution comes with the version of the gnuplot + info file that gets made by gnuplot 3.7. Use it rather than the + old one. If you really must use the older info file, see the + document string for the variable `gnuplot-info-hook'. If you + already have the info file installed on your computer, you will not + need the one that comes with gnuplot-mode. + +8. The interactive graphical graphical interface to setting command + arguments contained in gnuplot-gui.el is experimental. It is + incomplete and may make mistakes. Hopefully, you will find it + useful. It *requires* that you are using a version of emacs with + the widget library installed or that you have installed it + yourself. Version numbers in the 20's of Emacs and XEmacs ship + with the widget library. For version numbers in the 19's, it can + be obtained at http://www.dina.kvl.dk/~abraham/custom/ + diff --git a/util/gnuplot-mode.0.6.0/Win9x/INSTALL.Win9x b/util/gnuplot-mode.0.6.0/Win9x/INSTALL.Win9x new file mode 100644 index 000000000..63a7257b5 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/Win9x/INSTALL.Win9x @@ -0,0 +1,138 @@ + +Time-stamp: <1999-05-15 11:29:23 bruce> + + +This file describes how to install gnuplot-mode on a Windows 95 or 98 +system so that you may use Gnuplot from within Emacs. + +Gnuplot-mode was written by Bruce Ravel . +Contact him with any questions or comments regarding gnuplot-mode. +For questions or comments regarding Emacs or Gnuplot, contact the +authors of those programs. + + + ------O------ + + +Gnuplot-mode and Gnuplot can be used with Emacs on a Windows 95 or 98 +system, although a small amount of additional effort will be required +to get everything working. + +The best solution is to install a sufficiently recent version of +Gnuplot which includes the ability to run as a child process (as of +May 15 1999 there is no such version). A more complete description of +this is attached to the end of this document. Recent versions of +Gnuplot can be found at ftp://ftp.gnuplot.vt.edu/pub/gnuplot/ + + If you install a very recent version of gnuplot which includes the + ability to run as a child process, then the installation + instructions for gnuplot-mode are much simpler. After following + the normal installation instructions, just add the following line + to your Emacs initialization file: + + (add-hook 'gnuplot-load-hook + '(lambda () + (setq gnuplot-program + "c:/path/to/pgnuplot/pgnuplot.exe"))) + + Replace "c:/path/to/pgnuplot/pgnuplot.exe" with the full path to + pgnuplot on your computer. + + + +You can make gnuplot work even with an older version of Gnuplot for +Windows by following these steps: + + 1. Edit the file pgnuplot.c so that the variable FULLPATH at line 5 + is pointing at the actual location of the Gnuplot executable on + your computer. + + 2. Using any C compiler, compile pgnuplot.c to pgnuplot.exe + + 3. Byte-compile gnuplot.el and gnuplot-gui.el as described in the + INSTALL file in the main gnuplot-mode directory. Make sure the + .elc files a placed in a location where Emacs knows to look, + i.e. in its load-path. You can add new directories to the + load-path by placing the following line near the top of your + Emacs initialization file (.emacs or _emacs): + + (setq load-path (append (list "c:/path/to/lisp/files") + load-path)) + + 4. Add these lines to your Emacs initialization file (.emacs or + _emacs): + + (autoload 'gnuplot-mode "gnuplot" + "gnuplot major mode" t) + (autoload 'gnuplot-make-buffer "gnuplot" + "open a buffer in gnuplot-mode" t) + (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)) + auto-mode-alist)) + (global-set-key [(f9)] 'gnuplot-make-buffer) + (add-hook 'gnuplot-load-hook + '(lambda () + (setq gnuplot-program + "c:/path/to/pgnuplot/pgnuplot.exe"))) + + The last line is very important. It tells Emacs to launch + pgnuplot.exe as its subprocess rather than Gnuplot itself. The + first four lines are explained in the comments near the + beginning of gnuplot.el. + + + Replace "c:/path/to/pgnuplot/pgnuplot.exe" with the full path to + pgnuplot on your computer. + + + + + ------O------ + +Resources: + + Emacs for Windows NT/9x: + http://www.cs.washington.edu/homes/voelker/ntemacs.html + + The Gnuplot distribution site (includes Windows executables): + ftp://ftp.gnuplot.vt.edu/pub/gnuplot/ + + The gnuplot-mode homepage: + http://feff.phys.washington.edu/~ravel/gnuplot/ + + Cygwin, Unix tools for Windows NT/9x: + http://sourceware.cygnus.com/cygwin/ + + + ------O------ + + +What follows are the comments of the author of pgnuplot.c, +Hans-Bernhard Broeker, describing the function and need for this +program. + + Thu, 11 Feb 1999 + + Here's the tiny program I came up with to fix the single most + annoying problem specific to the Windows version of gnuplot: lack + of support for piping commands into it via STDIN. + + For those who don't know the context: Windows GUI programs like + wgnuplot do not have any access to the usual I/O channels stdin and + stdout. So the usual method to allow gnuplot to run as a child + application, being controlled via a command stream by another one + (i.e. the classical 'popen("gnuplot", "w");' method), can not work + on Windoze. + + It's implemented as a separate Win32 console application (that's a + different kind of program, which cannot display GUI windows, but + does have STDIN/STDOUT channels). This program will get hold of a + running wgnuplot (or start one itself, passing on any command line + arguments), and deliver each character it sees on its own standard + input stream as a keypress message to the command window of + wgnuplot. + + Effectively, this makes 'pgnuplot.exe' an almost 100% complete + replacement of wgnuplot.exe, as far as starting the program is + concerned, but adding the stdin capabilities. A different way of + seeing it is as a prototype of a general application that wants to + run wgnuplot as a child process. diff --git a/util/gnuplot-mode.0.6.0/Win9x/pgnuplot.c b/util/gnuplot-mode.0.6.0/Win9x/pgnuplot.c new file mode 100644 index 000000000..6274200e1 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/Win9x/pgnuplot.c @@ -0,0 +1,101 @@ +#include + +/* You MUST change the value of FULLPATH to the actual location of the + * gnuplot executable on your computer. */ +#define FULLPATH "e:/prg/gp36/gp37hbb/wgnuplot.exe" +#define WINDOWNAME "gnuplot" +#define PARENTCLASS "wgnuplot_parent" +#define TEXTCLASS "wgnuplot_text" +#define GRAPHWINDOW "gnuplot graph" +#define GRAPHCLASS "wgnuplot_graph" + +int main (int argc, char *argv[]) +{ + /* Customize this path if needed */ + char *d, buf[80]; + HWND hwnd_parent; + HWND hwnd_text; + BOOL startedWgnuplotMyself = FALSE; + + /* First, try to find if there is an instance of gnuplot + * running, already. If so, use that. */ + hwnd_parent = FindWindow(PARENTCLASS, WINDOWNAME); + + if ( ! hwnd_parent) { + /* None there, so start one: load gnuplot (minimized in order to + * show only the graphic window). Pass all command line arguments + * on to wgnuplot, by concatting the wgnuplot full path name and + * the given arguments, building up a new, usable command line: + */ + char *cmdline = strdup (FULLPATH); + + while (*(++argv)) { + /* Puzzle together a working from the given arguments. To account + * for possible spaces in arguments, we'll have to put double quotes + * around each of them: + */ + /* FIXME: doesn't check for out of memory */ + cmdline = realloc(cmdline, strlen(cmdline)+3+strlen(argv[0])); + strcat(cmdline, " \""); + strcat(cmdline, *argv); + strcat(cmdline, "\""); + } + + if (WinExec(cmdline, SW_SHOWMINNOACTIVE) < 32) { + printf("Can't load gnuplot\n"); + exit(EXIT_FAILURE); + } + + startedWgnuplotMyself = TRUE; + + /* wait for the gnuplot window */ + /* FIXME: is this necessary? As documented, WinExec shouldn't return + * until wgnuplot first calls GetMessage(). By then, the window should + * be there, shouldn't it? + */ + Sleep(1000); + hwnd_parent = FindWindow(PARENTCLASS, WINDOWNAME); + } + + if ( ! hwnd_parent) { + /* Still no gnuplot window? Problem! */ + printf("Can't find the gnuplot window"); + exit(EXIT_FAILURE); + } + + /* find the child text window */ + hwnd_text = FindWindowEx(hwnd_parent, NULL, "wgnuplot_text", NULL ); + + if (isatty(fileno(stdin))) { + /* Do not try to read from stdin if it hasn't been redirected + * (i.e., it should read from a pipe or a file) */ + exit(EXIT_SUCCESS); + } + + /* wait for commands on stdin, and pass them on to the wgnuplot text + * window */ + do { + d = fgets(buf, sizeof(buf), stdin); + + if (NULL == d) { + if (startedWgnuplotMyself) { + /* close gnuplot cleanly: */ + strcpy (buf, "exit"); + d = buf; + startedWgnuplotMyself = FALSE; + } else { + break; + } + } + + while(*d) { + PostMessage(hwnd_text, WM_CHAR, *d, 1L); + d++; + } + } while (NULL != d); + + /* Just in case stdin didn't have a terminating newline, add one: */ + PostMessage(hwnd_text, WM_CHAR, '\n', 1L); + + return EXIT_SUCCESS; +} diff --git a/util/gnuplot-mode.0.6.0/aclocal.m4 b/util/gnuplot-mode.0.6.0/aclocal.m4 new file mode 100644 index 000000000..e01e92541 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/aclocal.m4 @@ -0,0 +1,46 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4 + +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + + +# serial 1 + +AC_DEFUN(AM_PATH_LISPDIR, + [# If set to t, that means we are running in a shell under Emacs. + # If you have an Emacs named "t", then use the full path. + test "$EMACS" = t && EMACS= + AC_PATH_PROGS(EMACS, emacs xemacs, no) + if test $EMACS != "no"; then + AC_MSG_CHECKING([where .elc files should go]) + dnl Set default value + lispdir="\$(datadir)/emacs/site-lisp" + emacs_flavor=`echo "$EMACS" | sed -e 's,^.*/,,'` + if test "x$prefix" = "xNONE"; then + if test -d $ac_default_prefix/share/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/share/$emacs_flavor/site-lisp" + else + if test -d $ac_default_prefix/lib/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/lib/$emacs_flavor/site-lisp" + fi + fi + else + if test -d $prefix/share/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/share/$emacs_flavor/site-lisp" + else + if test -d $prefix/lib/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/lib/$emacs_flavor/site-lisp" + fi + fi + fi + AC_MSG_RESULT($lispdir) + fi + AC_SUBST(lispdir)]) + diff --git a/util/gnuplot-mode.0.6.0/auto/gpelcard.el b/util/gnuplot-mode.0.6.0/auto/gpelcard.el new file mode 100644 index 000000000..de0e36226 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/auto/gpelcard.el @@ -0,0 +1,21 @@ +(TeX-add-style-hook "gpelcard" + (function + (lambda () + (LaTeX-add-environments + "Boxedminipage" + "SqBoxedminipage") + (TeX-add-symbols + "version" + "revised" + "file" + "key" + "variable" + "command" + "Star") + (TeX-run-style-hooks + "fancybox" + "latex2e" + "art10" + "article" + "twocolumn")))) + diff --git a/util/gnuplot-mode.0.6.0/configure b/util/gnuplot-mode.0.6.0/configure new file mode 100755 index 000000000..53076cf61 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/configure @@ -0,0 +1,1002 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=dot.el + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:526: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:583: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# If set to t, that means we are running in a shell under Emacs. + # If you have an Emacs named "t", then use the full path. + test "$EMACS" = t && EMACS= + for ac_prog in emacs xemacs +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:643: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_EMACS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$EMACS" in + /*) + ac_cv_path_EMACS="$EMACS" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_EMACS="$EMACS" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_EMACS="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +EMACS="$ac_cv_path_EMACS" +if test -n "$EMACS"; then + echo "$ac_t""$EMACS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$EMACS" && break +done +test -n "$EMACS" || EMACS="no" + + if test $EMACS != "no"; then + echo $ac_n "checking where .elc files should go""... $ac_c" 1>&6 +echo "configure:681: checking where .elc files should go" >&5 + lispdir="\$(datadir)/emacs/site-lisp" + emacs_flavor=`echo "$EMACS" | sed -e 's,^.*/,,'` + if test "x$prefix" = "xNONE"; then + if test -d $ac_default_prefix/share/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/share/$emacs_flavor/site-lisp" + else + if test -d $ac_default_prefix/lib/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/lib/$emacs_flavor/site-lisp" + fi + fi + else + if test -d $prefix/share/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/share/$emacs_flavor/site-lisp" + else + if test -d $prefix/lib/$emacs_flavor/site-lisp; then + lispdir="\$(prefix)/lib/$emacs_flavor/site-lisp" + fi + fi + fi + echo "$ac_t""$lispdir" 1>&6 + fi + +EMACS=`basename $EMACS` +# Extract the first word of "makeinfo", so it can be a program name with args. +set dummy makeinfo; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:708: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MAKEINFO'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MAKEINFO" in + /*) + ac_cv_path_MAKEINFO="$MAKEINFO" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_MAKEINFO="$MAKEINFO" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_MAKEINFO="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MAKEINFO" && ac_cv_path_MAKEINFO="no" + ;; +esac +fi +MAKEINFO="$ac_cv_path_MAKEINFO" +if test -n "$MAKEINFO"; then + echo "$ac_t""$MAKEINFO" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@SET_MAKE@%$SET_MAKE%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@EMACS@%$EMACS%g +s%@lispdir@%$lispdir%g +s%@MAKEINFO@%$MAKEINFO%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 diff --git a/util/gnuplot-mode.0.6.0/configure.in b/util/gnuplot-mode.0.6.0/configure.in new file mode 100644 index 000000000..20d465d96 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/configure.in @@ -0,0 +1,7 @@ +AC_INIT(dot.el) +AC_SET_MAKE +AC_PROG_INSTALL +AM_PATH_LISPDIR +EMACS=`basename $EMACS` +AC_PATH_PROG(MAKEINFO, makeinfo, no) +AC_OUTPUT(Makefile) diff --git a/util/gnuplot-mode.0.6.0/dot.el b/util/gnuplot-mode.0.6.0/dot.el new file mode 100644 index 000000000..3ecc1c9f6 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/dot.el @@ -0,0 +1,7 @@ +;; These are some lines to help compilation of gnuplot-mode proceed +;; with fewer warning messages +(setq load-path (append (list ".") load-path) + byte-compile-verbose nil + byte-compile-warnings nil) +(require 'font-lock) +(defun hilit-repaint-command (foo)) diff --git a/util/gnuplot-mode.0.6.0/dotemacs b/util/gnuplot-mode.0.6.0/dotemacs new file mode 100644 index 000000000..6107f5544 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/dotemacs @@ -0,0 +1,21 @@ +;;-------------------------------------------------------------------- +;; Lines enabling gnuplot-mode + +;; move the files gnuplot.el to someplace in your lisp load-path or +;; use a line like +;; (setq load-path (append (list "/path/to/gnuplot") load-path)) + +;; these lines enable the use of gnuplot mode + (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t) + (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot mode" t) + +;; this line automatically causes all files with the .gp extension to +;; be loaded into gnuplot mode + (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)) auto-mode-alist)) + +;; This line binds the function-9 key so that it opens a buffer into +;; gnuplot mode + (global-set-key [(f9)] 'gnuplot-make-buffer) + +;; end of line for gnuplot-mode +;;-------------------------------------------------------------------- diff --git a/util/gnuplot-mode.0.6.0/gnuplot-gui.el b/util/gnuplot-mode.0.6.0/gnuplot-gui.el new file mode 100644 index 000000000..85520505d --- /dev/null +++ b/util/gnuplot-mode.0.6.0/gnuplot-gui.el @@ -0,0 +1,1750 @@ +;;;; gnuplot-gui.el -- GUI interface to setting options in gnuplot-mode + +;; Copyright (C) 1998-2000 Bruce Ravel + +;; Author: Bruce Ravel +;; Maintainer: Bruce Ravel +;; Created: 19 December 1998 +;; Updated: 16 November 2000 +;; Version: (same as gnuplot.el) +;; Keywords: gnuplot, plotting, interactive, GUI + +;; This file is not part of GNU Emacs. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This lisp script is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +;; +;; Permission is granted to distribute copies of this lisp script +;; provided the copyright notice and this permission are preserved in +;; all copies. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, you can either send email to this +;; program's maintainer or write to: The Free Software Foundation, +;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; send bug reports to the authors (ravel@phys.washington.edu) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This file provides a graphical user interface to setting arguments +;; to gnuplot commands. Positioning point near a command and invoking +;; `gnuplot-gui-set-options-and-insert' (C-c C-c or shift-mouse-2) +;; will pop open a frame with widgets for setting the various +;; arguments appropriate the the item that was near point. The goal +;; is to provide point-and-click functionality to gnuplot-mode. +;; +;; gnuplot-gui is designed for gnuplot 3.7, but since much of 3.7 is +;; backward compatible to 3.5, it will work well for that version +;; also. +;; +;; gnuplot-gui.el was developed using Emacs 19.34 and is known to work +;; on Emacs 20.x and XEmacs 20.x. I do not know what is the earliest +;; version for which it will work, but I make no guarantees for +;; versions before 19.34. Note that this makes heavy use of the +;; widget package, so this will not work on Emacs 19.34 unless you +;; install the widget package separately. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; To do: +;; +;; Widgets I need: +;; -- 'position: two or three comma separated numbers used to denote a +;; position or a tic start/end/increment (see arrow, +;; need a prefix) +;; -- 'modifier: colon separated fields used for datafile modifiers +;; +;; command types which are currently unsupported or contain mistakes +;; -- unsupported: cntrparam +;; -- plot, splot, fit: rather lame +;; -- label: position information missing +;; -- label: font string handled in overly simple manner +;; -- hidden3d: not really suited to 'list, but all options are exclusive... +;; -- pointstyle argument to "set label" +;; +;; overall: +;; -- continuation lines (ugh!) +;; -- multiple frames end up displaying same window after setting options +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Code: + +(require 'gnuplot) +(eval-and-compile + (condition-case () + (progn + (require 'widget) + (require 'wid-edit)) + (error nil))) +(require 'cl) +(eval-when-compile ; suppress some compiler warnings + (defvar gnuplot-xemacs-p nil) + (defvar gnuplot-quote-character nil) + (defvar gnuplot-info-display nil) + (defvar gnuplot-mode-map nil)) + +;; (eval-when-compile +;; (require 'wid-edit)) + +(eval-and-compile ; I need this! + (if (fboundp 'split-string) + () + (defun split-string (string &optional pattern) + "Return a list of substrings of STRING which are separated by PATTERN. +If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." + (or pattern + (setq pattern "[ \f\t\n\r\v]+")) + ;; The FSF version of this function takes care not to cons in case + ;; of infloop. Maybe we should synch? + (let (parts (start 0)) + (while (string-match pattern string start) + (setq parts (cons (substring string start (match-beginning 0)) parts) + start (match-end 0))) + (nreverse (cons (substring string start) parts)))) )) + + + +;;; customizable variables + +(defgroup gnuplot-gui nil + "Graphical interface to setting arguments in gnuplot scrips." + :prefix "gnuplot-gui-" + :group 'gnuplot) + +(defcustom gnuplot-gui-popup-flag nil + "*Non-nil means to open arguments pop-ups automatically. +This would be done after menu insertion of Gnuplot commands." + :group 'gnuplot-gui + :type 'boolean) + +(defvar gnuplot-gui-frame nil + "Frame used to hold the buffer for setting options.") +(defcustom gnuplot-gui-frame-plist + '(height 18 width 65 border-width 0 + user-position t top 150 left 150 + internal-border-width 0 unsplittable t + default-toolbar-visible-p nil has-modeline-p nil + menubar-visible-p nil) + "Frame plist for the input run-time display frame in XEmacs." + :type '(repeat (group :inline t + (symbol :tag "Property") + (sexp :tag "Value"))) + :group 'gnuplot-gui) +(defcustom gnuplot-gui-frame-parameters + '((height . 18) + (width . 65) + (user-position . t) + (top . 150) + (left . 150) + (border-width . 0) + (menu-bar-lines . 0) + (unsplittable . t)) + "Frame parameters for the input run-time display frame in Emacs." + :group 'gnuplot-gui + :type '(repeat (sexp :tag "Parameter:"))) + +(defcustom gnuplot-gui-fontname-list + '(" " "\"Helvetica\"" "\"Times-Roman\"") + "List of known font names. +These *must* be quoted, like so \"\\\"Helvetica\\\"\". This allows +for fonts with names like \"\\\"Arial Bold Italic\\\"\" to be treated +as single entries in the menu-buttons. And it is really important that +the first entry in the list be a blank string." + :group 'gnuplot-gui + :type '(repeat (string :tag "Font name:"))) + +;; some global variables +(defvar gnuplot-current-frame nil) +(defvar gnuplot-current-buffer nil) +(defvar gnuplot-current-buffer-point nil) +(defvar gnuplot-gui-alist nil) +(defvar gnuplot-gui-current-string nil) + + +;;; various tools for handling data structures and text in the buffer + +;; tools for accessing the elements of the lists in `gnuplot-gui-all-types' +(defsubst gnuplot-gui-type-tag (obj) (elt obj 0)) +(defsubst gnuplot-gui-type-symbol (obj) (elt obj 1)) +(defsubst gnuplot-gui-type-default (obj) (elt obj 2)) +(defsubst gnuplot-gui-type-prefix (obj) (elt obj 3)) ; also 'range seperator +(defsubst gnuplot-gui-type-fourth (obj) (elt obj 4)) +(defsubst gnuplot-gui-type-list (obj) (cddr obj)) + +(defun gnuplot-this-word () + "Return the word under point." + (let ((begin (save-excursion (beginning-of-line) (point-marker))) + (end (save-excursion (end-of-line) (point-marker)))) + (save-excursion + (or (looking-at "\\<") (= (current-column) 0) (forward-word -1)) + (if (> (point) begin) (setq begin (point-marker))) + (forward-word 1) + (if (> (point) end) (goto-char end)) + (buffer-substring-no-properties begin (point))))) + + + +;;; data structures containing regarding options in Gnuplot 3.7 + +;; various constants used for options that take the same sorts of arguments +(defconst gnuplot-gui-mtics-list + '(("FREQUENCY" 'number " ") + ("DEFAULT" 'list " " "default"))) +(defconst gnuplot-gui-data-list + '(("DATA TYPE" 'list " " "time"))) +(defconst gnuplot-gui-label-list + '(("LABEL" 'string " ") + ("POSITION" 'position " " "" 2) + ("FONTNAME" 'list " " gnuplot-gui-fontname-list) + ("FONTSIZE" 'fontsize " "))) +(defconst gnuplot-gui-range-list + '(("RANGE" 'range (" " . " ") ":") + ("REVERSE" 'list " " "reverse" "noreverse") + ("WRITEBACK" 'list " " "writeback" "nowriteback"))) +(defconst gnuplot-gui-tics-list + '(("WHERE" 'list " " "axis" "border") + ("MIRROR" 'list " " "mirror" "nomirror") + ("ROTATE" 'list " " "rotate" "norotate") + ("SERIES" 'position " " "" 3) + ("LABEL ARRAY" 'labels () ))) +(defconst gnuplot-gui-zeroaxis-list + '(("LINETYPE" 'number " "))) + +(defvar gnuplot-gui-terminal-types nil + "Associated list of terminal descriptions. +See the doc-string for `gnuplot-gui-all-types'.") +(setq gnuplot-gui-terminal-types + (list (cons "aifm" + '(("COLOR" 'list " " "monochrome" "gray" "color") + ("FONTNAME" 'list " " gnuplot-gui-fontname-list) + ("FONTSIZE" 'fontsize " "))) + (cons "cgm" + '(("MODE" 'list " " "landscape" "portrait" "default") + ("COLOR" 'list " " "color" "monochrome") + ("ROTATION" 'list " " "rotate" "norotate") + ("WIDTH" 'number " " "width") + ("LINEWIDTH" 'number " " "linewidth") + ("FONTNAME" 'list " " "\"Arial\"" "\"Arial Italic\"" + "\"Arial Bold\"" "\"Arial Bold Italic\"" + "\"Times Roman\"" "\"Times Roman Italic\"" + "\"Times Roman Bold\"" "\"Times Roman Bold Italic\"" + "\"Helvetica\"" "\"Roman\"") + ("FONTSIZE" 'fontsize " "))) + (cons "corel" + '(("COLOR" 'list " " "default" "color" "monochrome") + ("FONTNAME" 'list " " "\"SwitzerlandLight\"" + "\"Helvetica\"" "\"Times-Roman\"") + ("FONTSIZE " 'number " ") + ("X-SIZE " 'number " ") + ("Y-SIZE " 'number " ") + ("LINEWIDTH" 'number " "))) + (cons "dumb" + '(("LINEFEED" 'list " " "feed" "nofeed") + ("X-SIZE" 'number " ") + ("Y-SIZE" 'number " "))) + (cons "emf" + '(("COLOR" 'list " " "color" "monochrome") + ("LINE" 'list " " "solid" "dashed") + ("FONTNAME" 'string " ") + ("FONTSIZE" 'number " "))) + (cons "emtex" + '(("FONTNAME" 'list " " "courier" "roman") + ("FONTSIZE" 'fontsize " "))) + (cons "fig" + '(("COLOR" 'list " " "color" "monochrome") + ("FRAMESIZE" 'list " " "small" "big") + ("POINTSMAX" 'number " " "pointsmax") + ("ORIENTATION" 'list " " "landscape" "portrait") + ("UNITS" 'list " " "metric" "inches") + ("FONT SIZE" 'number " " "fontsize") + ("SIZE" 'pair (" " . " ") "size") + ("LINE THICKNESS" 'number " " "thickness") + ("LAYER DEPTH" 'number " " "depth"))) + (cons "hp500c" + '(("RESOLUTION" 'list " " "75" "100" "150" "300") + ("COMPRESSION" 'list " " "rle" "tiff"))) + (cons "hpgl" + '(("PENS" 'number " ") + ("EJECT" 'list " " "eject"))) + (cons "hpdj" + '(("RESOLUTION" 'list " " "75" "100" "150" "300"))) + (cons "hpljii" + '(("RESOLUTION" 'list " " "75" "100" "150" "300"))) + (cons "hppj" + '(("FONT" 'list " " "FNT9X17" "FNT5X9" "FNT13X25"))) + (cons "imagen" + '(("FONT SIZE" 'number " ") + ("LAYOUT" 'list " " "portrait" "landscape") + ("NUMBER OF GRAPHS" 'range (" " . " ") ","))) + (cons "gpic" + '(("X ORIGIN" 'number " ") + ("Y ORIGIN" 'number " " ","))) + (cons "latex" + '(("FONTNAME" 'list " " "courier" "roman") + ("FONTSIZE" 'fontsize " "))) + (cons "mif" + '(("COLOUR" 'list " " "colour" "monochrome") + ("LINETYPE" 'list " " "polyline" "vectors"))) + (cons "nec-cp6" + '(("MODE" 'list " " "monochrome" "colour" "draft"))) + (cons "pbm" + '(("SIZE" 'list " " "small" "medium" "large") + ("COLOR" 'list " " "monochrome" "gray" "color"))) + (cons "pcl5L" + '(("MODE" 'list " " "landscape" "portrait") + ("FONTNAME" 'list " " "stick" "univers" "cg_times") + ("FONTSIZE" 'fontsize " "))) + (cons "png" + '(("SIZE" 'list " " "small" "medium" "large") + ("COLOR" 'list " " "monochrome" "gray" "color"))) + (cons "postscript" + '(("MODE" 'list " " "landscape" "portrait" "eps" "default") + ("ENHANCED" 'list " " "enhanced" "noenhanced") + ("COLOR" 'list " " "color" "monochrome") + ("SOLID" 'list " " "solid" "dashed") + ("DUPLEXING" 'list " " "defaultplex" "simplex" "duplex") + ("FONTNAME" 'list " " gnuplot-gui-fontname-list) + ("FONTSIZE" 'fontsize " "))) + (cons "pslatex" + '(("COLOR" 'list " " "monochrome" "color") + ("DASHED" 'list " " "dashed") + ("ROTATION" 'list " " "rotate" "norotate") + ("AUXFILE" 'list " " "auxfile"))) + (cons "pstex" + '(("COLOR" 'list " " "monochrome" "color") + ("DASHED" 'list " " "dashed") + ("ROTATION" 'list " " "rotate" "norotate") + ("AUXFILE" 'list " " "auxfile"))) + (cons "pstricks" + '(("HACK TEXT" 'list " " "hacktext" "nohacktext") + ("PLOT SCALING" 'list " " "nounit" "unit"))) + (cons "regis" + '(("COLOR DEPTH" 'list "4" "16"))) + (cons "tgif" + '(("LAYOUT" 'list " " "portrait" "landscape") + ("NUMBER OF GRAPHS" 'range (" " . " ") ",") + ("LINE TYPE" 'list " " "solid" "dashed") + ("FONTNAME" 'list " " gnuplot-gui-fontname-list) + ("FONTSIZE" 'fontsize " "))) + (cons "tpic" + '(("POINTSIZE" 'number " ") + ("LINEWIDTH" 'number " ") + ("INTERVAL " 'number " "))) + (cons "vgagl" ; for pm3d patch (also persist, raise in x11) + '(("BACKGROUND" 'position " " "background" 3) + ("INTERPOLATION" 'list " " "uniform" "interpolate") + ("DUMP" 'file " ") + ("MODE" 'string " " ""))) + (cons "x11" + '(("RESET" 'list " " "reset") + ("TERMINAL NUMBER" 'number " ") + ("PERSIST" 'list " " "persist" "nopersist") + ("RAISE" 'list " " "raise" "noraise"))) )) + +(defvar gnuplot-gui-terminal-list nil) +(setq gnuplot-gui-terminal-list + (append (list " ") (mapcar 'car gnuplot-gui-terminal-types))) + +(defvar gnuplot-gui-set-types nil + "Associated list of set option descriptions. +See the doc-string for `gnuplot-gui-all-types'.") +(setq gnuplot-gui-set-types + (list (cons "angles" + '(("UNITS" 'list " " "degrees" "radians"))) + (cons "arrow" + '(("TAG" 'tag " ") + ("FROM" 'position " " "from" 3) + ("TO" 'position " " "to" 3) + ("HEAD" 'list " " "head" "nohead") + ("LINESTYLE" 'number " " "ls") + ("LINETYPE " 'number " " "lt") + ("LINEWIDTH" 'number " " "lw"))) + (cons "noarrow" + '(("TAG" 'tag " "))) + (cons "autoscale" + '(("AXIS" 'list " " "x" "y" "z" "x2" "y2" "xy" + "xmin" "ymin" "zmin" "x2min" "y2min" "xymin" + "xmax" "ymax" "zmax" "x2max" "y2max" "xymax"))) + (cons "noautoscale" + '(("AXIS" 'list " " "x" "y" "z" "x2" "y2" "xy" + "xmin" "ymin" "zmin" "x2min" "y2min" "xymin" + "xmax" "ymax" "zmax" "x2max" "y2max" "xymax"))) + (cons "bar" + '(("SIZE" 'list " " "small" "large"))) + (cons "border" + '(("BORDER CODE" 'number " ") + ("LINE STYLE" 'list " " "lines" + "dots" "points" "linespoints") + ("LINESTYLE" 'number " " "ls") + ("LINETYPE" 'number " " "lt") + ("LINEWIDTH" 'number " " "lw") + )) + (cons "boxwidth" + '(("WIDTH" 'number " "))) + (cons "clabel" + '(("FORMAT" 'format " "))) + (cons "clip" + '(("CLIP TYPE" 'list " " "points" "one" "two"))) + (cons "noclip" + '(("CLIP TYPE" 'list " " "points" "one" "two"))) + ;;(cons "cntrparam" + ;; '(("INTERPOLATION" 'list " " "linear" "cubicspline" "bspline") + ;; ("POINTS" 'number " " "points") + ;; ("ORDER" 'number " " "order"))) + (cons "contour" + '(("WHERE" 'list " " "base" "surface" "both"))) + (cons "dgrid3d" + '(("ROW,COLUMN,NORM" 'position " " "" 3))) + (cons "encoding" + '(("ENCODING" 'list " " "default" "iso_8859_1" + "cp850" "cp437"))) + (cons "format" + '(("AXIS" 'list " " "x" "y" "z" "xy" "x2" "y2") + ("FORMAT" 'format " "))) + (cons "dummy" + '(("VAR 1" 'string " " "") + ("VAR 2" 'string " " ","))) + (cons "grid" + '(("XTICS" 'list " " "xtics" "mxtics" "noxtics" "nomxtics") + ("YTICS" 'list " " "ytics" "mytics" "noytics" "nomytics") + ("ZTICS" 'list " " "ztics" "mztics" "noztics" "nomztics") + ("X2TICS" 'list " " "x2tics" "mx2tics" "nox2tics" "nomx2tics") + ("Y2TICS" 'list " " "y2tics" "my2tics" "noy2tics" "nomy2tics") + ("POLAR" 'number " " "polar") + ("MAJOR LINETYPE" 'number " ") + ("MINOR LINETYPE" 'number " "))) + (cons "hidden3d" + '(("ALGORITHM" 'list " " "defaults" + "offset" + "nooffset" + ;;"trianglepattern # bitpattern between 0 and 7" + "trianglepattern 0" "trianglepattern 1" + "trianglepattern 2" "trianglepattern 3" + "trianglepattern 4" "trianglepattern 5" + "trianglepattern 6" "trianglepattern 7" + ;;"undefined # level between 0 and 3" + "undefined 0" "undefined 1" "undefined 2" "undefined 3" + "noundefined" "altdiagonal" "noaltdiagonal" + "bentover" "nobentover"))) + (cons "historysize" + '(("SIZE" 'number " "))) + (cons "isosamples" + '(("ISO_U LINES" 'number " ") + ("ISO_V LINES" 'number " " ","))) + (cons "key" + '(("LOCATION" 'list " " "left" "right" "top" "bottom" + "outside" "below") + ("POSITION" 'position " " "" 3) + ("JUSTIFICATION" 'list " " "Left" "Right") + ("REVERSE" 'list " " "reverse" "noreverse") + ("SAMPLE LENGTH" 'number " " "samplen") + ("SPACING" 'number " " "spacing") + ("WIDTH" 'number " " "width") + ("TITLE" 'string " " "title ") + ("BOX LINETYPE" 'number " " "box") ;; linetype data + ("NOBOX" 'list " " "nobox"))) + (cons "label" + '(("TAG" 'tag " ") + ("LABEL TEXT" 'string " ") + ("POSITION" 'position " " "at" 3) + ;; first, second, graph, screen + ("JUSTIFICATION" 'list " " "left" "right" "center") + ("ROTATE" 'list " " "rotate" "norotate") + ("FONT" 'string " " "font"))) ;; font "name,size" + (cons "nolabel" + '(("TAG" 'tag " "))) + (cons "linestyle" + '(("TAG " 'tag " ") + ("LINE STYLE" 'list " " "boxerrorbars" "boxes" + "boxxyerrorbars" "candlesticks" "dots" + "financebars" "fsteps" "histeps" "impulses" + "lines" "linespoints" "points" "steps" "vector" + "xerrorbars" "xyerrorbars" "yerrorbars") + ("LINETYPE " 'number " " "lt") + ("LINEWIDTH" 'number " " "lw") + ("POINTTYPE" 'number " " "pt") + ("POINTSIZE" 'number " " "ps"))) + (cons "locale" + '(("LOCALE" 'string " "))) + (cons "logscale" + '(("AXIS" 'list " " "x" "y" "z" "xy" "xz" "yz" "xyz" + "x2" "y2") + ("BASE" 'number " "))) + (cons "nologscale" + '(("AXIS" 'list " " "x" "y" "z" "xy" "xz" "yz" "xyz" + "x2" "y2"))) + (cons "mapping" + '(("COORDINATE SYSTEM" 'list " " "cartesian" "spherical" + "cylindrical"))) + ; _margin + (cons "bmargin" + '(("BOTTOM MARGIN" 'number " "))) + (cons "lmargin" + '(("LEFT MARGIN" 'number " "))) + (cons "rmargin" + '(("RIGHT MARGIN" 'number " "))) + (cons "tmargin" + '(("TOP MARGIN" 'number " "))) + + (cons "missing" + '(("CHARACTER" 'string " " 1))) + ; m_tics + (cons "mxtics" gnuplot-gui-mtics-list) + (cons "mytics" gnuplot-gui-mtics-list) + (cons "mztics" gnuplot-gui-mtics-list) + (cons "mx2tics" gnuplot-gui-mtics-list) + (cons "my2tics" gnuplot-gui-mtics-list) + + ; pm3d additions + (cons "mouse" + '(("DOUBLECLICK" 'number " " "doubleclick") + ("ZOOM" 'list " " "zoomcoordinates" "nozoomcoordinates") + ("POLAR" 'list " " "polarcoordinates" "nopolarcoordinates") + ("FORMAT" 'string " " "format") + ("CLIPBOARDFORMAT" 'string " " "clipboardformat") + ("MOUSEFORMAT" 'string " " "mouseformat") + ("LABELS" 'list " " "labels" "nolabels") + ("LABELOPTIONS" 'string " " "labeloptions") + ("ZOOMJUMP" 'list " " "zoomjump" "nozoomjump") + ("VERBOSE" 'list " " "verbose" "noverbose"))) + (cons "palette" + '(("COLOR" 'list " " "gray" "color") + ("RGBFORMULAE" 'position " " "rgbformulae" 3) + ("PARITY" 'list " " "positive" "negative") + ("FORMULAE" 'list " " "nops_allcF" "ps_allcF") + ("MAXCOLORS" 'number " ") + ("COLOR_BOX" 'list " " "nocb" "cbdefault" "cbuser") + ("ORIENTATION" 'list " " "cbvertical" "cbhorizontal") + ("ORIGIN" 'position " " "origin" 2) + ("SIZE" 'position " " "size" 2) + ("BORDER" 'number " ") + ("NOBORDER" 'list " " "bdefault" "noborder"))) + (cons "pm3d" + '(("AT" 'list* " " "b" "s" "t" "bs" "bt" "st" "bst") + ("SCANS" 'list " " "scansautomatic" "scansforward" "scansbackward") + ("FLUSH" 'list* " " "begin" "center" "end") + ("CLIP" 'list " " "clip1in" "clip4in") + ("ZRANGE" 'range (" " . " ") ":") + ("HIDDEN3D" 'number " ") + ("NOHIDDEN3D" 'list " " "nohidden3d") + ("FILLING" 'list " " "transparent" "solid") + ("MAP" 'list " " "map"))) + + (cons "offsets" + '(("LEFT " 'number " ") + ("RIGHT " 'number " " ",") + ("TOP " 'number " " ",") + ("BOTTOM" 'number " " ","))) + (cons "origin" + '(("X ORIGIN" 'number " ") + ("Y ORIGIN" 'number " " ","))) + (cons "output" + '(("FILENAME" 'file " "))) + (cons "pointsize" + '(("MULTIPLIER" 'number " "))) + (cons "samples" + '(("2D PLOT" 'number " ") + ("3D PLOT" 'number " " ","))) + (cons "size" + '(("ASPECT" 'list " " "square" "nosquare" + "ratio" "noratio") + ("X-SCALE OR RATIO" 'number " ") + ("Y-SCALE" 'number " " ","))) + (cons "style" + '(("DATA TYPE" 'list " " "data" "function") + ("PLOT STYLE" 'list " " "boxerrorbars" "boxes" + "boxxyerrorbars" "candlesticks" "dots" + "financebars" "fsteps" "histeps" "impulses" + "lines" "linespoints" "points" "steps" "vector" + "xerrorbars" "xyerrorbars" "yerrorbars"))) + (cons "terminal" + '(("TERMINAL TYPE" 'list " " gnuplot-gui-terminal-list))) + (cons "tics" + '(("DIRECTION" 'list " " "in" "out"))) + (cons "ticslevel" + '(("RELATIVE HEIGHT" 'number " "))) + (cons "ticscale" + '(("MAJOR" 'number " ") + ("MINOR" 'number " "))) + (cons "timestamp" + '(("FORMAT STRING" 'format " ") + ("WHERE" 'list " " "top" "bottom") + ("ROTATE" 'list " " "rotate" "norotate") + ("X-OFFSET" 'number " ") + ("Y-OFFSET" 'number " " ",") + ("FONTNAME" 'list " " gnuplot-gui-fontname-list))) + (cons "timefmt" + '(("FORMAT STRING" 'string " "))) + (cons "title" + '(("TITLE" 'string " "))) + (cons "view" + '(("X-ROTATION" 'number " ") + ("Z-ROTATION" 'number " " ",") + ("SCALE" 'number " " ",") + ("Z-SCALE" 'number " " ","))) + ;; ("SCALE" 'position " " "," 4) + ; _data + (cons "xdata" gnuplot-gui-data-list) + (cons "ydata" gnuplot-gui-data-list) + (cons "zdata" gnuplot-gui-data-list) + (cons "x2data" gnuplot-gui-data-list) + (cons "y2data" gnuplot-gui-data-list) + ; _label + (cons "xlabel" gnuplot-gui-label-list) + (cons "ylabel" gnuplot-gui-label-list) + (cons "zlabel" gnuplot-gui-label-list) + (cons "x2label" gnuplot-gui-label-list) + (cons "y2label" gnuplot-gui-label-list) + ; _range, note that the [] syntax for + ; the writeback argument is + ; not properly supported + (cons "xrange" gnuplot-gui-range-list) + (cons "yrange" gnuplot-gui-range-list) + (cons "zrange" gnuplot-gui-range-list) + (cons "x2range" gnuplot-gui-range-list) + (cons "y2range" gnuplot-gui-range-list) + (cons "trange" gnuplot-gui-range-list) + (cons "rrange" gnuplot-gui-range-list) + (cons "urange" gnuplot-gui-range-list) + (cons "vrange" gnuplot-gui-range-list) + ; _tics + (cons "xtics" gnuplot-gui-tics-list) + (cons "ytics" gnuplot-gui-tics-list) + (cons "ztics" gnuplot-gui-tics-list) + (cons "x2tics" gnuplot-gui-tics-list) + (cons "y2tics" gnuplot-gui-tics-list) + ; zeroaxis + (cons "zeroaxis" gnuplot-gui-zeroaxis-list) + (cons "xzeroaxis" gnuplot-gui-zeroaxis-list) + (cons "yzeroaxis" gnuplot-gui-zeroaxis-list) + (cons "y2zeroaxis" gnuplot-gui-zeroaxis-list) + (cons "x2zeroaxis" gnuplot-gui-zeroaxis-list) + + (cons "zero" + '(("THRESHOLD" 'number " "))) + )) + +(defvar gnuplot-gui-command-types nil + "Associated list of command descriptions. +See the doc-string for `gnuplot-gui-all-types'.") +(setq gnuplot-gui-command-types + (list (cons "cd" + '(("FILENAME" 'file " "))) + (cons "call" + '(("INPUT FILE" 'file " ") + ("PARAMETER LIST" 'string " "))) + (cons "load" + '(("INPUT FILE" 'file " "))) + (cons "pause" + '(("TIME" 'number " ") + ("MESSAGE" 'string " "))) + (cons "print" + '(("EXPRESSION" 'string " "))) + (cons "save" + '(("SAVE" 'list " " "functions" "variables" "set") + ("FILE" 'file " "))) + (cons "update" + '(("INITIAL FILE" 'file " " t) + ("UPDATED FILE" 'file " " t))) )) + + +(defcustom gnuplot-gui-plot-splot-fit-style 'simple + "Control the complexity of the GUI display for plot, splot, and fit. +The values are 'simple, which causes a limited set of plot, splot, or +fit options to be displayed, and 'complete, which attempts to display +all options. The 'complete setting is prone to making errors when +parsing values already in the script buffer." + :group 'gnuplot-gui + :type '(radio (const :tag "Simple listing" simple) + (const :tag "Complete listing" complete))) + + +(defconst gnuplot-gui-plot-simple-list + '(("X RANGE" 'range (" " . " ") ":") + ("Y RANGE" 'range (" " . " ") ":") + ("DATA FILE" 'file " ") + ("THRU" 'string* " " "thru") + ("USING" 'modifier " ") + ("TITLE" 'string " ") + ("WITH" 'list* " " "boxerrorbars" "boxes" + "boxxyerrorbars" "candlesticks" "dots" "financebars" + "fsteps" "histeps" "impulses" "lines" "linespoints" + "points" "steps" "vector" "xerrorbars" "xyerrorbars" + "yerrorbars"))) +(defconst gnuplot-gui-plot-full-list + '(;;("T RANGE" 'range (" " . " ") ":") + ("X RANGE" 'range (" " . " ") ":") + ("Y RANGE" 'range (" " . " ") ":") + ("xa" 'text "\t---------------------") + ("FUNCTION" 'string " ") + ("xc" 'text " or") + ("DATA FILE" 'file " ") + ("INDEX" 'modifier " ") + ("EVERY" 'modifier " ") + ("THRU" 'string* " " "thru") + ("USING" 'modifier " ") + ("SMOOTH" 'list* " " "unique" "csplines" "acsplines" + "bezier" "sbezier") + ;; datafile modifiers + ("AXES" 'list* " " "x1y1" "x2y2" "x1y2" "x2y1") + ("TITLE" 'string " ") + ("NOTITLE" 'list " " "notitle") + ("xf" 'text "\t---------------------") + ("xi" 'text "Select a standard plotting style") + ("WITH" 'list* " " "boxerrorbars" "boxes" + "boxxyerrorbars" "candlesticks" "dots" "financebars" + "fsteps" "histeps" "impulses" "lines" "linespoints" + "points" "steps" "vector" "xerrorbars" "xyerrorbars" + "yerrorbars") + ("xo" 'text " or a previously defined style") + ("LINE STYLE " 'number " " "ls") + ("xr" 'text " or specify a style in-line") + ("LINE TYPE " 'number " " "lt") + ("LINE WIDTH " 'number " " "lw") + ("POINT TYPE " 'number " " "pt") + ("POINT STYLE" 'number " " "ps") + )) +(defconst gnuplot-gui-splot-simple-list + '(("DATA FILE" 'file " ") + ("TITLE" 'string " ") + ("WITH" 'list* " " "lines" "linespoints" "points" "dots" "impulses"))) +(defconst gnuplot-gui-splot-full-list + '(;;("U RANGE" 'range (" " . " ") ":") + ;;("V RANGE" 'range (" " . " ") ":") + ("X RANGE" 'range (" " . " ") ":") + ("Y RANGE" 'range (" " . " ") ":") + ("Z RANGE" 'range (" " . " ") ":") + ("xa" 'text "\t---------------------") + ("FUNCTION" 'string " ") + ("xc" 'text " or") + ("DATA FILE" 'file " ") + ("INDEX" 'modifier " ") + ("EVERY" 'modifier " ") + ("THRU" 'string* " " "thru") + ("USING" 'modifier " ") + ("SMOOTH" 'list* " " "unique" "csplines" "acsplines" + "bezier" "sbezier") + ("TITLE" 'string " ") + ("NOTITLE" 'list " " "notitle") + ("WITH" 'list* " " "lines" "linespoints" "points" "dots" "impulses"))) +(defconst gnuplot-gui-fit-simple-list + '(("FUNCTION" 'string* " " "") + ("DATA FILE" 'file " ") + ("VIA (params)" 'string* " " "via") )) +(defconst gnuplot-gui-fit-full-list + '(("X RANGE" 'range (" " . " ") ":") + ("Y RANGE" 'range (" " . " ") ":") + ("xa" 'text "----- fitting functionn and file --------") + ("FUNCTION" 'string* " " "") + ("DATA FILE" 'file " ") + ("xb" 'text "----- datafile modifiers ----------------") + ("INDEX" 'modifier " ") + ("EVERY" 'modifier " ") + ("THRU" 'string* " " "thru") + ("USING" 'modifier " ") + ("SMOOTH" 'list* " " "unique" "csplines" "acsplines" + "bezier" "sbezier") + ("xc" 'text "----- parameters (file or parameters) ---") + ("VIA (file)" 'string " " "via") + ("VIA (params)" 'string* " " "via") )) + +(defvar gnuplot-gui-plot-splot-fit nil + "Associated list of plot, splot, and fit descriptions. +See the doc-string for `gnuplot-gui-all-types'.") +(setq gnuplot-gui-plot-splot-fit + (list (cons "plot" (if (equal gnuplot-gui-plot-splot-fit-style 'complete) + gnuplot-gui-plot-full-list + gnuplot-gui-plot-simple-list)) + (cons "splot" (if (equal gnuplot-gui-plot-splot-fit-style 'complete) + gnuplot-gui-splot-full-list + gnuplot-gui-splot-simple-list)) + (cons "fit" (if (equal gnuplot-gui-plot-splot-fit-style 'complete) + gnuplot-gui-fit-full-list + gnuplot-gui-fit-simple-list))) ) + + +(defvar gnuplot-gui-test-type nil) +(setq gnuplot-gui-test-type + (list (cons "test" + '(("TAG" 'tag " ") + ("LIST" 'list " " "1" "2" "3") + ("LIST*" 'list* " " "1" "2" "3") + ("NUMBER" 'number " " "number") + ("RANGE" 'range (" " . " ") ":") + ("PAIR" 'pair (" " . " ") "pair") + ("LABELS" 'labels ()) + ("FILE" 'file " ") + ("TEXT" 'text "this is text") + ("STRING" 'string " ") + ("STRING*" 'string* " " "string*") + ("FORMAT" 'format " ") + ("POSITION" 'position " " "at" 3) + ("FONTSIZE" 'fontsize " ") )))) + +(defvar gnuplot-gui-all-types nil + "Associated list of terminal, set option, and command arguments. + +Each entry in the list is a cons cell of the form + (OPTION . ALIST) +where OPTION is one of the recognized options in Gnuplot, either a +command, something that is set, or a terminal type. Only those +commands, set options, and terminal types that actually take arguments +are in this associated list. + +ALIST is itself an associated list where each entry is of the form: + + (TAG TYPE DEFAULT REST) + +TAG is the name used on the widget and indicates one of the options +for this command, set option, or terminal type. + +TYPE is one of + 'list a menu-list of strings + 'list* a menu-list of strings with a prefix + 'number a number with an optional prefix + 'tag like number but must be the first argument + 'fontsize like number but must be the last argument + 'range a pair of numbers like [#,#] or [#:#] + 'pair a pair of numbers with no punctuation and a prefix + 'file a quoted string and a file browser + 'string a quoted string with an optional prefix + 'string* an unquoted string with a prefix + 'format a quoted string and an info-link to (gnuplot)format + 'labels an array as needed for xtics, ytics, etc + 'position 2 or 3 comma separated numbers with an optional prefix + +DEFAULT is the default value for this option. Note that the default +for 'range and 'pair is a cons cell and the default for 'labels is a +list. For most things, the best choice of DEFAULT is a string of +white space or a cons cell of two strings of white space. Strings of +white space are better defaults than empty strings or nil. + +The value of REST depends upon TYPE: + + For 'list & REST is the list of options that will go into the + 'list* menu-button. This can also be a symbol which + evaluates to a list containing the options to go into + the menu-button. This list variable must contain the + DEFAULT. + For 'number REST is the prefix string (if it exists) for that number. + For 'range REST is the separator, \":\" for plot ranges and + \",\" for plot dimensions (see for example the tgif + terminal type) + For 'string & REST may a number denoting the width of the editable-text + 'string* field or it may be a string denoting a prefix. By + default, the width is half the width of the frame + and there is no prefix. It may be useful to + specify \"1\" when the input is a single character + as in 'set missing'. + For 'file REST determines the label placed before the file insertion + field. If non-nil, then TAG is used. If nil, then + the default \"File\" is used. + For 'position REST is the prefix and the number of comma separated numbers + For others REST is not used. + +Here is an example entry for the png terminal type: + + (cons \"png\" + '((\"SIZE\" 'list \" \" \"small\" \"medium\" \"large\") + (\"COLOR\" 'list \" \" \"monochrome\" \"gray\" \"color\"))) + +This alist is formed at load time by appending together +`gnuplot-gui-terminal-types', `gnuplot-gui-set-types' and +`gnuplot-gui-command-types'.") + +(setq gnuplot-gui-all-types (append gnuplot-gui-terminal-types + gnuplot-gui-set-types + gnuplot-gui-command-types + gnuplot-gui-plot-splot-fit + gnuplot-gui-test-type + )) + + +(defun gnuplot-gui-swap-simple-complete () + (interactive) + (setq gnuplot-gui-plot-splot-fit-style + (if (equal gnuplot-gui-plot-splot-fit-style 'complete) + 'simple 'complete)) + (if (equal gnuplot-gui-plot-splot-fit-style 'complete) + (progn + (setcdr (assoc "plot" gnuplot-gui-all-types) gnuplot-gui-plot-full-list) + (setcdr (assoc "splot" gnuplot-gui-all-types) gnuplot-gui-splot-full-list) + (setcdr (assoc "fit" gnuplot-gui-all-types) gnuplot-gui-fit-full-list)) + (setcdr (assoc "plot" gnuplot-gui-all-types) gnuplot-gui-plot-simple-list) + (setcdr (assoc "splot" gnuplot-gui-all-types) gnuplot-gui-splot-simple-list) + (setcdr (assoc "fit" gnuplot-gui-all-types) gnuplot-gui-fit-simple-list)) + (message "Using %s lists for plot, splot, and fit." + gnuplot-gui-plot-splot-fit-style) ) + + + + +;;; user interface to the widget-y stuff + +(defun gnuplot-gui-mouse-set (event) + "Use the mouse to begin setting options using a GUI interface. +EVENT is a mouse event. Bound to \\[gnuplot-gui-mouse-set] +Note that \"plot\", \"splot\", \"fit\", and \"cntrparam\" are not +currently supported." + (interactive "@e") + (when (fboundp 'widget-create) + (save-excursion + (mouse-set-point event) + (gnuplot-gui-set-options-and-insert)))) + +(defun gnuplot-gui-get-frame-param (param) + (if gnuplot-xemacs-p + (plist-get gnuplot-gui-frame-plist param) + (cdr (assoc param gnuplot-gui-frame-parameters)))) +(defun gnuplot-gui-set-frame-param (param value) + (if gnuplot-xemacs-p + (plist-put gnuplot-gui-frame-plist param value) + (setcdr (assoc param gnuplot-gui-frame-parameters) value))) + +(defun gnuplot-gui-set-options-and-insert () + "Insert arguments using a GUI interface. +Determine contents of current line and set up the appropriate GUI +frame. Bound to \\[gnuplot-gui-set-options-and-insert] +Note that \"cntrparam\" is not currently supported." + (interactive) + (when (fboundp 'widget-create) + (let ((begin (save-excursion (beginning-of-line) (point-marker))) + (end (save-excursion (end-of-line) (point-marker))) + (termin (concat "\\(,\\s-*" (regexp-quote "\\") "\\|;\\)")) + (set nil) (term nil)) + (save-excursion + ;; there can be more then one command per line + (if (search-backward ";" begin "to_limit") + (progn (forward-char 1) (setq begin (point-marker)))) + (if (re-search-forward termin end "to_limit") + (progn (backward-char (length (match-string 1))) + (setq end (point-marker)))) + (goto-char begin) + (skip-syntax-forward "-" end) + ;; various constructions are recognized here. at the end of this + ;; cond, point should be just after the word whose arguments are + ;; to be set + (cond ((looking-at "set\\s-+") + (setq set t) + (goto-char (match-end 0)) + (if (looking-at "\\sw+") (goto-char (match-end 0))) + (when (string-match "^ter" (gnuplot-this-word)) ; terminal? + (setq term t) + (forward-word 1)) + (when (string-match "^\\(da\\|fu\\)" (gnuplot-this-word)) + (unless (looking-at "\\s-+st") + (insert " style") (forward-word 1)) + (forward-word 1))) + ((looking-at (concat "\\(cd\\|ca\\|lo\\|pa\\|pr\\|sa\\|u\\)" + "\\w*" + "[\\s-\\']")) + (forward-word 1)) + ;;(goto-char (match-end 0))) + (t + (forward-word 1))) + (if (> (point) end) (goto-char end)) + (let* ((w (gnuplot-this-word)) + (wd (try-completion w gnuplot-gui-all-types)) + (word "") wrd list) + (cond ((equal wd t) (setq word w)) + ((equal wd nil) (setq word w)) + ((assoc wd gnuplot-gui-all-types) (setq word wd)) + (t (setq wd nil))) + (cond ((equal (string-match "^\\s-*$" w) 0) + (message "Blank line")) + ((and wd (stringp word)) + (gnuplot-gui-correct-command word set term begin) + (setq gnuplot-gui-alist nil + gnuplot-gui-current-string + (buffer-substring-no-properties (point) end)) + (gnuplot-gui-set-alist word gnuplot-gui-current-string) + (let* ((old-height (gnuplot-gui-get-frame-param 'height)) + (old-top (gnuplot-gui-get-frame-param 'top))) + (when (or + (and (equal gnuplot-gui-plot-splot-fit-style 'complete) + (member* word '("plot" "splot" "fit") + :test 'string=)) + (equal word "test")) + (gnuplot-gui-set-frame-param 'height 32) + (gnuplot-gui-set-frame-param 'top 50)) + (gnuplot-gui-prompt-for-frame word) + (when (or + (and (equal gnuplot-gui-plot-splot-fit-style 'complete) + (member* word '("plot" "splot" "fit") + :test 'string=)) + (equal word "test")) + (gnuplot-gui-set-frame-param 'height old-height) + (gnuplot-gui-set-frame-param 'top old-top)) )) + ((setq wrd (car (all-completions w '(("cntrparam"))))) + (message + "Setting arguments for %S is currently unsuported in gnuplot-mode" + wrd)) + ((setq list (all-completions w gnuplot-gui-all-types)) + (message "%S could be one of %S" w list)) + (t + (message + "%S is not a gnuplot command which takes options" w)))) )))) + +(defun gnuplot-gui-toggle-popup () + (interactive) + (setq gnuplot-gui-popup-flag (not gnuplot-gui-popup-flag)) + (message (if gnuplot-gui-popup-flag + "Argument popup will appear after insertions." + "Argument popup will no longer appear after insertions."))) + + +(defun gnuplot-gui-y-n (foo)) +(if gnuplot-xemacs-p + (defalias 'gnuplot-gui-y-n 'y-or-n-p-maybe-dialog-box) + (defalias 'gnuplot-gui-y-n 'y-or-n-p)) + +(defun gnuplot-gui-correct-command (word set term begin) + "Check syntax of set command and terminal specifications. +WORD is the item being set. SET and TERM are non-nil if the words +\"set\" and \"terminal\" were found preceding WORD in the buffer. +BEGIN is the beginning of the command." + (save-excursion + (cond ((assoc word gnuplot-gui-terminal-types) + (when (and (not (and set term)) + (gnuplot-gui-y-n + (format + "%S must be preceded by \"set terminal\". Add it? " + word))) + (backward-word 1) + (let ((e (point-marker))) + (goto-char begin) + (skip-syntax-forward "-" e) + (delete-region (point) e) + (insert "set terminal ")))) + ((assoc word gnuplot-gui-set-types) + (when (and (not set) + (gnuplot-gui-y-n + (format + "%S must be preceded by \"set\". Add \"set\"? " word))) + (backward-word 1) + (let ((e (point-marker))) + (goto-char begin) + (skip-syntax-forward "-" e) + (delete-region (point) e) + (insert "set ")))))) + (message nil)) + + + +;;; handle the actual arguments + +(defun gnuplot-gui-fix-arg-list (list) + "Correct the result of splitting `gnuplot-gui-current-string'. +LIST is the split string. This removes empty and all-blank strings +from the list and concatenates the strings that are part of a quoted +argument, for example an axis label or a font name. It also replaces +bounding single quotes with double quotes, since double quotes are +used in `gnuplot-gui-all-types'." + (let (fixed-list quote quoted) ; remove blanks + (setq list (remove* "\\s-+" list :test 'string-match) + list (remove* "" list :test 'string=)) + (while list ; concatinate parts of quoted string + (if (not (string-match "^\\([\]\[()'\"]\\)" (car list))) + (setq fixed-list (append fixed-list (list (car list)))) + (setq quote (match-string 1 (car list)) + quoted (car list)) + (if (string= quote "[") (setq quote "]")) + (if (string= quote "(") (setq quote ")")) + (while (and list + (or (equal (length quoted) 1) + (not (string-match (concat (regexp-quote quote) "$") + quoted)))) + (setq quoted (concat quoted " " (cadr list)) + list (cdr list))) + (if (string= quote "'") + (setq quoted (concat "\"" (substring quoted 1)) + quoted (concat (substring quoted 0 -1) "\""))) + (setq fixed-list (append fixed-list (list quoted)))) + (setq list (cdr list)) ) + fixed-list)) + +(defun gnuplot-gui-set-alist (word string) + "Set defaults for arguments, using text from buffer if appropriate. +WORD is the Gnuplot expression whose arguments are being set. STRING +is text from the buffer containing the previous values for WORD's +arguments." + (let ((alist (cdr (assoc word gnuplot-gui-all-types))) + (arg-list (gnuplot-gui-fix-arg-list (split-string string)) )) + ;; arg-list contains the arguments taken from the buffer + (setq gnuplot-gui-alist nil) + (while alist + (let* ((list (car alist)) + (tag (gnuplot-gui-type-tag list)) + (symbol (eval (gnuplot-gui-type-symbol list))) + (default (gnuplot-gui-type-default list)) + (prefix (gnuplot-gui-type-prefix list)) + (values (gnuplot-gui-type-list list)) + (this-cons (cond ((stringp default) (cons tag default)) + ((consp default) ; set cons valued default w/care + (cons tag (cons (car default) (cdr default)))) + (t (cons tag default)))) + (temp-list arg-list) ) + ;;(message "%S" temp-list) ; want to lop values off arg-list + ; as they are found + (if (symbolp (cadr values)) + (setq values (symbol-value (cadr values)))) + ;; check if an argument of this type is in arg-list + ;; set the current cons cell if it is + (while temp-list + (cond + ;; ---------------------------- list + ((member* symbol '(list list*) :test 'equal) + (let* ((case-fold-search nil) + (match-cons (member* (concat "^" (car temp-list)) + values :test 'string-match))) + (if (and (car match-cons) ; " " may be first elem. of list + (not (string= " " (car match-cons)))) + (setq this-cons (cons tag (car match-cons)) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + temp-list nil) + (setq temp-list (cdr temp-list))))) + ;; ---------------------------- tag (first number in list) + ((equal symbol 'tag) + (if (string-match "^[-0-9.]+$" (car arg-list)) + (setq this-cons (cons tag (car arg-list)) + temp-list nil) + (setq temp-list (cdr temp-list))) ) + ;; ---------------------------- fontsize (last number in list) + ((equal symbol 'fontsize) + (if (string-match "^[-0-9.]+$" (car (last arg-list))) + (setq this-cons (cons tag (car (last arg-list))) + temp-list nil) + (setq temp-list (cdr temp-list))) ) + ;; ---------------------------- number with prefix + ((equal symbol 'number) + (cond ((and (string= prefix (car temp-list)) + (string-match "^[-0-9.]+$" (cadr temp-list))) + (setq this-cons (cons tag (cadr temp-list)) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + arg-list (remove* (cadr temp-list) arg-list + :test 'string= :count 1) + temp-list nil)) + ;; --------------------- number without prefix + ((and (not prefix) + (string-match "^[-0-9.]+$" (car temp-list))) + (setq this-cons (cons tag (car temp-list)) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + temp-list nil)) + (t + (setq temp-list (cdr temp-list))))) + ;; ---------------------------- pair with prefix + ((equal symbol 'pair) + (if (and (string= prefix (car temp-list)) + (string-match "^[-0-9.]+$" (cadr temp-list))) + (let ((this-car (cadr temp-list)) + (this-cdr (if (string-match "^[-0-9.]+$" (caddr temp-list)) + (caddr temp-list) ""))) + (setq this-cons (cons tag (cons this-car this-cdr)) + temp-list nil)) + (setq temp-list (cdr temp-list)))) + ;; ---------------------------- range + ((equal symbol 'range) + (if (string-match (concat "\\[\\s-*" ; opening bracket + "\\([^:, \t]*\\)" ; first argument + "\\s-*[:,]\\s-*" ; separator + "\\([^\] \t]*\\)" ; second argument + "\\s-*\\]") ; closing bracket + (car temp-list)) + (setq this-cons + (cons tag (cons (match-string 1 (car temp-list)) + (match-string 2 (car temp-list)))) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + temp-list nil) + (setq temp-list (cdr temp-list)) )) + ;; ---------------------------- labels + ((equal symbol 'labels) + (if (string-match (concat "(" ; opening paren + "\\([^\)]*\\)" ; string + ")") ; closing paren + (car temp-list)) + (let* ((list (split-string (car temp-list) "[ \t(),]+")) + (list (remove* "" list :test 'string=)) + (return ())) + (while list + (if (string-match "['\"]\\([^'\"]*\\)['\"]" (car list)) + (setq return (append return + (list (match-string 1 (car list)))) + list (cdr list) + return (append return (list (car list))) ) + (setq return (append return (list "" (car list))))) + (setq list (cdr list)) ) + (setq this-cons (cons tag return) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + temp-list nil)) + (setq temp-list (cdr temp-list))) ) + ;; ---------------------------- string, file, format + ((member* symbol '(string file format) :test 'equal) + (if (string-match (concat "['\"]" ; opening quote + "\\([^'\"]*\\)" ; string + "['\"]") ; closing quote + (car temp-list)) + (setq this-cons (cons tag (match-string 0 (car temp-list))) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + temp-list nil) + (setq temp-list (cdr temp-list)) )) + ;; ---------------------------- string* + ((equal symbol 'string*) + (if (string= prefix (car temp-list)) + (setq this-cons (cons tag (cadr temp-list)) + arg-list (remove* (car temp-list) arg-list + :test 'string= :count 1) + arg-list (remove* (cadr temp-list) arg-list + :test 'string= :count 1) + temp-list nil) + (setq temp-list (cdr temp-list)) ) ) + ;; ---------------------------- other or unknown + (t + (setq temp-list nil)) + )) + (setq gnuplot-gui-alist + (append gnuplot-gui-alist (list this-cons)))) + (setq alist (cdr alist))) )) + + +(defun gnuplot-gui-post-process-alist (type) + "A few types need some additional processing. +'range, 'pair, and 'labels are cons or list valued and need to b made +into strings. This is called right before inserting the arguments +into the buffer. TYPE is the object whose arguments are being set." + (let ((alist gnuplot-gui-alist) + (types (cdr (assoc type gnuplot-gui-all-types))) ) + (while alist ;; loop thru alist looking for tyeps needing post-processing + (let* ((list (assoc (caar alist) types)) + (value (cdr (assoc (caar alist) gnuplot-gui-alist))) + (prefix (gnuplot-gui-type-prefix list)) + (symb (gnuplot-gui-type-symbol list)) ) + (cond + ;;-------------------------- flat text + ((equal (eval symb) 'text) + (setcdr (assoc (caar alist) gnuplot-gui-alist) "")) + ;;-------------------------- range [#:#] or [#,#] + ((equal (eval symb) 'range) + (if (and (string-match "^\\s-*$" (car value)) + (string-match "^\\s-*$" (cdr value))) + (setcdr (assoc (caar alist) gnuplot-gui-alist) "") + (setcdr (assoc (caar alist) gnuplot-gui-alist) + (concat "[" (car value) prefix (cdr value) "]")) ) ) + ;;-------------------------- pair + ((equal (eval symb) 'pair) + (if (and (string-match "^\\s-*$" (car value)) + (string-match "^\\s-*$" (cdr value))) + (setcdr (assoc (caar alist) gnuplot-gui-alist) "") + (setcdr (assoc (caar alist) gnuplot-gui-alist) + (concat prefix " " (car value) " " (cdr value) )) ) ) + ;;-------------------------- labels + ((equal (eval symb) 'labels) + (if (consp value) + (let ((word "") (list value)) + (while list + (if (string-match "^\\s-*$" (car list)) + (setq word (concat word (format "%s, " (cadr list)))) + (setq word (concat word (format "%S %s, " (car list) + (cadr list))))) + (setq list (cddr list)) ) + (setq value (concat "(" (substring word 0 -2) ")"))) + (setq value "") ) + (setcdr (assoc (caar alist) gnuplot-gui-alist) value) )) + + (setq alist (cdr alist))) ))) + + +;;; GUI frames + +(defun gnuplot-gui-prompt-for-frame (&optional option save-frame) + (setq option (or option (completing-read "Option: " gnuplot-gui-all-types + nil t nil t))) + (gnuplot-gui-make-frame + option (cdr (assoc option gnuplot-gui-all-types)) save-frame) ) + + +(defface gnuplot-gui-error-face '((((class color) (background light)) + (:foreground "grey30")) + (((class color) (background dark)) + (:foreground "grey70"))) + "Face used to display message about unknown widget types." + :group 'gnuplot-faces) + +(defface gnuplot-gui-flat-text-face '((((class color) (background light)) + (:foreground "MediumBlue")) + (((class color) (background dark)) + (:foreground "LightSteelBlue"))) + "Face used to display message about unknown widget types." + :group 'gnuplot-faces) + +(defun gnuplot-gui-make-frame (item alist &optional save-frame) + "Open the frame and populate it with widgets. +ITEM is the object for which arguments are being set. ALIST is +the alist of arguments for ITEM taken from `gnuplot-gui-all-types'. +SAVE-FRAME is non-nil when the widgets are being reset." + (unless save-frame + (setq gnuplot-current-frame (selected-frame) + gnuplot-current-buffer (current-buffer) + gnuplot-current-buffer-point (point-marker)) + (unless (and gnuplot-gui-frame (frame-live-p gnuplot-gui-frame)) + (setq gnuplot-gui-frame (if gnuplot-xemacs-p + (make-frame gnuplot-gui-frame-plist) + (make-frame gnuplot-gui-frame-parameters)))) + (select-frame gnuplot-gui-frame) + ;;(set-frame-position gnuplot-gui-frame 150 150) ;; so herky-jerky + (if gnuplot-xemacs-p + (set-mouse-position (selected-window) 0 0) + (set-mouse-position gnuplot-gui-frame 0 0))) + (kill-buffer (get-buffer-create "*Gnuplot GUI*")) + (switch-to-buffer (get-buffer-create "*Gnuplot GUI*")) + (kill-all-local-variables) + (if gnuplot-xemacs-p + (progn + (set (make-local-variable 'frame-title-format) + "Set Gnuplot Options") + (set (make-local-variable 'frame-icon-title-format) + "Set Gnuplot Options")) + (modify-frame-parameters (selected-frame) + '((title . "Set Gnuplot Options"))) ) + (widget-insert "\nSet options for \"" item "\" ") + (let (tag help val) + (cond ((string-match "^[xyz]2?tics" item) + (setq tag "info on tic labels" + help "Open a frame displaying the info entry for tic labels" + val "xtics")) + ((string-match "^no" item) + (setq tag (concat "info on " (substring item 2)) + help (format "Open a frame displaying the info entry for %S" + item) + val item)) + (t + (setq tag (concat "info on " item) + help (format "Open a frame displaying the info entry for %S" + item) + val item))) + (widget-create 'gnuplot-gui-info-link :tag tag :help-echo help :value val)) + + (widget-insert "\n\n") + (while alist + (let* ((this (car alist)) + (tag (gnuplot-gui-type-tag this)) + (wtype (gnuplot-gui-type-symbol this)) + (prefix (gnuplot-gui-type-prefix this)) + (default (cdr (assoc tag gnuplot-gui-alist))) + (list (gnuplot-gui-type-list this))) + (if (symbolp (cadr list)) + (setq list (symbol-value (cadr list)))) + (widget-insert "\t") ; insert the appropriate widget + (cond + ;;------------------------------ list, list* ------------ + ((member* (eval wtype) '(list list*) :test 'equal) + (let ((starred (if (equal (eval wtype) 'list*) t nil))) + (gnuplot-gui-menu-choice tag default list starred))) + ;;------------------------------ number, tag, fontsize -- + ((member* (eval wtype) '(number tag fontsize) :test 'equal) + (gnuplot-gui-number tag default prefix)) + ;;------------------------------ position --------------- + ;;------------------------------ range, pair ------------ + ((member* (eval wtype) '(range pair) :test 'equal) + (let ((is-range (equal (eval wtype) 'range))) + (gnuplot-gui-range tag default prefix is-range))) + ;;------------------------------ string, string* -------- + ((member* (eval wtype) '(string string*) :test 'equal) + (let ((starred (if (equal (eval wtype) 'string) nil t))) + (gnuplot-gui-string tag default prefix starred))) + ;;------------------------------ format ----------------- + ((equal (eval wtype) 'format) + (gnuplot-gui-format tag default)) + ;;------------------------------ file ------------------- + ((equal (eval wtype) 'file) + (gnuplot-gui-file tag default prefix)) + ;;------------------------------ labels ----------------- + ((equal (eval wtype) 'labels) + (gnuplot-gui-labels tag default)) + ;;------------------------------ text ------------------- + ((equal (eval wtype) 'text) + (let ((str (gnuplot-gui-type-default this))) + (put-text-property 0 (length str) 'face 'gnuplot-gui-flat-text-face str) + (widget-insert str "\n"))) + ;;------------------------------ unknown ---------------- + (t + (let ((str (concat "<" (downcase tag) "> ('" + (symbol-name (eval wtype)) + " arguments are not yet supported)\n"))) + (put-text-property 0 (length str) 'face 'gnuplot-gui-error-face str) + (widget-insert str)) ))) + (setq alist (cdr alist))) + ;; insert control buttons: [Set options] [Reset] [Clear] [Cancel] + (widget-insert "\n\t") + (widget-create 'push-button + :value "Set options" + :doc item + :button-face 'gnuplot-gui-button-face + :help-echo "Push this button to set options" + :notify + (lambda (widget &rest ignore) + (kill-buffer (get-buffer-create "*Gnuplot GUI*")) + (delete-frame) + (select-frame gnuplot-current-frame) + (switch-to-buffer gnuplot-current-buffer) + (goto-char gnuplot-current-buffer-point) + (gnuplot-gui-post-process-alist + (widget-get widget :doc)) + (let ((alist gnuplot-gui-alist) marker + (eol (save-excursion (end-of-line) (point-marker) )) ) + (if (re-search-forward ";" eol "to_limit") + (backward-char 1)) + (delete-region gnuplot-current-buffer-point (point-marker)) + (delete-horizontal-space) + (setq marker (point-marker)) + (while alist + (let ((val (cdar alist))) + (if (string-match "^\\s-+$" val) () + (if (string-match "^['\"]\\(.*\\)['\"]$" val) + (setq val (concat gnuplot-quote-character + (match-string 1 val) + gnuplot-quote-character))) + (insert (format " %s" val)))) + (setq alist (cdr alist))) + (setq eol (point-marker)) + (goto-char marker) + (while (< (point) eol) ; a few odd cases + (unless (looking-at (concat "[" (regexp-quote "(") + (regexp-quote "*") ",]")) + (just-one-space)) + (forward-sexp))) + (delete-horizontal-space) + (if (string= "terminal" (widget-get widget :doc)) + (gnuplot-gui-set-options-and-insert)) )) + (widget-insert " ") + (widget-create 'push-button :value "Reset" + :help-echo "Push this button to reset all values" + :button-face 'gnuplot-gui-button-face + :doc item + :notify + (lambda (widget &rest ignore) + (let ((word (widget-get widget :doc))) + (gnuplot-gui-set-alist word gnuplot-gui-current-string) + (gnuplot-gui-prompt-for-frame word t)))) + (widget-insert " ") + (widget-create 'push-button :value "Clear" + :help-echo "Push this button to clear all values" + :button-face 'gnuplot-gui-button-face + :doc item + :notify + (lambda (widget &rest ignore) + (let* ((word (widget-get widget :doc)) + (alist (cdr (assoc word gnuplot-gui-all-types)))) + (while alist + (setcdr (assoc (gnuplot-gui-type-tag (car alist)) + gnuplot-gui-alist) + (gnuplot-gui-type-default (car alist))) + (setq alist (cdr alist))) + (gnuplot-gui-prompt-for-frame word t))) ) + (widget-insert " ") + (widget-create 'push-button :value "Cancel" + :help-echo "Quit setting options and dismiss frame" + :button-face 'gnuplot-gui-button-face + :notify (lambda (widget &rest ignore) + (kill-buffer (get-buffer-create "*Gnuplot GUI*")) + (setq gnuplot-gui-alist nil + gnuplot-gui-current-string nil) + (delete-frame) + (select-frame gnuplot-current-frame))) + (goto-char (point-min)) + (use-local-map widget-keymap) + (widget-setup)) + + +;;; widgets + +(defface gnuplot-gui-menu-face '((((class color) (background light)) + (:bold t :foreground "darkolivegreen")) + (((class color) (background dark)) + (:bold t :foreground "seagreen")) + (t + (:italic t))) + "Face used for menu-buttons." + :group 'gnuplot-faces) +(defface gnuplot-gui-button-face '((((class color) (background light)) + (:bold t :foreground "sienna")) + (((class color) (background dark)) + (:bold t :foreground "tan")) + (t + (:italic t))) + "Face used for push-buttons. +Only used in Emacs. XEmacs displays push-buttons with a pixmap." + :group 'gnuplot-faces) +(defface gnuplot-gui-labels-face '((((class color) (background light)) + (:bold t :foreground "darkslateblue")) + (((class color) (background dark)) + (:bold t :foreground "lightslateblue")) + (t + (:italic t))) + "Face used for insert and delete button in the labels widget." + :group 'gnuplot-faces) + +(defun gnuplot-gui-menu-choice (item default list &optional starred) + "Create a menu widget for the Gnuplot GUI. +ITEM is the object whose arguments are set by this widget, DEFAULT +is the default argument value, LIST contains the items for the pop-up +menu. STARRED is true if this a 'list* widget." + (let ((widget + (apply 'widget-create + 'menu-choice :value default :tag item :doc starred + :button-face 'gnuplot-gui-menu-face + :button-prefix "[" :button-suffix "]" + :help-echo (format "Mouse-2 to view the %S menu" (downcase item)) + :notify + (lambda (widget &rest ignore) + (let ((lab (if (widget-get widget :doc) + (concat (downcase (widget-get widget :tag)) " ") + "" ))) + (setcdr (assoc (widget-get widget :tag) gnuplot-gui-alist) + (if (string= (widget-value widget) " ") "" + (format "%s%s" lab (widget-value widget))) ))) + (mapcar (lambda (x) (list 'item :value x)) + list)))) + (widget-value-set widget default) + (if (and starred (not (string-match "^\\s-*$" default))) + (setcdr (assoc item gnuplot-gui-alist) + (format "%s %s" (downcase item) default))) + widget)) + +(defun gnuplot-gui-number (item default &optional prefix) + "Create a number widget for the Gnuplot GUI. +ITEM is the object whose arguments are set by this widget, DEFAULT +is the default value for the widget, PREFIX is a text string preceding +the numerical argument." + (let ((help-label (or prefix (downcase item)))) + (widget-insert (capitalize item) ": ") + (widget-create 'editable-field + :size 2 :tag item :value default :doc prefix + :help-echo (format "Insert new value of %S here" help-label) + :notify (lambda (widget &rest ignore) + (let ((val (widget-value widget)) + (pre (concat (widget-get widget :doc) " "))) + (setcdr (assoc (widget-get widget :tag) + gnuplot-gui-alist) + (if (string-match + "^\\s-*[-0-9.*]+\\s-*$" val) + (format "%s%s" pre val) "") ))))) + (unless (string-match "^\\s-*$" default) + (setcdr (assoc item gnuplot-gui-alist) (format "%s %s" prefix default))) + (widget-insert " " (make-string (- 40 (current-column)) ?.) + " (numeric value)\n")) + +(defun gnuplot-gui-string (item default &optional width_or_prefix starred) + "Create a string widget for the Gnuplot GUI. +ITEM is the object whose arguments are set by this widget, DEFAULT is +the default value for the widget, and WIDTH_OR_PREFIX is the width of +the text entry field (which defaults to half the frame width) or the +prefix for the string. STARRED is t if quotes are not to be used." + (let ((help-label (downcase item)) width (prefix "") (pp "")) + (cond ((stringp width_or_prefix) + (setq prefix width_or_prefix + pp prefix) + (if starred (setq prefix (concat prefix "_star"))) ) + ((numberp width_or_prefix) + (setq width width_or_prefix))) + (setq width (or width (/ (frame-width) 2))) + (if (string-match "^['\"]" default) + (setq default (replace-match "" nil nil default))) + (if (string-match "['\"]$" default) + (setq default (replace-match "" nil nil default))) + (widget-insert (capitalize item) ": ") + (widget-create + 'editable-field + :size width :tag item :doc prefix :value default + :help-echo (format "Insert new value of %S here" help-label) + :notify (lambda (widget &rest ignore) + (let ((val (widget-value widget)) + (q gnuplot-quote-character) + (p (widget-get widget :doc)) ) + (setcdr (assoc (widget-get widget :tag) gnuplot-gui-alist) + (if (string-match "^\\s-*$" val) + "" + (progn + (if (string-match "_star$" p) + (setq p (concat (substring p 0 -5) " ") + q "")) + (if (string-match "^\\s-+" val) + (setq val (replace-match "" nil nil val))) + (if (string-match "\\s-+$" val) + (setq val (replace-match "" nil nil val))) + (format "%s%s%s%s" p q val q))))))) + (unless (string-match "^\\s-*$" default) + (setcdr (assoc item gnuplot-gui-alist) (format "%s %s" pp default))) + (widget-insert "\n"))) + +(defun gnuplot-gui-format (item default) + "Create a string widget for the Gnuplot GUI. +ITEM is the object whose arguments are set by this widget, DEFAULT is +the default value for the widget, and WIDTH_OR_PREFIX is the width of +the text entry field (which defaults to half the frame width) or the +prefix for the string." + (if (string-match "^['\"]" default) + (setq default (replace-match "" nil nil default))) + (if (string-match "['\"]$" default) + (setq default (replace-match "" nil nil default))) + (widget-insert (capitalize item) ": ") + (widget-create 'editable-field + :size (/ (frame-width) 3) :tag item :value default + :help-echo (format "Insert new format string here") + :notify (lambda (widget &rest ignore) + (let ((val (widget-value widget))) + (setcdr (assoc (widget-get widget :tag) + gnuplot-gui-alist) + (format "%s%s%s" + gnuplot-quote-character + val + gnuplot-quote-character))))) + (widget-insert " ") + (widget-create 'gnuplot-gui-info-link + :tag (concat "info on format") + :help-echo "Open a frame displaying the info entry for format" + :value "format") + (widget-insert "\n")) + + +;; swiped from widget-color-complete +(defun gnuplot-gui-file-completion (widget) + "Complete the filename in WIDGET." + (let* ((str (buffer-substring-no-properties (widget-field-start widget) + (point))) + (file (or (file-name-nondirectory str) "")) + (dir (or (file-name-directory str) "./")) + (val (file-name-completion file dir)) ) + (cond ((eq val t) + (message "Exact match")) + ((null val) + (error "Can't find completion for \"%s\"" str)) + ((not (string-equal str val)) + (insert (substring val (length file)))) + (t + (message "Making completion list...") + (let ((list (file-name-all-completions file dir))) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list list))) + (message "Making completion list...done"))))) + +(defun gnuplot-gui-file (item default &optional tag) + "Create a file widget for the Gnuplot GUI. +ITEM is the object whose arguments is set by this widget, DEFAULT is +the default value for the argument. TAG is non-nil if ITEM rather than +\"File:\" is to be used as the tag." + (setq tag (if tag (capitalize item) "File")) + (if (string-match "^['\"]" default) + (setq default (replace-match "" nil nil default))) + (if (string-match "['\"]$" default) + (setq default (replace-match "" nil nil default))) + (let ((widg (widget-create + 'file + :value default :tag tag + :size (- (/ (frame-width) 2) 3) + :doc item :help-echo "Insert a filename here" + :complete 'gnuplot-gui-file-completion + :notify + (lambda (widget &rest ignore) + (setcdr (assoc (widget-get widget :doc) gnuplot-gui-alist) + (format "%s%s%s" gnuplot-quote-character + (widget-value widget) + gnuplot-quote-character)) )) )) + (widget-insert " ") + (widget-create + 'push-button :value "Browse" + :doc item :help-echo "Browse directories for a filename." + :parent widg + :notify (lambda (widget &rest ignore) + (let ((fname (file-relative-name (read-file-name "File: ") + default-directory)) + (q gnuplot-quote-character)) + (widget-value-set (widget-get widget :parent) fname) + (setcdr (assoc (widget-get widget :doc) gnuplot-gui-alist) + (format "%s%s%s" q fname q)) + (widget-setup)))) + (widget-insert "\n"))) + +(defun gnuplot-gui-labels (item default) + "Create a labels widget for the Gnuplot GUI. +ITEM is the object whose arguments is set by this widget, DEFAULT is +the default value for the argument." + (widget-create + '(editable-list + (list :inline t :tag "Tic label" + (string :tag "label" :size 10 + :help-echo "Enter the tic label here" ) + (string :tag " position" :size 10 + :help-echo "Enter an expression for the tic location here" ))) + :tag (capitalize item) + :value default + :format "%{%t%}:\n%v\t %i\n" + :entry-format "\t %i %d %v\n" + :button-face 'gnuplot-gui-labels-face + :notify (lambda (widget &rest ignore) + (setcdr (assoc (upcase (widget-get widget :tag)) + gnuplot-gui-alist) + (widget-value widget))))) + +(defun gnuplot-gui-range (item default separator is-range) + "Create a range or pair widget for the Gnuplot GUI. +ITEM is the object whose arguments are set by this widget, DEFAULT is +the default value for the widget, SEPARATOR is a text string preceding +the numerical argument, or the prefix for a pair operator. IS-RANGE +is non-nil if this is a 'range widget." + (widget-insert (capitalize item) ": ") + (if is-range (widget-insert "[")) + (widget-create 'editable-field + :size 4 :tag item :value (car default) + :help-echo (format "Insert the first value of the %S here" + (downcase item)) + :notify (lambda (widget &rest ignore) + (setcar (cdr (assoc (widget-get widget :tag) + gnuplot-gui-alist)) + (format "%s" (widget-value widget))))) + (if is-range (widget-insert separator) (widget-insert " ")) + (widget-create 'editable-field + :size 4 :tag item :value (cdr default) + :help-echo (format "Insert the second value of the %S here" + (downcase item)) + :notify (lambda (widget &rest ignore) + (setcdr (cdr (assoc (widget-get widget :tag) + gnuplot-gui-alist)) + (format "%s" (widget-value widget))))) + (if is-range (widget-insert "]")) + (widget-insert " " (make-string (- 39 (current-column)) ?.) + " (numeric values)\n")) + + +;; suppress compiler warning +;;(eval-when-compile (defun gnuplot-info-lookup-symbol (sym mode))) +(define-widget 'gnuplot-gui-info-link 'info-link + "A link to an info file for the Gnuplot GUI." + :action '(lambda (widget &optional event) + (let ((gnuplot-info-display 'frame)) + (if gnuplot-keywords-pending ; + (gnuplot-setup-info-look)) + (gnuplot-info-lookup-symbol (widget-value widget) + 'gnuplot-mode)))) + + +;;; just about done + +(provide 'gnuplot-gui) +;;;============================================================================ +;;; +;;; gnuplot-gui.el ends here diff --git a/util/gnuplot-mode.0.6.0/gnuplot.el b/util/gnuplot-mode.0.6.0/gnuplot.el new file mode 100644 index 000000000..f1022cbaa --- /dev/null +++ b/util/gnuplot-mode.0.6.0/gnuplot.el @@ -0,0 +1,2576 @@ +;;;; gnuplot.el -- drive gnuplot from within emacs + +;; Copyright (C) 1998 Phil Type and Bruce Ravel, 1999-2002 Bruce Ravel + +;; Author: Bruce Ravel and Phil Type +;; Maintainer: Bruce Ravel +;; Created: June 28 1998 +;; Updated: December 13, 2002 +;; Version: 0.6.0 +;; Keywords: gnuplot, plotting + +;; This file is not part of GNU Emacs. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This lisp script is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +;; +;; Permission is granted to distribute copies of this lisp script +;; provided the copyright notice and this permission are preserved in +;; all copies. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, you can either send email to this +;; program's maintainer or write to: The Free Software Foundation, +;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; send bug reports to the author (ravel@phys.washington.edu) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Commentary: +;; +;; This is a major mode for composing gnuplot scripts and displaying +;; their results using gnuplot. It is optimized for use with gnuplot +;; 3.7 or one of the later patchlevels of "version 3.6". It should +;; also work very handily with version 3.5. This mode offers several +;; tools to help you compose your scripts, including syntax +;; colorization using either font-lock or hilit19, a syntax table +;; appropriate to gnuplot, key bindings, pull-down menus, indentation, +;; keyword completions and variable customization using the Custom +;; package. Once the script is composed, there are several function +;; for sending some or all of the script to gnuplot. The interaction +;; with the gnuplot process is within a comint buffer. +;; +;; C-c C-l send current line to gnuplot +;; C-c C-v send current line to gnuplot and move forward 1 line +;; C-c C-r send current region to gnuplot +;; C-c C-b send entire buffer to gnuplot +;; C-c C-f send a file to gnuplot +;; C-c C-i insert filename at point +;; C-c C-n negate set option on current line +;; C-c C-c comment region +;; C-c C-o set arguments for command at point +;; S-mouse-2 set arguments for command under mouse cursor +;; C-c C-h read the gnuplot info file +;; C-c C-e show-gnuplot-buffer +;; C-c C-k kill gnuplot process +;; C-c C-u submit a bug report about gnuplot-mode +;; M-tab or M-ret complete keyword before point +;; ret newline and indent +;; tab indent current line +;; +;; Gnuplot-mode adds two key bindings to the comint buffer: +;; M-C-p plot the current script buffer line-by-line +;; M-C-f save the current script buffer and load that file +;; +;; These two functions are useful for starting up gnuplot-mode. +;; +;; M-x gnuplot-mode +;; start gnuplot-mode in the current buffer +;; +;; M-x gnuplot-make-buffer +;; open a new buffer (which is not visiting a file) and start +;; gnuplot-mode in that buffer +;; +;; --------------------------------------------------------------------- +;; +;; Other lisp files used by gnuplot.el +;; +;; info-look.el (comes with GNU Emacs 20): +;; This provides the interface to the gnuplot-info file and provides +;; on-line help and keyword completion functionality. The version +;; of info-look.el that comes with version 20.2 of Emacs contains a +;; bug that will impede its interaction with the gnuplot info file. +;; You should use the version from the gnuplot-mode homepage +;; instead. info-look is not distributed with XEmacs and so should +;; be installed along with gnuplot-mode when using XEmacs. +;; +;; gnuplot-gui.el (written by Bruce): +;; Defines the GUI interface for setting setting arguments to +;; gnuplot options. This uses the widget package extensively. +;; +;; --------------------------------------------------------------------- +;; +;; This mode was inspired by the original gnu-plot-mode by Gershon +;; Elber, which is distributed with gnuplot itself and which dates +;; back to the early 90's. Although this mode encompasses the +;; functionality of the original, the two share no code and the +;; current implementation takes advantage of many features of modern +;; versions of emacs and adheres (or so I intend) to the major mode +;; conventions described in the emacs-lisp reference for version 19 +;; and later. +;; +;; --------------------------------------------------------------------- +;; +;; Installation +;; ============ +;; +;; A recent version of this file can be found at +;; http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/ +;; +;; To autoload gnuplot-mode on any file with gp extension, put this in +;; your .emacs file +;; (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t) +;; (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t) +;; +;; Something like +;; (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)) +;; auto-mode-alist)) +;; is useful for having files ending in .gp start up in gnuplot-mode. +;; +;; Something like +;; (global-set-key [(f9)] 'gnuplot-make-buffer) +;; may be useful. This binds f9 to the function that opens a scratch +;; buffer (i.e. one that is not visiting a file) in gnuplot-mode. +;; This is handy for your quick 'n' dirty plotting chores. +;; +;; To use the `gnuplot-info-lookup-symbol' function, the file +;; gnuplot.info MUST be installed somewhere that info can find it. +;; This means you must either: +;; 1. Copy gnuplot.info to the normal info directory or +;; 2. Make sure info can find gnuplot.info by putting this in your +;; .emacs file: +;; (setenv "INFOPATH" +;; (concat (getenv "INFOPATH") ":" +;; (expand-file-name "/path/to/file"))) +;; where "/path/to/file" is the location of gnuplot.info +;; +;; This had been tested extensively with Emacs 19.34 and 20.2 and +;; XEmacs 20.3 and in a limited manner with Emacs 19.30 and XEmacs +;; 19.14. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; History: +;; +;; 0.1 Jun 25 1998 Finished with initial release. +;; 0.2 Sep 4 1998 Added filename insertion, indentation, and +;; colorization/completion in comint buffer.
+;; 0.2a Sep 11 1998 made `indent-line-function' buffer-local (whoops!) +;; and fixed some stuff in the installation script
+;; 0.3 Sep 12 1998 include insertions menu
+;; 0.3a Sep 14 1998 fixed bug finding info file if missing, fixed bug +;; starting font-lock, fixed bug re overwriting files in +;; installation script
+;; 0.3b Sep 15 1998 Added (require 'info) to `(eval-and-compile' +;; clause, Added (kill-all-local-variables) to `gnuplot-mode', +;; altered order of:- +;; (provide 'gnuplot) +;; (run-hooks 'gnuplot-load-hook) +;; at the end of the file in case something in the load hook +;; requires gnuplot (oh not that old one again...), added +;; `gnuplot-comint-setup-hook', corrected `gnuplot-mark-active' +;; which caused an error to be raised by (mark) when the mark +;; was inactive Some changes to font-lock rules &
+;; 0.4 Nov 14 1998
Use info-look for info interface. No +;; change to gnuplot-mode user interface, but cleaner code. +;; With info-look, the help funcion works regardless of the +;; version number of gnuplot. Also, `gnuplot-keywords' (used +;; for help, keyword-completion, and hilit19 highlighting) is +;; now generated automatically. +;; 0.4a Nov 18 1998
info-look leaves a couple of really useless +;; buffers lying around so I cleaned them up. Also fixed +;; font-lock rules so that things in quotes get highlighted +;; correctly and the surrounding text is unhighlighted. Fixed +;; up font-lock rules for plot and splot. Added +;; `gnuplot-send-line-and-forward' as suggested by . +;; 0.4b Nov 21 1998
added toolbar for xemacs -- see file +;; gnuplot-toolbar.el. fixed error message in plot line +;; function when line is empty. option added to display the +;; comint buffer showing the gnuplot process in a separate +;; frame +;; 0.4c Minor stuff: Nov 30 1998
fixed highlighting in comint +;; buffer. fixed frame behavior. added "[:]" to range +;; insertions. added :link to defgroup. Dec 1 1998
fixed +;; some mismatched defcustoms. added a few lines to suppress +;; some compile-time warnings. Dec 3 1998
Fixed behavior +;; of filename insertion function. Added more :links to +;; defgroup. +;; 0.4d Dec 6 1998
Added function gnuplot-setup-info-look and +;; variable gnuplot-info-hook to handle various versions of the +;; gnuplot info file. +;; 0.4e Dec 12 1998
Split up gnuplot-insertions-menu for ease of +;; custimization, put menubar initialization in a function. +;; 0.4f Dec 14 1998
defcustom the insertions submenus, add +;; gnuplot-insertion-menu-flag, intelligent Makefile knows +;; which info-look to compile +;; 0.5 Dec 27 1998
wrote initial draft of gnuplot-gui.el, +;; included it in insertions menu and in `gnuplot-insert'. +;; Negate option function, bound to C-c C-n. Dec 29 1998
+;; C-c C-h with no response goes to Commands menu. Transparent +;; toolbar icons. Replace kw-compl with a simple completion +;; function. Put gnuplot-toolbar code in gnuplot.el. +;; 0.5a Jan 23 1999
send file uses the load command. add +;; gnuplot-plot-from-comint and +;; gnuplot-save-and-plot-from-comint and keybindings in the +;; comint buffer. do (process-kill-without-query +;; gnuplot-process nil). `gnuplot-negate-option' checks if set +;; option has a negated form. +;; 0.5b `gnuplot-kill-gnuplot-buffer' made more robust. fixed a bug +;; in `gnuplot-plot-from-comint'. fixed description of +;; gnuplot-faces group. +;; 0.5c update copyright information, update gpelcard +;; 0.5d Mar 20 1999
adopt installation materials from . Add +;; some support for hidden3d. Use constants in types alists in +;; gui. Various other minor improvements to the types alists. +;; 0.5e Apr 6 1999
at the suggestion of I did away with the +;; gnuplot-which-highlight variable and revamped how +;; colorization gets turned on. This is a bit tricky since I +;; want it to work with font-lock under emacs and xemacs and +;; with hilit19. Apr 11 1999
insert space at end of +;; unique completion. add a few GUI types, rewrite some stuff +;; in the GUI interface. primitive support for plot, splot, +;; and fit. Fixed completion in file widget. +;; 0.5f May 15 1999
Add pgnuplot.c and Win9x install instructions +;; to the distribution. Fixed a defface bug. Added +;; `gnuplot-keywords-when' allowing deferral of parsing the +;; info file. +;; 0.5g May 27 1999
Fixed font-locking of strings and +;; comments. Figure out gnuplot-version number from startup +;; message and set `gnuplot-echo-command-line-flag' +;; accordingly. Added `gnuplot-program-version' variable. +;; Check that font-lock is actually a feature, as suggested by +;; +;; 0.5h Aug 15 1999
Added `gnuplot-determine-gnuplot-version' so +;; that the gnuplot version number and `comint-process-echos' +;; actually get set correctly. Actually, the first time +;; something is plotted, the echoing might not work, but the +;; second time it will. +;; 0.5i Sep 2 1999
Once again changed how +;; `comint-process-echos' gets set. Maybe I got it right this +;; time? Also fixed certain situations where the info file +;; did notget properly loaded (insertion with info toggle on +;; and info button in GUI). +;; 0.5j Sep 9 1999
Do a more robust check for the gnuplot +;; process before killing the gnuplot buffer, as suggested by +;; . +;; 0.5k Sep 22 1999
make `gnuplot-send-line-and-forward' skip +;; over blank and comment lines as suggested by . Jan 10 +;; 2000 Bound C-c C-j to `gnuplot-forward-script-line'. +;; 0.5l Nov 16 2000
support for pm3d in gnuplot-gui and in plot +;; options insertions menu. mentioned pm3d in gpelcard. gui +;; support for x11 pm3d and vgagl terms. +;; `gnuplot-negate-option' works with new syntax. +;; 0.5m Nov 17 2000
add colorization and gui support for new +;; commands in 3.8. gui support for emf term. gui support for +;; new "set style" syntax. much better scheme for determining +;; gnuplot version number + make better use of it. +;; 0.5n Jan 4 2001
corrected a serious problem interacting with +;; speedbar +;; 0.5o skipped +;; 0.5p Mar 14 2001
fixed problem with toolbar creation and +;; speedbar clicking +;; 0.5q May 30 2001
added font-lock bindings for words associated +;; with plotting +;; 0.5r Oct 17 2001
Incorporate two suggestions by , bind +;; C-c C-c to comment-region and C-c C-o to the GUI, also make +;; C-c C-l respect continuation lines +;; April 12, 2002
added feature to trim length of gnuplot +;; process buffer +;; 0.5s Jun 7 2002
Yet again changed how `comint-process-echos' +;; gets set. It really needs to be nil on NTEmacs 21.1 or +;; comint gets stuck in an infinate loop. +;; 0.5t Sep 16 2002
Fixed a problem with C-c C-v jumping +;; forward 2 lines at a time +;; 0.6.0 Dec 13 2002
Changed numbering scheme to accommodate +;; gnuplot packaging requirements +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Acknowledgements: +;; David Batty (numerous corrections) +;; Laurent Bonnaud (suggestions regarding font-lock rules) +;; Markus Dickebohm (suggested `gnuplot-send-line-and-forward') +;; Stephen Eglan (suggested the use of info-look, +;; contributed a bug fix regarding shutting +;; down the gnuplot process, improvement to +;; `gnuplot-send-line-and-forward') +;; Robert Fenk (suggested respecting continuation lines) +;; Michael Karbach (suggested trimming the gnuplot process buffer) +;; Alex Chan Libchen (suggested font-lock for plotting words) +;; Kuang-Yu Liu (pointed out buggy dependence on font-lock) +;; Hrvoje Niksic (help with defcustom arguments for insertions) +;; Andreas Rechtsteiner (pointed out problem with C-c C-v) +;; Michael Sanders (help with the info-look interface) +;; Jinwei Shen (suggested functionality in comint buffer) +;; Michael M. Tung (prompted me to add pm3d support) +;; Holger Wenzel (suggested using `gnuplot-keywords-when') +;; Wolfgang Zocher (pointed out problem with gnuplot-mode + speedbar) +;; and especially to Lars Hecking for including gnuplot-mode +;; with the gnuplot 3.7-beta distribution and for providing me with +;; installation materials +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; To Do: +;; +;; 1. Since `gnuplot-display-process' can be nil, it would be +;; handy to have a function to put on +;; `gnuplot-after-plot-buffer-hook' to check and see if the script +;; executed properly. Alas I am not sure how gnuplot signals its +;; errors. +;; 2. improve plot, splot, fit in GUI +;; 3. interface to setting bind command using `read-key-sequence'. +;; this is a pain because the nomenclature is really different in +;; gnuplot than in `read-key-sequence' +;; +;;; Bugs: +;; +;; -- indentation is not quite right (but close) +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Code: + +(require 'comint) +(require 'easymenu) + + +;;; --- variable definitions + eval-and-compile clauses + +;; handle defcustom +(eval-and-compile + (condition-case () + (require 'custom) + (error nil)) + (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) + nil ;; We've got what we needed + ;; We have the old custom-library, hack around it! + (if (fboundp 'defgroup) + nil + (defmacro defgroup (&rest args) + nil)) + (if (fboundp 'defface) + nil + (defmacro defface (var values doc &rest args) + (` (progn + (defvar (, var) (quote (, var))) + ;; To make colors for your faces you need to set your .Xdefaults + ;; or set them up ahead of time in your .emacs file. + (make-face (, var)) + )))) + (if (fboundp 'defcustom) + nil + (defmacro defcustom (var value doc &rest args) + (` (defvar (, var) (, value) (, doc))))))) + +;; (eval-and-compile +;; (condition-case () +;; (require 'kw-compl) +;; (error nil))) +(eval-and-compile ;; + (require 'info)) +(eval-and-compile + (condition-case () + (require 'info-look) + (error nil))) +;; this just gets rid of an annoying compile time error message +;; (eval-when-compile +;; (defun gnuplot-dummy ()) +;; (defalias 'hilit-set-mode-patterns 'gnuplot-dummy)) + + +(defconst gnuplot-xemacs-p (string-match "XEmacs" (emacs-version))) +(defconst gnuplot-ntemacs-p (string-match "msvc" (emacs-version))) +(defvar gnuplot-three-eight-p "") + +(defconst gnuplot-maintainer "Bruce Ravel") +(defconst gnuplot-maintainer-email "ravel@phys.washington.edu") +(defconst gnuplot-maintainer-url + "http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/") +(defconst gnuplot-version "0.6.0") + +(defgroup gnuplot nil + "Gnuplot-mode for Emacs." + :prefix "gnuplot-" + :group 'processes + :group 'applications + :group 'local + :link '(emacs-library-link :tag "Lisp File" "gnuplot.el") + :link '(url-link :tag "Homepage" + "http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/") + :link '(custom-manual "(gnuplot)Top") + :link '(emacs-commentary-link :tag "Commentary" "gnuplot.el") ) +(defgroup gnuplot-insertions nil + "Insert commands into gnuplot-scripts from a pull-down menu." + :prefix "gnuplot-insertions-" + :group 'gnuplot) +(defgroup gnuplot-hooks nil + "Hook variables used by `gnuplot-mode'." + :prefix "gnuplot-" + :group 'gnuplot) + +(defcustom gnuplot-mode-hook nil + "*Hook run when `gnuplot-mode' is entered." + :group 'gnuplot-hooks + :type 'hook) +(defcustom gnuplot-load-hook nil + "*Hook run when gnuplot.el is first loaded." + :group 'gnuplot-hooks + :type 'hook) +(defcustom gnuplot-after-plot-hook nil + "*Hook run after gnuplot plots something. +This is the last thing done by the functions for plotting a line, a +region, a buffer, or a file." + :group 'gnuplot-hooks + :type 'hook) +(defcustom gnuplot-info-hook nil + "*Hook run before setting up the info-look interface. +This hook is necessary to handle inconsistencies in versions of and +sources of the gnuplot info file. If Gnuplot-mode can find the info +file generated from the 3.6beta patchlevel 347 (or later) release of +Gnuplot, then this hook probably is not necessary. Some versions of +the info file may have a General Index session, which can be used by +info-look. In that case the following (or something similar with the +value of `info-lookup-symbol-alist' altered appropriately) should be +placed in the .emacs file. + +Emacs version 20.2 ships with a different version of info-look that +does 20.3. If you use any version of Emacs 19, you must use the +version from 20.2. Any version of XEmacs 20 or 21 should use the +version from 20.3 but can use either. XEmacs 19 should use the +version 20.2. + +For the newer version of info-look, do this: + + (add-hook \'gnuplot-info-hook + \'(lambda () + (let ((elem (assoc \'gnuplot-mode info-lookup-alist))) + (delete elem info-lookup-alist) + (info-lookup-maybe-add-help + :mode 'gnuplot-mode :topic 'symbol + :regexp \"[a-zA-Z][_a-zA-Z0-9]*\" + :doc-spec '((\"(gnuplot)General Index\" nil + \"[_a-zA-Z0-9]+\")))))) + +For the older version of info-look, do this: + + (add-hook \'gnuplot-info-hook + \'(lambda () + (let ((elem (assoc \'gnuplot-mode info-lookup-alist))) + (delete elem info-lookup-alist) + (setq info-lookup-alist + (append info-lookup-alist + \'((gnuplot-mode + \"[a-zA-Z][_a-zA-Z0-9]*\" nil + ((\"(gnuplot)General Index\" nil + \"[_a-zA-Z0-9]+\" )))))))))" + :group 'gnuplot-hooks + :type 'hook) +;; comint hook suggested by +(defcustom gnuplot-comint-setup-hook nil + "*Hook run after setting up the gnuplot buffer in comint mode. +So the configuration can be customised by the user." + :group 'gnuplot-hooks + :type 'hook) +(defvar gnuplot-recently-sent nil + "This is a record of the most recent kind of text sent to gnuplot. +It takes as its value nil, 'line, 'region, 'buffer, or 'file. It is +useful for functions included in `gnuplot-after-plot-hook'.") +(make-variable-buffer-local 'gnuplot-recently-sent) + +(defcustom gnuplot-program "gnuplot" + "*The name of the gnuplot executable." + :group 'gnuplot + :type 'string) +(defvar gnuplot-program-version nil + "Version number of gnuplot. +This is found using `gnuplot-determine-gnuplot-version") +(defcustom gnuplot-process-name "gnuplot" + "Name given to the gnuplot buffer and process." + :group 'gnuplot + :type 'string) +(defvar gnuplot-buffer nil + "*The name of the buffer displaying the gnuplot process.") +(defvar gnuplot-process nil + "Variable holding the process handle.") +(defvar gnuplot-process-frame nil + "The frame for displaying the gnuplot process. +This is used when `gnuplot-display-process' is equal to 'frame.") +(defvar gnuplot-comint-recent-buffer nil + "The most recently plotted gnuplot script buffer. +This is used by the function that plot from the comint buffer. It is +reset every time something is plotted from a script buffer.") + +(defcustom gnuplot-gnuplot-buffer "plot.gp" + "*The name of the gnuplot scratch buffer opened by 'gnuplot-make-buffer'." + :group 'gnuplot + :type 'string) + +(defcustom gnuplot-display-process 'window + "This controls how the gnuplot process buffer is displayed. +The values are + 'frame display gnuplot process in a separate frame + 'window display gnuplot process in this frame but in another window + nil `gnuplot-process' is in the current frame but not displayed" + :group 'gnuplot + :type '(radio (const :tag "Separate frame" frame) + (const :tag "Separate window" window) + (const :tag "Not displayed" nil))) +(defcustom gnuplot-info-display 'window + "*Determines how `gnuplot-info-lookup-symbol' displays the info file. +The values are + 'frame display info file in a separate frame + 'window display info file in another window + nil display info file in the current window" + :group 'gnuplot + :type '(radio (const :tag "Separate frame" frame) + (const :tag "Separate window" window) + (const :tag "This window" nil))) + +(defcustom gnuplot-echo-command-line-flag (not gnuplot-ntemacs-p) + "*This sets the fall-back value of `comint-process-echos'. +If `gnuplot-mode' cannot figure out what version number of gnuplot +this is, then the value of this variable will be used for +`comint-process-echos'. It seems that gnuplot 3.5 wants this to be +nil and 3.7 wants it to be t. If lines that you send to gnuplot from +the `gnuplot-mode' buffer are not appearing at the gnuplot prompt in +the process buffer, try toggling it. Also see the document string for +`comint-process-echos'. If you change this, kill the gnuplot process +and start it again." + :group 'gnuplot + :type 'boolean) +(defcustom gnuplot-insertions-show-help-flag nil + "*Non-nil means to display certain help messages automatically. +These messages are shown after menu insertion of gnuplot commands." + :group 'gnuplot-insertions + :type 'boolean) + +(defcustom gnuplot-delay 0.01 + "*Amount of time to delay before sending a new line to gnuplot. +This is needed so that the the line is not written in the gnuplot +buffer in advance of its prompt. Increase this number if the +prompts and lines are displayed out of order." + :group 'gnuplot + :type 'number) +(defcustom gnuplot-buffer-max-size 1000 + "*The maximum size in lines of the gnuplot process buffer. +Each time text is written in the gnuplot process buffer, lines are +trimmed from the beginning of the buffer so that the buffer is this +many lines long. The lines are deleted after the most recent lines +were interpretted by gnuplot. Setting to 0 turns off this feature +(i.e. no lines get trimmed)." + :group 'gnuplot + :type 'integer) +(defcustom gnuplot-quote-character "\'" + "*Quotation character used for inserting quoted strings. +Gnuplot can use single or double quotes. If you prefer to have the +filename insertion function never insert quotes for you, set this +to the empty string." + :group 'gnuplot + :type '(radio (const :tag "double quote" "\"") + (const :tag "single quote" "\'") + (const :tag "none" "" ))) +;; (defcustom gnuplot-gnuplot-version nil +;; "*Force gnuplot-mode to behave for this version of gnuplot." +;; :group 'gnuplot +;; :type '(radio (const :tag "unspecified" nil) +;; (const :tag "3.8 or newer" "3.8") +;; (const :tag "3.7 or older" "3.7"))) + +(defvar gnuplot-info-frame nil) +(defvar gnuplot-info-nodes '()) + +(defvar gnuplot-first-call t) + +;; with info-look, there is no need to carry this list around -- it +;; can be generated on the fly appropriate to the currently installed +;; version of gnuplot.info +(defvar gnuplot-keywords nil + "A list of keywords used in GNUPLOT. +These are set by `gnuplot-set-keywords-list' from the values in +`info-lookup-cache'.") +(defvar gnuplot-keywords-pending t ;; + "A boolean which gets toggled when the info file is probed.") +(defcustom gnuplot-keywords-when 'deferred ;; 'immediately + "This variable controls when the info file is parsed. +The choices are immediately upon starting gnuplot-mode or the first +time that data is needed. If you use hilit19, then the info file is +parsed immediately regardless of the value of this variable. But +you're not using that musty old thing, are you..." + :group 'gnuplot + :type + '(radio (const :tag "Parse info file when gnuplot-mode starts" immediately) + (const :tag "Parse info file the first time it is needed" deferred))) + +(defgroup gnuplot-faces nil + "Text faces used by gnuplot-mode." + :prefix "gnuplot-" + :group 'gnuplot) + +(cond ((and (featurep 'custom) (fboundp 'custom-declare-variable)) + (defface gnuplot-prompt-face '((((class color)) + (:foreground "firebrick")) + (t + (:bold t :underline t))) + "Face used for the prompt in the gnuplot process buffer." + :group 'gnuplot-faces)) + (t + (make-face 'gnuplot-prompt-face) + (set-face-foreground 'gnuplot-prompt-face "firebrick"))) + + +;;; --- key bindings and menus + +(defvar gnuplot-mode-map nil) +(if gnuplot-mode-map + () + (setq gnuplot-mode-map (make-sparse-keymap)) + (define-key gnuplot-mode-map "\C-c\C-b" 'gnuplot-send-buffer-to-gnuplot) + (define-key gnuplot-mode-map "\C-c\C-c" 'comment-region) ; + (define-key gnuplot-mode-map "\C-c\C-o" 'gnuplot-gui-set-options-and-insert) + (define-key gnuplot-mode-map "\C-c\C-d" 'gnuplot-show-version) + (define-key gnuplot-mode-map "\C-c\C-e" 'gnuplot-show-gnuplot-buffer) + (define-key gnuplot-mode-map "\C-c\C-f" 'gnuplot-send-file-to-gnuplot) + (define-key gnuplot-mode-map "\C-c\C-h" 'gnuplot-info-lookup-symbol) + (define-key gnuplot-mode-map "\C-c\C-i" 'gnuplot-insert-filename) + (define-key gnuplot-mode-map "\C-c\C-j" 'gnuplot-forward-script-line) + (define-key gnuplot-mode-map "\C-c\C-k" 'gnuplot-kill-gnuplot-buffer) + (define-key gnuplot-mode-map "\C-c\C-l" 'gnuplot-send-line-to-gnuplot) + (define-key gnuplot-mode-map "\C-c\C-n" 'gnuplot-negate-option) + (define-key gnuplot-mode-map "\C-c\C-p" 'gnuplot-show-gnuplot-version) + (define-key gnuplot-mode-map "\C-c\C-r" 'gnuplot-send-region-to-gnuplot) + ;;(define-key gnuplot-mode-map "\C-c\C-t" 'gnuplot-gui-swap-simple-complete) + (define-key gnuplot-mode-map "\C-c\C-u" 'gnuplot-bug-report) + (define-key gnuplot-mode-map "\C-c\C-v" 'gnuplot-send-line-and-forward) + (define-key gnuplot-mode-map "\C-c\C-z" 'gnuplot-customize) + (define-key gnuplot-mode-map "\M-\r" 'gnuplot-complete-keyword) + (define-key gnuplot-mode-map "\M-\t" 'gnuplot-complete-keyword) + (define-key gnuplot-mode-map "\C-i" 'indent-for-tab-command) + (define-key gnuplot-mode-map "\C-m" 'newline-and-indent) + ;;(define-key gnuplot-mode-map "\C-m" 'reindent-then-newline-and-indent) + ;;(if (featurep 'kw-compl) + ;; (define-key gnuplot-mode-map "\M-\r" 'kw-compl-abbrev))) + (cond (gnuplot-xemacs-p + (define-key gnuplot-mode-map '(shift button2) + 'gnuplot-gui-mouse-set)) + (t + (define-key gnuplot-mode-map [S-mouse-2] + 'gnuplot-gui-mouse-set))) ) + +(defvar gnuplot-mode-menu nil) +(defvar gnuplot-menu nil + "Menu for `gnuplot-mode'.") +(setq gnuplot-menu + '("Gnuplot" + ["Send line to gnuplot" gnuplot-send-line-to-gnuplot t] + ["Send line & move forward" gnuplot-send-line-and-forward (not (eobp))] + ["Send region to gnuplot" gnuplot-send-region-to-gnuplot + (gnuplot-mark-active)] + ["Send buffer to gnuplot" gnuplot-send-buffer-to-gnuplot t] + ["Send file to gnuplot" gnuplot-send-file-to-gnuplot t] + "---" + ["Insert filename at point" gnuplot-insert-filename t] + ["Negate set option" gnuplot-negate-option t] + ;;["Set key binding" gnuplot-set-binding gnuplot-three-eight-p] + ["Keyword help" gnuplot-info-lookup-symbol + (or gnuplot-keywords gnuplot-keywords-pending)] + ["Show gnuplot process buffer" gnuplot-show-gnuplot-buffer t] + ["Set arguments at point" gnuplot-gui-set-options-and-insert + (fboundp 'gnuplot-gui-set-options-and-insert)] + ["Swap plot/splot/fit lists in GUI" gnuplot-gui-swap-simple-complete + (fboundp 'gnuplot-gui-swap-simple-complete)] + "---" + ["Customize gnuplot" gnuplot-customize t] + ["Submit bug report" gnuplot-bug-report t] + ["Show gnuplot-mode version" gnuplot-show-version t] + ["Show gnuplot version" gnuplot-show-gnuplot-version t] + "---" + ["Kill gnuplot" gnuplot-kill-gnuplot-buffer t] + )) + + +;;; --- insertions variables and menus + +;;(load-library "gnuplot-insertions") +(defvar gnuplot-mode-insertions-menu nil) +(defvar gnuplot-insertions-menu nil + "Menu for insertions in `gnuplot-mode'. + +The insertions menu is composed of several sub-menus. The variables +describing the sub-menus are: + `gnuplot-insertions-adornments' + `gnuplot-insertions-plot-options' + `gnuplot-insertions-terminal' + `gnuplot-insertions-x-axis' + `gnuplot-insertions-y-axis' + `gnuplot-insertions-z-axis' + `gnuplot-insertions-x2-axis' + `gnuplot-insertions-y2-axis' + `gnuplot-insertions-parametric-plots' + `gnuplot-insertions-polar-plots' + `gnuplot-insertions-surface-plots' +These variables can be customized by the user. For example, there are +many terminal types which are not in the terminal submenu but which +may be compiled into a user's copy of gnuplot. + +Each of these variables is a list whose first element is a string and +all the rest are vectors as described in the document string for +`easy-menu-define'. The callback used throughout these menus is +`gnuplot-insert' which inserts the appropriate set expression and, +optionally, looks up that item in the gnuplot info file. + +The easiest way to customize the submenus is to use the custom +package. Just type \\[gnuplot-customize] and follow your nose. + +You can also add new items to any of these sub-menus by adding to the +`gnuplot-load-hook' in your .emacs file. Here is an example of adding +the \"regis\" terminal type to the terminal sub-menu: + + (add-hook + 'gnuplot-load-hook + '(lambda () + (setq gnuplot-insertions-terminal + (append gnuplot-insertions-terminal + (list + [\"regis\" + (gnuplot-insert \"set terminal regis\") + t])))))") + +(defvar gnuplot-insertions-top () + "Top part of insertions menu. +See the document string for `gnuplot-insertions-menu'") + +(defcustom gnuplot-insertions-menu-flag t + "*Non-nil means to place the insertion menu in the menubar. +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type 'boolean) + +(defcustom gnuplot-insertions-adornments ; this is icky... + (if gnuplot-three-eight-p + '("adornments" + ["arrow" (gnuplot-insert "set arrow ") t] + ["bar" (gnuplot-insert "set bar") t] + ["border" (gnuplot-insert "set border") t] + ["boxwidth" (gnuplot-insert "set boxwidth ") t] + ["format" (gnuplot-insert "set format ") t] + ["grid" (gnuplot-insert "set grid") t] + ["key" (gnuplot-insert "set key ") t] + ["label" (gnuplot-insert "set label ") t] + ["pointsize" (gnuplot-insert "set pointsize ") t] + ["samples" (gnuplot-insert "set samples ") t] + ["size" (gnuplot-insert "set size ") t] + ["style" (gnuplot-insert "set style ") t] + ["tics" (gnuplot-insert "set tics ") t] + ["timefmt" (gnuplot-insert "set timefmt ") t] + ["timestamp" (gnuplot-insert "set timestamp ") t] + ["title" (gnuplot-insert "set title ") t] + ["zeroaxis" (gnuplot-insert "set zeroaxis") t] ) + '("adornments" + ["data style" (gnuplot-insert "set data style ") t] + ["function style" (gnuplot-insert "set function style ") t] + ["arrow" (gnuplot-insert "set arrow ") t] + ["bar" (gnuplot-insert "set bar") t] + ["border" (gnuplot-insert "set border") t] + ["boxwidth" (gnuplot-insert "set boxwidth ") t] + ["format" (gnuplot-insert "set format ") t] + ["grid" (gnuplot-insert "set grid") t] + ["key" (gnuplot-insert "set key ") t] + ["label" (gnuplot-insert "set label ") t] + ["pointsize" (gnuplot-insert "set pointsize ") t] + ["samples" (gnuplot-insert "set samples ") t] + ["size" (gnuplot-insert "set size ") t] + ["tics" (gnuplot-insert "set tics ") t] + ["timefmt" (gnuplot-insert "set timefmt ") t] + ["timestamp" (gnuplot-insert "set timestamp ") t] + ["title" (gnuplot-insert "set title ") t] + ["zeroaxis" (gnuplot-insert "set zeroaxis") t] )) + "Adornments submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + + +(defcustom gnuplot-insertions-plot-options + '("plot options" + ["autoscale" (gnuplot-insert "set autoscale ") t] + ["clip" (gnuplot-insert "set clip ") t] + ["encoding" (gnuplot-insert "set encoding ") t] + ["locale" (gnuplot-insert "set locale ") t] + ["logscale" (gnuplot-insert "set logscale ") t] + ["multiplot" (gnuplot-insert "set multiplot") t] + ["missing" (gnuplot-insert "set missing \"\"") t] + ["palette" (gnuplot-insert "set palette ") t] ; + ["pm3d" (gnuplot-insert "set pm3d ") t] + ["offsets" (gnuplot-insert "set offsets ") t] + ["output" (gnuplot-insert "set output ") t] + ["zero" (gnuplot-insert "set zero ") t] ) + "Plot options submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-terminal + '("terminal" + ["eepic" (gnuplot-insert "set terminal eepic") t] + ["fig" (gnuplot-insert "set terminal fig") t] + ["gpic" (gnuplot-insert "set terminal gpic") t] + ["latex" (gnuplot-insert "set terminal latex") t] + ["linux" (gnuplot-insert "set terminal linux") t] + ["pbm" (gnuplot-insert "set terminal pbm") t] + ["png" (gnuplot-insert "set terminal png") t] + ["postscript" (gnuplot-insert "set terminal postscript") t] + ["pslatex" (gnuplot-insert "set terminal pslatex") t] + ["table" (gnuplot-insert "set terminal table") t] + ["tek40xx" (gnuplot-insert "set terminal tek40xx") t] + ["tkcanvas" (gnuplot-insert "set terminal tkcanvas") t] + ["tpic" (gnuplot-insert "set terminal tpic") t] + ["vgagl" (gnuplot-insert "set terminal vgagl") t] ; for pm3d patch + ["vttek" (gnuplot-insert "set terminal vttek") t] + ["x11" (gnuplot-insert "set terminal x11") t] ) + "Terminal submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-x-axis + '("x-axis" + ["xdata" (gnuplot-insert "set xdata ") t] + ["xlabel" (gnuplot-insert "set xlabel ") t] + ["xrange" (gnuplot-insert "set xrange [:]") t] + ["xtics" (gnuplot-insert "set xtics ") t] + ["mxtics" (gnuplot-insert "set mxtics ") t] + ["xzeroaxis" (gnuplot-insert "set xzeroaxis ") t] + ["xdtics" (gnuplot-insert "set xdtics ") t] + ["xmtics" (gnuplot-insert "set xmtics ") t]) + "X-axis submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-x2-axis + '("x2-axis" + ["x2data" (gnuplot-insert "set xdata ") t] + ["x2label" (gnuplot-insert "set xlabel ") t] + ["x2range" (gnuplot-insert "set xrange [:]") t] + ["x2tics" (gnuplot-insert "set xtics ") t] + ["mx2tics" (gnuplot-insert "set mxtics ") t] + ["x2zeroaxis" (gnuplot-insert "set xzeroaxis ") t] + ["x2dtics" (gnuplot-insert "set xdtics ") t] + ["x2mtics" (gnuplot-insert "set xmtics ") t]) + "X2-axis submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-y-axis + '("y-axis" + ["ydata" (gnuplot-insert "set ydata ") t] + ["ylabel" (gnuplot-insert "set ylabel ") t] + ["ymtics" (gnuplot-insert "set ymtics ") t] + ["yrange" (gnuplot-insert "set yrange [:]") t] + ["ytics" (gnuplot-insert "set ytics ") t] + ["yzeroaxis" (gnuplot-insert "set yzeroaxis ") t] + ["ydtics" (gnuplot-insert "set ydtics ") t] + ["mytics" (gnuplot-insert "set mytics ") t]) + "Y-axis submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + +(defcustom gnuplot-insertions-y2-axis + '("y2-axis" + ["y2data" (gnuplot-insert "set ydata ") t] + ["y2label" (gnuplot-insert "set ylabel ") t] + ["y2range" (gnuplot-insert "set yrange [:]") t] + ["y2tics" (gnuplot-insert "set ytics ") t] + ["my2tics" (gnuplot-insert "set mytics ") t] + ["y2zeroaxis" (gnuplot-insert "set yzeroaxis ") t] + ["y2mtics" (gnuplot-insert "set ymtics ") t] + ["y2dtics" (gnuplot-insert "set ydtics ") t]) + "Y2-axis submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + + +(defcustom gnuplot-insertions-z-axis + '("z-axis" + ["zdata" (gnuplot-insert "set zdata ") t] + ["zlabel" (gnuplot-insert "set zlabel ") t] + ["zrange" (gnuplot-insert "set zrange [:]") t] + ["ztics" (gnuplot-insert "set ztics ") t] + ["mztics" (gnuplot-insert "set mztics ") t] + ["zdtics" (gnuplot-insert "set zdtics ") t] + ["zmtics" (gnuplot-insert "set zmtics ") t] ) + "Z-axis submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-parametric-plots + '("parametric plots" + ["parametric" (gnuplot-insert "set parametric") t] + ["isosamples" (gnuplot-insert "set isosamples ") t] + ["dummy" (gnuplot-insert "set dummy ") t] + ["trange" (gnuplot-insert "set trange [:]") t] + ["urange" (gnuplot-insert "set urange [:]") t] + ["vrange" (gnuplot-insert "set vrange [:]") t] ) + "Parametric plots submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-polar-plots + '("polar plots" + ["polar" (gnuplot-insert "set polar") t] + ["angles" (gnuplot-insert "set angles ") t] + ["rrange" (gnuplot-insert "set rrange [:]") t] ) + "Polar plots submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + +(defcustom gnuplot-insertions-surface-plots + '("surface plots" + ["clabel" (gnuplot-insert "set clabel ") t] + ["cntrparam" (gnuplot-insert "set cntrparam ") t] + ["contour" (gnuplot-insert "set contour") t] + ["dgrid3d" (gnuplot-insert "set dgrid3d ") t] + ["hidden3d" (gnuplot-insert "set hidden3d ") t] + ["mapping" (gnuplot-insert "set mapping ") t] + ["surface" (gnuplot-insert "set surface ") t] + ["view" (gnuplot-insert "set view ") t] ) + "Surface plots submenu in the insertions menu. +See the document string for `gnuplot-insertions-menu' +Changing this will not effect a change in any currently existing +`gnuplot-mode' buffer. You will see the change the next time you +create a `gnuplot-mode' buffer." + :group 'gnuplot-insertions + :type '(list (string :tag "Title") + (repeat :inline t + (vector (string :tag "Name") + (function :tag "Callback") + (boolean :tag "Enabled" t))))) + + + +(defvar gnuplot-insertions-bottom () + "Bottom part of the insertions menu. +This part contains the toggle buttons for displaying info or +opening an argument-setting popup.") +(setq gnuplot-insertions-bottom + '("---" + ["Display of info with insertion" gnuplot-toggle-info-display + :style toggle :selected gnuplot-insertions-show-help-flag] + ["Display GUI popup with insertion" gnuplot-gui-toggle-popup + :active (fboundp 'gnuplot-gui-toggle-popup) + :style toggle :selected (and (fboundp 'gnuplot-gui-toggle-popup) + gnuplot-gui-popup-flag)] )) + + +;; Regarding a comment by : +;; +;; This is from the header in easymenu.el distributed with XEmacs: +;; +;; ;; - Function: easy-menu-add MENU [ MAP ] +;; ;; Add MENU to the current menubar in MAP. +;; ;; +;; ;; - Function: easy-menu-remove MENU +;; ;; Remove MENU from the current menubar. +;; ;; +;; ;; Emacs 19 never uses `easy-menu-add' or `easy-menu-remove', menus +;; ;; automatically appear and disappear when the keymaps specified by +;; ;; the MAPS argument to `easy-menu-define' are activated. +;; ;; +;; ;; XEmacs will bind the map to button3 in each MAPS, but you must +;; ;; explicitly call `easy-menu-add' and `easy-menu-remove' to add and +;; ;; remove menus from the menu bar. +;; +;; in Emacs, easy-menu-add is defined like this: +;; (defun easy-menu-add (menu &optional map)) + +(defun gnuplot-setup-menubar () + "Initial setup of gnuplot and insertions menus." + (if gnuplot-insertions-menu-flag ; set up insertions menu + (progn + (if gnuplot-xemacs-p + (setq gnuplot-insertions-top + '("insert set expression" "--:doubleLine")) + (setq gnuplot-insertions-top + '("insert set expression" "---"))) + (setq gnuplot-insertions-menu + (append (list "Insertions") + gnuplot-insertions-top + (list gnuplot-insertions-adornments) + (list gnuplot-insertions-plot-options) + (list gnuplot-insertions-terminal) + (list gnuplot-insertions-x-axis) + (list gnuplot-insertions-y-axis) + (list gnuplot-insertions-z-axis) + (list gnuplot-insertions-x2-axis) + (list gnuplot-insertions-y2-axis) + (list gnuplot-insertions-parametric-plots) + (list gnuplot-insertions-polar-plots) + (list gnuplot-insertions-surface-plots) + gnuplot-insertions-bottom)) + (easy-menu-define gnuplot-mode-insertions-menu gnuplot-mode-map + "Insertions menu used in Gnuplot-mode" + gnuplot-insertions-menu) + (easy-menu-add gnuplot-mode-insertions-menu gnuplot-mode-map))) + (easy-menu-define ; set up gnuplot menu + gnuplot-mode-menu gnuplot-mode-map "Menu used in gnuplot-mode" + gnuplot-menu) + (easy-menu-add gnuplot-mode-menu gnuplot-mode-map) ) + +;; There is no `mark-active' variable in XEmacs. Hassle! This is not +;; only replicates mark-active, but it only returns true if the region +;; is of non-zero width. +;; Error checking suggested by +(defun gnuplot-mark-active () + "Return non-nil if the mark is active and it is not equal to point." + (condition-case nil + (and (mark) (/= (mark) (point))) + (error nil))) + + +;;; --- XEmacs toolbar + +(defgroup gnuplot-toolbar nil + "Toolbar used by XEmacs." + :prefix "gnuplot-toolbar-" + :group 'gnuplot) + +(defcustom gnuplot-toolbar-display-flag gnuplot-xemacs-p + "*Non-nil means to display display a toolbar in XEmacs." + :group 'gnuplot-toolbar + :type 'boolean) + +(defcustom gnuplot-toolbar-use-toolbar (if (featurep 'toolbar) 'left-toolbar nil) + "*If nil, do not use a toolbar. +If it is non-nil, it must be a toolbar. The five legal values are +`default-toolbar', `top-toolbar', `bottom-toolbar', `right-toolbar', +and `left-toolbar', although choosing `default-toolbar' or +`top-toolbar' may be a bad idea since either will make the GNUPLOT +toolbar replace the standard toolbar. Changing this will not change +the toolbar in a currently existing buffer, but it will take effect +the next time you use `gnuplot-mode' and emacs. + +This is only used if a toolbar can be displayed, thus this is used in +XEmacs and ignored in FSF Emacs." + :type '(choice (const default-toolbar) + (const top-toolbar) + (const bottom-toolbar) + (const left-toolbar) + (const right-toolbar) + (const :tag "No toolbar" nil)) + :group 'gnuplot-toolbar) + +(defvar gnuplot-toolbar-location "") + +(defun gnuplot-toolbar-setup-toolbar (toolbar) + "Setup function for the `gnuplot-mode' toolbar. +TOOLBAR contains the toolbar specification. +This is basically swiped from VM." + (let ((width 46) (height 46) + (buffer (current-buffer)) + (frame (selected-frame)) + (tag-set '(win))) + (cond + ((eq (symbol-value gnuplot-toolbar-use-toolbar) right-toolbar) + (setq gnuplot-toolbar-location "right") + (set-specifier right-toolbar toolbar buffer) + (set-specifier right-toolbar-width width frame tag-set)) + ((eq (symbol-value gnuplot-toolbar-use-toolbar) left-toolbar) + (setq gnuplot-toolbar-location "left") + (set-specifier left-toolbar toolbar buffer) + (set-specifier left-toolbar-width width frame tag-set)) + ((eq (symbol-value gnuplot-toolbar-use-toolbar) bottom-toolbar) + (setq gnuplot-toolbar-location "bottom") + (set-specifier bottom-toolbar toolbar buffer) + (set-specifier bottom-toolbar-height height frame tag-set)) + ((eq (symbol-value gnuplot-toolbar-use-toolbar) top-toolbar) + (setq gnuplot-toolbar-location "top") + (set-specifier top-toolbar toolbar buffer) + (set-specifier top-toolbar-height height frame tag-set))) )) + +(defvar gnuplot-line-xpm + (if (featurep 'xpm) + (toolbar-make-button-list + "/* XPM */ +static char *line[] = { +/* width height num_colors chars_per_pixel */ +\" 40 40 5 1\", +/* colors */ +\". c #000000\", +\"a c #bebebe s backgroundToolBarColor\", +\"b c #2f4f4f\", +\"c c #ff6347\", +\"d c #0000ff\", +/* pixels */ +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaa..a..aaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaa..a..a....aaa...aaaaaaaaaaaa\", +\"aaaaaaaaaaaa..a..a..a..a..a..aaaaaaaaaaa\", +\"aaaaaaaaaaaa..a..a.aa..a.....aaaaaaaaaaa\", +\"aaaaaaaaaaa..a..a..a..a..aaaaaaaaaaaaaaa\", +\"aaaaaaaaaaa..a..a..a..a..a..aaaaaaaaaaaa\", +\"aaaaaaaaaaa..a..a..a..aa...aaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaadaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaadaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaadaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaadaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaacaaaadaadaaaaaaaaaaaa\", +\"aaaaaaaa.caaadaaaccaccadaddaaaaaccaaaaaa\", +\"aaaaaaa..accdaddcaaaaaccaaaaaaccaaaaaaaa\", +\"aaaaaaaa.aadcaccdaaaadaaccaaccaaaaaaaaaa\", +\"aaaaaaaa.adaacaaaddadaaaaaccaaaaaaaaaaaa\", +\"aaaaaaaa.daaaaaaaaadaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaa............................aaaaaa\", +\"aaaaaaaa.aaaa.aaaa.aaaa.aaaa.aaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};") + "XPM format image used for the \"plot line\" button")) + +(defvar gnuplot-region-xpm + (if (featurep 'xpm) + (toolbar-make-button-list + "/* XPM */ +static char *region[] = { +/* width height num_colors chars_per_pixel */ +\" 40 40 5 1\", +/* colors */ +\". c #000000\", +\"a c #bebebe s backgroundToolBarColor\", +\"b c #2f4f4f\", +\"c c #ff6347\", +\"d c #0000ff\", +/* pixels */ +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaa..aaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaa.a..a...aaa....a..aa...aa....aaaaa\", +\"aaaaaa...a..a..a..a..a..a..a..a..a..aaaa\", +\"aaaaaa..aa.....a.aa..a....aa..a.aa..aaaa\", +\"aaaaa..a...aaaa..aa.a..a..aa....a..aaaaa\", +\"aaaaa..a...a..a..a..a..a..a..a..a..aaaaa\", +\"aaaa..aaaa...aaa....a..aa...aa..a..aaaaa\", +\"aaaaaaaaaaaaaaaaa..aaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaadaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaadaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaadaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaadaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaacaaaadaadaaaaaaaaaaaa\", +\"aaaaaaaa.caaadaaaccaccadaddaaaaaccaaaaaa\", +\"aaaaaaa..accdaddcaaaaaccaaaaaaccaaaaaaaa\", +\"aaaaaaaa.aadcaccdaaaadaaccaaccaaaaaaaaaa\", +\"aaaaaaaa.adaacaaaddadaaaaaccaaaaaaaaaaaa\", +\"aaaaaaaa.daaaaaaaaadaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaa............................aaaaaa\", +\"aaaaaaaa.aaaa.aaaa.aaaa.aaaa.aaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};") + "XPM format image used for the \"plot region\" button")) + +(defvar gnuplot-buffer-xpm + (if (featurep 'xpm) + (toolbar-make-button-list + "/* XPM */ +static char *buffer[] = { +/* width height num_colors chars_per_pixel */ +\" 40 40 5 1\", +/* colors */ +\". c #000000\", +\"a c #bebebe s backgroundToolBarColor\", +\"b c #2f4f4f\", +\"c c #ff6347\", +\"d c #0000ff\", +/* pixels */ +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa..aaaaaaaaaa......aaaaaaaaaaaaaa\", +\"aaaaaaaa..aaaaaaaaa..a..aaaaaaaaaaaaaaaa\", +\"aaaaaaa....aa..a.........a...aa.a.aaaaaa\", +\"aaaaaaa..a..a..a..a..a..a..a..a...aaaaaa\", +\"aaaaaaa.aa....aa..a..a..a.....a..aaaaaaa\", +\"aaaaaa...a.a..a..a..a..a..aaaa..aaaaaaaa\", +\"aaaaaa.....a..a..a..a..a..a..a..aaaaaaaa\", +\"aaaaaa....aaa..a.a..a..aa...aa..aaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaadaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaadaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaadaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaadaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaacaaaadaadaaaaaaaaaaaa\", +\"aaaaaaaa.caaadaaaccaccadaddaaaaaccaaaaaa\", +\"aaaaaaa..accdaddcaaaaaccaaaaaaccaaaaaaaa\", +\"aaaaaaaa.aadcaccdaaaadaaccaaccaaaaaaaaaa\", +\"aaaaaaaa.adaacaaaddadaaaaaccaaaaaaaaaaaa\", +\"aaaaaaaa.daaaaaaaaadaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaa............................aaaaaa\", +\"aaaaaaaa.aaaa.aaaa.aaaa.aaaa.aaaaaaaaaaa\", +\"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};") + "XPM format image used for the \"plot buffer\" button")) + +(defvar gnuplot-doc-xpm + (if (featurep 'xpm) + (toolbar-make-button-list + "/* XPM */ +static char *book_index[] = { +/* width height num_colors chars_per_pixel */ +\" 40 40 6 1\", +/* colors */ +\". c #000000\", +\"a c #bebebe s backgroundToolBarColor\", +\"b c #2f4f4f\", +\"c c #ff0000\", +\"d c #ffffff\", +\"e c #708090\", +/* pixels */ +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaa.........bbeaaaebb..........aaaaaa\", +\"aaaaaa.ddddddddaaebebeaaddddddddd.aaaaaa\", +\"aaaa...dab.bddeebadbdaeebedeeeeed...aaaa\", +\"aaaa.c.dbaddddebeedbdeebeedebebed.c.aaaa\", +\"aaaa.c.d.de.edeebeabdbbeeddebbbed.c.aaaa\", +\"aaaa.c.dbad.ddebeadbdeeebeddeeeed.c.aaaa\", +\"aaaa.c.dab..ddeeeedbdebeeedebebed.c.aaaa\", +\"aaaa.c.dddddddeebeabdebebedeebedd.c.aaaa\", +\"aaaa.c.debebedebeedbdbebeedbeeeeb.c.aaaa\", +\"aaaa.c.debeeedeeeaabdaaddddebedbb.c.aaaa\", +\"aaaa.c.deebeddbebedbdbaa.adeeedeb.c.aaaa\", +\"aaaa.c.ddeebedeeebaba.dd.dddeeedd.c.aaaa\", +\"aaaa.c.debeebdbeeedbd....ddeebeed.c.aaaa\", +\"aaaa.c.deebeedeebadbd.dd.ddeeeedd.c.aaaa\", +\"aaaa.c.dbbebddeeeeabd.aa.adebebbd.c.aaaa\", +\"aaaa.c.deeeeedeebeabaedddddeeeedd.c.aaaa\", +\"aaaa.c.dbebbbdebeadbdaeeeedebeeed.c.aaaa\", +\"aaaa.c.deeebddeeebdbdeebeedeebeed.c.aaaa\", +\"aaaa.c.debeeedebeeabdebebedebeebd.c.aaaa\", +\"aaaa.c.deebbedeeeedbdeeeeddeeeeed.c.aaaa\", +\"aaaa.c.dddddddddaadbdaddddddddddd.c.aaaa\", +\"aaaa.c..........beabaeb...........c.aaaa\", +\"aaaa.c.bbbbbbbbbb.bbbbbbbbbbbbbbb.c.aaaa\", +\"aaaa.c.bbbbbbbbbb..e.bbbbbbbbbbbb.c.aaaa\", +\"aaaa.c.bbbbbbbbbb.b.bbbbbbbbbbbbb.c.aaaa\", +\"aaaa.c............e.e.............c.aaaa\", +\"aaaa.cccccccccccc.a.a.ccccccccccccc.aaaa\", +\"aaaa................................aaaa\", +\"aaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};") + "XPM format image used for the \"document\" button")) + +(defvar gnuplot-help-xpm + (if (featurep 'xpm) + (toolbar-make-button-list + "/* XPM */ +static char *help_btn[] = { +/* width height num_colors chars_per_pixel */ +\" 40 40 3 1\", +/* colors */ +\"a c #bebebe s backgroundToolBarColor\", +\"b c #000000\", +\"c c #ff0000\", +/* pixels */ +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabbbbbbbbaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaabbbccccccccbbbaaaaaaaaaaaaa\", +\"aaaaaaaaaaabbccccccccccccccbbaaaaaaaaaaa\", +\"aaaaaaaaaabccccccccccccccccccbaaaaaaaaaa\", +\"aaaaaaaaabccccccccccccccccccccbaaaaaaaaa\", +\"aaaaaaaabcccccccbbbbbbbbcccccccbaaaaaaaa\", +\"aaaaaaaabccccbbbaaaaaaaabbbccccbaaaaaaaa\", +\"aaaaaaabccccbaaaaaaaaaaaaaabccccbaaaaaaa\", +\"aaaaaaabcccbaaaaaaaaaaaaaaaabcccbaaaaaaa\", +\"aaaaaaabcccbaaaaaaaaaaaaaaaabcccbaaaaaaa\", +\"aaaaaaabcccbaaaaaaaaaaaaaaaabcccbaaaaaaa\", +\"aaaaaaabbbbbaaaaaaaaaaaaaaabccccbaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaabbbccccbaaaaaaaa\", +\"aaaaaaaaaaaaaaaabbbbbbbbcccccccbaaaaaaaa\", +\"aaaaaaaaaaaaaaaabcccccccccccccbaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccccccccccbaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccccccccbbaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccbbbbbbaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabbbbbbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabbbbbbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaabbbbbbaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", +\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};") + "XPM format image used for the \"help\" button")) + +(defvar gnuplot-toolbar + '([gnuplot-line-xpm + gnuplot-line-fn t "Plot the line under point"] + [gnuplot-region-xpm + gnuplot-region-fn t "Plot the selected region"] + [gnuplot-buffer-xpm + gnuplot-buffer-fn t "Plot the entire buffer"] + [:style 3d :size 8] + [gnuplot-help-xpm + gnuplot-help-fn t "Look at the gnuplot process buffer"] + [gnuplot-doc-xpm + gnuplot-doc-fn t "Look at the gnuplot document"]) + "The gnuplot toolbar.") + +(fset 'gnuplot-line-fn 'gnuplot-send-line-and-forward) +(fset 'gnuplot-region-fn 'gnuplot-send-region-to-gnuplot) +(fset 'gnuplot-buffer-fn 'gnuplot-send-buffer-to-gnuplot) +(fset 'gnuplot-help-fn 'gnuplot-show-gnuplot-buffer) +(fset 'gnuplot-doc-fn 'gnuplot-info-lookup-symbol) + +(defvar gnuplot-all-buttons-defined + (and (listp gnuplot-line-xpm) (listp gnuplot-region-xpm) + (listp gnuplot-buffer-xpm) (listp gnuplot-doc-xpm) + (listp gnuplot-help-xpm))) + + +(defun gnuplot-make-toolbar-function () + (if (and gnuplot-xemacs-p gnuplot-all-buttons-defined) + (progn + ;;(remove-specifier gnuplot-toolbar-use-toolbar (current-buffer)) + (gnuplot-toolbar-setup-toolbar gnuplot-toolbar) + (add-spec-to-specifier (symbol-value gnuplot-toolbar-use-toolbar) + gnuplot-toolbar + (current-buffer) )))) + +;;(defalias 'gnuplot-make-toolbar 'gnuplot-make-toolbar-function) + + + +;;; --- syntax colorization, syntax table + +(defvar gnuplot-mode-syntax-table nil + "Syntax table in use in `gnuplot-mode' buffers. +This is the same as the standard syntax table except that ' is a +string quote character, ` and _ are word characters, and math +operators are punctuation characters.") +(if gnuplot-mode-syntax-table + () + (setq gnuplot-mode-syntax-table (make-syntax-table)) + (modify-syntax-entry ?* "." gnuplot-mode-syntax-table) + (modify-syntax-entry ?+ "." gnuplot-mode-syntax-table) + (modify-syntax-entry ?- "." gnuplot-mode-syntax-table) + (modify-syntax-entry ?/ "." gnuplot-mode-syntax-table) + (modify-syntax-entry ?% "." gnuplot-mode-syntax-table) + ;;(modify-syntax-entry ?& "." gnuplot-mode-syntax-table) ; rarely used + ;;(modify-syntax-entry ?^ "." gnuplot-mode-syntax-table) ; operators + ;;(modify-syntax-entry ?| "." gnuplot-mode-syntax-table) ; in gnuplot, + ;;(modify-syntax-entry ?& "." gnuplot-mode-syntax-table) ; (by me, + ;;(modify-syntax-entry ?? "." gnuplot-mode-syntax-table) ; anyway...) + ;;(modify-syntax-entry ?~ "." gnuplot-mode-syntax-table) ; + (modify-syntax-entry ?' "\"" gnuplot-mode-syntax-table) + (modify-syntax-entry ?` "w" gnuplot-mode-syntax-table) + (modify-syntax-entry ?_ "w" gnuplot-mode-syntax-table)) + + +(defvar gnuplot-font-lock-keywords nil) +(defvar gnuplot-font-lock-keywords-1 nil) +(defvar gnuplot-font-lock-keywords-2 nil) + +;; used make-regexp to generate the regular expression strings +;; this is all pattern based +;; (insert (format "%s" +;; (regexp-quote +;; (make-regexp +;; '("abs" "acos" "acosh" "arg" "asin" "asinh" "atan" +;; "atan2" "atanh" "besj0" "besj1" "besy0" "besy1" +;; "ceil" "cos" "cosh" "erf" "erfc" "exp" "floor" +;; "gamma" "ibeta" "inverf" "igamma" "imag" "invnorm" +;; "int" "lgamma" "log" "log10" "norm" "rand" "real" +;; "sgn" "sin" "sinh" "sqrt" "tan" "tanh" "column" +;; "tm_hour" "tm_mday" "tm_min" "tm_mon" "tm_sec" +;; "tm_wday" "tm_yday" "tm_year" "valid"))))) + +;; Set up colorization for gnuplot. +;; This handles font-lock for emacs and xemacs. +;; hilit19 is handled in `gnuplot-mode'. +;; These regular expressions treat the gnuplot vocabulary as complete +;; words. Although gnuplot will recognise unique abbreviations, these +;; regular expressions will not." +(if (featurep 'font-lock) ; + (setq gnuplot-font-lock-keywords + (list + ; comments + '("#.*$" . font-lock-comment-face) + ; quoted things + ;'("['\"]\\([^'\"\n]*\\)['\"]" + ; 1 font-lock-string-face) + '("'[^'\n]*'?" . font-lock-string-face) + ; stuff in brackets, sugg. by + '("\\[\\([^]]+\\)\\]" + 1 font-lock-reference-face) + ; variable/function definitions + '("\\(\\<[a-z]+[a-z_0-9()]*\\)[ \t]*=" + 1 font-lock-variable-name-face) + ; built-in function names + (cons (concat + "\\<\\(" + "a\\(bs\\|cosh\?\\|rg\\|sinh\?\\|" + "tan\\(\\|\[2h\]\\)\\)\\|" + "bes\\(j\[01\]\\|y\[01\]\\)\\|" + "c\\(eil\\|o\\(lumn\\|sh\?\\)\\)\\|" + "e\\(rfc\?\\|xp\\)\\|floor\\|gamma\\|" + "i\\(beta\\|gamma\\|mag\\|" + "n\\(t\\|v\\(erf\\|norm\\)\\)\\)\\|" + "l\\(gamma\\|og\\(\\|10\\)\\)\\|" + "norm\\|r\\(and\\|eal\\)\\|" + "s\\(gn\\|inh\?\\|qrt\\)\\|" + "t\\(anh\?\\|m_\\(hour\\|m\\(day\\|in\\|on\\)\\|" + "sec\\|wday\\|y\\(day\\|ear\\)\\)\\)\\|" + "valid" + "\\)\\>") + font-lock-function-name-face) + ; reserved words associated with + ; plotting + '("\\<\\(axes\\|every\\|index\\|l\\(\[stw\]\\|ine\\(style\\|type\\|width\\)\\)\\|notitle\\|p\\(\[st\]\\|oint\\(size\\|type\\)\\)\\|smooth\\|t\\(hru\\|itle\\)\\|using\\|with\\)\\>" . font-lock-type-face) + '("\\<\\(box\\(e\\(rrorbars\\|s\\)\\|xyerrorbars\\)\\|candlesticks\\|dots\\|errorbars\\|f\\(inancebars\\|steps\\)\\|histeps\\|impulses\\|lines\\(\\|points\\)\\|points\\|steps\\|vector\\|x\\(errorbars\\|yerrorbars\\)\\|yerrorbars\\)\\>" . font-lock-function-name-face) + ; (s)plot -- also thing (s)plotted + '("\\" . font-lock-keyword-face) + '("\\\\|!.*$") + font-lock-reference-face)) + gnuplot-font-lock-keywords-1 gnuplot-font-lock-keywords + gnuplot-font-lock-keywords-2 gnuplot-font-lock-keywords) ) + +(if (and gnuplot-xemacs-p (featurep 'font-lock)) + (put 'gnuplot-mode 'font-lock-defaults + '((gnuplot-font-lock-keywords + gnuplot-font-lock-keywords-1 + gnuplot-font-lock-keywords-2) + t t ((?_ . "w")) ))) + +;; these two lines get rid of an annoying compile time error +;; message. that function gets non-trivially defalias-ed in +;; gnuplot-toolbar.el +;; (defun gnuplot-make-toolbar-dummy ()) +;; (defalias 'gnuplot-make-toolbar 'gnuplot-make-toolbar-dummy) + + +;;; --- functions for sending commands to gnuplot + +(defun gnuplot-split-string (string) + "Break STRING at each carriage return, returning a list of lines." + (let ((list ()) (line "") (index 0)) + (while (< index (length string)) + (if (char-equal (elt string index) ?\n) + (setq list (append list (list line)) + line "") + (setq line (concat line (char-to-string (elt string index))))) + (setq index (1+ index)) ) + list)) + +;; -- the calls to `sleep-for' are to allow enough time for gnuplot +;; to write to the buffer before the next line is inserted +;; -- note that the input string is split into lines and each line is +;; sent to gnuplot individually. this is a bit slow, but it puts +;; each line on the comint history. +(defun gnuplot-send-string-to-gnuplot (string text) + "Sends STRING to the gnuplot program. +If no gnuplot process exists, a new one is created. TEXT indicates +the type of text being sent to gnuplot and is typically one of +nil, 'line, 'region, 'buffer, or 'file. TEXT may be useful for +functions in `gnuplot-after-plot-hook'. `gnuplot-after-plot-hook' is +called by this function after all of STRING is sent to gnuplot." + (gnuplot-make-gnuplot-buffer) ; make sure a gnuplot buffer exists + (or gnuplot-program-version + (progn + (message "Determining gnuplot version number (sitting for 2 seconds)") + (gnuplot-fetch-version-number) + (sit-for 2))) + (setq gnuplot-comint-recent-buffer (current-buffer)) + (if (equal gnuplot-display-process 'frame) + (or (and gnuplot-process-frame + (frame-live-p gnuplot-process-frame)) + (let ((frame (selected-frame))) + (setq gnuplot-process-frame (make-frame)) + (select-frame gnuplot-process-frame) + (switch-to-buffer gnuplot-buffer) + (delete-other-windows) + (select-frame frame))) ) + (let ((buffer (current-buffer)) + (gbuffer (get-buffer gnuplot-buffer)) + (list (gnuplot-split-string string))) + (set-buffer gbuffer) + (goto-char (point-max)) + ;; bruce asks: what is this next line for? + (set-marker (process-mark gnuplot-process) (point-marker)) + (sleep-for (* 20 gnuplot-delay)) + (while list + (insert (car list)) + (comint-send-input) + (sleep-for gnuplot-delay) + (setq list (cdr list)) + (goto-char (point-max))) + (set-buffer buffer) + (cond ((equal gnuplot-display-process 'window) + (select-window (display-buffer gbuffer)) + (goto-char (point-max)) + (or (pos-visible-in-window-p (point) (selected-window)) + (recenter 5)) + (other-window 1)) + ((equal gnuplot-display-process 'frame) + ;;(raise-frame gnuplot-process-frame) + (select-frame gnuplot-process-frame) + (display-buffer gbuffer) + (goto-char (point-max)) + (or (pos-visible-in-window-p (point) (selected-window)) + (recenter 5)))) + ;;(process-send-string gnuplot-program string) + (setq gnuplot-recently-sent text) + (run-hooks 'gnuplot-after-plot-hook))) + +(defun gnuplot-send-region-to-gnuplot (&optional begin end text) + "Sends a selected region to the gnuplot program. +If BEGIN and END are not specified, point and mark are used. TEXT +indicates the type of text being sent to gnuplot. This will be +'region unless explicitly set by a function calling this one. Other +typical values are of nil, 'line, 'buffer, or 'file. TEXT may be +useful for function in `gnuplot-after-plot-hook'." + (interactive "r") + (let (string (txt (or text 'region))) + (cond ((equal major-mode 'gnuplot-mode) + (setq string (buffer-substring-no-properties begin end)) + (if (string= (substring string -1) "\n") () + (setq string (concat string "\n"))) + (gnuplot-send-string-to-gnuplot string txt)) + (t + (message (concat "You can only send regions from " + "gnuplot-mode buffers to gnuplot.")))))) + +(defun gnuplot-send-line-to-gnuplot () + "Sends the current line to the gnuplot program. +Respects continuation lines. +This sets `gnuplot-recently-sent' to 'line." + (interactive) + (cond ((equal major-mode 'gnuplot-mode) + (let ((start (save-excursion (beginning-of-line) (point-marker))) + end + ;(end (save-excursion (beginning-of-line 2) (point-marker))) + ) + (save-excursion + (goto-char start) + (end-of-line) + (backward-char 1) + (while (looking-at "\\\\") ; go to end of last continuation line + (end-of-line 2) + (backward-char 1)) + (beginning-of-line 2) + (setq end (point-marker))) + (if (not (string-match "\\`\\s-*\\'" + (buffer-substring-no-properties start end))) + (gnuplot-send-region-to-gnuplot start end 'line)) + end)) + (t + (message "You can only send lines in gnuplot-mode buffers to gnuplot.") + nil))) + +;; I chose a very easy to type but slightly non-mnemonic key-binding +;; for this (C-c C-v). It seems like the kind of thing one would want +;; to do repeatedly without incurring RSI. 8^) +(defun gnuplot-send-line-and-forward (&optional num) + "Call `gnuplot-send-line-to-gnuplot' and move forward 1 line. +You can use a numeric prefix to send more than one line. Blank lines and +lines with only comments are skipped when moving forward." + (interactive "p") + (let (end) + (while (> num 0) + (setq end (gnuplot-send-line-to-gnuplot)) + (goto-char end) + (backward-char 1) ; + (gnuplot-forward-script-line 1) + (setq num (1- num))))) + + +(defun gnuplot-forward-script-line (&optional num) ; + "Move forward my NUM script lines. +Blank lines and commented lines are not included in the NUM count." + (interactive "p") + (while (> num 0) + (and (not (eobp)) (forward-line 1)) + (while (and (not (eobp)) + (or (looking-at "^\\s-*$") + (looking-at "^\\s-*#"))) + (forward-line 1)) + (setq num (1- num))) ) + +(defun gnuplot-send-buffer-to-gnuplot () + "Sends the entire buffer to the gnuplot program. +This sets `gnuplot-recently-sent' to 'buffer." + (interactive) + (if (equal major-mode 'gnuplot-mode) + (gnuplot-send-region-to-gnuplot (point-min) (point-max) 'buffer) + (message "You can only send gnuplot-mode buffers to gnuplot."))) + +(defun gnuplot-send-file-to-gnuplot () + "Sends a selected file to the gnuplot program using the \"load\" command. +This sets `gnuplot-recently-sent' to 'file." + (interactive) + (let ((string (read-file-name "Name of file to send to gnuplot > " nil nil t))) + (setq string (concat "load '" (expand-file-name string) "'\n")) + (message "%S" string) + (gnuplot-make-gnuplot-buffer) ; make sure a gnuplot buffer exists + (gnuplot-send-string-to-gnuplot string 'file))) + +;; suggested by +(defun gnuplot-plot-from-comint () + "Send the contents of a script to gnuplot from the process buffer. +This inserts the contents of the most recently used gnuplot script +into the process buffer and sends those lines to gnuplot. It does +this by copying the script line by line." + (interactive) + (if (equal major-mode 'comint-mode) + (let (string list (buffer (current-buffer))) + (set-buffer gnuplot-comint-recent-buffer) + (setq string (buffer-substring-no-properties (point-min) (point-max)) + string (concat string "\n") + list (gnuplot-split-string string)) + (set-buffer buffer) + (while list + (insert (car list)) + (comint-send-input) + (sleep-for gnuplot-delay) + (setq list (cdr list))) + (comint-send-input)) + (message + "`gnuplot-plot-from-comint' only works in the gnuplot process buffer"))) + +(defun gnuplot-save-and-plot-from-comint () + "Send a current script to gnuplot from the process buffer. +This sends the most recently used gnuplot script to gnuplot using the +\"load\" command. This function first saves the script buffer to a +file, prompting for a filename if one is not associated with the script +buffer. Then it sends a load command to gnuplot using the name of the +file visited by the script buffer." + (interactive) + (if (equal major-mode 'comint-mode) + (let (fname (buffer (current-buffer))) + (set-buffer gnuplot-comint-recent-buffer) + (save-buffer) + (setq fname (buffer-file-name)) + (set-buffer buffer) + (goto-char (point-max)) + (insert (format "load '%s'" fname)) + (comint-send-input)) + (message (concat "`gnuplot-save-and-plot-from-comint' only works " + "in the gnuplot process buffer")))) + + +(defun gnuplot-trim-gnuplot-buffer () + "Trim lines form the beginning of the *gnuplot* buffer. +This keeps that buffer from growing excessively in size. Normally, +this function is attached to `gnuplot-after-plot-hook'" + (if (> gnuplot-buffer-max-size 0) + (save-excursion + (set-buffer gnuplot-buffer) + (let ((nlines (count-lines (point-min) (point-max))) + (kill-whole-line t)) + (while (> nlines gnuplot-buffer-max-size) + (goto-char (point-min)) + (kill-line) + (setq nlines (1- nlines))) + (goto-char (point-max)) )))) +(add-hook 'gnuplot-after-plot-hook 'gnuplot-trim-gnuplot-buffer nil nil) + + +;;; --- functions controlling the gnuplot process + +;; use of comint-setup-hook suggested by +(defun gnuplot-comint-start-function () + "Function run when comint/gnuplot started. +This sets font-lock and keyword completion in the comint/gnuplot +buffer. Further customization is possible via +`gnuplot-comint-setup-hook'." + ;;(if (not (fboundp 'hilit-set-mode-patterns)) + (if (featurep 'font-lock) + (progn + (make-variable-buffer-local 'font-lock-defaults) + (setq font-lock-defaults '(gnuplot-font-lock-keywords t t)) + (if gnuplot-xemacs-p (turn-on-font-lock)))) + ;;(if (featurep 'kw-compl) + ;; (progn + ;; (setq kw-compl-list gnuplot-keywords + ;; kw-compl-upper-case nil) + ;; (define-key comint-mode-map "\M-\r" 'kw-compl-abbrev))) + (define-key comint-mode-map "\M-\C-p" 'gnuplot-plot-from-comint) + (define-key comint-mode-map "\M-\C-f" 'gnuplot-save-and-plot-from-comint) + (define-key comint-mode-map "\C-d" 'gnuplot-delchar-or-maybe-eof) + (define-key comint-mode-map "\M-\r" 'gnuplot-complete-keyword) + (define-key comint-mode-map "\M-\t" 'gnuplot-complete-keyword) + (run-hooks 'gnuplot-comint-setup-hook)) + +(defun gnuplot-make-gnuplot-buffer () + "Switch to the gnuplot program buffer or create one if none exists." + (or (and gnuplot-process (get-process gnuplot-process) + gnuplot-buffer (get-buffer gnuplot-buffer)) + (progn + (message "Starting gnuplot plotting program...") + (setq gnuplot-buffer (make-comint gnuplot-process-name gnuplot-program) + gnuplot-process (get-process gnuplot-process-name)) + (process-kill-without-query gnuplot-process nil) + (save-excursion + (set-buffer gnuplot-buffer) + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'gnuplot-close-down nil t) + (gnuplot-comint-start-function) + (make-local-variable 'comint-output-filter-functions) + (setq comint-output-filter-functions + (append comint-output-filter-functions + '(comint-postoutput-scroll-to-bottom + gnuplot-protect-prompt-fn))) + (message "Starting gnuplot plotting program...Done"))))) + + +(defun gnuplot-fetch-version-number () + ;;(interactive) + (message "gnuplot-mode %s -- determining gnuplot version ......" + gnuplot-version) + (let* ((command (concat "echo \"show version\" | " gnuplot-program)) + (process (start-process-shell-command "gnuplot-version" + "*gnuplot-version*" + command))) + (set-process-sentinel process 'gnuplot-determine-version-number))) + +(defun gnuplot-determine-version-number (process event) + (save-excursion + (let (version) + (if (string-match "SPEEDBAR" (format "%S" (current-buffer))) ;; + (if (fboundp 'speedbar-switch-buffer-attached-frame) + (speedbar-switch-buffer-attached-frame "*gnuplot-version*") + (progn + (speedbar-select-attached-frame) + (switch-to-buffer "*gnuplot-version*"))) + (switch-to-buffer "*gnuplot-version*")) + (goto-char (point-min)) + (re-search-forward "[Vv]ersion\\s-+" (point-max) t) + (if (looking-at "[0-9]\\.[0-9]+") + (setq version (match-string 0)) + (setq version "3.7")) + (kill-buffer (get-buffer "*gnuplot-version*")) + ;;(and (interactive-p) (message "You are using gnuplot version %s" version)) + (setq gnuplot-program-version version + gnuplot-three-eight-p (>= (string-to-number gnuplot-program-version) 3.8)) + (gnuplot-setup-menu-and-toolbar) + ))) + +(defun gnuplot-setup-menu-and-toolbar () + ;; set up the menubar (possibly dependent on version number) + (gnuplot-setup-menubar) + ;; set up the toolbar (possibly dependent on version number) + (if (and gnuplot-xemacs-p gnuplot-toolbar-display-flag) + (condition-case () ; deal with the toolbar + (and (require 'toolbar) + (require 'xpm) + (gnuplot-make-toolbar-function)) + (error nil))) + (message "gnuplot-mode %s (gnuplot %s) -- report bugs with %S" + gnuplot-version gnuplot-program-version + (substitute-command-keys "\\[gnuplot-bug-report]")) + ) + + + +;; (defun gnuplot-determine-gnuplot-version () +;; "Figure out which version of gnuplot we are running." +;; (interactive) +;; (cond (gnuplot-gnuplot-version +;; (setq comint-process-echoes nil ;; t +;; gnuplot-program-version gnuplot-gnuplot-version)) +;; (t +;; (let ((counter 0)) +;; (save-excursion +;; (set-buffer gnuplot-buffer) +;; (goto-char (point-min)) +;; ;; it may take a while for emacs to display the gnuplot start-up +;; ;; message. since we need this to determine the version number +;; ;; and hence the value of `comint-process-echoes', we must wait +;; ;; for this to happen. +;; (while (and (equal (point-max) (point-min)) (< 10 counter)) +;; (1+ counter) +;; (sleep-for 0.1)) +;; (if (re-search-forward "[Vv]ersion" (point-max) t) +;; (progn +;; (cond ((or (looking-at "\\s-*3.8") (looking-at "\\s-*4")) +;; (setq comint-process-echoes nil ;; t +;; gnuplot-program-version "3.8")) +;; ((looking-at "\\s-*3.7") +;; (setq comint-process-echoes nil ;; t +;; gnuplot-program-version "3.7")) +;; (t +;; (setq comint-process-echoes nil +;; gnuplot-program-version "3.5") ))) +;; (setq comint-process-echoes gnuplot-echo-command-line-flag))))))) + +(defun gnuplot-protect-prompt-fn (string) + "Prevent the Gnuplot prompt from being deleted or overwritten. +STRING is the text as originally inserted in the comint buffer." + (save-excursion + (let ((b (progn + (goto-char (point-max)) + (beginning-of-line) + (point))) + e) + (if (re-search-forward "^gnuplot> " (point-max) t) + (progn + (setq e (point)) + (put-text-property b e 'rear-nonsticky '(read-only intangible face)) + (put-text-property b e 'intangible t) + (put-text-property b e 'face 'gnuplot-prompt-face) + ;;(put-text-property b e 'read-only t) + )) ))) + +(defun gnuplot-close-down () + "Tidy up when deleting the gnuplot buffer." + (if (eq (process-status gnuplot-process) 'run);; + (kill-process gnuplot-process)) + (setq gnuplot-process nil + gnuplot-buffer nil)) + +(defun gnuplot-delchar-or-maybe-eof (arg) + "Delete ARG characters forward, or (if at eob) send an EOF to subprocess. +This is very similar to `comint-delchar-or-maybe-eof'." + (interactive "p") + (if (eobp) + (gnuplot-kill-gnuplot-buffer) + (delete-char arg))) + +(defun gnuplot-kill-gnuplot-buffer () + "Kill the gnuplot process and its display buffers." + (interactive) + (if (and gnuplot-process + (eq (process-status gnuplot-process) 'run)) ;; + (kill-process gnuplot-process)) + (if (and gnuplot-buffer (get-buffer gnuplot-buffer)) + (progn + (if (one-window-p) () + (delete-window (get-buffer-window gnuplot-buffer))) + (kill-buffer gnuplot-buffer))) + (setq gnuplot-process nil + gnuplot-buffer nil)) + + +(defun gnuplot-show-gnuplot-buffer () + "Switch to the buffer containing the gnuplot process. +When `gnuplot-display-process' is nil this will switch to +the gnuplot process buffer. When that variable is non-nil, the +gnuplot process buffer will be displayed in a window." + (interactive) + (if (and gnuplot-buffer (get-buffer gnuplot-buffer)) + (cond ((equal gnuplot-display-process 'window) + (switch-to-buffer-other-window gnuplot-buffer)) + ((equal gnuplot-display-process 'frame) + (or (and gnuplot-process-frame + (frame-live-p gnuplot-process-frame)) + (setq gnuplot-process-frame (make-frame))) + (raise-frame gnuplot-process-frame) + (select-frame gnuplot-process-frame) + (switch-to-buffer gnuplot-buffer)) + (t + (switch-to-buffer gnuplot-buffer))) + (message "There is not an active Gnuplot process."))) + + +;;; --- miscellaneous functions: insert file name, indentation, negation + +(defun gnuplot-insert-filename () + "Insert a filename at point, prompting for name in the minibuffer. +This inserts a filename relative to the buffer's default directory. +Uses completion and the value of `gnuplot-quote-character'. +Bound to \\[gnuplot-insert-filename]" + (interactive) + (insert gnuplot-quote-character + (file-relative-name (read-file-name "Filename > " "") + default-directory) + gnuplot-quote-character) ) + +;; is this more complicated than it need be ...? +;; this doesn't quite do plot lists correctly: +;; plot sin(x),\ +;; cos(x) # ok +;; set auto # not ok, should be under "p" (but does it matter?) + +(defun gnuplot-indent-line () + "Set indentation in gnuplot buffer. +For most lines, set indentation to previous level of indentation. +Attempt to add additional indentation for continued plot and splot +lines." + (interactive) + (let ((indent 0)) + (save-excursion + (save-excursion + (end-of-line 0) + (if (bobp) () + (re-search-backward "^[ \t]*." (point-min) "to_limit") + (back-to-indentation) + (setq indent (current-column)) + (if (looking-at "s?pl\\(o?\\|\\(ot\\)?\\)[ \t]+.?") + (let ((plus (1- (length (match-string 0))))) + (end-of-line) + (backward-char 1) + (if (looking-at (regexp-quote "\\")) + (setq indent (+ plus indent))))))) + (if (= (current-indentation) indent) + () + (beginning-of-line) + (delete-horizontal-space) + (insert (make-string indent ? )))) + (if (looking-at "[ \t]+$") + (end-of-line)))) + +;; FWIW, here are all the options which can be negated: +;; (insert (format "%s" +;; (regexp-quote +;; (make-regexp +;; '("arrow" "autoscale" "border" "clabel" "clip" +;; "contour" "dgrid3d" "grid" "hidden3d" "key" "label" +;; "linestyle" "logscale" "multiplot" "mxtics" +;; "mytics" "mztics" "mx2tics" "my2tics" +;; "offsets" "polar" "surface" "timestamp" "title" +;; "xdtics" "ydtics" "zdtics" "x2dtics" "y2dtics" +;; "xmtics" "ymtics" "zmtics" "x2mtics" "y2mtics" +;; "xtics" "ytics" "ztics" "x2tics" "y2tics" +;; "xzeroaxis" "yzeroaxis" "zzeroaxis" "x2zeroaxis" +;; "y2zeroaxis"))))) + +(defun gnuplot-negate-option () + "Append \"no\" to or remove \"no\" from the set option on the current line. +This checks if the set option is one which has a negated form." + (interactive) + (let ((begin (save-excursion (beginning-of-line) (point-marker))) + (end (save-excursion (end-of-line) (point-marker))) + (regex "a\\(rrow\\|utoscale\\)\\|border\\|c\\(l\\(abel\\|ip\\)\\|ontour\\)\\|dgrid3d\\|grid\\|hi\\(dden3d\\|storysize\\)\\|key\\|l\\(abel\\|inestyle\\|ogscale\\)\\|m\\(ouse\\|ultiplot\\|x\\(2tics\\|tics\\)\\|y\\(2tics\\|tics\\)\\|ztics\\)\\|offsets\\|polar\\|surface\\|ti\\(mestamp\\|tle\\)\\|x\\(2\\(dtics\\|mtics\\|tics\\|zeroaxis\\)\\|dtics\\|mtics\\|tics\\|zeroaxis\\)\\|y\\(2\\(dtics\\|mtics\\|tics\\|zeroaxis\\)\\|dtics\\|mtics\\|tics\\|zeroaxis\\)\\|z\\(dtics\\|mtics\\|tics\\|zeroaxis\\)")) + (save-excursion + (if (search-backward ";" begin t) + (progn (forward-char 1) (setq begin (point-marker)))) + (if (search-forward ";" end t) + (progn (forward-char -1) (setq end (point-marker)))) + (goto-char begin) + (skip-syntax-forward "-" end) + (if (looking-at "\\(un\\)?set\\s-+") + (cond ((and gnuplot-program-version + (> (string-to-number gnuplot-program-version) 3.7)) + (cond ((looking-at "unset") + (delete-char 2)) + ((looking-at (concat "set\\s-+\\(" regex "\\)")) + (insert "un")) + (t + (message "There is not a negatable set option on this line")))) + (t + (goto-char (match-end 0)) + (if (> (point) end) (goto-char end)) + (cond ((looking-at "no") + (delete-char 2)) + ((looking-at regex) + (insert "no")) + (t + (message "There is not a negatable set option on this line"))))) + (message "There is not a set option on this line")) ))) + +;; (defun gnuplot-set-binding () +;; "Interactively select a key sequence for binding to a plot function. +;; This is only useful in gnuplot 3.8 and for plot terminals which support +;; key bindings (i.e. those covered by pm3d)." +;; (interactive) +;; (let ((keyseq (read-key-sequence "Choose a key sequence now")) +;; (command (read-string "Bind to this command > "))) +;; (setq keyseq (format "%S" keyseq)) +;; (string-match "keypress-event\\s-+" keyseq) +;; (setq keyseq (substring keyseq (match-end 0) -2)) +;; ;; need to convert from emacs nomenclature to gnuplot. what a pain. +;; (let* ((alist '(("backspace" . "Backspace") ("tab" . "Tab") ("linefeed" . "Linefeed") +;; ("clear" . "Clear") ("return" . "Return") ("pause" . "Pause") +;; ("scroll-lock" . "Scroll_Lock") ("SysReq" . "sys-req") +;; ("escape" . "Escape") ("delete" . "Delete") ("home" . "Home") +;; ("left" . "Left") ("right" . "Right") ("up" . "Up") ("down" . "Down") +;; ("prior" . "PageUp") ("next" . "PageDown") ("end" . "End") +;; ("begin". "Begin"))) +;; (match (assoc keyseq alist))) +;; (if match (setq keyseq (cdr match))) +;; +;; (insert (format "bind \"%s\" \"%s\"" keyseq command))))) + + +(defun gnuplot-customize () + "Customize `gnuplot-mode'." + (interactive) + (if (fboundp 'customize-group) + (customize-group "gnuplot") + (message "The Custom library is not installed."))) + + + +;;; --- help from the info file, keyword list + completion, insert function + + +;; set up stuff for info-look (as suggested by ) +;; modified with suggestion from +(defun gnuplot-setup-info-look () + "Setup info-look in the gnuplot buffer. +Also set the variable `gnuplot-keywords' and do something sensible if +info-look was not available. +See the comments in `gnuplot-info-hook'." + (interactive) + (setq gnuplot-keywords-pending nil) + (if (featurep 'info-look) + (progn + (cond ((boundp 'info-lookup-symbol-alist) ; older version + (setq info-lookup-symbol-alist + (append + info-lookup-symbol-alist + '((gnuplot-mode + "[a-zA-Z][_a-zA-Z0-9]*" nil + (("(gnuplot)Top" nil "[_a-zA-Z0-9]+") + ("(gnuplot)Commands" nil "[_a-zA-Z0-9]+") + ("(gnuplot)Functions" nil "[_a-zA-Z0-9]+") + ("(gnuplot)plot" nil "[_a-zA-Z0-9]+") + ("(gnuplot)set-show" nil "[_a-zA-Z0-9]+") + ("(gnuplot)data-file" nil "[_a-zA-Z0-9]+") + ("(gnuplot)smooth" nil "[_a-zA-Z0-9]+") + ("(gnuplot)style" nil "[_a-zA-Z0-9]+") + ("(gnuplot)terminal" nil "[_a-zA-Z0-9]+") + ;;("(gnuplot)General Index" nil "[_a-zA-Z0-9]+") + ) "[_a-zA-Z0-9]+" ))) )) + (t ; newer version + (info-lookup-maybe-add-help + :mode 'gnuplot-mode :topic 'symbol + :regexp "[a-zA-Z][_a-zA-Z0-9]*" + :doc-spec '(("(gnuplot)Top" nil "[_a-zA-Z0-9]+") + ("(gnuplot)Commands" nil "[_a-zA-Z0-9]+") + ("(gnuplot)Functions" nil "[_a-zA-Z0-9]+") + ("(gnuplot)plot" nil "[_a-zA-Z0-9]+") + ("(gnuplot)set-show" nil "[_a-zA-Z0-9]+") + ("(gnuplot)data-file" nil "[_a-zA-Z0-9]+") + ("(gnuplot)smooth" nil "[_a-zA-Z0-9]+") + ("(gnuplot)style" nil "[_a-zA-Z0-9]+") + ("(gnuplot)terminal" nil "[_a-zA-Z0-9]+") + ) ))) + ;; this hook is my best way of working with info-look and + ;; allowing multiple versions of the gnuplot-info file. + ;; yes, this is a hassle. + (run-hooks 'gnuplot-info-hook) + (let ((there (bufferp (get-buffer "*info*")))) + (info-lookup-setup-mode 'symbol 'gnuplot-mode) + (or there (and (get-buffer "*info*") (kill-buffer "*info*"))) + ;; why are these buffers here? I think that the general + ;; user will not want them lying around + (and (get-buffer "info dir") (kill-buffer "info dir")) + (and (get-buffer "info dir<2>") (kill-buffer "info dir<2>"))) + (setq gnuplot-keywords (gnuplot-set-keywords-list)) + ) + + ;; or do something sensible if info-look is not installed + (defun info-lookup-interactive-arguments (symbol) + (message + "Help is not available. The gnuplot info file could not be found.") + (list nil nil))) ) + + +(defun gnuplot-set-keywords-list () + "Set `gnuplot-keywords' from `info-lookup-cache'. +Return a list of keywords." + (let* ((list (cdr (assoc 'symbol info-lookup-cache))) + (list (cdr (cdr (assoc 'gnuplot-mode list)))) + (list (car list)) + (store ()) item) + (while list + (setq item (car (car list)) + item (format "%s" item) ; keep this line for the sake of + store (append (list item) store) ; info-look.el w/o my patch + list (cdr list))) + (delete "nil" store) + store )) + + +(defun gnuplot-complete-keyword () + "Perform completion on keyword preceding point. +This is a pretty simple minded completion function. It is loosely +adapted from `lisp-complete-symbol'." + (interactive) + (if gnuplot-keywords-pending ; + (gnuplot-setup-info-look)) + (let* ((end (point)) + (beg (unwind-protect (save-excursion (backward-sexp 1) (point)))) + (patt (buffer-substring beg end)) + (pattern (if (string-match "\\([^ \t]*\\)\\s-+$" patt) + (match-string 1 patt) patt)) + (alist (mapcar 'list gnuplot-keywords)) + (completion (try-completion pattern alist))) + (cond ((eq completion t)) + ((null completion) + (message "No gnuplot keywords complete \"%s\"" pattern)) + (t + (when (not (string= pattern completion)) + (delete-region beg end) + (insert completion)) + (let* ((list (all-completions pattern alist)) + (mess (format "%S could be one of %S" pattern list)) + (orig (current-buffer)) + (buff (get-buffer-create " *gnuplot-completions*"))) + (if (= (length list) 1) (insert " ")) + (if (< (length mess) (frame-width)) + (if (> (length list) 1) (message mess)) + (switch-to-buffer-other-window buff) + (insert mess) + (fill-region (point-min) (point-max)) + (goto-char (point-min)) + (enlarge-window + (+ 2 (- (count-lines (point-min) (point-max)) + (window-height)))) + (sit-for (max (length list) 15)) + (switch-to-buffer orig) + (kill-buffer buff) + (delete-other-windows) ))) ))) + +(defun gnuplot-info-lookup-symbol (symbol &optional mode) + "Wrapper for `info-lookup-symbol'. +Takes SYMBOL and MODE as arguments exactly as `info-lookup-symbol'. +After doing the info lookup, this displays the info file in a window +frame as specified by the value of `gnuplot-info-display'. If +`gnuplot-info-display' is 'window, then the window will be shrunk to +the size of the info entry if it is smaller than half the height of +the frame." + (interactive + (cond (gnuplot-keywords + (info-lookup-interactive-arguments 'symbol)) + (gnuplot-keywords-pending ; + (gnuplot-setup-info-look) + (info-lookup-interactive-arguments 'symbol)) + (t + (list nil (message + "Help is not available. The gnuplot info file could not be found."))))) + (if (and (featurep 'info-look) gnuplot-keywords) + (let ((buff (current-buffer)) + (info-lookup-other-window-flag + (if gnuplot-info-display t nil))) + (if symbol () (setq symbol "Commands")) + (info-lookup-symbol symbol mode) + (cond ((equal gnuplot-info-display 'window) + (let ((sw (selected-window)) + (window-min-height 2)) + (other-window 1) + (enlarge-window + (min (- (count-lines (point-min) (point-max)) (window-height)) + (- (/ (frame-height) 2) (window-height)))) + (select-window sw))) + ((equal gnuplot-info-display 'frame) + (switch-to-buffer buff) + (delete-other-windows) + (or (and gnuplot-info-frame + (frame-live-p gnuplot-info-frame)) + (setq gnuplot-info-frame (make-frame))) + (select-frame gnuplot-info-frame) + (raise-frame gnuplot-info-frame) + (if gnuplot-xemacs-p (setq toolbar-info-frame gnuplot-info-frame)) + (switch-to-buffer "*info*") )) ))) + + +(defun gnuplot-insert (string) + "Insert STRING at point and display help for for STRING. +Help is not shown if `gnuplot-insertions-show-help-flag' is nil. The +help shown is for STRING unless STRING begins with the word \"set\" or +\"show\", in which case help is shown for the thing being set or +shown." + (interactive) + (cond ((and (not gnuplot-three-eight-p) + (string-match "\\(emf\\|p\\(alette\\|m3d\\)\\|vgagl\\)" string)) + (message "%S is an option introduced in gnuplot 3.8 (You are using %s)" + string gnuplot-program-version) ) + (t + (insert string) + (let ((topic string) term) + (if (string-match + "\\(set\\|show\\)[ \t]+\\([^ \t]+\\)\\(\\s-+\\([^ \t]+\\)\\)?" + string) + (progn + (setq topic (downcase (match-string 2 string)) + term (match-string 4 string)) + (if (string= topic "terminal") (setq topic (downcase term))))) + (cond ((and (fboundp 'gnuplot-gui-set-options-and-insert) + gnuplot-gui-popup-flag) + (gnuplot-gui-set-options-and-insert)) + (gnuplot-insertions-show-help-flag + (if gnuplot-keywords-pending ; + (gnuplot-setup-info-look)) + (gnuplot-info-lookup-symbol topic)) ) )) ) ) + +(defun gnuplot-toggle-info-display () + (interactive) + (setq gnuplot-insertions-show-help-flag (not gnuplot-insertions-show-help-flag)) + (message (if gnuplot-insertions-show-help-flag + "Help will be displayed after insertions." + "Help no longer displayed after insertions."))) + + +;;; --- bug reports +;; grep '(defcustom' gnuplot.el gnuplot-gui.el | awk '{print $2}' +(defun gnuplot-bug-report () + "Submit a bug report about `gnuplot-mode' by email. +Please do not send any bug reports about gnuplot itself to the +maintainer of `gnuplot-mode'." + (interactive) + (let ((line (make-string 62 ?-))) + (require 'reporter) + (and (y-or-n-p + "Do you really want to submit an email report about gnuplot? ") + (y-or-n-p + (concat "Variable values will be written to the message. " + "Don't erase them. OK? ")) + (reporter-submit-bug-report + (format "%s <%s>" gnuplot-maintainer gnuplot-maintainer-email) + (format "gnuplot-mode (version %s)" gnuplot-version) + (append ; variables to display values of in mail + '(gnuplot-mode-hook + gnuplot-load-hook + gnuplot-after-plot-hook + gnuplot-info-hook + gnuplot-comint-setup-hook + gnuplot-program + gnuplot-program-version + gnuplot-process-name + gnuplot-gnuplot-buffer + gnuplot-display-process + gnuplot-info-display + gnuplot-echo-command-line-flag + gnuplot-insertions-show-help-flag + gnuplot-delay + gnuplot-quote-character + gnuplot-keywords-when + ;;gnuplot-insertions-menu-flag + ;;gnuplot-insertions-adornments + ;;gnuplot-insertions-plot-options + ;;gnuplot-insertions-terminal + ;;gnuplot-insertions-x-axis + ;;gnuplot-insertions-x2-axis + ;;gnuplot-insertions-y-axis + ;;gnuplot-insertions-y2-axis + ;;gnuplot-insertions-z-axis + ;;gnuplot-insertions-parametric-plots + ;;gnuplot-insertions-polar-plots + ;;gnuplot-insertions-surface-plots + gnuplot-toolbar-display-flag + gnuplot-toolbar-use-toolbar + gnuplot-gui-popup-flag + gnuplot-gui-frame-plist + gnuplot-gui-frame-parameters + gnuplot-gui-fontname-list + gnuplot-gui-plot-splot-fit-style + ;; plus a few more... + gnuplot-comint-recent-buffer + gnuplot-version + Info-directory-list + exec-path + features )) + nil ; pre-hooks + nil ; post-hooks + (concat line ; salutation + "\nInsert your description of the gnuplot-mode bug here.\n" + "Please be as specific as possible.\n\n" + "There are several known shortcomings of gnuplot-mode.\n" + "Many of these have to do with the complicated and inconsistent\n" + "syntax of gnuplot itself. See the document string for the\n" + "function `gnuplot-mode' (use `" + (substitute-command-keys "\\[describe-function]") + "') for details.\n\n" + "Note that this bug report form should be used for problems\n" + "with gnuplot-mode only. Problems with gnuplot itself should\n" + "be addressed directly to the developers of gnuplot.\n" + "The maintainer of gnuplot-mode will not field questions about\n" + "gnuplot itself. Thank you.\n" + line) + )))) + + + +;;; --- autoloaded functions: gnuplot-mode and gnuplot-make-buffer + +;;;###autoload +(defun gnuplot-mode () + "Major mode for editing and executing GNUPLOT scripts. +This was written with version 3.7 of gnuplot in mind but it should +work fine with version 3.5 and the various 3.6 beta versions. + +Report bugs in `gnuplot-mode' using \\[gnuplot-bug-report]. + + ------O------ + +The help functions, keyword completion, and several other features +depend upon having the info file properly installed. The info file +can be made in the document directory of the gnuplot distribution or +is available at the `gnuplot-mode' web page: + http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/ + +If the help function does not work properly, you may have an older +version of the gnuplot info file. Try the suggestion in the document +string for the variable `gnuplot-info-hook'. See the `gnuplot-mode' +web page for more details. + + ------O------ + +There are several known shortcomings of `gnuplot-mode', version 0.5g +and up. Many of the shortcomings involve the graphical interface +(refered to as the GUI) to setting arguments to plot options. Here is +a list: + + 1. Currently there is no way for `gnuplot-mode' to know if information + sent to gnuplot was correctly plotted. + 2. Indentation is sometimes a bit flaky. + 3. \"plot\", \"splot\", and \"fit\" are handled in the GUI, but are + a bit flaky. Their arguments may not be read correctly from + existing text, and continuation lines (common for plot and splot) + are not supported. + 4. The GUI does not know how to read from continuation lines. + 5. Comma separated position arguments to plot options are + unsupported in the GUI. Colon separated datafile modifiers (used + for plot, splot, and fit) are not supported either. Arguments + not yet supported by the GUI generate messages printed in grey + text. + 6. The GUI handling of \"hidden3d\" is flaky and \"cntrparam\" is + unsupported. + + ------O------ + + Key bindings: + \\{gnuplot-mode-map}" + (interactive) + (kill-all-local-variables) + (use-local-map gnuplot-mode-map) + (setq major-mode 'gnuplot-mode + mode-name "Gnuplot") + (set (make-local-variable 'comment-start) "# ") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'comment-column) 32) + (set (make-local-variable 'comment-start-skip) "#[ \t]*") + (set (make-local-variable 'indent-line-function) 'gnuplot-indent-line) + (set-syntax-table gnuplot-mode-syntax-table) + (if (or (fboundp 'hilit-set-mode-patterns) + (equal gnuplot-keywords-when 'immediately)) ; + (gnuplot-setup-info-look)) ;; + (if (fboundp 'hilit-set-mode-patterns) ; deal with hilit19 (ho hum!) + (let ((keywords (concat "\\b\\(" (mapconcat 'identity + gnuplot-keywords "\\|") + "\\)\\b"))) + (hilit-set-mode-patterns + 'gnuplot-mode + `(("#.*$" nil comment) + ("\\([a-zA-Z0-9_-]+\\)\\(([^)]*)\\)?\\s *=" nil define) + ,(list keywords 'nil 'keyword) + (hilit-string-find ?\\ string) + ))) ) + ;;(if (featurep 'kw-compl) ; old-style keyword completion + ;; (setq kw-compl-list gnuplot-keywords + ;; kw-compl-upper-case nil)) ; gnuplot keywords must be lower case + (if gnuplot-xemacs-p ; deal with font-lock + (if (fboundp 'turn-on-font-lock) (turn-on-font-lock)) + (progn + (make-variable-buffer-local 'font-lock-defaults) + (setq font-lock-defaults '(gnuplot-font-lock-keywords t t)))) +;; (if (and gnuplot-xemacs-p gnuplot-toolbar-display-flag) +;; (condition-case () ; deal with the toolbar +;; (and (require 'toolbar) +;; (require 'xpm) +;; (gnuplot-make-toolbar-function)) +;; (error nil))) + (if (fboundp 'widget-create) ; gunplot-gui + (condition-case () + (require 'gnuplot-gui) + (error nil))) + (setq gnuplot-first-call nil ; a few more details ... + gnuplot-comint-recent-buffer (current-buffer) + comint-process-echoes gnuplot-echo-command-line-flag) + (run-hooks 'gnuplot-mode-hook) + ;; the first time we need to figure out which gnuplot we are running + (if gnuplot-program-version + (gnuplot-setup-menu-and-toolbar) + (gnuplot-fetch-version-number))) + +;;;###autoload +(defun gnuplot-make-buffer () + "Open a new buffer in `gnuplot-mode'. +When invoked, it switches to a new, empty buffer visiting no file +and then starts `gnuplot-mode'. + +It is convenient to bind this function to a global key sequence. For +example, to make the F10 key open a gnuplot script buffer, put the +following in your .emacs file: + (autoload 'gnuplot-make-buffer \"gnuplot\" + \"open a buffer in gnuplot mode\" t) + (global-set-key [(f10)] 'gnuplot-make-buffer)" + (interactive) + (switch-to-buffer gnuplot-gnuplot-buffer) + (gnuplot-mode)) + +(defun gnuplot-show-version () + "Show version number in echo area" + (interactive) + (message "gnuplot-mode %s -- URL: %s" gnuplot-version gnuplot-maintainer-url)) + +(defun gnuplot-show-gnuplot-version () + "Show gnuplot program and version number in echo area" + (interactive) + (message "You are calling gnuplot %s as %s" gnuplot-program-version gnuplot-program)) + + +;;; That's it! ---------------------------------------------------------------- + + +;;; --- final chores: provide 'gnuplot and run load-hook +;; provide before run-hooks suggested by +(provide 'gnuplot) +(run-hooks 'gnuplot-load-hook) + +;;;============================================================================ +;;; +;;; gnuplot.el ends here diff --git a/util/gnuplot-mode.0.6.0/gnuplot.info b/util/gnuplot-mode.0.6.0/gnuplot.info new file mode 100644 index 000000000..89168dcc8 --- /dev/null +++ b/util/gnuplot-mode.0.6.0/gnuplot.info @@ -0,0 +1,7710 @@ +This file is gnuplot.info created by doc2info from ./gnuplot.doc. + + +File: gnuplot.info, Node: Top, Prev: (dir), Next: gnuplot, Up: (dir) + +gnuplot +******* + + +* Menu: + +* gnuplot:: +* Commands:: +* Graphical User Interfaces:: +* Bugs:: + + +File: gnuplot.info, Node: gnuplot, Prev: Top, Up: Top, Next: Copyright + + +* Menu: + +* Copyright:: +* Introduction:: +* Seeking-assistance:: +* What's New in version 3.7:: +* Batch/Interactive Operation:: +* Command-line-editing:: +* Comments:: +* Coordinates:: +* Environment:: +* Expressions:: +* Glossary:: +* Plotting:: +* Start-up:: +* Substitution:: +* Syntax:: +* Time/Date data:: + + +File: gnuplot.info, Node: Copyright, Prev: gnuplot, Up: gnuplot, Next: Introduction + + Copyright (C) 1986 - 1993, 1998 Thomas Williams, Colin Kelley + + Permission to use, copy, and distribute this software and its + documentation for any purpose with or without fee is hereby granted, + provided that the above copyright notice appear in all copies and + that both that copyright notice and this permission notice appear + in supporting documentation. + + Permission to modify the software is granted, but not the right to + distribute the complete modified source code. Modifications are to + be distributed as patches to the released version. Permission to + distribute binaries produced by compiling modified sources is granted, + provided you + 1. distribute the corresponding source modifications from the + released version in the form of a patch file along with the binaries, + 2. add special version identification to distinguish your version + in addition to the base release version number, + 3. provide your name and address as the primary contact for the + support of your modified version, and + 4. retain our contact information in regard to use of the base + software. + Permission to distribute the released version of the source code along + with corresponding source modifications in the form of a patch file is + granted with same provisions 2 through 4 for binary distributions. + + This software is provided "as is" without express or implied warranty + to the extent permitted by applicable law. + + + AUTHORS + + Original Software: + Thomas Williams, Colin Kelley. + + Gnuplot 2.0 additions: + Russell Lang, Dave Kotz, John Campbell. + + Gnuplot 3.0 additions: + Gershon Elber and many others. + + +File: gnuplot.info, Node: Introduction, Prev: Copyright, Up: gnuplot, Next: Seeking-assistance + + `gnuplot` (*note gnuplot:: ) is a command-driven interactive function and data + plotting program. It is case sensitive (commands and function names written in + lowercase are not the same as those written in CAPS). All command names may + be abbreviated as long as the abbreviation is not ambiguous. Any number of + commands may appear on a line (with the exception that `load` (*note load:: ) + or `call` (*note call:: ) must be the final command), separated by semicolons + (;). Strings are indicated with quotes. They may be either single or double + quotation marks, e.g., + + load "filename" + cd 'dir' + + although there are some subtle differences (see `syntax` (*note Syntax:: ) for + more details). + + Any command-line arguments are assumed to be names of files containing + `gnuplot` commands, with the exception of standard X11 arguments, which are + processed first. Each file is loaded with the `load` command, in the order + specified. `gnuplot` exits after the last file is processed. When no load + files are named, `gnuplot` enters into an interactive mode. The special + filename "-" is used to denote standard input. See "help batch/interactive" + for more details. + + Many `gnuplot` commands have multiple options. These options must appear in + the proper order, although unwanted ones may be omitted in most cases. Thus + if the entire command is "command a b c", then "command a c" will probably + work, but "command c a" will fail. + + Commands may extend over several input lines by ending each line but the last + with a backslash (\). The backslash must be the _last_ character on each + line. The effect is as if the backslash and newline were not there. That + is, no white space is implied, nor is a comment terminated. Therefore, + commenting out a continued line comments out the entire command (see + `comment`). But note that if an error occurs somewhere on a multi-line + command, the parser may not be able to locate precisely where the error is + and in that case will not necessarily point to the correct line. + + In this document, curly braces ({}) denote optional arguments and a vertical + bar (|) separates mutually exclusive choices. `gnuplot` keywords or `help` + (*note help:: ) topics are indicated by backquotes or `boldface` (where + available). Angle brackets (<>) are used to mark replaceable tokens. In many + cases, a default value of the token will be taken for optional arguments if + the token is omitted, but these cases are not always denoted with braces + around the angle brackets. + + For on-line help on any topic, type `help` followed by the name of the topic + or just `help` or `?` to get a menu of available topics. + + The new `gnuplot` user should begin by reading about `plotting` + (*note Plotting:: ) (if on-line, type `help plotting`). + + + +File: gnuplot.info, Node: Seeking-assistance, Prev: Introduction, Up: gnuplot, Next: What's New in version 3.7 + + There is a mailing list for `gnuplot` (*note gnuplot:: ) users. Note, + however, that the newsgroup comp.graphics.apps.gnuplot is identical to + the mailing list (they both carry the same set of messages). We prefer that + you read the messages through the newsgroup rather than subscribing to the + mailing list. Administrative requests should be sent to + majordomo@dartmouth.edu Send a message with the body (not the subject) + consisting of the single word "help" (without the quotes) for more details. + + The address for mailing to list members is: + info-gnuplot@dartmouth.edu + + Bug reports and code contributions should be mailed to: + bug-gnuplot@dartmouth.edu + + The list of those interested in beta-test versions is: + info-gnuplot-beta@dartmouth.edu + + There is also a World Wide Web page with up-to-date information, including + known bugs: + http://www.cs.dartmouth.edu/gnuplot_info.html + + Before seeking help, please check the + FAQ (Frequently Asked Questions) list. + If you do not have a copy of the FAQ, you may request a copy by email from + the Majordomo address above, ftp a copy from + ftp://ftp.dartmouth.edu/pub/gnuplot + or see the WWW `gnuplot` page. + + When posting a question, please include full details of the version of + `gnuplot`, the machine, and operating system you are using. A _small_ script + demonstrating the problem may be useful. Function plots are preferable to + datafile plots. If email-ing to info-gnuplot, please state whether or not + you are subscribed to the list, so that users who use news will know to email + a reply to you. There is a form for such postings on the WWW site. + + +File: gnuplot.info, Node: What's New in version 3.7, Prev: Seeking-assistance, Up: gnuplot, Next: Batch/Interactive Operation + + Gnuplot version 3.7 contains many new features. This section gives a partial + list and links to the new items in no particular order. + + 1. `fit f(x) 'file' via` uses the Marquardt-Levenberg method to fit data. + (This is only slightly different from the `gnufit` patch available for 3.5.) + + 2. Greatly expanded `using` (*note using:: ) command. See plot using. + + 3. `set timefmt` (*note timefmt:: ) allows for the use of dates as input and + output for time series plots. See `Time/Date data` and timedat.dem. + + 4. Multiline labels and font selection in some drivers. + + 5. Minor (unlabeled) tics. See `set mxtics` (*note mxtics:: ). + + 6. `key` (*note key:: ) options for moving the key box in the page (and even + outside of the plot), putting a title on it and a box around it, and + more. See `set key`. + + 7. Multiplots on a single logical page with `set multiplot` + (*note multiplot:: ). + + 8. Enhanced `postscript` (*note postscript:: ) driver with super/subscripts + and font changes. (This was a separate driver (`enhpost`) that was available + as a patch for 3.5.) + + 9. Second axes: use the top and right axes independently of the bottom and + left, both for plotting and labels. See `plot` (*note plot:: ). + + 10. Special datafile names `'-'` and `""`. See `plot special-filenames` + (*note special-filenames:: ). + + 11. Additional coordinate systems for labels and arrows. See `coordinates` + (*note Coordinates:: ). + + 12. `set size` (*note size:: ) can try to plot with a specified aspect ratio. + + 13. `set missing` (*note missing:: ) now treats missing data correctly. + + 14. The `call` (*note call:: ) command: `load` (*note load:: ) with + arguments. + + 15. More flexible `range` commands with `reverse` and `writeback` keywords. + + 16. `set encoding` (*note encoding:: ) for multi-lingual encoding. + + 17. New `x11` (*note x11:: ) driver with persistent and multiple windows. + + 18. New plotting styles: `xerrorbars` (*note xerrorbars:: ), `histeps` + (*note histeps:: ), `financebars` (*note financebars:: ) and more. See `set + style` (*note style:: ). + + 19. New tic label formats, including `"%l %L"` which uses the mantissa and + exponents to a given base for labels. See `set format` (*note format:: ). + + 20. New drivers, including `cgm` (*note cgm:: ) for inclusion into MS-Office + applications and `gif` for serving plots to the WEB. + + 21. Smoothing and spline-fitting options for `plot`. See `plot smooth` + (*note smooth:: ). + + 22. `set margin` (*note margin:: ) and `set origin` (*note origin:: ) give + much better control over where a graph appears on the page. + + 23. `set border` (*note border:: ) now controls each border individually. + + 24. The new commands `if` (*note if:: ) and `reread` (*note reread:: ) allow + command loops. + + 25. Point styles and sizes, line types and widths can be specified on the + `plot` command. Line types and widths can also be specified for grids, + borders, tics and arrows. See `plot with` (*note with:: ). Furthermore these + types may be combined and stored for further use. See `set linestyle` + (*note linestyle:: ). + + 26. Text (labels, tic labels, and the time stamp) can be written vertically + by those terminals capable of doing so. + + +File: gnuplot.info, Node: Batch/Interactive Operation, Prev: What's New in version 3.7, Up: gnuplot, Next: Command-line-editing + + `gnuplot` (*note gnuplot:: ) may be executed in either batch or interactive + modes, and the two may even be mixed together on many systems. + + Any command-line arguments are assumed to be names of files containing + `gnuplot` commands (with the exception of standard X11 arguments, which are + processed first). Each file is loaded with the `load` (*note load:: ) + command, in the order specified. `gnuplot` exits after the last file is + processed. When no load files are named, `gnuplot` enters into an interactive + mode. The special filename "-" is used to denote standard input. + + Both the `exit` (*note exit:: ) and `quit` (*note quit:: ) commands terminate + the current command file and `load` the next one, until all have been + processed. + + Examples: + + To launch an interactive session: + gnuplot + + To launch a batch session using two command files "input1" and "input2": + gnuplot input1 input2 + + To launch an interactive session after an initialization file "header" and + followed by another command file "trailer": + gnuplot header - trailer + + +File: gnuplot.info, Node: Command-line-editing, Prev: Batch/Interactive Operation, Up: gnuplot, Next: Comments + + Command-line editing is supported by the Unix, Atari, VMS, MS-DOS and OS/2 + versions of `gnuplot` (*note gnuplot:: ). Also, a history mechanism allows + previous commands to be edited and re-executed. After the command line has + been edited, a newline or carriage return will enter the entire line without + regard to where the cursor is positioned. + + (The readline function in `gnuplot` is not the same as the readline used in + GNU Bash and GNU Emacs. If the GNU version is desired, it may be selected + instead of the `gnuplot` version at compile time.) + + + The editing commands are as follows: + + `Line-editing`: + + ^B moves back a single character. + ^F moves forward a single character. + ^A moves to the beginning of the line. + ^E moves to the end of the line. + ^H and DEL delete the previous character. + ^D deletes the current character. + ^K deletes from current position to the end of line. + ^L,^R redraws line in case it gets trashed. + ^U deletes the entire line. + ^W deletes the last word. + + `History`: + + ^P moves back through history. + ^N moves forward through history. + + On the IBM PC, the use of a TSR program such as DOSEDIT or CED may be desired + for line editing. The default makefile assumes that this is the case; by + default `gnuplot` will be compiled with no line-editing capability. If you + want to use `gnuplot`'s line editing, set READLINE in the makefile and add + readline.obj to the link file. The following arrow keys may be used on the + IBM PC and Atari versions if readline is used: + + Left Arrow - same as ^B. + Right Arrow - same as ^F. + Ctrl Left Arrow - same as ^A. + Ctrl Right Arrow - same as ^E. + Up Arrow - same as ^P. + Down Arrow - same as ^N. + + The Atari version of readline defines some additional key aliases: + + Undo - same as ^L. + Home - same as ^A. + Ctrl Home - same as ^E. + Esc - same as ^U. + Help - `help` (*note help:: ) plus return. Ctrl Help + - `help `. + + + +File: gnuplot.info, Node: Comments, Prev: Command-line-editing, Up: gnuplot, Next: Coordinates + + Comments are supported as follows: a `#` may appear in most places in a line + and `gnuplot` (*note gnuplot:: ) will ignore the rest of the line. It will + not have this effect inside quotes, inside numbers (including complex + numbers), inside command substitutions, etc. In short, it works anywhere it + makes sense to work. + + + +File: gnuplot.info, Node: Coordinates, Prev: Comments, Up: gnuplot, Next: Environment + + The commands `set arrow` (*note arrow:: ), `set key` (*note key:: ), and + `set label` (*note label:: ) allow you to draw something at an arbitrary + position on the graph. This position is specified by the syntax: + + {} , {} {,{} } + + Each can either be `first`, `second`, `graph` or `screen`. + + `first` places the x, y, or z coordinate in the system defined by the left + and bottom axes; `second` places it in the system defined by the second axes + (top and right); `graph` specifies the area within the axes---0,0 is bottom + left and 1,1 is top right (for splot, 0,0,0 is bottom left of plotting area; + use negative z to get to the base---see `set ticslevel` (*note ticslevel:: )); + and screen specifies the screen area (the entire area---not just the portion + selected by `set size` (*note size:: )), with 0,0 at bottom left and 1,1 at + top right. + + If the coordinate system for x is not specified, `first` is used. If the + system for y is not specified, the one used for x is adopted. + + If one (or more) axis is timeseries, the appropriate coordinate should + be given as a quoted time string according to the `timefmt` (*note timefmt:: ) + format string. See `set xdata` (*note xdata:: ) and set timefmt. . `gnuplot` + (*note gnuplot:: ) will also accept an integer expression, which will be + interpreted as seconds from 1 January 2000. + + + +File: gnuplot.info, Node: Environment, Prev: Coordinates, Up: gnuplot, Next: Expressions + + A number of shell environment variables are understood by `gnuplot` + (*note gnuplot:: ). None of these are required, but may be useful. + + If GNUTERM is defined, it is used as the name of the terminal type to be + used. This overrides any terminal type sensed by `gnuplot` on start-up, but + is itself overridden by the .gnuplot (or equivalent) start-up file (see + `start-up`) and, of course, by later explicit changes. + + On Unix, AmigaOS, AtariTOS, MS-DOS and OS/2, GNUHELP may be defined to be the + pathname of the HELP file (gnuplot.gih). + + On VMS, the logical name GNUPLOT$HELP should be defined as the name of the + help library for `gnuplot`. The `gnuplot` help can be put inside any system + help library, allowing access to help from both within and outside `gnuplot` + if desired. + + On Unix, HOME is used as the name of a directory to search for a .gnuplot + file if none is found in the current directory. On AmigaOS, AtariTOS, + MS-DOS and OS/2, gnuplot is used. On VMS, SYS$LOGIN: is used. See `help + (*note help:: ) start-up`. + + On Unix, PAGER is used as an output filter for help messages. + + On Unix, AtariTOS and AmigaOS, SHELL is used for the `shell` (*note shell:: ) + command. On MS-DOS and OS/2, COMSPEC is used for the `shell` command. + + On MS-DOS, if the BGI or Watcom interface is used, PCTRM is used to tell + the maximum resolution supported by your monitor by setting it to + S. E.g. if your monitor's maximum resolution is + 800x600, then use: + set PCTRM=S800 + If PCTRM is not set, standard VGA is used. + + FIT_SCRIPT may be used to specify a `gnuplot` command to be executed when a + fit is interrupted---see `fit` (*note fit:: ). FIT_LOG specifies the filename + of the logfile maintained by fit. + + + +File: gnuplot.info, Node: Expressions, Prev: Environment, Up: gnuplot, Next: Functions + + In general, any mathematical expression accepted by C, FORTRAN, Pascal, or + BASIC is valid. The precedence of these operators is determined by the + specifications of the C programming language. White space (spaces and tabs) + is ignored inside expressions. + + Complex constants are expressed as {,}, where and + must be numerical constants. For example, {3,2} represents 3 + 2i; {0,1} + represents 'i' itself. The curly braces are explicitly required here. + + Note that gnuplot uses both "real" and "integer" arithmetic, like FORTRAN and + C. Integers are entered as "1", "-10", etc; reals as "1.0", "-10.0", "1e1", + 3.5e-1, etc. The most important difference between the two forms is in + division: division of integers truncates: 5/2 = 2; division of reals does + not: 5.0/2.0 = 2.5. In mixed expressions, integers are "promoted" to reals + before evaluation: 5/2e0 = 2.5. The result of division of a negative integer + by a positive one may vary among compilers. Try a test like "print -5/2" to + determine if your system chooses -2 or -3 as the answer. + + The integer expression "1/0" may be used to generate an "undefined" flag, + which causes a point to ignored; the `ternary` (*note Ternary:: ) operator + gives an example. + + The real and imaginary parts of complex expressions are always real, whatever + the form in which they are entered: in {3,2} the "3" and "2" are reals, not + integers. + +* Menu: + +* Functions:: +* Operators:: +* User-defined:: + + +File: gnuplot.info, Node: Functions, Prev: Expressions, Up: Expressions, Next: abs + + The functions in `gnuplot` (*note gnuplot:: ) are the same as the + corresponding functions in the Unix math library, except that all functions + accept integer, real, and complex arguments, unless otherwise noted. + + For those functions that accept or return angles that may be given in either + degrees or radians (sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), + atan2(x) and arg(z)), the unit may be selected by `set angles` + (*note angles:: ), which defaults to radians. + + +* Menu: + +* abs:: +* acos:: +* acosh:: +* arg:: +* asin:: +* asinh:: +* atan:: +* atan2:: +* atanh:: +* besj0:: +* besj1:: +* besy0:: +* besy1:: +* ceil:: +* cos:: +* cosh:: +* erf:: +* erfc:: +* exp:: +* floor:: +* gamma:: +* ibeta:: +* inverf:: +* igamma:: +* imag:: +* invnorm:: +* int:: +* lgamma:: +* log:: +* log10:: +* norm:: +* rand:: +* real:: +* sgn:: +* sin:: +* sinh:: +* sqrt:: +* tan:: +* tanh:: +* column:: +* tm_hour:: +* tm_mday:: +* tm_min:: +* tm_mon:: +* tm_sec:: +* tm_wday:: +* tm_yday:: +* tm_year:: +* valid:: + + +File: gnuplot.info, Node: abs, Prev: Functions, Up: Functions, Next: acos + + The `abs` function returns the absolute value of its argument. The returned + value is of the same type as the argument. + + For complex arguments, abs(x) is defined as the length of x in the complex + plane [i.e., sqrt(real(x)**2 + imag(x)**2) ]. + + +File: gnuplot.info, Node: acos, Prev: abs, Up: Functions, Next: acosh + + The `acos` function returns the arc cosine (inverse cosine) of its argument. + `acos` returns its argument in radians or degrees, as selected by `set + angles`. + + +File: gnuplot.info, Node: acosh, Prev: acos, Up: Functions, Next: arg + + The `acosh` function returns the inverse hyperbolic cosine of its argument in + radians. + + +File: gnuplot.info, Node: arg, Prev: acosh, Up: Functions, Next: asin + + The `arg` function returns the phase of a complex number in radians or + degrees, as selected by `set angles` (*note angles:: ). + + + +File: gnuplot.info, Node: asin, Prev: arg, Up: Functions, Next: asinh + + The `asin` function returns the arc sin (inverse sin) of its argument. + `asin` returns its argument in radians or degrees, as selected by `set + angles`. + + +File: gnuplot.info, Node: asinh, Prev: asin, Up: Functions, Next: atan + + The `asinh` function returns the inverse hyperbolic sin of its argument in + radians. + + +File: gnuplot.info, Node: atan, Prev: asinh, Up: Functions, Next: atan2 + + The `atan` function returns the arc tangent (inverse tangent) of its + argument. `atan` returns its argument in radians or degrees, as selected by + `set angles` (*note angles:: ). + + + +File: gnuplot.info, Node: atan2, Prev: atan, Up: Functions, Next: atanh + + The `atan2` function returns the arc tangent (inverse tangent) of the ratio + of the real parts of its arguments. `atan2` returns its argument in radians + or degrees, as selected by `set angles` (*note angles:: ), in the correct + quadrant. + + + +File: gnuplot.info, Node: atanh, Prev: atan2, Up: Functions, Next: besj0 + + The `atanh` function returns the inverse hyperbolic tangent of its argument + in radians. + + +File: gnuplot.info, Node: besj0, Prev: atanh, Up: Functions, Next: besj1 + + The `besj0` function returns the j0th Bessel function of its argument. + `besj0` expects its argument to be in radians. + + +File: gnuplot.info, Node: besj1, Prev: besj0, Up: Functions, Next: besy0 + + The `besj1` function returns the j1st Bessel function of its argument. + `besj1` expects its argument to be in radians. + + +File: gnuplot.info, Node: besy0, Prev: besj1, Up: Functions, Next: besy1 + + The `besy0` function returns the y0th Bessel function of its argument. + `besy0` expects its argument to be in radians. + + +File: gnuplot.info, Node: besy1, Prev: besy0, Up: Functions, Next: ceil + + The `besy1` function returns the y1st Bessel function of its argument. + `besy1` expects its argument to be in radians. + + +File: gnuplot.info, Node: ceil, Prev: besy1, Up: Functions, Next: cos + + The `ceil` function returns the smallest integer that is not less than its + argument. For complex numbers, `ceil` returns the smallest integer not less + than the real part of its argument. + + +File: gnuplot.info, Node: cos, Prev: ceil, Up: Functions, Next: cosh + + The `cos` function returns the cosine of its argument. `cos` accepts its + argument in radians or degrees, as selected by `set angles` + (*note angles:: ). + + + +File: gnuplot.info, Node: cosh, Prev: cos, Up: Functions, Next: erf + + The `cosh` function returns the hyperbolic cosine of its argument. `cosh` + expects its argument to be in radians. + + +File: gnuplot.info, Node: erf, Prev: cosh, Up: Functions, Next: erfc + + The `erf` function returns the error function of the real part of its + argument. If the argument is a complex value, the imaginary component is + ignored. + + +File: gnuplot.info, Node: erfc, Prev: erf, Up: Functions, Next: exp + + The `erfc` function returns 1.0 - the error function of the real part of its + argument. If the argument is a complex value, the imaginary component is + ignored. + + +File: gnuplot.info, Node: exp, Prev: erfc, Up: Functions, Next: floor + + The `exp` function returns the exponential function of its argument (`e` + raised to the power of its argument). On some implementations (notably + suns), exp(-x) returns undefined for very large x. A user-defined function + like safe(x) = x<-100 ? 0 : exp(x) might prove useful in these cases. + + +File: gnuplot.info, Node: floor, Prev: exp, Up: Functions, Next: gamma + + The `floor` function returns the largest integer not greater than its + argument. For complex numbers, `floor` returns the largest integer not + greater than the real part of its argument. + + +File: gnuplot.info, Node: gamma, Prev: floor, Up: Functions, Next: ibeta + + The `gamma` function returns the gamma function of the real part of its + argument. For integer n, gamma(n+1) = n!. If the argument is a complex + value, the imaginary component is ignored. + + +File: gnuplot.info, Node: ibeta, Prev: gamma, Up: Functions, Next: inverf + + The `ibeta` function returns the incomplete beta function of the real parts + of its arguments. p, q > 0 and x in [0:1]. If the arguments are complex, + the imaginary components are ignored. + + +File: gnuplot.info, Node: inverf, Prev: ibeta, Up: Functions, Next: igamma + + The `inverf` function returns the inverse error function of the real part + of its argument. + + +File: gnuplot.info, Node: igamma, Prev: inverf, Up: Functions, Next: imag + + The `igamma` function returns the incomplete gamma function of the real + parts of its arguments. a > 0 and x >= 0. If the arguments are complex, + the imaginary components are ignored. + + +File: gnuplot.info, Node: imag, Prev: igamma, Up: Functions, Next: invnorm + + The `imag` function returns the imaginary part of its argument as a real + number. + + +File: gnuplot.info, Node: invnorm, Prev: imag, Up: Functions, Next: int + + The `invnorm` function returns the inverse normal distribution function of + the real part of its argument. + + +File: gnuplot.info, Node: int, Prev: invnorm, Up: Functions, Next: lgamma + + The `int` function returns the integer part of its argument, truncated + toward zero. + + +File: gnuplot.info, Node: lgamma, Prev: int, Up: Functions, Next: log + + The `lgamma` function returns the natural logarithm of the gamma function + of the real part of its argument. If the argument is a complex value, the + imaginary component is ignored. + + +File: gnuplot.info, Node: log, Prev: lgamma, Up: Functions, Next: log10 + + The `log` function returns the natural logarithm (base `e`) of its argument. + + +File: gnuplot.info, Node: log10, Prev: log, Up: Functions, Next: norm + + The `log10` function returns the logarithm (base 10) of its argument. + + +File: gnuplot.info, Node: norm, Prev: log10, Up: Functions, Next: rand + + The `norm` function returns the normal distribution function (or Gaussian) + of the real part of its argument. + + +File: gnuplot.info, Node: rand, Prev: norm, Up: Functions, Next: real + + The `rand` function returns a pseudo random number in the interval [0:1] + using the real part of its argument as a seed. If seed < 0, the sequence + is (re)initialized. If the argument is a complex value, the imaginary + component is ignored. + + +File: gnuplot.info, Node: real, Prev: rand, Up: Functions, Next: sgn + + The `real` function returns the real part of its argument. + + +File: gnuplot.info, Node: sgn, Prev: real, Up: Functions, Next: sin + + The `sgn` function returns 1 if its argument is positive, -1 if its argument + is negative, and 0 if its argument is 0. If the argument is a complex value, + the imaginary component is ignored. + + +File: gnuplot.info, Node: sin, Prev: sgn, Up: Functions, Next: sinh + + The `sin` function returns the sine of its argument. `sin` expects its + argument to be in radians or degrees, as selected by `set angles` + (*note angles:: ). + + + +File: gnuplot.info, Node: sinh, Prev: sin, Up: Functions, Next: sqrt + + The `sinh` function returns the hyperbolic sine of its argument. `sinh` + expects its argument to be in radians. + + +File: gnuplot.info, Node: sqrt, Prev: sinh, Up: Functions, Next: tan + + The `sqrt` function returns the square root of its argument. + + +File: gnuplot.info, Node: tan, Prev: sqrt, Up: Functions, Next: tanh + + The `tan` function returns the tangent of its argument. `tan` expects + its argument to be in radians or degrees, as selected by `set angles` + (*note angles:: ). + + + +File: gnuplot.info, Node: tanh, Prev: tan, Up: Functions, Next: column + + The `tanh` function returns the hyperbolic tangent of its argument. `tanh` + expects its argument to be in radians. + + A few additional functions are also available. + + + +File: gnuplot.info, Node: column, Prev: tanh, Up: Functions, Next: tm_hour + + `column(x)` may be used only in expressions as part of `using` + (*note using:: ) manipulations to fits or datafile plots. See `plot datafile + using`. + + + +File: gnuplot.info, Node: tm_hour, Prev: column, Up: Functions, Next: tm_mday + + The `tm_hour` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the hour (an integer in the range 0--23) as a real. + + +File: gnuplot.info, Node: tm_mday, Prev: tm_hour, Up: Functions, Next: tm_min + + The `tm_mday` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the day of the month (an integer in the range 1--31) + as a real. + + +File: gnuplot.info, Node: tm_min, Prev: tm_mday, Up: Functions, Next: tm_mon + + The `tm_min` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the minute (an integer in the range 0--59) as a real. + + +File: gnuplot.info, Node: tm_mon, Prev: tm_min, Up: Functions, Next: tm_sec + + The `tm_mon` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the month (an integer in the range 1--12) as a real. + + +File: gnuplot.info, Node: tm_sec, Prev: tm_mon, Up: Functions, Next: tm_wday + + The `tm_sec` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the second (an integer in the range 0--59) as a real. + + +File: gnuplot.info, Node: tm_wday, Prev: tm_sec, Up: Functions, Next: tm_yday + + The `tm_wday` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the day of the week (an integer in the range 1--7) as + a real. + + +File: gnuplot.info, Node: tm_yday, Prev: tm_wday, Up: Functions, Next: tm_year + + The `tm_yday` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the day of the year (an integer in the range 1--366) + as a real. + + +File: gnuplot.info, Node: tm_year, Prev: tm_yday, Up: Functions, Next: valid + + The `tm_year` function interprets its argument as a time, in seconds from + 1 Jan 2000. It returns the year (an integer) as a real. + + +File: gnuplot.info, Node: valid, Prev: tm_year, Up: Functions + + `valid(x)` may be used only in expressions as part of `using` (*note using:: ) + manipulations to fits or datafile plots. See `plot datafile using`. + + + +File: gnuplot.info, Node: Operators, Prev: Functions, Up: Expressions, Next: Unary + + The operators in `gnuplot` (*note gnuplot:: ) are the same as the + corresponding operators in the C programming language, except that all + operators accept integer, real, and complex arguments, unless otherwise + noted. The ** operator (exponentiation) is supported, as in FORTRAN. + + Parentheses may be used to change order of evaluation. + +* Menu: + +* Unary:: +* Binary:: +* Ternary:: + + +File: gnuplot.info, Node: Unary, Prev: Operators, Up: Operators, Next: Binary + + The following is a list of all the unary operators and their usages: + + Symbol Example Explanation + - -a unary minus + + +a unary plus (no-operation) + ~ ~a * one's complement + ! !a * logical negation + ! a! * factorial + $ $3 * call arg/column during `using` (*note using:: ) + manipulation (*) Starred explanations indicate that the operator requires an + integer argument. + + Operator precedence is the same as in Fortran and C. As in those languages, + parentheses may be used to change the order of operation. Thus -2**2 = -4, + but (-2)**2 = 4. + + The factorial operator returns a real number to allow a greater range. + + +File: gnuplot.info, Node: Binary, Prev: Unary, Up: Operators, Next: Ternary + + The following is a list of all the binary operators and their usages: + + Symbol Example Explanation + ** a**b exponentiation + * a*b multiplication + / a/b division + % a%b * modulo + + a+b addition + - a-b subtraction + == a==b equality + != a!=b inequality + < a a>b greater than + >= a>=b greater than or equal to + & a&b * bitwise AND + ^ a^b * bitwise exclusive OR + | a|b * bitwise inclusive OR + && a&&b * logical AND + || a||b * logical OR + + (*) Starred explanations indicate that the operator requires integer + arguments. + + Logical AND (&&) and OR (||) short-circuit the way they do in C. That is, + the second `&&` operand is not evaluated if the first is false; the second + `||` operand is not evaluated if the first is true. + + +File: gnuplot.info, Node: Ternary, Prev: Binary, Up: Operators + + There is a single ternary operator: + + Symbol Example Explanation + ?: a?b:c ternary operation + + The ternary operator behaves as it does in C. The first argument (a), which + must be an integer, is evaluated. If it is true (non-zero), the second + argument (b) is evaluated and returned; otherwise the third argument (c) is + evaluated and returned. + + The ternary operator is very useful both in constructing piecewise functions + and in plotting points only when certain conditions are met. + + Examples: + + Plot a function that is to equal sin(x) for 0 <= x < 1, 1/x for 1 <= x < 2, + and undefined elsewhere: + f(x) = 0<=x && x<1 ? sin(x) : 1<=x && x<2 ? 1/x : 1/0 + plot f(x) + Note that `gnuplot` (*note gnuplot:: ) quietly ignores undefined values, so + the final branch of the function (1/0) will produce no plottable points. Note + also that f(x) will be plotted as a continuous function across the + discontinuity if a line style is used. To plot it discontinuously, create + separate functions for the two pieces. (Parametric functions are also useful + for this purpose.) + + For data in a file, plot the average of the data in columns 2 and 3 against + the datum in column 1, but only if the datum in column 4 is non-negative: + + plot 'file' using 1:( $4<0 ? 1/0 : ($2+$3)/2 ) + + Please see `plot data-file using` (*note using:: ) for an explanation of the + using syntax. + + + +File: gnuplot.info, Node: User-defined, Prev: Operators, Up: Expressions + + New user-defined variables and functions of one through five variables may + be declared and used anywhere, including on the `plot` (*note plot:: ) command + itself. + + User-defined function syntax: + ( {,} ... {,} ) = + + where is defined in terms of through . + + User-defined variable syntax: + = + + Examples: + w = 2 + q = floor(tan(pi/2 - 0.1)) + f(x) = sin(w*x) + sinc(x) = sin(pi*x)/(pi*x) + delta(t) = (t == 0) + ramp(t) = (t > 0) ? t : 0 + min(a,b) = (a < b) ? a : b + comb(n,k) = n!/(k!*(n-k)!) + len3d(x,y,z) = sqrt(x*x+y*y+z*z) + plot f(x) = sin(x*a), a = 0.2, f(x), a = 0.4, f(x) + + Note that the variable `pi` is already defined. But it is in no way magic; + you may redefine it to be whatever you like. + + Valid names are the same as in most programming languages: they must begin + with a letter, but subsequent characters may be letters, digits, "$", or "_". + Note, however, that the `fit` (*note fit:: ) mechanism uses several variables + with names that begin "FIT_". It is safest to avoid using such + names. "FIT_LIMIT", however, is one that you may wish to redefine. See the + documentation on `fit` for details. + + + See `show functions` (*note functions:: ), `show variables` + (*note variables:: ), and fit. + + + +File: gnuplot.info, Node: Glossary, Prev: Expressions, Up: gnuplot, Next: Plotting + + Throughout this document an attempt has been made to maintain consistency of + nomenclature. This cannot be wholly successful because as `gnuplot` + (*note gnuplot:: ) has evolved over time, certain command and keyword names + have been adopted that preclude such perfection. This section contains + explanations of the way some of these terms are used. + + A "page" or "screen" is the entire area addressable by `gnuplot`. On a + monitor, it is the full screen; on a plotter, it is a single sheet of paper. + + A screen may contain one or more "plots". A plot is defined by an abscissa + and an ordinate, although these need not actually appear on it, as well as + the margins and any text written therein. + + A plot contains one "graph". A graph is defined by an abscissa and an + ordinate, although these need not actually appear on it. + + A graph may contain one or more "lines". A line is a single function or + data set. "Line" is also a plotting style. The word will also be used in + sense "a line of text". Presumably the context will remove any ambiguity. + + The lines on a graph may have individual names. These may be listed + together with a sample of the plotting style used to represent them in + the "key", sometimes also called the "legend". + + The word "title" occurs with multiple meanings in `gnuplot`. In this + document, it will always be preceded by the adjective "plot", "line", or + "key" to differentiate among them. + + A graph may have up to four labelled axes. Various commands have the name of + an axis built into their names, such as `set xlabel` (*note xlabel:: ). Other + commands have one or more axis names as options, such as `set logscale + xy`. The names of the four axes for these usages are "x" for the axis along + the bottom border of the plot, "y" for the left border, "x2" for the top + border, and "y2" for the right border. "z" also occurs in commands used with + 3-d plotting. + + When discussing data files, the term "record" will be resurrected and used + to denote a single line of text in the file, that is, the characters between + newline or end-of-record characters. A "point" is the datum extracted from + a single record. A "datablock" is a set of points from consecutive records, + delimited by blank records. A line, when referred to in the context of a + data file, is a subset of a datablock. + + +File: gnuplot.info, Node: Plotting, Prev: Glossary, Up: gnuplot, Next: Start-up + + There are three `gnuplot` (*note gnuplot:: ) commands which actually create a + plot: `plot` (*note plot:: ), `splot` (*note splot:: ) and `replot` + (*note replot:: ). plot generates 2-d plots, splot generates 3-d plots + (actually 2-d projections, of course), and `replot` appends its arguments to + the previous `plot` or `splot` and executes the modified command. + + Much of the general information about plotting can be found in the discussion + of `plot`; information specific to 3-d can be found in the `splot` section. + + `plot` operates in either rectangular or polar coordinates -- see `set polar` + (*note polar:: ) for details of the latter. `splot` operates only in + rectangular coordinates, but the `set mapping` (*note mapping:: ) command + allows for a few other coordinate systems to be treated. In addition, the + `using` (*note using:: ) option allows both plot and splot to treat almost any + coordinate system you'd care to define. + + `splot` can plot surfaces and contours in addition to points and/or lines. + In addition to `splot`, see `set isosamples` (*note isosamples:: ) for + information about defining the grid for a 3-d function; `splot datafile` + (*note data-file:: ) for information about the requisite file structure for + 3-d data values; and `set contour` (*note contour:: ) and set cntrparam` for + information about contours. + + + +File: gnuplot.info, Node: Start-up, Prev: Plotting, Up: gnuplot, Next: Substitution + + When `gnuplot` (*note gnuplot:: ) is run, it looks for an initialization file + to load. This file is called `.gnuplot` on Unix and AmigaOS systems, and + `GNUPLOT.INI` on other systems. If this file is not found in the current + directory, the program will look for it in the home directory (under AmigaOS, + Atari(single)TOS, MS-DOS and OS/2, the environment variable `gnuplot` should + contain the name of this directory). Note: if NOCWDRC is defined during the + installation, `gnuplot` will not read from the current directory. + + If the initialization file is found, `gnuplot` executes the commands in it. + These may be any legal `gnuplot` commands, but typically they are limited to + setting the terminal and defining frequently-used functions or variables. + + +File: gnuplot.info, Node: Substitution, Prev: Start-up, Up: gnuplot, Next: Syntax + + Command-line substitution is specified by a system command enclosed in + backquotes. This command is spawned and the output it produces replaces + the name of the command (and backquotes) on the command line. Some + implementations also support pipes; see `plot data-file special-filenames` + (*note special-filenames:: ). + + Newlines in the output produced by the spawned command are replaced with + blanks. + + Command-line substitution can be used anywhere on the `gnuplot` + (*note gnuplot:: ) command line. + + Example: + + This will run the program `leastsq` and replace `leastsq` (including + backquotes) on the command line with its output: + f(x) = `leastsq` + + or, in VMS + f(x) = `run leastsq` + + +File: gnuplot.info, Node: Syntax, Prev: Substitution, Up: gnuplot, Next: Time/Date data + + The general rules of syntax and punctuation in `gnuplot` (*note gnuplot:: ) + are that keywords and options are order-dependent. Options and any + accompanying parameters are separated by spaces whereas lists and coordinates + are separated by commas. Ranges are separated by colons and enclosed in + brackets [], text and file names are enclosed in quotes, and a few + miscellaneous things are enclosed in parentheses. Braces {} are used for a + few special purposes. + + Commas are used to separate coordinates on the `set` (*note set-show:: ) + commands `arrow` (*note arrow:: ), `key` (*note key:: ), and `label` + (*note label:: ); the list of variables being fitted (the list after the `via` + keyword on the `fit` (*note fit:: ) command); lists of discrete contours or + the loop parameters which specify them on the `set cntrparam` + (*note cntrparam:: ) command; the arguments of the `set` commands `dgrid3d` + (*note dgrid3d:: ), `dummy` (*note dummy:: ), `isosamples` + (*note isosamples:: ), `offsets` (*note offsets:: ), `origin` + (*note origin:: ), `samples` (*note samples:: ), `size` (*note size:: ), + time, and nd `view` (*note view:: ); lists of tics or the loop parameters + which specify them; the offsets for titles and axis labels; parametric + functions to be used to calculate the x, y, and z coordinates on the `plot` + (*note plot:: ), `replot` (*note replot:: ) and `splot` (*note splot:: ) + commands; and the complete sets of keywords specifying individual plots (data + sets or functions) on the `plot`, `replot` and `splot` commands. + + Parentheses are used to delimit sets of explicit tics (as opposed to loop + parameters) and to indicate computations in the `using` (*note using:: ) + filter of the fit, `plot`, `replot` and `splot` commands. + + (Parentheses and commas are also used as usual in function notation.) + + Brackets are used to delimit ranges, whether they are given on `set`, `plot` + or `splot` commands. + + Colons are used to separate extrema in `range` specifications (whether they + are given on `set`, `plot` or `splot` commands) and to separate entries in + the `using` filter of the `plot`, `replot`, `splot` and `fit` commands. + + Semicolons are used to separate commands given on a single command line. + + Braces are used in text to be specially processed by some terminals, like + `postscript` (*note postscript:: ). They are also used to denote complex + numbers: {3,2} = 3 + 2i. + + Text may be enclosed in single- or double-quotes. Backslash processing of + sequences like \n (newline) and \345 (octal character code) is performed for + double-quoted strings, but not for single-quoted strings. + + The justification is the same for each line of a multi-line string. Thus the + center-justified string + "This is the first line of text.\nThis is the second line." + will produce + This is the first line of text. + This is the second line. + but + 'This is the first line of text.\nThis is the second line.' + will produce + This is the first line of text.\nThis is the second line. + + Filenames may be entered with either single- or double-quotes. In this + manual the command examples generally single-quote filenames and double-quote + other string tokens for clarity. + + At present you should not embed \n inside {} when using the enhanced option + of the postscript terminal. + + The EEPIC, Imagen, Uniplex, LaTeX, and TPIC drivers allow a newline to be + specified by \\ in a single-quoted string or \\\\ in a double-quoted string. + + Back-quotes are used to enclose system commands for substitution. + + +File: gnuplot.info, Node: Time/Date data, Prev: Syntax, Up: gnuplot + + `gnuplot` (*note gnuplot:: ) supports the use of time and/or date information + as input data. This feature is activated by the commands `set xdata time`, + `set ydata time`, etc. + + Internally all times and dates are converted to the number of seconds from + the year 2000. The command `set timefmt` (*note timefmt:: ) defines the + format for all inputs: data files, ranges, tics, label positions---in short, + anything that accepts a data value must receive it in this format. Since only + one input format can be in force at a given time, all time/date quantities + being input at the same time must be presented in the same format. Thus if + both x and y data in a file are time/date, they must be in the same format. + + The conversion to and from seconds assumes Universal Time (which is the same + as Greenwich Standard Time). There is no provision for changing the time + zone or for daylight savings. If all your data refer to the same time zone + (and are all either daylight or standard) you don't need to worry about these + things. But if the absolute time is crucial for your application, you'll + need to convert to UT yourself. + + Commands like `show xrange` (*note xrange:: ) will re-interpret the integer + according to `timefmt`. If you change `timefmt`, and then `show` + (*note set-show:: ) the quantity again, it will be displayed in the new + `timefmt`. For that matter, if you give the deactivation command (like `set + xdata` (*note xdata:: )), the quantity will be shown in its numerical form. + + The command `set format` (*note format:: ) defines the format that will be + used for tic labels, whether or not the specified axis is time/date. + + If time/date information is to be plotted from a file, the `using` + (*note using:: ) option _must_ be used on the `plot` (*note plot:: ) or + `splot` (*note splot:: ) command. These commands simply use white space to + separate columns, but white space may be embedded within the time/date + string. If you use tabs as a separator, some trial-and-error may be necessary + to discover how your system treats them. + + The following example demonstrates time/date plotting. + + Suppose the file "data" contains records like + + 03/21/95 10:00 6.02e23 + + This file can be plotted by + + set xdata time + set timefmt "%m/%d/%y" + set xrange ["03/21/95":"03/22/95"] + set format x "%m/%d" + set timefmt "%m/%d/%y %H:%M" + plot "data" using 1:3 + + which will produce xtic labels that look like "03/21". + + See the descriptions of each command for more details. + + +File: gnuplot.info, Node: Commands, Prev: gnuplot, Up: Top, Next: cd + + This section lists the commands acceptable to `gnuplot` (*note gnuplot:: ) in + alphabetical order. Printed versions of this document contain all commands; + on-line versions may not be complete. Indeed, on some systems there may be + no commands at all listed under this heading. + + Note that in most cases unambiguous abbreviations for command names and their + options are permissible, i.e., "`p f(x) w l`" instead of "`plot f(x) with + lines`". + + In the syntax descriptions, braces ({}) denote optional arguments and a + vertical bar (|) separates mutually exclusive choices. + +* Menu: + +* cd:: +* call:: +* clear:: +* exit:: +* fit:: +* help:: +* if:: +* load:: +* pause:: +* plot:: +* print:: +* pwd:: +* quit:: +* replot:: +* reread:: +* reset:: +* save:: +* set-show:: +* shell:: +* splot:: +* test:: +* update:: + + +File: gnuplot.info, Node: cd, Prev: Commands, Up: Commands, Next: call + + The `cd` command changes the working directory. + + Syntax: + cd '' + + The directory name must be enclosed in quotes. + + Examples: + cd 'subdir' + cd ".." + + DOS users _must_ use single-quotes---backslash [\] has special significance + inside double-quotes. For example, + cd "c:\newdata" + fails, but + cd 'c:\newdata' + works as expected. + + +File: gnuplot.info, Node: call, Prev: cd, Up: Commands, Next: clear + + The `call` command is identical to the load command with one exception: you + can have up to ten additional parameters to the command (delimited according + to the standard parser rules) which can be substituted into the lines read + from the file. As each line is read from the `call`ed input file, it is + scanned for the sequence `$` (dollar-sign) followed by a digit (0--9). If + found, the sequence is replaced by the corresponding parameter from the + `call` command line. If the parameter was specified as a string in the + `call` line, it is substituted without its enclosing quotes. `$` followed by + any character other than a digit will be that character. E.g. use `$$` to + get a single `$`. Providing more than ten parameters on the `call` command + line will cause an error. A parameter that was not provided substitutes as + nothing. Files being `call`ed may themselves contain `call` or `load` + (*note load:: ) commands. + + The `call` command _must_ be the last command on a multi-command line. + + Syntax: + call "" ... + + The name of the input file must be enclosed in quotes, and it is recommended + that parameters are similarly enclosed in quotes (future versions of gnuplot + may treat quoted and unquoted arguments differently). + + Example: + + If the file 'calltest.gp' contains the line: + print "p0=$0 p1=$1 p2=$2 p3=$3 p4=$4 p5=$5 p6=$6 p7=x$7x" + + entering the command: + call 'calltest.gp' "abcd" 1.2 + "'quoted'" -- "$2" + + will display: + p0=abcd p1=1.2 p2=+ p3='quoted' p4=- p5=- p6=$2 p7=xx + + NOTE: there is a clash in syntax with the datafile `using` (*note using:: ) + callback operator. Use `$$n` or `column(n)` to access column n from a + datafile inside a `call`ed datafile plot. + + + +File: gnuplot.info, Node: clear, Prev: call, Up: Commands, Next: exit + + The `clear` command erases the current screen or output device as specified + by `set output` (*note output:: ). This usually generates a formfeed on + hardcopy devices. Use `set terminal` (*note terminal:: ) to set the device + type. + + For some terminals `clear` erases only the portion of the plotting surface + defined by `set size` (*note size:: ), so for these it can be used in + conjunction with set multiplot` to create an inset. + + Example: + set multiplot + plot sin(x) + set origin 0.5,0.5 + set size 0.4,0.4 + clear + plot cos(x) + set nomultiplot + + Please see `set multiplot` (*note multiplot:: ), set size, and nd `set origin` + (*note origin:: ) for details of these commands. + + + +File: gnuplot.info, Node: exit, Prev: clear, Up: Commands, Next: fit + + The commands `exit` and `quit` (*note quit:: ) and the END-OF-FILE character + will exit the current `gnuplot` (*note gnuplot:: ) command file and `load` + (*note load:: ) the next one. See "help batch/interactive" for more details. + + Each of these commands will clear the output device (as does the `clear` + (*note clear:: ) command) before exiting. + + + +File: gnuplot.info, Node: fit, Prev: exit, Up: Commands, Next: adjustable parameters + + The `fit` command can fit a user-defined function to a set of data points + (x,y) or (x,y,z), using an implementation of the nonlinear least-squares + (NLLS) Marquardt-Levenberg algorithm. Any user-defined variable occurring in + the function body may serve as a fit parameter, but the return type of the + function must be real. + + Syntax: + fit {[xrange] {[yrange]}} '' + {datafile-modifiers} + via '' | {,,...} + + Ranges may be specified to temporarily limit the data which is to be fitted; + any out-of-range data points are ignored. The syntax is + [{dummy_variable=}{}{:}], + analogous to `plot` (*note plot:: ); see `plot ranges` (*note ranges:: ). + + is any valid `gnuplot` (*note gnuplot:: ) expression, although it + is usual to use a previously user-defined function of the form f(x) or + f(x,y). + + is treated as in the `plot` command. All the `plot datafile` + (*note data-file:: ) modifiers (`using` (*note using:: ), `every` + (*note every:: ),...) except `smooth` (*note smooth:: ) are applicable to + fit. See `plot datafile`. + + The default data formats for fitting functions with a single independent + variable, y=f(x), are {x:}y or x:y:s; those formats can be changed with + the datafile `using` qualifier. The third item, (a column number or an + expression), if present, is interpreted as the standard deviation of the + corresponding y value and is used to compute a weight for the datum, 1/s**2. + Otherwise, all data points are weighted equally, with a weight of one. + + To fit a function with two independent variables, z=f(x,y), the required + format is `using` with four items, x:y:z:s. The complete format must be + given---no default columns are assumed for a missing token. Weights for + each data point are evaluated from 's' as above. If error estimates are + not available, a constant value can be specified as a constant expression + (see `plot datafile using`), e.g., `using 1:2:3:(1)`. + + Multiple datasets may be simultaneously fit with functions of one + independent variable by making y a 'pseudo-variable', e.g., the dataline + number, and fitting as two independent variables. See `fit multibranch`. + + The `via` qualifier specifies which parameters are to be adjusted, either + directly, or by referencing a parameter file. + + Examples: + f(x) = a*x**2 + b*x + c + g(x,y) = a*x**2 + b*y**2 + c*x*y + FIT_LIMIT = 1e-6 + fit f(x) 'measured.dat' via 'start.par' + fit f(x) 'measured.dat' using 3:($7-5) via 'start.par' + fit f(x) './data/trash.dat' using 1:2:3 via a, b, c + fit g(x,y) 'surface.dat' using 1:2:3:(1) via a, b, c + + After each iteration step, detailed information about the current state + of the fit is written to the display. The same information about the + initial and final states is written to a log file, "fit.log". This file + is always appended to, so as to not lose any previous fit history; it + should be deleted or renamed as desired. + + The fit may be interrupted by pressing Ctrl-C (any key but Ctrl-C under + MSDOS and Atari Multitasking Systems). After the current iteration + completes, you have the option to (1) stop the fit and accept the current + parameter values, (2) continue the fit, (3) execute a `gnuplot` command + as specified by the environment variable FIT_SCRIPT. The default for + FIT_SCRIPT is `replot` (*note replot:: ), so if you had previously plotted + both the data and the fitting function in one graph, you can display the + current state of the fit. + + Once `fit` has finished, the `update` (*note update:: ) command may be used to + store final values in a file for subsequent use as a parameter file. See + `update` for details. + + +* Menu: + +* adjustable parameters:: +* beginner's guide:: +* error estimates:: +* fit controlling:: +* multi-branch:: +* starting values:: +* tips:: + + +File: gnuplot.info, Node: adjustable parameters, Prev: fit, Up: fit, Next: beginner's guide + + There are two ways that `via` can specify the parameters to be adjusted, + either directly on the command line or indirectly, by referencing a + parameter file. The two use different means to set initial values. + + Adjustable parameters can be specified by a comma-separated list of variable + names after the `via` keyword. Any variable that is not already defined is + is created with an initial value of 1.0. However, the fit is more likely + to converge rapidly if the variables have been previously declared with more + appropriate starting values. + + In a parameter file, each parameter to be varied and a corresponding initial + value are specified, one per line, in the form + varname = value + + Comments, marked by '#', and blank lines are permissible. The + special form + varname = value # FIXED + + means that the variable is treated as a 'fixed parameter', initialized by the + parameter file, but not adjusted by `fit` (*note fit:: ). For clarity, it may + be useful to designate variables as fixed parameters so that their values are + reported by `fit`. The keyword `# FIXED` has to appear in exactly this form. + + + +File: gnuplot.info, Node: beginner's guide, Prev: adjustable parameters, Up: fit, Next: error estimates + + `fit` (*note fit:: ) is used to find a set of parameters that 'best' fits your + data to your user-defined function. The fit is judged on the basis of the the + sum of the squared differences or 'residuals' (SSR) between the input data + points and the function values, evaluated at the same places. This quantity + is often called 'chisquare' (i.e., the Greek letter chi, to the power of + 2). The algorithm attempts to minimize SSR, or more precisely, WSSR, as the + residuals are 'weighted' by the input data errors (or 1.0) before being + squared; see `fit error_estimates` for details. + + That's why it is called 'least-squares fitting'. Let's look at an example + to see what is meant by 'non-linear', but first we had better go over some + terms. Here it is convenient to use z as the dependent variable for + user-defined functions of either one independent variable, z=f(x), or two + independent variables, z=f(x,y). A parameter is a user-defined variable + that `fit` will adjust, i.e., an unknown quantity in the function + declaration. Linearity/non-linearity refers to the relationship of the + dependent variable, z, to the parameters which `fit` is adjusting, not of + z to the independent variables, x and/or y. (To be technical, the + second {and higher} derivatives of the fitting function with respect to + the parameters are zero for a linear least-squares problem). + + For linear least-squares (LLS), the user-defined function will be a sum of + simple functions, not involving any parameters, each multiplied by one + parameter. NLLS handles more complicated functions in which parameters can + be used in a large number of ways. An example that illustrates the + difference between linear and nonlinear least-squares is the Fourier series. + One member may be written as + z=a*sin(c*x) + b*cos(c*x). + If a and b are the unknown parameters and c is constant, then estimating + values of the parameters is a linear least-squares problem. However, if + c is an unknown parameter, the problem is nonlinear. + + In the linear case, parameter values can be determined by comparatively + simple linear algebra, in one direct step. However LLS is a special case + which is also solved along with more general NLLS problems by the iterative + procedure that `gnuplot` (*note gnuplot:: ) uses. fit attempts to find the + minimum by doing a search. Each step (iteration) calculates WSSR with a new + set of parameter values. The Marquardt-Levenberg algorithm selects the + parameter values for the next iteration. The process continues until a preset + criterium is met, either (1) the fit has "converged" (the relative change in + WSSR is less than FIT_LIMIT), or (2) it reaches a preset iteration count + limit, FIT_MAXITER (see `fit control variables` + (*note control variables:: )). The fit may also be interrupted and + subsequently halted from the keyboard (see `fit`). + + Often the function to be fitted will be based on a model (or theory) that + attempts to describe or predict the behaviour of the data. Then `fit` can + be used to find values for the free parameters of the model, to determine + how well the data fits the model, and to estimate an error range for each + parameter. See `fit error_estimates`. + + Alternatively, in curve-fitting, functions are selected independent of + a model (on the basis of experience as to which are likely to describe + the trend of the data with the desired resolution and a minimum number + of parameters*functions.) The `fit` solution then provides an analytic + representation of the curve. + + However, if all you really want is a smooth curve through your data points, + the `smooth` (*note smooth:: ) option to `plot` (*note plot:: ) may be what + you've been looking for rather than `fit`. + + + +File: gnuplot.info, Node: error estimates, Prev: beginner's guide, Up: fit, Next: statistical overview + + In `fit` (*note fit:: ), the term "error" is used in two different contexts, + data error estimates and parameter error estimates. + + Data error estimates are used to calculate the relative weight of each data + point when determining the weighted sum of squared residuals, WSSR or + chisquare. They can affect the parameter estimates, since they determine + how much influence the deviation of each data point from the fitted function + has on the final values. Some of the `fit` output information, including + the parameter error estimates, is more meaningful if accurate data error + estimates have been provided. + + The 'statistical overview' describes some of the `fit` output and gives some + background for the 'practical guidelines'. + +* Menu: + +* statistical overview:: +* practical guidelines:: + + +File: gnuplot.info, Node: statistical overview, Prev: error estimates, Up: error estimates, Next: practical guidelines + + The theory of non-linear least-squares (NLLS) is generally described in terms + of a normal distribution of errors, that is, the input data is assumed to be + a sample from a population having a given mean and a Gaussian (normal) + distribution about the mean with a given standard deviation. For a sample of + sufficiently large size, and knowing the population standard deviation, one + can use the statistics of the chisquare distribution to describe a "goodness + of fit" by looking at the variable often called "chisquare". Here, it is + sufficient to say that a reduced chisquare (chisquare/degrees of freedom, + where degrees of freedom is the number of datapoints less the number of + parameters being fitted) of 1.0 is an indication that the weighted sum of + squared deviations between the fitted function and the data points is the + same as that expected for a random sample from a population characterized by + the function with the current value of the parameters and the given standard + deviations. + + If the standard deviation for the population is not constant, as in counting + statistics where variance = counts, then each point should be individually + weighted when comparing the observed sum of deviations and the expected sum + of deviations. + + At the conclusion `fit` (*note fit:: ) reports 'stdfit', the standard + deviation of the fit, which is the rms of the residuals, and the variance of + the residuals, also called 'reduced chisquare' when the data points are + weighted. The number of degrees of freedom (the number of data points minus + the number of fitted parameters) is used in these estimates because the + parameters used in calculating the residuals of the datapoints were obtained + from the same data. + + To estimate confidence levels for the parameters, one can use the minimum + chisquare obtained from the fit and chisquare statistics to determine the + value of chisquare corresponding to the desired confidence level, but + considerably more calculation is required to determine the combinations of + parameters which produce such values. + + Rather than determine confidence intervals, `fit` reports parameter error + estimates which are readily obtained from the variance-covariance matrix + after the final iteration. By convention, these estimates are called + "standard errors" or "asymptotic standard errors", since they are calculated + in the same way as the standard errors (standard deviation of each parameter) + of a linear least-squares problem, even though the statistical conditions for + designating the quantity calculated to be a standard deviation are not + generally valid for the NLLS problem. The asymptotic standard errors are + generally over-optimistic and should not be used for determining confidence + levels, but are useful for qualitative purposes. + + The final solution also produces a correlation matrix, which gives an + indication of the correlation of parameters in the region of the solution; + if one parameter is changed, increasing chisquare, does changing another + compensate? The main diagonal elements, autocorrelation, are all 1; if + all parameters were independent, all other elements would be nearly 0. Two + variables which completely compensate each other would have an off-diagonal + element of unit magnitude, with a sign depending on whether the relation is + proportional or inversely proportional. The smaller the magnitudes of the + off-diagonal elements, the closer the estimates of the standard deviation + of each parameter would be to the asymptotic standard error. + + +File: gnuplot.info, Node: practical guidelines, Prev: statistical overview, Up: error estimates + + If you have a basis for assigning weights to each data point, doing so lets + you make use of additional knowledge about your measurements, e.g., take into + account that some points may be more reliable than others. That may affect + the final values of the parameters. + + Weighting the data provides a basis for interpreting the additional `fit` + (*note fit:: ) output after the last iteration. Even if you weight each point + equally, estimating an average standard deviation rather than using a weight + of 1 makes WSSR a dimensionless variable, as chisquare is by definition. + + Each fit iteration will display information which can be used to evaluate + the progress of the fit. (An '*' indicates that it did not find a smaller + WSSR and is trying again.) The 'sum of squares of residuals', also called + 'chisquare', is the WSSR between the data and your fitted function; `fit` + has minimized that. At this stage, with weighted data, chisquare is expected + to approach the number of degrees of freedom (data points minus parameters). + The WSSR can be used to calculate the reduced chisquare (WSSR/ndf) or stdfit, + the standard deviation of the fit, sqrt(WSSR/ndf). Both of these are + reported for the final WSSR. + + If the data are unweighted, stdfit is the rms value of the deviation of the + data from the fitted function, in user units. + + If you supplied valid data errors, the number of data points is large enough, + and the model is correct, the reduced chisquare should be about unity. (For + details, look up the 'chi-squared distribution' in your favourite statistics + reference.) If so, there are additional tests, beyond the scope of this + overview, for determining how well the model fits the data. + + A reduced chisquare much larger than 1.0 may be due to incorrect data error + estimates, data errors not normally distributed, systematic measurement + errors, 'outliers', or an incorrect model function. A plot of the residuals, + e.g., `plot 'datafile' using 1:($2-f($1))`, may help to show any systematic + trends. Plotting both the data points and the function may help to suggest + another model. + + Similarly, a reduced chisquare less than 1.0 indicates WSSR is less than that + expected for a random sample from the function with normally distributed + errors. The data error estimates may be too large, the statistical + assumptions may not be justified, or the model function may be too general, + fitting fluctuations in a particular sample in addition to the underlying + trends. In the latter case, a simpler function may be more appropriate. + + You'll have to get used to both `fit` and the kind of problems you apply it + to before you can relate the standard errors to some more practical estimates + of parameter uncertainties or evaluate the significance of the correlation + matrix. + + Note that `fit`, in common with most NLLS implementations, minimizes the + weighted sum of squared distances (y-f(x))**2. It does not provide any means + to account for "errors" in the values of x, only in y. Also, any "outliers" + (data points outside the normal distribution of the model) will have an + exaggerated effect on the solution. + + +File: gnuplot.info, Node: fit controlling, Prev: error estimates, Up: fit, Next: control variables + + There are a number of `gnuplot` (*note gnuplot:: ) variables that can be + defined to affect `fit` (*note fit:: ). Those which can be defined once + gnuplot is running are listed under 'control_variables' while those defined + before starting `gnuplot` are listed under 'environment_variables'. + + +* Menu: + +* control variables:: +* environment variables:: + + +File: gnuplot.info, Node: control variables, Prev: fit controlling, Up: fit controlling, Next: environment variables + + The default epsilon limit (1e-5) may be changed by declaring a value for + FIT_LIMIT + When the sum of squared residuals changes between two iteration steps by + a factor less than this number (epsilon), the fit is considered to have + 'converged'. + + The maximum number of iterations may be limited by declaring a value for + FIT_MAXITER + A value of 0 (or not defining it at all) means that there is no limit. + + If you need even more control about the algorithm, and know the + Marquardt-Levenberg algorithm well, there are some more variables to + influence it. The startup value of `lambda` is normally calculated + automatically from the ML-matrix, but if you want to, you may provide + your own one with + FIT_START_LAMBDA + Specifying FIT_START_LAMBDA as zero or less will re-enable the automatic + selection. The variable + FIT_LAMBDA_FACTOR + gives the factor by which `lambda` is increased or decreased whenever + the chi-squared target function increased or decreased significantly. + Setting FIT_LAMBDA_FACTOR to zero re-enables the default factor of + 10.0. + + Oher variables with the FIT_ prefix may be added to `fit` (*note fit:: ), so + it is safer not to use that prefix for user-defined variables. + + The variables FIT_SKIP and FIT_INDEX were used by earlier releases of + `gnuplot` (*note gnuplot:: ) with a 'fit' patch called gnufit and are no + longer available. The datafile `every` (*note every:: ) modifier provides the + functionality of FIT_SKIP. FIT_INDEX was used for multi-branch fitting, but + multi-branch fitting of one independent variable is now done as a pseudo-3D + fit in which the second independent variable and `using` (*note using:: ) are + used to specify the branch. See `fit multi-branch` (*note multi-branch:: ). + + + +File: gnuplot.info, Node: environment variables, Prev: control variables, Up: fit controlling + + The environment variables must be defined before `gnuplot` (*note gnuplot:: ) + is executed; how to do so depends on your operating system. + + FIT_LOG + changes the name (and/or path) of the file to which the fit log will be + written from the default of "fit.log" in the working directory. + + FIT_SCRIPT + specifies a command that may be executed after an user interrupt. The default + is `replot` (*note replot:: ), but a `plot` (*note plot:: ) or `load` + (*note load:: ) command may be useful to display a plot customized to + highlight the progress of the fit. + + + +File: gnuplot.info, Node: multi-branch, Prev: fit controlling, Up: fit, Next: starting values + + In multi-branch fitting, multiple data sets can be simultaneously fit with + functions of one independent variable having common parameters by minimizing + the total WSSR. The function and parameters (branch) for each data set are + selected by using a 'pseudo-variable', e.g., either the dataline number (a + 'column' index of -1) or the datafile index (-2), as the second independent + variable. + + Example: Given two exponential decays of the form, z=f(x), each describing + a different data set but having a common decay time, estimate the values of + the parameters. If the datafile has the format x:z:s, then + f(x,y) = (y==0) ? a*exp(-x/tau) : b*exp(-x/tau) + fit f(x,y) 'datafile' using 1:-1:2:3 via a, b, tau + + For a more complicated example, see the file "hexa.fnc" used by the + "fit.dem" demo. + + Appropriate weighting may be required since unit weights may cause one + branch to predominate if there is a difference in the scale of the dependent + variable. Fitting each branch separately, using the multi-branch solution + as initial values, may give an indication as to the relative effect of each + branch on the joint solution. + + +File: gnuplot.info, Node: starting values, Prev: multi-branch, Up: fit, Next: tips + + Nonlinear fitting is not guaranteed to converge to the global optimum (the + solution with the smallest sum of squared residuals, SSR), and can get stuck + at a local minimum. The routine has no way to determine that; it is up to + you to judge whether this has happened. + + `fit` (*note fit:: ) may, and often will get "lost" if started far from a + solution, where SSR is large and changing slowly as the parameters are varied, + or it may reach a numerically unstable region (e.g., too large a number + causing a floating point overflow) which results in an "undefined value" + message or `gnuplot` (*note gnuplot:: ) halting. + + To improve the chances of finding the global optimum, you should set the + starting values at least roughly in the vicinity of the solution, e.g., + within an order of magnitude, if possible. The closer your starting values + are to the solution, the less chance of stopping at another minimum. One way + to find starting values is to plot data and the fitting function on the same + graph and change parameter values and `replot` (*note replot:: ) until + reasonable similarity is reached. The same plot is also useful to check + whether the fit stopped at a minimum with a poor fit. + + Of course, a reasonably good fit is not proof there is not a "better" fit (in + either a statistical sense, characterized by an improved goodness-of-fit + criterion, or a physical sense, with a solution more consistent with the + model.) Depending on the problem, it may be desirable to `fit` with various + sets of starting values, covering a reasonable range for each parameter. + + +File: gnuplot.info, Node: tips, Prev: starting values, Up: fit + + Here are some tips to keep in mind to get the most out of `fit` + (*note fit:: ). They're not very organized, so you'll have to read them + several times until their essence has sunk in. + + The two forms of the `via` argument to `fit` serve two largely distinct + purposes. The `via "file"` form is best used for (possibly unattended) batch + operation, where you just supply the startup values in a file and can later + use `update` (*note update:: ) to copy the results back into another (or the + same) parameter file. + + The `via var1, var2, ...` form is best used interactively, where the command + history mechanism may be used to edit the list of parameters to be fitted or + to supply new startup values for the next try. This is particularly useful + for hard problems, where a direct fit to all parameters at once won't work + without good starting values. To find such, you can iterate several times, + fitting only some of the parameters, until the values are close enough to the + goal that the final fit to all parameters at once will work. + + Make sure that there is no mutual dependency among parameters of the function + you are fitting. For example, don't try to fit a*exp(x+b), because + a*exp(x+b)=a*exp(b)*exp(x). Instead, fit either a*exp(x) or exp(x+b). + + A technical issue: the parameters must not be too different in magnitude. + The larger the ratio of the largest and the smallest absolute parameter + values, the slower the fit will converge. If the ratio is close to or above + the inverse of the machine floating point precision, it may take next to + forever to converge, or refuse to converge at all. You will have to adapt + your function to avoid this, e.g., replace 'parameter' by '1e9*parameter' in + the function definition, and divide the starting value by 1e9. + + If you can write your function as a linear combination of simple functions + weighted by the parameters to be fitted, by all means do so. That helps a + lot, because the problem is no longer nonlinear and should converge with only + a small number of iterations, perhaps just one. + + Some prescriptions for analysing data, given in practical experimentation + courses, may have you first fit some functions to your data, perhaps in a + multi-step process of accounting for several aspects of the underlying + theory one by one, and then extract the information you really wanted from + the fitting parameters of those functions. With `fit`, this may often be + done in one step by writing the model function directly in terms of the + desired parameters. Transforming data can also quite often be avoided, + though sometimes at the cost of a more difficult fit problem. If you think + this contradicts the previous paragraph about simplifying the fit function, + you are correct. + + A "singular matrix" message indicates that this implementation of the + Marquardt-Levenberg algorithm can't calculate parameter values for the next + iteration. Try different starting values, writing the function in another + form, or a simpler function. + + Finally, a nice quote from the manual of another fitting package (fudgit), + that kind of summarizes all these issues: "Nonlinear fitting is an art!" + + +File: gnuplot.info, Node: help, Prev: fit, Up: Commands, Next: if + + The `help` command displays on-line help. To specify information on a + particular topic use the syntax: + + help {} + + If is not specified, a short message is printed about `gnuplot` + (*note gnuplot:: ). After help for the requested topic is given, a menu of + subtopics is given; help for a subtopic may be requested by typing its name, + extending the help request. After that subtopic has been printed, the request + may be extended again or you may go back one level to the previous + topic. Eventually, the `gnuplot` command line will return. + + If a question mark (?) is given as the topic, the list of topics currently + available is printed on the screen. + + +File: gnuplot.info, Node: if, Prev: help, Up: Commands, Next: load + + The `if` command allows commands to be executed conditionally. + + Syntax: + if () + + will be evaluated. If it is true (non-zero), then the command(s) + of the will be executed. If is false (zero), then + the entire is ignored. Note that use of `;` to allow multiple + commands on the same line will _not_ end the conditionalized commands. + + Examples: + pi=3 + if (pi!=acos(-1)) print "?Fixing pi!"; pi=acos(-1); print pi + will display: + ?Fixing pi! + 3.14159265358979 + but + if (1==2) print "Never see this"; print "Or this either" + will not display anything. + + See `reread` (*note reread:: ) for an example of how if and reread can be used + together to perform a loop. + + + +File: gnuplot.info, Node: load, Prev: if, Up: Commands, Next: pause + + The `load` command executes each line of the specified input file as if it + had been typed in interactively. Files created by the `save` (*note save:: ) + command can later be `load`ed. Any text file containing valid commands can be + created and then executed by the `load` command. Files being `load`ed may + themselves contain `load` or `call` (*note call:: ) commands. See comment for + information about comments in commands. To `load` with arguments, see + `call`. + + The `load` command _must_ be the last command on a multi-command line. + + Syntax: + load "" + + The name of the input file must be enclosed in quotes. + + The special filename "-" may be used to `load` commands from standard input. + This allows a `gnuplot` (*note gnuplot:: ) command file to accept some + commands from standard input. Please see "help batch/interactive" for more + details. + + Examples: + load 'work.gnu' + load "func.dat" + + The `load` command is performed implicitly on any file names given as + arguments to `gnuplot`. These are loaded in the order specified, and + then `gnuplot` exits. + + +File: gnuplot.info, Node: pause, Prev: load, Up: Commands, Next: plot + + The `pause` command displays any text associated with the command and then + waits a specified amount of time or until the carriage return is pressed. + `pause` is especially useful in conjunction with `load` (*note load:: ) + files. + + Syntax: + pause