gnuplot.el 105 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576
  1. ;;;; gnuplot.el -- drive gnuplot from within emacs
  2. ;; Copyright (C) 1998 Phil Type and Bruce Ravel, 1999-2002 Bruce Ravel
  3. ;; Author: Bruce Ravel <ravel@phys.washington.edu> and Phil Type
  4. ;; Maintainer: Bruce Ravel <ravel@phys.washington.edu>
  5. ;; Created: June 28 1998
  6. ;; Updated: December 13, 2002
  7. ;; Version: 0.6.0
  8. ;; Keywords: gnuplot, plotting
  9. ;; This file is not part of GNU Emacs.
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. ;; This program is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15. ;;
  16. ;; This lisp script is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. ;;
  20. ;; Permission is granted to distribute copies of this lisp script
  21. ;; provided the copyright notice and this permission are preserved in
  22. ;; all copies.
  23. ;;
  24. ;; You should have received a copy of the GNU General Public License
  25. ;; along with this program; if not, you can either send email to this
  26. ;; program's maintainer or write to: The Free Software Foundation,
  27. ;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. ;; send bug reports to the author (ravel@phys.washington.edu)
  30. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  31. ;;; Commentary:
  32. ;;
  33. ;; This is a major mode for composing gnuplot scripts and displaying
  34. ;; their results using gnuplot. It is optimized for use with gnuplot
  35. ;; 3.7 or one of the later patchlevels of "version 3.6". It should
  36. ;; also work very handily with version 3.5. This mode offers several
  37. ;; tools to help you compose your scripts, including syntax
  38. ;; colorization using either font-lock or hilit19, a syntax table
  39. ;; appropriate to gnuplot, key bindings, pull-down menus, indentation,
  40. ;; keyword completions and variable customization using the Custom
  41. ;; package. Once the script is composed, there are several function
  42. ;; for sending some or all of the script to gnuplot. The interaction
  43. ;; with the gnuplot process is within a comint buffer.
  44. ;;
  45. ;; C-c C-l send current line to gnuplot
  46. ;; C-c C-v send current line to gnuplot and move forward 1 line
  47. ;; C-c C-r send current region to gnuplot
  48. ;; C-c C-b send entire buffer to gnuplot
  49. ;; C-c C-f send a file to gnuplot
  50. ;; C-c C-i insert filename at point
  51. ;; C-c C-n negate set option on current line
  52. ;; C-c C-c comment region
  53. ;; C-c C-o set arguments for command at point
  54. ;; S-mouse-2 set arguments for command under mouse cursor
  55. ;; C-c C-h read the gnuplot info file
  56. ;; C-c C-e show-gnuplot-buffer
  57. ;; C-c C-k kill gnuplot process
  58. ;; C-c C-u submit a bug report about gnuplot-mode
  59. ;; M-tab or M-ret complete keyword before point
  60. ;; ret newline and indent
  61. ;; tab indent current line
  62. ;;
  63. ;; Gnuplot-mode adds two key bindings to the comint buffer:
  64. ;; M-C-p plot the current script buffer line-by-line
  65. ;; M-C-f save the current script buffer and load that file
  66. ;;
  67. ;; These two functions are useful for starting up gnuplot-mode.
  68. ;;
  69. ;; M-x gnuplot-mode
  70. ;; start gnuplot-mode in the current buffer
  71. ;;
  72. ;; M-x gnuplot-make-buffer
  73. ;; open a new buffer (which is not visiting a file) and start
  74. ;; gnuplot-mode in that buffer
  75. ;;
  76. ;; ---------------------------------------------------------------------
  77. ;;
  78. ;; Other lisp files used by gnuplot.el
  79. ;;
  80. ;; info-look.el (comes with GNU Emacs 20):
  81. ;; This provides the interface to the gnuplot-info file and provides
  82. ;; on-line help and keyword completion functionality. The version
  83. ;; of info-look.el that comes with version 20.2 of Emacs contains a
  84. ;; bug that will impede its interaction with the gnuplot info file.
  85. ;; You should use the version from the gnuplot-mode homepage
  86. ;; instead. info-look is not distributed with XEmacs and so should
  87. ;; be installed along with gnuplot-mode when using XEmacs.
  88. ;;
  89. ;; gnuplot-gui.el (written by Bruce):
  90. ;; Defines the GUI interface for setting setting arguments to
  91. ;; gnuplot options. This uses the widget package extensively.
  92. ;;
  93. ;; ---------------------------------------------------------------------
  94. ;;
  95. ;; This mode was inspired by the original gnu-plot-mode by Gershon
  96. ;; Elber, which is distributed with gnuplot itself and which dates
  97. ;; back to the early 90's. Although this mode encompasses the
  98. ;; functionality of the original, the two share no code and the
  99. ;; current implementation takes advantage of many features of modern
  100. ;; versions of emacs and adheres (or so I intend) to the major mode
  101. ;; conventions described in the emacs-lisp reference for version 19
  102. ;; and later.
  103. ;;
  104. ;; ---------------------------------------------------------------------
  105. ;;
  106. ;; Installation
  107. ;; ============
  108. ;;
  109. ;; A recent version of this file can be found at
  110. ;; http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/
  111. ;;
  112. ;; To autoload gnuplot-mode on any file with gp extension, put this in
  113. ;; your .emacs file
  114. ;; (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
  115. ;; (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)
  116. ;;
  117. ;; Something like
  118. ;; (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode))
  119. ;; auto-mode-alist))
  120. ;; is useful for having files ending in .gp start up in gnuplot-mode.
  121. ;;
  122. ;; Something like
  123. ;; (global-set-key [(f9)] 'gnuplot-make-buffer)
  124. ;; may be useful. This binds f9 to the function that opens a scratch
  125. ;; buffer (i.e. one that is not visiting a file) in gnuplot-mode.
  126. ;; This is handy for your quick 'n' dirty plotting chores.
  127. ;;
  128. ;; To use the `gnuplot-info-lookup-symbol' function, the file
  129. ;; gnuplot.info MUST be installed somewhere that info can find it.
  130. ;; This means you must either:
  131. ;; 1. Copy gnuplot.info to the normal info directory or
  132. ;; 2. Make sure info can find gnuplot.info by putting this in your
  133. ;; .emacs file:
  134. ;; (setenv "INFOPATH"
  135. ;; (concat (getenv "INFOPATH") ":"
  136. ;; (expand-file-name "/path/to/file")))
  137. ;; where "/path/to/file" is the location of gnuplot.info
  138. ;;
  139. ;; This had been tested extensively with Emacs 19.34 and 20.2 and
  140. ;; XEmacs 20.3 and in a limited manner with Emacs 19.30 and XEmacs
  141. ;; 19.14.
  142. ;;
  143. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  144. ;;; History:
  145. ;;
  146. ;; 0.1 Jun 25 1998 Finished with initial release.
  147. ;; 0.2 Sep 4 1998 Added filename insertion, indentation, and
  148. ;; colorization/completion in comint buffer. <BR>
  149. ;; 0.2a Sep 11 1998 made `indent-line-function' buffer-local (whoops!)
  150. ;; and fixed some stuff in the installation script <BR>
  151. ;; 0.3 Sep 12 1998 include insertions menu <BR>
  152. ;; 0.3a Sep 14 1998 fixed bug finding info file if missing, fixed bug
  153. ;; starting font-lock, fixed bug re overwriting files in
  154. ;; installation script <BR>
  155. ;; 0.3b Sep 15 1998 Added (require 'info) to `(eval-and-compile'
  156. ;; clause, Added (kill-all-local-variables) to `gnuplot-mode',
  157. ;; altered order of:-
  158. ;; (provide 'gnuplot)
  159. ;; (run-hooks 'gnuplot-load-hook)
  160. ;; at the end of the file in case something in the load hook
  161. ;; requires gnuplot (oh not that old one again...), added
  162. ;; `gnuplot-comint-setup-hook', corrected `gnuplot-mark-active'
  163. ;; which caused an error to be raised by (mark) when the mark
  164. ;; was inactive <DB> Some changes to font-lock rules <LB>&<BR>
  165. ;; 0.4 Nov 14 1998 <BR> Use info-look for info interface. No
  166. ;; change to gnuplot-mode user interface, but cleaner code.
  167. ;; With info-look, the help funcion works regardless of the
  168. ;; version number of gnuplot. Also, `gnuplot-keywords' (used
  169. ;; for help, keyword-completion, and hilit19 highlighting) is
  170. ;; now generated automatically.
  171. ;; 0.4a Nov 18 1998 <BR> info-look leaves a couple of really useless
  172. ;; buffers lying around so I cleaned them up. Also fixed
  173. ;; font-lock rules so that things in quotes get highlighted
  174. ;; correctly and the surrounding text is unhighlighted. Fixed
  175. ;; up font-lock rules for plot and splot. Added
  176. ;; `gnuplot-send-line-and-forward' as suggested by <MD>.
  177. ;; 0.4b Nov 21 1998 <BR> added toolbar for xemacs -- see file
  178. ;; gnuplot-toolbar.el. fixed error message in plot line
  179. ;; function when line is empty. option added to display the
  180. ;; comint buffer showing the gnuplot process in a separate
  181. ;; frame
  182. ;; 0.4c Minor stuff: Nov 30 1998 <BR> fixed highlighting in comint
  183. ;; buffer. fixed frame behavior. added "[:]" to range
  184. ;; insertions. added :link to defgroup. Dec 1 1998 <BR> fixed
  185. ;; some mismatched defcustoms. added a few lines to suppress
  186. ;; some compile-time warnings. Dec 3 1998 <BR> Fixed behavior
  187. ;; of filename insertion function. Added more :links to
  188. ;; defgroup.
  189. ;; 0.4d Dec 6 1998 <BR> Added function gnuplot-setup-info-look and
  190. ;; variable gnuplot-info-hook to handle various versions of the
  191. ;; gnuplot info file.
  192. ;; 0.4e Dec 12 1998 <BR> Split up gnuplot-insertions-menu for ease of
  193. ;; custimization, put menubar initialization in a function.
  194. ;; 0.4f Dec 14 1998 <BR> defcustom the insertions submenus, add
  195. ;; gnuplot-insertion-menu-flag, intelligent Makefile knows
  196. ;; which info-look to compile
  197. ;; 0.5 Dec 27 1998 <BR> wrote initial draft of gnuplot-gui.el,
  198. ;; included it in insertions menu and in `gnuplot-insert'.
  199. ;; Negate option function, bound to C-c C-n. Dec 29 1998 <BR>
  200. ;; C-c C-h with no response goes to Commands menu. Transparent
  201. ;; toolbar icons. Replace kw-compl with a simple completion
  202. ;; function. Put gnuplot-toolbar code in gnuplot.el.
  203. ;; 0.5a Jan 23 1999 <BR> send file uses the load command. add
  204. ;; gnuplot-plot-from-comint and
  205. ;; gnuplot-save-and-plot-from-comint and keybindings in the
  206. ;; comint buffer. do (process-kill-without-query
  207. ;; gnuplot-process nil). `gnuplot-negate-option' checks if set
  208. ;; option has a negated form.
  209. ;; 0.5b `gnuplot-kill-gnuplot-buffer' made more robust. fixed a bug
  210. ;; in `gnuplot-plot-from-comint'. fixed description of
  211. ;; gnuplot-faces group.
  212. ;; 0.5c update copyright information, update gpelcard
  213. ;; 0.5d Mar 20 1999 <BR> adopt installation materials from <LH>. Add
  214. ;; some support for hidden3d. Use constants in types alists in
  215. ;; gui. Various other minor improvements to the types alists.
  216. ;; 0.5e Apr 6 1999 <BR> at the suggestion of <SE> I did away with the
  217. ;; gnuplot-which-highlight variable and revamped how
  218. ;; colorization gets turned on. This is a bit tricky since I
  219. ;; want it to work with font-lock under emacs and xemacs and
  220. ;; with hilit19. Apr 11 1999 <BR> insert space at end of
  221. ;; unique completion. add a few GUI types, rewrite some stuff
  222. ;; in the GUI interface. primitive support for plot, splot,
  223. ;; and fit. Fixed completion in file widget.
  224. ;; 0.5f May 15 1999 <BR> Add pgnuplot.c and Win9x install instructions
  225. ;; to the distribution. Fixed a defface bug. Added
  226. ;; `gnuplot-keywords-when' allowing deferral of parsing the
  227. ;; info file.
  228. ;; 0.5g May 27 1999 <BR> Fixed font-locking of strings and
  229. ;; comments. Figure out gnuplot-version number from startup
  230. ;; message and set `gnuplot-echo-command-line-flag'
  231. ;; accordingly. Added `gnuplot-program-version' variable.
  232. ;; Check that font-lock is actually a feature, as suggested by
  233. ;; <KL>
  234. ;; 0.5h Aug 15 1999 <BR> Added `gnuplot-determine-gnuplot-version' so
  235. ;; that the gnuplot version number and `comint-process-echos'
  236. ;; actually get set correctly. Actually, the first time
  237. ;; something is plotted, the echoing might not work, but the
  238. ;; second time it will.
  239. ;; 0.5i Sep 2 1999 <BR> Once again changed how
  240. ;; `comint-process-echos' gets set. Maybe I got it right this
  241. ;; time? Also fixed certain situations where the info file
  242. ;; did notget properly loaded (insertion with info toggle on
  243. ;; and info button in GUI).
  244. ;; 0.5j Sep 9 1999 <BR> Do a more robust check for the gnuplot
  245. ;; process before killing the gnuplot buffer, as suggested by
  246. ;; <SE>.
  247. ;; 0.5k Sep 22 1999 <BR> make `gnuplot-send-line-and-forward' skip
  248. ;; over blank and comment lines as suggested by <SE>. Jan 10
  249. ;; 2000 Bound C-c C-j to `gnuplot-forward-script-line'.
  250. ;; 0.5l Nov 16 2000 <BR> support for pm3d in gnuplot-gui and in plot
  251. ;; options insertions menu. mentioned pm3d in gpelcard. gui
  252. ;; support for x11 pm3d and vgagl terms.
  253. ;; `gnuplot-negate-option' works with new syntax.
  254. ;; 0.5m Nov 17 2000 <BR> add colorization and gui support for new
  255. ;; commands in 3.8. gui support for emf term. gui support for
  256. ;; new "set style" syntax. much better scheme for determining
  257. ;; gnuplot version number + make better use of it.
  258. ;; 0.5n Jan 4 2001 <BR> corrected a serious problem interacting with
  259. ;; speedbar
  260. ;; 0.5o skipped
  261. ;; 0.5p Mar 14 2001 <BR> fixed problem with toolbar creation and
  262. ;; speedbar clicking
  263. ;; 0.5q May 30 2001 <BR> added font-lock bindings for words associated
  264. ;; with plotting
  265. ;; 0.5r Oct 17 2001 <BR> Incorporate two suggestions by <RF>, bind
  266. ;; C-c C-c to comment-region and C-c C-o to the GUI, also make
  267. ;; C-c C-l respect continuation lines
  268. ;; April 12, 2002 <BR> added feature to trim length of gnuplot
  269. ;; process buffer
  270. ;; 0.5s Jun 7 2002 <BR> Yet again changed how `comint-process-echos'
  271. ;; gets set. It really needs to be nil on NTEmacs 21.1 or
  272. ;; comint gets stuck in an infinate loop.
  273. ;; 0.5t Sep 16 2002 <BR> Fixed a problem with C-c C-v jumping
  274. ;; forward 2 lines at a time
  275. ;; 0.6.0 Dec 13 2002 <BR> Changed numbering scheme to accommodate
  276. ;; gnuplot packaging requirements
  277. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  278. ;;; Acknowledgements:
  279. ;; David Batty <DB> (numerous corrections)
  280. ;; Laurent Bonnaud <LB> (suggestions regarding font-lock rules)
  281. ;; Markus Dickebohm <MD> (suggested `gnuplot-send-line-and-forward')
  282. ;; Stephen Eglan <SE> (suggested the use of info-look,
  283. ;; contributed a bug fix regarding shutting
  284. ;; down the gnuplot process, improvement to
  285. ;; `gnuplot-send-line-and-forward')
  286. ;; Robert Fenk <RF> (suggested respecting continuation lines)
  287. ;; Michael Karbach <MK> (suggested trimming the gnuplot process buffer)
  288. ;; Alex Chan Libchen <AL> (suggested font-lock for plotting words)
  289. ;; Kuang-Yu Liu <KL> (pointed out buggy dependence on font-lock)
  290. ;; Hrvoje Niksic <HN> (help with defcustom arguments for insertions)
  291. ;; Andreas Rechtsteiner <AR> (pointed out problem with C-c C-v)
  292. ;; Michael Sanders <MS> (help with the info-look interface)
  293. ;; Jinwei Shen <JS> (suggested functionality in comint buffer)
  294. ;; Michael M. Tung <MT> (prompted me to add pm3d support)
  295. ;; Holger Wenzel <HW> (suggested using `gnuplot-keywords-when')
  296. ;; Wolfgang Zocher <WZ> (pointed out problem with gnuplot-mode + speedbar)
  297. ;; and especially to Lars Hecking <LH> for including gnuplot-mode
  298. ;; with the gnuplot 3.7-beta distribution and for providing me with
  299. ;; installation materials
  300. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  301. ;;; To Do:
  302. ;;
  303. ;; 1. Since `gnuplot-display-process' can be nil, it would be
  304. ;; handy to have a function to put on
  305. ;; `gnuplot-after-plot-buffer-hook' to check and see if the script
  306. ;; executed properly. Alas I am not sure how gnuplot signals its
  307. ;; errors.
  308. ;; 2. improve plot, splot, fit in GUI
  309. ;; 3. interface to setting bind command using `read-key-sequence'.
  310. ;; this is a pain because the nomenclature is really different in
  311. ;; gnuplot than in `read-key-sequence'
  312. ;;
  313. ;;; Bugs:
  314. ;;
  315. ;; -- indentation is not quite right (but close)
  316. ;;
  317. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  318. ;;; Code:
  319. (require 'comint)
  320. (require 'easymenu)
  321. ;;; --- variable definitions + eval-and-compile clauses
  322. ;; handle defcustom
  323. (eval-and-compile
  324. (condition-case ()
  325. (require 'custom)
  326. (error nil))
  327. (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
  328. nil ;; We've got what we needed
  329. ;; We have the old custom-library, hack around it!
  330. (if (fboundp 'defgroup)
  331. nil
  332. (defmacro defgroup (&rest args)
  333. nil))
  334. (if (fboundp 'defface)
  335. nil
  336. (defmacro defface (var values doc &rest args)
  337. (` (progn
  338. (defvar (, var) (quote (, var)))
  339. ;; To make colors for your faces you need to set your .Xdefaults
  340. ;; or set them up ahead of time in your .emacs file.
  341. (make-face (, var))
  342. ))))
  343. (if (fboundp 'defcustom)
  344. nil
  345. (defmacro defcustom (var value doc &rest args)
  346. (` (defvar (, var) (, value) (, doc)))))))
  347. ;; (eval-and-compile
  348. ;; (condition-case ()
  349. ;; (require 'kw-compl)
  350. ;; (error nil)))
  351. (eval-and-compile ;; <DB>
  352. (require 'info))
  353. (eval-and-compile
  354. (condition-case ()
  355. (require 'info-look)
  356. (error nil)))
  357. ;; this just gets rid of an annoying compile time error message
  358. ;; (eval-when-compile
  359. ;; (defun gnuplot-dummy ())
  360. ;; (defalias 'hilit-set-mode-patterns 'gnuplot-dummy))
  361. (defconst gnuplot-xemacs-p (string-match "XEmacs" (emacs-version)))
  362. (defconst gnuplot-ntemacs-p (string-match "msvc" (emacs-version)))
  363. (defvar gnuplot-three-eight-p "")
  364. (defconst gnuplot-maintainer "Bruce Ravel")
  365. (defconst gnuplot-maintainer-email "ravel@phys.washington.edu")
  366. (defconst gnuplot-maintainer-url
  367. "http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/")
  368. (defconst gnuplot-version "0.6.0")
  369. (defgroup gnuplot nil
  370. "Gnuplot-mode for Emacs."
  371. :prefix "gnuplot-"
  372. :group 'processes
  373. :group 'applications
  374. :group 'local
  375. :link '(emacs-library-link :tag "Lisp File" "gnuplot.el")
  376. :link '(url-link :tag "Homepage"
  377. "http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/")
  378. :link '(custom-manual "(gnuplot)Top")
  379. :link '(emacs-commentary-link :tag "Commentary" "gnuplot.el") )
  380. (defgroup gnuplot-insertions nil
  381. "Insert commands into gnuplot-scripts from a pull-down menu."
  382. :prefix "gnuplot-insertions-"
  383. :group 'gnuplot)
  384. (defgroup gnuplot-hooks nil
  385. "Hook variables used by `gnuplot-mode'."
  386. :prefix "gnuplot-"
  387. :group 'gnuplot)
  388. (defcustom gnuplot-mode-hook nil
  389. "*Hook run when `gnuplot-mode' is entered."
  390. :group 'gnuplot-hooks
  391. :type 'hook)
  392. (defcustom gnuplot-load-hook nil
  393. "*Hook run when gnuplot.el is first loaded."
  394. :group 'gnuplot-hooks
  395. :type 'hook)
  396. (defcustom gnuplot-after-plot-hook nil
  397. "*Hook run after gnuplot plots something.
  398. This is the last thing done by the functions for plotting a line, a
  399. region, a buffer, or a file."
  400. :group 'gnuplot-hooks
  401. :type 'hook)
  402. (defcustom gnuplot-info-hook nil
  403. "*Hook run before setting up the info-look interface.
  404. This hook is necessary to handle inconsistencies in versions of and
  405. sources of the gnuplot info file. If Gnuplot-mode can find the info
  406. file generated from the 3.6beta patchlevel 347 (or later) release of
  407. Gnuplot, then this hook probably is not necessary. Some versions of
  408. the info file may have a General Index session, which can be used by
  409. info-look. In that case the following (or something similar with the
  410. value of `info-lookup-symbol-alist' altered appropriately) should be
  411. placed in the .emacs file.
  412. Emacs version 20.2 ships with a different version of info-look that
  413. does 20.3. If you use any version of Emacs 19, you must use the
  414. version from 20.2. Any version of XEmacs 20 or 21 should use the
  415. version from 20.3 but can use either. XEmacs 19 should use the
  416. version 20.2.
  417. For the newer version of info-look, do this:
  418. (add-hook \'gnuplot-info-hook
  419. \'(lambda ()
  420. (let ((elem (assoc \'gnuplot-mode info-lookup-alist)))
  421. (delete elem info-lookup-alist)
  422. (info-lookup-maybe-add-help
  423. :mode 'gnuplot-mode :topic 'symbol
  424. :regexp \"[a-zA-Z][_a-zA-Z0-9]*\"
  425. :doc-spec '((\"(gnuplot)General Index\" nil
  426. \"[_a-zA-Z0-9]+\"))))))
  427. For the older version of info-look, do this:
  428. (add-hook \'gnuplot-info-hook
  429. \'(lambda ()
  430. (let ((elem (assoc \'gnuplot-mode info-lookup-alist)))
  431. (delete elem info-lookup-alist)
  432. (setq info-lookup-alist
  433. (append info-lookup-alist
  434. \'((gnuplot-mode
  435. \"[a-zA-Z][_a-zA-Z0-9]*\" nil
  436. ((\"(gnuplot)General Index\" nil
  437. \"[_a-zA-Z0-9]+\" )))))))))"
  438. :group 'gnuplot-hooks
  439. :type 'hook)
  440. ;; comint hook suggested by <DB>
  441. (defcustom gnuplot-comint-setup-hook nil
  442. "*Hook run after setting up the gnuplot buffer in comint mode.
  443. So the configuration can be customised by the user."
  444. :group 'gnuplot-hooks
  445. :type 'hook)
  446. (defvar gnuplot-recently-sent nil
  447. "This is a record of the most recent kind of text sent to gnuplot.
  448. It takes as its value nil, 'line, 'region, 'buffer, or 'file. It is
  449. useful for functions included in `gnuplot-after-plot-hook'.")
  450. (make-variable-buffer-local 'gnuplot-recently-sent)
  451. (defcustom gnuplot-program "gnuplot"
  452. "*The name of the gnuplot executable."
  453. :group 'gnuplot
  454. :type 'string)
  455. (defvar gnuplot-program-version nil
  456. "Version number of gnuplot.
  457. This is found using `gnuplot-determine-gnuplot-version")
  458. (defcustom gnuplot-process-name "gnuplot"
  459. "Name given to the gnuplot buffer and process."
  460. :group 'gnuplot
  461. :type 'string)
  462. (defvar gnuplot-buffer nil
  463. "*The name of the buffer displaying the gnuplot process.")
  464. (defvar gnuplot-process nil
  465. "Variable holding the process handle.")
  466. (defvar gnuplot-process-frame nil
  467. "The frame for displaying the gnuplot process.
  468. This is used when `gnuplot-display-process' is equal to 'frame.")
  469. (defvar gnuplot-comint-recent-buffer nil
  470. "The most recently plotted gnuplot script buffer.
  471. This is used by the function that plot from the comint buffer. It is
  472. reset every time something is plotted from a script buffer.")
  473. (defcustom gnuplot-gnuplot-buffer "plot.gp"
  474. "*The name of the gnuplot scratch buffer opened by 'gnuplot-make-buffer'."
  475. :group 'gnuplot
  476. :type 'string)
  477. (defcustom gnuplot-display-process 'window
  478. "This controls how the gnuplot process buffer is displayed.
  479. The values are
  480. 'frame display gnuplot process in a separate frame
  481. 'window display gnuplot process in this frame but in another window
  482. nil `gnuplot-process' is in the current frame but not displayed"
  483. :group 'gnuplot
  484. :type '(radio (const :tag "Separate frame" frame)
  485. (const :tag "Separate window" window)
  486. (const :tag "Not displayed" nil)))
  487. (defcustom gnuplot-info-display 'window
  488. "*Determines how `gnuplot-info-lookup-symbol' displays the info file.
  489. The values are
  490. 'frame display info file in a separate frame
  491. 'window display info file in another window
  492. nil display info file in the current window"
  493. :group 'gnuplot
  494. :type '(radio (const :tag "Separate frame" frame)
  495. (const :tag "Separate window" window)
  496. (const :tag "This window" nil)))
  497. (defcustom gnuplot-echo-command-line-flag (not gnuplot-ntemacs-p)
  498. "*This sets the fall-back value of `comint-process-echos'.
  499. If `gnuplot-mode' cannot figure out what version number of gnuplot
  500. this is, then the value of this variable will be used for
  501. `comint-process-echos'. It seems that gnuplot 3.5 wants this to be
  502. nil and 3.7 wants it to be t. If lines that you send to gnuplot from
  503. the `gnuplot-mode' buffer are not appearing at the gnuplot prompt in
  504. the process buffer, try toggling it. Also see the document string for
  505. `comint-process-echos'. If you change this, kill the gnuplot process
  506. and start it again."
  507. :group 'gnuplot
  508. :type 'boolean)
  509. (defcustom gnuplot-insertions-show-help-flag nil
  510. "*Non-nil means to display certain help messages automatically.
  511. These messages are shown after menu insertion of gnuplot commands."
  512. :group 'gnuplot-insertions
  513. :type 'boolean)
  514. (defcustom gnuplot-delay 0.01
  515. "*Amount of time to delay before sending a new line to gnuplot.
  516. This is needed so that the the line is not written in the gnuplot
  517. buffer in advance of its prompt. Increase this number if the
  518. prompts and lines are displayed out of order."
  519. :group 'gnuplot
  520. :type 'number)
  521. (defcustom gnuplot-buffer-max-size 1000
  522. "*The maximum size in lines of the gnuplot process buffer.
  523. Each time text is written in the gnuplot process buffer, lines are
  524. trimmed from the beginning of the buffer so that the buffer is this
  525. many lines long. The lines are deleted after the most recent lines
  526. were interpretted by gnuplot. Setting to 0 turns off this feature
  527. (i.e. no lines get trimmed)."
  528. :group 'gnuplot
  529. :type 'integer)
  530. (defcustom gnuplot-quote-character "\'"
  531. "*Quotation character used for inserting quoted strings.
  532. Gnuplot can use single or double quotes. If you prefer to have the
  533. filename insertion function never insert quotes for you, set this
  534. to the empty string."
  535. :group 'gnuplot
  536. :type '(radio (const :tag "double quote" "\"")
  537. (const :tag "single quote" "\'")
  538. (const :tag "none" "" )))
  539. ;; (defcustom gnuplot-gnuplot-version nil
  540. ;; "*Force gnuplot-mode to behave for this version of gnuplot."
  541. ;; :group 'gnuplot
  542. ;; :type '(radio (const :tag "unspecified" nil)
  543. ;; (const :tag "3.8 or newer" "3.8")
  544. ;; (const :tag "3.7 or older" "3.7")))
  545. (defvar gnuplot-info-frame nil)
  546. (defvar gnuplot-info-nodes '())
  547. (defvar gnuplot-first-call t)
  548. ;; with info-look, there is no need to carry this list around -- it
  549. ;; can be generated on the fly appropriate to the currently installed
  550. ;; version of gnuplot.info
  551. (defvar gnuplot-keywords nil
  552. "A list of keywords used in GNUPLOT.
  553. These are set by `gnuplot-set-keywords-list' from the values in
  554. `info-lookup-cache'.")
  555. (defvar gnuplot-keywords-pending t ;; <HW>
  556. "A boolean which gets toggled when the info file is probed.")
  557. (defcustom gnuplot-keywords-when 'deferred ;; 'immediately
  558. "This variable controls when the info file is parsed.
  559. The choices are immediately upon starting gnuplot-mode or the first
  560. time that data is needed. If you use hilit19, then the info file is
  561. parsed immediately regardless of the value of this variable. But
  562. you're not using that musty old thing, are you..."
  563. :group 'gnuplot
  564. :type
  565. '(radio (const :tag "Parse info file when gnuplot-mode starts" immediately)
  566. (const :tag "Parse info file the first time it is needed" deferred)))
  567. (defgroup gnuplot-faces nil
  568. "Text faces used by gnuplot-mode."
  569. :prefix "gnuplot-"
  570. :group 'gnuplot)
  571. (cond ((and (featurep 'custom) (fboundp 'custom-declare-variable))
  572. (defface gnuplot-prompt-face '((((class color))
  573. (:foreground "firebrick"))
  574. (t
  575. (:bold t :underline t)))
  576. "Face used for the prompt in the gnuplot process buffer."
  577. :group 'gnuplot-faces))
  578. (t
  579. (make-face 'gnuplot-prompt-face)
  580. (set-face-foreground 'gnuplot-prompt-face "firebrick")))
  581. ;;; --- key bindings and menus
  582. (defvar gnuplot-mode-map nil)
  583. (if gnuplot-mode-map
  584. ()
  585. (setq gnuplot-mode-map (make-sparse-keymap))
  586. (define-key gnuplot-mode-map "\C-c\C-b" 'gnuplot-send-buffer-to-gnuplot)
  587. (define-key gnuplot-mode-map "\C-c\C-c" 'comment-region) ; <RF>
  588. (define-key gnuplot-mode-map "\C-c\C-o" 'gnuplot-gui-set-options-and-insert)
  589. (define-key gnuplot-mode-map "\C-c\C-d" 'gnuplot-show-version)
  590. (define-key gnuplot-mode-map "\C-c\C-e" 'gnuplot-show-gnuplot-buffer)
  591. (define-key gnuplot-mode-map "\C-c\C-f" 'gnuplot-send-file-to-gnuplot)
  592. (define-key gnuplot-mode-map "\C-c\C-h" 'gnuplot-info-lookup-symbol)
  593. (define-key gnuplot-mode-map "\C-c\C-i" 'gnuplot-insert-filename)
  594. (define-key gnuplot-mode-map "\C-c\C-j" 'gnuplot-forward-script-line)
  595. (define-key gnuplot-mode-map "\C-c\C-k" 'gnuplot-kill-gnuplot-buffer)
  596. (define-key gnuplot-mode-map "\C-c\C-l" 'gnuplot-send-line-to-gnuplot)
  597. (define-key gnuplot-mode-map "\C-c\C-n" 'gnuplot-negate-option)
  598. (define-key gnuplot-mode-map "\C-c\C-p" 'gnuplot-show-gnuplot-version)
  599. (define-key gnuplot-mode-map "\C-c\C-r" 'gnuplot-send-region-to-gnuplot)
  600. ;;(define-key gnuplot-mode-map "\C-c\C-t" 'gnuplot-gui-swap-simple-complete)
  601. (define-key gnuplot-mode-map "\C-c\C-u" 'gnuplot-bug-report)
  602. (define-key gnuplot-mode-map "\C-c\C-v" 'gnuplot-send-line-and-forward)
  603. (define-key gnuplot-mode-map "\C-c\C-z" 'gnuplot-customize)
  604. (define-key gnuplot-mode-map "\M-\r" 'gnuplot-complete-keyword)
  605. (define-key gnuplot-mode-map "\M-\t" 'gnuplot-complete-keyword)
  606. (define-key gnuplot-mode-map "\C-i" 'indent-for-tab-command)
  607. (define-key gnuplot-mode-map "\C-m" 'newline-and-indent)
  608. ;;(define-key gnuplot-mode-map "\C-m" 'reindent-then-newline-and-indent)
  609. ;;(if (featurep 'kw-compl)
  610. ;; (define-key gnuplot-mode-map "\M-\r" 'kw-compl-abbrev)))
  611. (cond (gnuplot-xemacs-p
  612. (define-key gnuplot-mode-map '(shift button2)
  613. 'gnuplot-gui-mouse-set))
  614. (t
  615. (define-key gnuplot-mode-map [S-mouse-2]
  616. 'gnuplot-gui-mouse-set))) )
  617. (defvar gnuplot-mode-menu nil)
  618. (defvar gnuplot-menu nil
  619. "Menu for `gnuplot-mode'.")
  620. (setq gnuplot-menu
  621. '("Gnuplot"
  622. ["Send line to gnuplot" gnuplot-send-line-to-gnuplot t]
  623. ["Send line & move forward" gnuplot-send-line-and-forward (not (eobp))]
  624. ["Send region to gnuplot" gnuplot-send-region-to-gnuplot
  625. (gnuplot-mark-active)]
  626. ["Send buffer to gnuplot" gnuplot-send-buffer-to-gnuplot t]
  627. ["Send file to gnuplot" gnuplot-send-file-to-gnuplot t]
  628. "---"
  629. ["Insert filename at point" gnuplot-insert-filename t]
  630. ["Negate set option" gnuplot-negate-option t]
  631. ;;["Set key binding" gnuplot-set-binding gnuplot-three-eight-p]
  632. ["Keyword help" gnuplot-info-lookup-symbol
  633. (or gnuplot-keywords gnuplot-keywords-pending)]
  634. ["Show gnuplot process buffer" gnuplot-show-gnuplot-buffer t]
  635. ["Set arguments at point" gnuplot-gui-set-options-and-insert
  636. (fboundp 'gnuplot-gui-set-options-and-insert)]
  637. ["Swap plot/splot/fit lists in GUI" gnuplot-gui-swap-simple-complete
  638. (fboundp 'gnuplot-gui-swap-simple-complete)]
  639. "---"
  640. ["Customize gnuplot" gnuplot-customize t]
  641. ["Submit bug report" gnuplot-bug-report t]
  642. ["Show gnuplot-mode version" gnuplot-show-version t]
  643. ["Show gnuplot version" gnuplot-show-gnuplot-version t]
  644. "---"
  645. ["Kill gnuplot" gnuplot-kill-gnuplot-buffer t]
  646. ))
  647. ;;; --- insertions variables and menus
  648. ;;(load-library "gnuplot-insertions")
  649. (defvar gnuplot-mode-insertions-menu nil)
  650. (defvar gnuplot-insertions-menu nil
  651. "Menu for insertions in `gnuplot-mode'.
  652. The insertions menu is composed of several sub-menus. The variables
  653. describing the sub-menus are:
  654. `gnuplot-insertions-adornments'
  655. `gnuplot-insertions-plot-options'
  656. `gnuplot-insertions-terminal'
  657. `gnuplot-insertions-x-axis'
  658. `gnuplot-insertions-y-axis'
  659. `gnuplot-insertions-z-axis'
  660. `gnuplot-insertions-x2-axis'
  661. `gnuplot-insertions-y2-axis'
  662. `gnuplot-insertions-parametric-plots'
  663. `gnuplot-insertions-polar-plots'
  664. `gnuplot-insertions-surface-plots'
  665. These variables can be customized by the user. For example, there are
  666. many terminal types which are not in the terminal submenu but which
  667. may be compiled into a user's copy of gnuplot.
  668. Each of these variables is a list whose first element is a string and
  669. all the rest are vectors as described in the document string for
  670. `easy-menu-define'. The callback used throughout these menus is
  671. `gnuplot-insert' which inserts the appropriate set expression and,
  672. optionally, looks up that item in the gnuplot info file.
  673. The easiest way to customize the submenus is to use the custom
  674. package. Just type \\[gnuplot-customize] and follow your nose.
  675. You can also add new items to any of these sub-menus by adding to the
  676. `gnuplot-load-hook' in your .emacs file. Here is an example of adding
  677. the \"regis\" terminal type to the terminal sub-menu:
  678. (add-hook
  679. 'gnuplot-load-hook
  680. '(lambda ()
  681. (setq gnuplot-insertions-terminal
  682. (append gnuplot-insertions-terminal
  683. (list
  684. [\"regis\"
  685. (gnuplot-insert \"set terminal regis\")
  686. t])))))")
  687. (defvar gnuplot-insertions-top ()
  688. "Top part of insertions menu.
  689. See the document string for `gnuplot-insertions-menu'")
  690. (defcustom gnuplot-insertions-menu-flag t
  691. "*Non-nil means to place the insertion menu in the menubar.
  692. Changing this will not effect a change in any currently existing
  693. `gnuplot-mode' buffer. You will see the change the next time you
  694. create a `gnuplot-mode' buffer."
  695. :group 'gnuplot-insertions
  696. :type 'boolean)
  697. (defcustom gnuplot-insertions-adornments ; this is icky...
  698. (if gnuplot-three-eight-p
  699. '("adornments"
  700. ["arrow" (gnuplot-insert "set arrow ") t]
  701. ["bar" (gnuplot-insert "set bar") t]
  702. ["border" (gnuplot-insert "set border") t]
  703. ["boxwidth" (gnuplot-insert "set boxwidth ") t]
  704. ["format" (gnuplot-insert "set format ") t]
  705. ["grid" (gnuplot-insert "set grid") t]
  706. ["key" (gnuplot-insert "set key ") t]
  707. ["label" (gnuplot-insert "set label ") t]
  708. ["pointsize" (gnuplot-insert "set pointsize ") t]
  709. ["samples" (gnuplot-insert "set samples ") t]
  710. ["size" (gnuplot-insert "set size ") t]
  711. ["style" (gnuplot-insert "set style ") t]
  712. ["tics" (gnuplot-insert "set tics ") t]
  713. ["timefmt" (gnuplot-insert "set timefmt ") t]
  714. ["timestamp" (gnuplot-insert "set timestamp ") t]
  715. ["title" (gnuplot-insert "set title ") t]
  716. ["zeroaxis" (gnuplot-insert "set zeroaxis") t] )
  717. '("adornments"
  718. ["data style" (gnuplot-insert "set data style ") t]
  719. ["function style" (gnuplot-insert "set function style ") t]
  720. ["arrow" (gnuplot-insert "set arrow ") t]
  721. ["bar" (gnuplot-insert "set bar") t]
  722. ["border" (gnuplot-insert "set border") t]
  723. ["boxwidth" (gnuplot-insert "set boxwidth ") t]
  724. ["format" (gnuplot-insert "set format ") t]
  725. ["grid" (gnuplot-insert "set grid") t]
  726. ["key" (gnuplot-insert "set key ") t]
  727. ["label" (gnuplot-insert "set label ") t]
  728. ["pointsize" (gnuplot-insert "set pointsize ") t]
  729. ["samples" (gnuplot-insert "set samples ") t]
  730. ["size" (gnuplot-insert "set size ") t]
  731. ["tics" (gnuplot-insert "set tics ") t]
  732. ["timefmt" (gnuplot-insert "set timefmt ") t]
  733. ["timestamp" (gnuplot-insert "set timestamp ") t]
  734. ["title" (gnuplot-insert "set title ") t]
  735. ["zeroaxis" (gnuplot-insert "set zeroaxis") t] ))
  736. "Adornments submenu in the insertions menu.
  737. See the document string for `gnuplot-insertions-menu'
  738. Changing this will not effect a change in any currently existing
  739. `gnuplot-mode' buffer. You will see the change the next time you
  740. create a `gnuplot-mode' buffer."
  741. :group 'gnuplot-insertions
  742. :type '(list (string :tag "Title")
  743. (repeat :inline t
  744. (vector (string :tag "Name")
  745. (function :tag "Callback")
  746. (boolean :tag "Enabled" t)))))
  747. (defcustom gnuplot-insertions-plot-options
  748. '("plot options"
  749. ["autoscale" (gnuplot-insert "set autoscale ") t]
  750. ["clip" (gnuplot-insert "set clip ") t]
  751. ["encoding" (gnuplot-insert "set encoding ") t]
  752. ["locale" (gnuplot-insert "set locale ") t]
  753. ["logscale" (gnuplot-insert "set logscale ") t]
  754. ["multiplot" (gnuplot-insert "set multiplot") t]
  755. ["missing" (gnuplot-insert "set missing \"\"") t]
  756. ["palette" (gnuplot-insert "set palette ") t] ; <MT>
  757. ["pm3d" (gnuplot-insert "set pm3d ") t]
  758. ["offsets" (gnuplot-insert "set offsets ") t]
  759. ["output" (gnuplot-insert "set output ") t]
  760. ["zero" (gnuplot-insert "set zero ") t] )
  761. "Plot options submenu in the insertions menu.
  762. See the document string for `gnuplot-insertions-menu'
  763. Changing this will not effect a change in any currently existing
  764. `gnuplot-mode' buffer. You will see the change the next time you
  765. create a `gnuplot-mode' buffer."
  766. :group 'gnuplot-insertions
  767. :type '(list (string :tag "Title")
  768. (repeat :inline t
  769. (vector (string :tag "Name")
  770. (function :tag "Callback")
  771. (boolean :tag "Enabled" t)))))
  772. (defcustom gnuplot-insertions-terminal
  773. '("terminal"
  774. ["eepic" (gnuplot-insert "set terminal eepic") t]
  775. ["fig" (gnuplot-insert "set terminal fig") t]
  776. ["gpic" (gnuplot-insert "set terminal gpic") t]
  777. ["latex" (gnuplot-insert "set terminal latex") t]
  778. ["linux" (gnuplot-insert "set terminal linux") t]
  779. ["pbm" (gnuplot-insert "set terminal pbm") t]
  780. ["png" (gnuplot-insert "set terminal png") t]
  781. ["postscript" (gnuplot-insert "set terminal postscript") t]
  782. ["pslatex" (gnuplot-insert "set terminal pslatex") t]
  783. ["table" (gnuplot-insert "set terminal table") t]
  784. ["tek40xx" (gnuplot-insert "set terminal tek40xx") t]
  785. ["tkcanvas" (gnuplot-insert "set terminal tkcanvas") t]
  786. ["tpic" (gnuplot-insert "set terminal tpic") t]
  787. ["vgagl" (gnuplot-insert "set terminal vgagl") t] ; for pm3d patch
  788. ["vttek" (gnuplot-insert "set terminal vttek") t]
  789. ["x11" (gnuplot-insert "set terminal x11") t] )
  790. "Terminal submenu in the insertions menu.
  791. See the document string for `gnuplot-insertions-menu'
  792. Changing this will not effect a change in any currently existing
  793. `gnuplot-mode' buffer. You will see the change the next time you
  794. create a `gnuplot-mode' buffer."
  795. :group 'gnuplot-insertions
  796. :type '(list (string :tag "Title")
  797. (repeat :inline t
  798. (vector (string :tag "Name")
  799. (function :tag "Callback")
  800. (boolean :tag "Enabled" t)))))
  801. (defcustom gnuplot-insertions-x-axis
  802. '("x-axis"
  803. ["xdata" (gnuplot-insert "set xdata ") t]
  804. ["xlabel" (gnuplot-insert "set xlabel ") t]
  805. ["xrange" (gnuplot-insert "set xrange [:]") t]
  806. ["xtics" (gnuplot-insert "set xtics ") t]
  807. ["mxtics" (gnuplot-insert "set mxtics ") t]
  808. ["xzeroaxis" (gnuplot-insert "set xzeroaxis ") t]
  809. ["xdtics" (gnuplot-insert "set xdtics ") t]
  810. ["xmtics" (gnuplot-insert "set xmtics ") t])
  811. "X-axis submenu in the insertions menu.
  812. See the document string for `gnuplot-insertions-menu'
  813. Changing this will not effect a change in any currently existing
  814. `gnuplot-mode' buffer. You will see the change the next time you
  815. create a `gnuplot-mode' buffer."
  816. :group 'gnuplot-insertions
  817. :type '(list (string :tag "Title")
  818. (repeat :inline t
  819. (vector (string :tag "Name")
  820. (function :tag "Callback")
  821. (boolean :tag "Enabled" t)))))
  822. (defcustom gnuplot-insertions-x2-axis
  823. '("x2-axis"
  824. ["x2data" (gnuplot-insert "set xdata ") t]
  825. ["x2label" (gnuplot-insert "set xlabel ") t]
  826. ["x2range" (gnuplot-insert "set xrange [:]") t]
  827. ["x2tics" (gnuplot-insert "set xtics ") t]
  828. ["mx2tics" (gnuplot-insert "set mxtics ") t]
  829. ["x2zeroaxis" (gnuplot-insert "set xzeroaxis ") t]
  830. ["x2dtics" (gnuplot-insert "set xdtics ") t]
  831. ["x2mtics" (gnuplot-insert "set xmtics ") t])
  832. "X2-axis submenu in the insertions menu.
  833. See the document string for `gnuplot-insertions-menu'
  834. Changing this will not effect a change in any currently existing
  835. `gnuplot-mode' buffer. You will see the change the next time you
  836. create a `gnuplot-mode' buffer."
  837. :group 'gnuplot-insertions
  838. :type '(list (string :tag "Title")
  839. (repeat :inline t
  840. (vector (string :tag "Name")
  841. (function :tag "Callback")
  842. (boolean :tag "Enabled" t)))))
  843. (defcustom gnuplot-insertions-y-axis
  844. '("y-axis"
  845. ["ydata" (gnuplot-insert "set ydata ") t]
  846. ["ylabel" (gnuplot-insert "set ylabel ") t]
  847. ["ymtics" (gnuplot-insert "set ymtics ") t]
  848. ["yrange" (gnuplot-insert "set yrange [:]") t]
  849. ["ytics" (gnuplot-insert "set ytics ") t]
  850. ["yzeroaxis" (gnuplot-insert "set yzeroaxis ") t]
  851. ["ydtics" (gnuplot-insert "set ydtics ") t]
  852. ["mytics" (gnuplot-insert "set mytics ") t])
  853. "Y-axis submenu in the insertions menu.
  854. See the document string for `gnuplot-insertions-menu'
  855. Changing this will not effect a change in any currently existing
  856. `gnuplot-mode' buffer. You will see the change the next time you
  857. create a `gnuplot-mode' buffer."
  858. :group 'gnuplot-insertions
  859. :type '(list (string :tag "Title")
  860. (repeat :inline t
  861. (vector (string :tag "Name")
  862. (function :tag "Callback")
  863. (boolean :tag "Enabled" t)))))
  864. (defcustom gnuplot-insertions-y2-axis
  865. '("y2-axis"
  866. ["y2data" (gnuplot-insert "set ydata ") t]
  867. ["y2label" (gnuplot-insert "set ylabel ") t]
  868. ["y2range" (gnuplot-insert "set yrange [:]") t]
  869. ["y2tics" (gnuplot-insert "set ytics ") t]
  870. ["my2tics" (gnuplot-insert "set mytics ") t]
  871. ["y2zeroaxis" (gnuplot-insert "set yzeroaxis ") t]
  872. ["y2mtics" (gnuplot-insert "set ymtics ") t]
  873. ["y2dtics" (gnuplot-insert "set ydtics ") t])
  874. "Y2-axis submenu in the insertions menu.
  875. See the document string for `gnuplot-insertions-menu'
  876. Changing this will not effect a change in any currently existing
  877. `gnuplot-mode' buffer. You will see the change the next time you
  878. create a `gnuplot-mode' buffer."
  879. :group 'gnuplot-insertions
  880. :type '(list (string :tag "Title")
  881. (repeat :inline t
  882. (vector (string :tag "Name")
  883. (function :tag "Callback")
  884. (boolean :tag "Enabled" t)))))
  885. (defcustom gnuplot-insertions-z-axis
  886. '("z-axis"
  887. ["zdata" (gnuplot-insert "set zdata ") t]
  888. ["zlabel" (gnuplot-insert "set zlabel ") t]
  889. ["zrange" (gnuplot-insert "set zrange [:]") t]
  890. ["ztics" (gnuplot-insert "set ztics ") t]
  891. ["mztics" (gnuplot-insert "set mztics ") t]
  892. ["zdtics" (gnuplot-insert "set zdtics ") t]
  893. ["zmtics" (gnuplot-insert "set zmtics ") t] )
  894. "Z-axis submenu in the insertions menu.
  895. See the document string for `gnuplot-insertions-menu'
  896. Changing this will not effect a change in any currently existing
  897. `gnuplot-mode' buffer. You will see the change the next time you
  898. create a `gnuplot-mode' buffer."
  899. :group 'gnuplot-insertions
  900. :type '(list (string :tag "Title")
  901. (repeat :inline t
  902. (vector (string :tag "Name")
  903. (function :tag "Callback")
  904. (boolean :tag "Enabled" t)))))
  905. (defcustom gnuplot-insertions-parametric-plots
  906. '("parametric plots"
  907. ["parametric" (gnuplot-insert "set parametric") t]
  908. ["isosamples" (gnuplot-insert "set isosamples ") t]
  909. ["dummy" (gnuplot-insert "set dummy ") t]
  910. ["trange" (gnuplot-insert "set trange [:]") t]
  911. ["urange" (gnuplot-insert "set urange [:]") t]
  912. ["vrange" (gnuplot-insert "set vrange [:]") t] )
  913. "Parametric plots submenu in the insertions menu.
  914. See the document string for `gnuplot-insertions-menu'
  915. Changing this will not effect a change in any currently existing
  916. `gnuplot-mode' buffer. You will see the change the next time you
  917. create a `gnuplot-mode' buffer."
  918. :group 'gnuplot-insertions
  919. :type '(list (string :tag "Title")
  920. (repeat :inline t
  921. (vector (string :tag "Name")
  922. (function :tag "Callback")
  923. (boolean :tag "Enabled" t)))))
  924. (defcustom gnuplot-insertions-polar-plots
  925. '("polar plots"
  926. ["polar" (gnuplot-insert "set polar") t]
  927. ["angles" (gnuplot-insert "set angles ") t]
  928. ["rrange" (gnuplot-insert "set rrange [:]") t] )
  929. "Polar plots submenu in the insertions menu.
  930. See the document string for `gnuplot-insertions-menu'
  931. Changing this will not effect a change in any currently existing
  932. `gnuplot-mode' buffer. You will see the change the next time you
  933. create a `gnuplot-mode' buffer."
  934. :group 'gnuplot-insertions
  935. :type '(list (string :tag "Title")
  936. (repeat :inline t
  937. (vector (string :tag "Name")
  938. (function :tag "Callback")
  939. (boolean :tag "Enabled" t)))))
  940. (defcustom gnuplot-insertions-surface-plots
  941. '("surface plots"
  942. ["clabel" (gnuplot-insert "set clabel ") t]
  943. ["cntrparam" (gnuplot-insert "set cntrparam ") t]
  944. ["contour" (gnuplot-insert "set contour") t]
  945. ["dgrid3d" (gnuplot-insert "set dgrid3d ") t]
  946. ["hidden3d" (gnuplot-insert "set hidden3d ") t]
  947. ["mapping" (gnuplot-insert "set mapping ") t]
  948. ["surface" (gnuplot-insert "set surface ") t]
  949. ["view" (gnuplot-insert "set view ") t] )
  950. "Surface plots submenu in the insertions menu.
  951. See the document string for `gnuplot-insertions-menu'
  952. Changing this will not effect a change in any currently existing
  953. `gnuplot-mode' buffer. You will see the change the next time you
  954. create a `gnuplot-mode' buffer."
  955. :group 'gnuplot-insertions
  956. :type '(list (string :tag "Title")
  957. (repeat :inline t
  958. (vector (string :tag "Name")
  959. (function :tag "Callback")
  960. (boolean :tag "Enabled" t)))))
  961. (defvar gnuplot-insertions-bottom ()
  962. "Bottom part of the insertions menu.
  963. This part contains the toggle buttons for displaying info or
  964. opening an argument-setting popup.")
  965. (setq gnuplot-insertions-bottom
  966. '("---"
  967. ["Display of info with insertion" gnuplot-toggle-info-display
  968. :style toggle :selected gnuplot-insertions-show-help-flag]
  969. ["Display GUI popup with insertion" gnuplot-gui-toggle-popup
  970. :active (fboundp 'gnuplot-gui-toggle-popup)
  971. :style toggle :selected (and (fboundp 'gnuplot-gui-toggle-popup)
  972. gnuplot-gui-popup-flag)] ))
  973. ;; Regarding a comment by <DB>:
  974. ;;
  975. ;; This is from the header in easymenu.el distributed with XEmacs:
  976. ;;
  977. ;; ;; - Function: easy-menu-add MENU [ MAP ]
  978. ;; ;; Add MENU to the current menubar in MAP.
  979. ;; ;;
  980. ;; ;; - Function: easy-menu-remove MENU
  981. ;; ;; Remove MENU from the current menubar.
  982. ;; ;;
  983. ;; ;; Emacs 19 never uses `easy-menu-add' or `easy-menu-remove', menus
  984. ;; ;; automatically appear and disappear when the keymaps specified by
  985. ;; ;; the MAPS argument to `easy-menu-define' are activated.
  986. ;; ;;
  987. ;; ;; XEmacs will bind the map to button3 in each MAPS, but you must
  988. ;; ;; explicitly call `easy-menu-add' and `easy-menu-remove' to add and
  989. ;; ;; remove menus from the menu bar.
  990. ;;
  991. ;; in Emacs, easy-menu-add is defined like this:
  992. ;; (defun easy-menu-add (menu &optional map))
  993. (defun gnuplot-setup-menubar ()
  994. "Initial setup of gnuplot and insertions menus."
  995. (if gnuplot-insertions-menu-flag ; set up insertions menu
  996. (progn
  997. (if gnuplot-xemacs-p
  998. (setq gnuplot-insertions-top
  999. '("insert set expression" "--:doubleLine"))
  1000. (setq gnuplot-insertions-top
  1001. '("insert set expression" "---")))
  1002. (setq gnuplot-insertions-menu
  1003. (append (list "Insertions")
  1004. gnuplot-insertions-top
  1005. (list gnuplot-insertions-adornments)
  1006. (list gnuplot-insertions-plot-options)
  1007. (list gnuplot-insertions-terminal)
  1008. (list gnuplot-insertions-x-axis)
  1009. (list gnuplot-insertions-y-axis)
  1010. (list gnuplot-insertions-z-axis)
  1011. (list gnuplot-insertions-x2-axis)
  1012. (list gnuplot-insertions-y2-axis)
  1013. (list gnuplot-insertions-parametric-plots)
  1014. (list gnuplot-insertions-polar-plots)
  1015. (list gnuplot-insertions-surface-plots)
  1016. gnuplot-insertions-bottom))
  1017. (easy-menu-define gnuplot-mode-insertions-menu gnuplot-mode-map
  1018. "Insertions menu used in Gnuplot-mode"
  1019. gnuplot-insertions-menu)
  1020. (easy-menu-add gnuplot-mode-insertions-menu gnuplot-mode-map)))
  1021. (easy-menu-define ; set up gnuplot menu
  1022. gnuplot-mode-menu gnuplot-mode-map "Menu used in gnuplot-mode"
  1023. gnuplot-menu)
  1024. (easy-menu-add gnuplot-mode-menu gnuplot-mode-map) )
  1025. ;; There is no `mark-active' variable in XEmacs. Hassle! This is not
  1026. ;; only replicates mark-active, but it only returns true if the region
  1027. ;; is of non-zero width.
  1028. ;; Error checking suggested by <DB>
  1029. (defun gnuplot-mark-active ()
  1030. "Return non-nil if the mark is active and it is not equal to point."
  1031. (condition-case nil
  1032. (and (mark) (/= (mark) (point)))
  1033. (error nil)))
  1034. ;;; --- XEmacs toolbar
  1035. (defgroup gnuplot-toolbar nil
  1036. "Toolbar used by XEmacs."
  1037. :prefix "gnuplot-toolbar-"
  1038. :group 'gnuplot)
  1039. (defcustom gnuplot-toolbar-display-flag gnuplot-xemacs-p
  1040. "*Non-nil means to display display a toolbar in XEmacs."
  1041. :group 'gnuplot-toolbar
  1042. :type 'boolean)
  1043. (defcustom gnuplot-toolbar-use-toolbar (if (featurep 'toolbar) 'left-toolbar nil)
  1044. "*If nil, do not use a toolbar.
  1045. If it is non-nil, it must be a toolbar. The five legal values are
  1046. `default-toolbar', `top-toolbar', `bottom-toolbar', `right-toolbar',
  1047. and `left-toolbar', although choosing `default-toolbar' or
  1048. `top-toolbar' may be a bad idea since either will make the GNUPLOT
  1049. toolbar replace the standard toolbar. Changing this will not change
  1050. the toolbar in a currently existing buffer, but it will take effect
  1051. the next time you use `gnuplot-mode' and emacs.
  1052. This is only used if a toolbar can be displayed, thus this is used in
  1053. XEmacs and ignored in FSF Emacs."
  1054. :type '(choice (const default-toolbar)
  1055. (const top-toolbar)
  1056. (const bottom-toolbar)
  1057. (const left-toolbar)
  1058. (const right-toolbar)
  1059. (const :tag "No toolbar" nil))
  1060. :group 'gnuplot-toolbar)
  1061. (defvar gnuplot-toolbar-location "")
  1062. (defun gnuplot-toolbar-setup-toolbar (toolbar)
  1063. "Setup function for the `gnuplot-mode' toolbar.
  1064. TOOLBAR contains the toolbar specification.
  1065. This is basically swiped from VM."
  1066. (let ((width 46) (height 46)
  1067. (buffer (current-buffer))
  1068. (frame (selected-frame))
  1069. (tag-set '(win)))
  1070. (cond
  1071. ((eq (symbol-value gnuplot-toolbar-use-toolbar) right-toolbar)
  1072. (setq gnuplot-toolbar-location "right")
  1073. (set-specifier right-toolbar toolbar buffer)
  1074. (set-specifier right-toolbar-width width frame tag-set))
  1075. ((eq (symbol-value gnuplot-toolbar-use-toolbar) left-toolbar)
  1076. (setq gnuplot-toolbar-location "left")
  1077. (set-specifier left-toolbar toolbar buffer)
  1078. (set-specifier left-toolbar-width width frame tag-set))
  1079. ((eq (symbol-value gnuplot-toolbar-use-toolbar) bottom-toolbar)
  1080. (setq gnuplot-toolbar-location "bottom")
  1081. (set-specifier bottom-toolbar toolbar buffer)
  1082. (set-specifier bottom-toolbar-height height frame tag-set))
  1083. ((eq (symbol-value gnuplot-toolbar-use-toolbar) top-toolbar)
  1084. (setq gnuplot-toolbar-location "top")
  1085. (set-specifier top-toolbar toolbar buffer)
  1086. (set-specifier top-toolbar-height height frame tag-set))) ))
  1087. (defvar gnuplot-line-xpm
  1088. (if (featurep 'xpm)
  1089. (toolbar-make-button-list
  1090. "/* XPM */
  1091. static char *line[] = {
  1092. /* width height num_colors chars_per_pixel */
  1093. \" 40 40 5 1\",
  1094. /* colors */
  1095. \". c #000000\",
  1096. \"a c #bebebe s backgroundToolBarColor\",
  1097. \"b c #2f4f4f\",
  1098. \"c c #ff6347\",
  1099. \"d c #0000ff\",
  1100. /* pixels */
  1101. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1102. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1103. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1104. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1105. \"aaaaaaaaaaaaa..a..aaaaaaaaaaaaaaaaaaaaaa\",
  1106. \"aaaaaaaaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaa\",
  1107. \"aaaaaaaaaaaa..a..a....aaa...aaaaaaaaaaaa\",
  1108. \"aaaaaaaaaaaa..a..a..a..a..a..aaaaaaaaaaa\",
  1109. \"aaaaaaaaaaaa..a..a.aa..a.....aaaaaaaaaaa\",
  1110. \"aaaaaaaaaaa..a..a..a..a..aaaaaaaaaaaaaaa\",
  1111. \"aaaaaaaaaaa..a..a..a..a..a..aaaaaaaaaaaa\",
  1112. \"aaaaaaaaaaa..a..a..a..aa...aaaaaaaaaaaaa\",
  1113. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1114. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1115. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1116. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1117. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1118. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaadaaaaaaaa\",
  1119. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaadaaaaaaaaa\",
  1120. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaadaaaaaaaaaa\",
  1121. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaadaaaaaaaaaaa\",
  1122. \"aaaaaaaa.aaaaaaaaaacaaaadaadaaaaaaaaaaaa\",
  1123. \"aaaaaaaa.caaadaaaccaccadaddaaaaaccaaaaaa\",
  1124. \"aaaaaaa..accdaddcaaaaaccaaaaaaccaaaaaaaa\",
  1125. \"aaaaaaaa.aadcaccdaaaadaaccaaccaaaaaaaaaa\",
  1126. \"aaaaaaaa.adaacaaaddadaaaaaccaaaaaaaaaaaa\",
  1127. \"aaaaaaaa.daaaaaaaaadaaaaaaaaaaaaaaaaaaaa\",
  1128. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1129. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1130. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1131. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1132. \"aaaaaa............................aaaaaa\",
  1133. \"aaaaaaaa.aaaa.aaaa.aaaa.aaaa.aaaaaaaaaaa\",
  1134. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1135. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1136. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1137. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1138. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1139. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1140. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};")
  1141. "XPM format image used for the \"plot line\" button"))
  1142. (defvar gnuplot-region-xpm
  1143. (if (featurep 'xpm)
  1144. (toolbar-make-button-list
  1145. "/* XPM */
  1146. static char *region[] = {
  1147. /* width height num_colors chars_per_pixel */
  1148. \" 40 40 5 1\",
  1149. /* colors */
  1150. \". c #000000\",
  1151. \"a c #bebebe s backgroundToolBarColor\",
  1152. \"b c #2f4f4f\",
  1153. \"c c #ff6347\",
  1154. \"d c #0000ff\",
  1155. /* pixels */
  1156. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1157. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1158. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1159. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1160. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1161. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1162. \"aaaaaaaaaaaaaaaaaaaaaaa..aaaaaaaaaaaaaaa\",
  1163. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1164. \"aaaaaa.a..a...aaa....a..aa...aa....aaaaa\",
  1165. \"aaaaaa...a..a..a..a..a..a..a..a..a..aaaa\",
  1166. \"aaaaaa..aa.....a.aa..a....aa..a.aa..aaaa\",
  1167. \"aaaaa..a...aaaa..aa.a..a..aa....a..aaaaa\",
  1168. \"aaaaa..a...a..a..a..a..a..a..a..a..aaaaa\",
  1169. \"aaaa..aaaa...aaa....a..aa...aa..a..aaaaa\",
  1170. \"aaaaaaaaaaaaaaaaa..aaaaaaaaaaaaaaaaaaaaa\",
  1171. \"aaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaa\",
  1172. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1173. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaadaaaaaaaa\",
  1174. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaadaaaaaaaaa\",
  1175. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaadaaaaaaaaaa\",
  1176. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaadaaaaaaaaaaa\",
  1177. \"aaaaaaaa.aaaaaaaaaacaaaadaadaaaaaaaaaaaa\",
  1178. \"aaaaaaaa.caaadaaaccaccadaddaaaaaccaaaaaa\",
  1179. \"aaaaaaa..accdaddcaaaaaccaaaaaaccaaaaaaaa\",
  1180. \"aaaaaaaa.aadcaccdaaaadaaccaaccaaaaaaaaaa\",
  1181. \"aaaaaaaa.adaacaaaddadaaaaaccaaaaaaaaaaaa\",
  1182. \"aaaaaaaa.daaaaaaaaadaaaaaaaaaaaaaaaaaaaa\",
  1183. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1184. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1185. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1186. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1187. \"aaaaaa............................aaaaaa\",
  1188. \"aaaaaaaa.aaaa.aaaa.aaaa.aaaa.aaaaaaaaaaa\",
  1189. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1190. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1191. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1192. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1193. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1194. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1195. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};")
  1196. "XPM format image used for the \"plot region\" button"))
  1197. (defvar gnuplot-buffer-xpm
  1198. (if (featurep 'xpm)
  1199. (toolbar-make-button-list
  1200. "/* XPM */
  1201. static char *buffer[] = {
  1202. /* width height num_colors chars_per_pixel */
  1203. \" 40 40 5 1\",
  1204. /* colors */
  1205. \". c #000000\",
  1206. \"a c #bebebe s backgroundToolBarColor\",
  1207. \"b c #2f4f4f\",
  1208. \"c c #ff6347\",
  1209. \"d c #0000ff\",
  1210. /* pixels */
  1211. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1212. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1213. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1214. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1215. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1216. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1217. \"aaaaaaaa..aaaaaaaaaa......aaaaaaaaaaaaaa\",
  1218. \"aaaaaaaa..aaaaaaaaa..a..aaaaaaaaaaaaaaaa\",
  1219. \"aaaaaaa....aa..a.........a...aa.a.aaaaaa\",
  1220. \"aaaaaaa..a..a..a..a..a..a..a..a...aaaaaa\",
  1221. \"aaaaaaa.aa....aa..a..a..a.....a..aaaaaaa\",
  1222. \"aaaaaa...a.a..a..a..a..a..aaaa..aaaaaaaa\",
  1223. \"aaaaaa.....a..a..a..a..a..a..a..aaaaaaaa\",
  1224. \"aaaaaa....aaa..a.a..a..aa...aa..aaaaaaaa\",
  1225. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1226. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1227. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1228. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaadaaaaaaaa\",
  1229. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaadaaaaaaaaa\",
  1230. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaadaaaaaaaaaa\",
  1231. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaadaaaaaaaaaaa\",
  1232. \"aaaaaaaa.aaaaaaaaaacaaaadaadaaaaaaaaaaaa\",
  1233. \"aaaaaaaa.caaadaaaccaccadaddaaaaaccaaaaaa\",
  1234. \"aaaaaaa..accdaddcaaaaaccaaaaaaccaaaaaaaa\",
  1235. \"aaaaaaaa.aadcaccdaaaadaaccaaccaaaaaaaaaa\",
  1236. \"aaaaaaaa.adaacaaaddadaaaaaccaaaaaaaaaaaa\",
  1237. \"aaaaaaaa.daaaaaaaaadaaaaaaaaaaaaaaaaaaaa\",
  1238. \"aaaaaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1239. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1240. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1241. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1242. \"aaaaaa............................aaaaaa\",
  1243. \"aaaaaaaa.aaaa.aaaa.aaaa.aaaa.aaaaaaaaaaa\",
  1244. \"aaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1245. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1246. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1247. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1248. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1249. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1250. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};")
  1251. "XPM format image used for the \"plot buffer\" button"))
  1252. (defvar gnuplot-doc-xpm
  1253. (if (featurep 'xpm)
  1254. (toolbar-make-button-list
  1255. "/* XPM */
  1256. static char *book_index[] = {
  1257. /* width height num_colors chars_per_pixel */
  1258. \" 40 40 6 1\",
  1259. /* colors */
  1260. \". c #000000\",
  1261. \"a c #bebebe s backgroundToolBarColor\",
  1262. \"b c #2f4f4f\",
  1263. \"c c #ff0000\",
  1264. \"d c #ffffff\",
  1265. \"e c #708090\",
  1266. /* pixels */
  1267. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1268. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1269. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1270. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1271. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1272. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1273. \"aaaaaa.........bbeaaaebb..........aaaaaa\",
  1274. \"aaaaaa.ddddddddaaebebeaaddddddddd.aaaaaa\",
  1275. \"aaaa...dab.bddeebadbdaeebedeeeeed...aaaa\",
  1276. \"aaaa.c.dbaddddebeedbdeebeedebebed.c.aaaa\",
  1277. \"aaaa.c.d.de.edeebeabdbbeeddebbbed.c.aaaa\",
  1278. \"aaaa.c.dbad.ddebeadbdeeebeddeeeed.c.aaaa\",
  1279. \"aaaa.c.dab..ddeeeedbdebeeedebebed.c.aaaa\",
  1280. \"aaaa.c.dddddddeebeabdebebedeebedd.c.aaaa\",
  1281. \"aaaa.c.debebedebeedbdbebeedbeeeeb.c.aaaa\",
  1282. \"aaaa.c.debeeedeeeaabdaaddddebedbb.c.aaaa\",
  1283. \"aaaa.c.deebeddbebedbdbaa.adeeedeb.c.aaaa\",
  1284. \"aaaa.c.ddeebedeeebaba.dd.dddeeedd.c.aaaa\",
  1285. \"aaaa.c.debeebdbeeedbd....ddeebeed.c.aaaa\",
  1286. \"aaaa.c.deebeedeebadbd.dd.ddeeeedd.c.aaaa\",
  1287. \"aaaa.c.dbbebddeeeeabd.aa.adebebbd.c.aaaa\",
  1288. \"aaaa.c.deeeeedeebeabaedddddeeeedd.c.aaaa\",
  1289. \"aaaa.c.dbebbbdebeadbdaeeeedebeeed.c.aaaa\",
  1290. \"aaaa.c.deeebddeeebdbdeebeedeebeed.c.aaaa\",
  1291. \"aaaa.c.debeeedebeeabdebebedebeebd.c.aaaa\",
  1292. \"aaaa.c.deebbedeeeedbdeeeeddeeeeed.c.aaaa\",
  1293. \"aaaa.c.dddddddddaadbdaddddddddddd.c.aaaa\",
  1294. \"aaaa.c..........beabaeb...........c.aaaa\",
  1295. \"aaaa.c.bbbbbbbbbb.bbbbbbbbbbbbbbb.c.aaaa\",
  1296. \"aaaa.c.bbbbbbbbbb..e.bbbbbbbbbbbb.c.aaaa\",
  1297. \"aaaa.c.bbbbbbbbbb.b.bbbbbbbbbbbbb.c.aaaa\",
  1298. \"aaaa.c............e.e.............c.aaaa\",
  1299. \"aaaa.cccccccccccc.a.a.ccccccccccccc.aaaa\",
  1300. \"aaaa................................aaaa\",
  1301. \"aaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaa\",
  1302. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1303. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1304. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1305. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1306. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};")
  1307. "XPM format image used for the \"document\" button"))
  1308. (defvar gnuplot-help-xpm
  1309. (if (featurep 'xpm)
  1310. (toolbar-make-button-list
  1311. "/* XPM */
  1312. static char *help_btn[] = {
  1313. /* width height num_colors chars_per_pixel */
  1314. \" 40 40 3 1\",
  1315. /* colors */
  1316. \"a c #bebebe s backgroundToolBarColor\",
  1317. \"b c #000000\",
  1318. \"c c #ff0000\",
  1319. /* pixels */
  1320. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1321. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1322. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1323. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1324. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1325. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1326. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1327. \"aaaaaaaaaaaaaaaabbbbbbbbaaaaaaaaaaaaaaaa\",
  1328. \"aaaaaaaaaaaaabbbccccccccbbbaaaaaaaaaaaaa\",
  1329. \"aaaaaaaaaaabbccccccccccccccbbaaaaaaaaaaa\",
  1330. \"aaaaaaaaaabccccccccccccccccccbaaaaaaaaaa\",
  1331. \"aaaaaaaaabccccccccccccccccccccbaaaaaaaaa\",
  1332. \"aaaaaaaabcccccccbbbbbbbbcccccccbaaaaaaaa\",
  1333. \"aaaaaaaabccccbbbaaaaaaaabbbccccbaaaaaaaa\",
  1334. \"aaaaaaabccccbaaaaaaaaaaaaaabccccbaaaaaaa\",
  1335. \"aaaaaaabcccbaaaaaaaaaaaaaaaabcccbaaaaaaa\",
  1336. \"aaaaaaabcccbaaaaaaaaaaaaaaaabcccbaaaaaaa\",
  1337. \"aaaaaaabcccbaaaaaaaaaaaaaaaabcccbaaaaaaa\",
  1338. \"aaaaaaabbbbbaaaaaaaaaaaaaaabccccbaaaaaaa\",
  1339. \"aaaaaaaaaaaaaaaaaaaaaaaabbbccccbaaaaaaaa\",
  1340. \"aaaaaaaaaaaaaaaabbbbbbbbcccccccbaaaaaaaa\",
  1341. \"aaaaaaaaaaaaaaaabcccccccccccccbaaaaaaaaa\",
  1342. \"aaaaaaaaaaaaaaaabccccccccccccbaaaaaaaaaa\",
  1343. \"aaaaaaaaaaaaaaaabccccccccccbbaaaaaaaaaaa\",
  1344. \"aaaaaaaaaaaaaaaabccccbbbbbbaaaaaaaaaaaaa\",
  1345. \"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\",
  1346. \"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\",
  1347. \"aaaaaaaaaaaaaaaabbbbbbaaaaaaaaaaaaaaaaaa\",
  1348. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1349. \"aaaaaaaaaaaaaaaabbbbbbaaaaaaaaaaaaaaaaaa\",
  1350. \"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\",
  1351. \"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\",
  1352. \"aaaaaaaaaaaaaaaabccccbaaaaaaaaaaaaaaaaaa\",
  1353. \"aaaaaaaaaaaaaaaabbbbbbaaaaaaaaaaaaaaaaaa\",
  1354. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1355. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1356. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1357. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1358. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
  1359. \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"};")
  1360. "XPM format image used for the \"help\" button"))
  1361. (defvar gnuplot-toolbar
  1362. '([gnuplot-line-xpm
  1363. gnuplot-line-fn t "Plot the line under point"]
  1364. [gnuplot-region-xpm
  1365. gnuplot-region-fn t "Plot the selected region"]
  1366. [gnuplot-buffer-xpm
  1367. gnuplot-buffer-fn t "Plot the entire buffer"]
  1368. [:style 3d :size 8]
  1369. [gnuplot-help-xpm
  1370. gnuplot-help-fn t "Look at the gnuplot process buffer"]
  1371. [gnuplot-doc-xpm
  1372. gnuplot-doc-fn t "Look at the gnuplot document"])
  1373. "The gnuplot toolbar.")
  1374. (fset 'gnuplot-line-fn 'gnuplot-send-line-and-forward)
  1375. (fset 'gnuplot-region-fn 'gnuplot-send-region-to-gnuplot)
  1376. (fset 'gnuplot-buffer-fn 'gnuplot-send-buffer-to-gnuplot)
  1377. (fset 'gnuplot-help-fn 'gnuplot-show-gnuplot-buffer)
  1378. (fset 'gnuplot-doc-fn 'gnuplot-info-lookup-symbol)
  1379. (defvar gnuplot-all-buttons-defined
  1380. (and (listp gnuplot-line-xpm) (listp gnuplot-region-xpm)
  1381. (listp gnuplot-buffer-xpm) (listp gnuplot-doc-xpm)
  1382. (listp gnuplot-help-xpm)))
  1383. (defun gnuplot-make-toolbar-function ()
  1384. (if (and gnuplot-xemacs-p gnuplot-all-buttons-defined)
  1385. (progn
  1386. ;;(remove-specifier gnuplot-toolbar-use-toolbar (current-buffer))
  1387. (gnuplot-toolbar-setup-toolbar gnuplot-toolbar)
  1388. (add-spec-to-specifier (symbol-value gnuplot-toolbar-use-toolbar)
  1389. gnuplot-toolbar
  1390. (current-buffer) ))))
  1391. ;;(defalias 'gnuplot-make-toolbar 'gnuplot-make-toolbar-function)
  1392. ;;; --- syntax colorization, syntax table
  1393. (defvar gnuplot-mode-syntax-table nil
  1394. "Syntax table in use in `gnuplot-mode' buffers.
  1395. This is the same as the standard syntax table except that ' is a
  1396. string quote character, ` and _ are word characters, and math
  1397. operators are punctuation characters.")
  1398. (if gnuplot-mode-syntax-table
  1399. ()
  1400. (setq gnuplot-mode-syntax-table (make-syntax-table))
  1401. (modify-syntax-entry ?* "." gnuplot-mode-syntax-table)
  1402. (modify-syntax-entry ?+ "." gnuplot-mode-syntax-table)
  1403. (modify-syntax-entry ?- "." gnuplot-mode-syntax-table)
  1404. (modify-syntax-entry ?/ "." gnuplot-mode-syntax-table)
  1405. (modify-syntax-entry ?% "." gnuplot-mode-syntax-table)
  1406. ;;(modify-syntax-entry ?& "." gnuplot-mode-syntax-table) ; rarely used
  1407. ;;(modify-syntax-entry ?^ "." gnuplot-mode-syntax-table) ; operators
  1408. ;;(modify-syntax-entry ?| "." gnuplot-mode-syntax-table) ; in gnuplot,
  1409. ;;(modify-syntax-entry ?& "." gnuplot-mode-syntax-table) ; (by me,
  1410. ;;(modify-syntax-entry ?? "." gnuplot-mode-syntax-table) ; anyway...)
  1411. ;;(modify-syntax-entry ?~ "." gnuplot-mode-syntax-table) ;
  1412. (modify-syntax-entry ?' "\"" gnuplot-mode-syntax-table)
  1413. (modify-syntax-entry ?` "w" gnuplot-mode-syntax-table)
  1414. (modify-syntax-entry ?_ "w" gnuplot-mode-syntax-table))
  1415. (defvar gnuplot-font-lock-keywords nil)
  1416. (defvar gnuplot-font-lock-keywords-1 nil)
  1417. (defvar gnuplot-font-lock-keywords-2 nil)
  1418. ;; used make-regexp to generate the regular expression strings
  1419. ;; this is all pattern based
  1420. ;; (insert (format "%s"
  1421. ;; (regexp-quote
  1422. ;; (make-regexp
  1423. ;; '("abs" "acos" "acosh" "arg" "asin" "asinh" "atan"
  1424. ;; "atan2" "atanh" "besj0" "besj1" "besy0" "besy1"
  1425. ;; "ceil" "cos" "cosh" "erf" "erfc" "exp" "floor"
  1426. ;; "gamma" "ibeta" "inverf" "igamma" "imag" "invnorm"
  1427. ;; "int" "lgamma" "log" "log10" "norm" "rand" "real"
  1428. ;; "sgn" "sin" "sinh" "sqrt" "tan" "tanh" "column"
  1429. ;; "tm_hour" "tm_mday" "tm_min" "tm_mon" "tm_sec"
  1430. ;; "tm_wday" "tm_yday" "tm_year" "valid")))))
  1431. ;; Set up colorization for gnuplot.
  1432. ;; This handles font-lock for emacs and xemacs.
  1433. ;; hilit19 is handled in `gnuplot-mode'.
  1434. ;; These regular expressions treat the gnuplot vocabulary as complete
  1435. ;; words. Although gnuplot will recognise unique abbreviations, these
  1436. ;; regular expressions will not."
  1437. (if (featurep 'font-lock) ; <KL>
  1438. (setq gnuplot-font-lock-keywords
  1439. (list
  1440. ; comments
  1441. '("#.*$" . font-lock-comment-face)
  1442. ; quoted things
  1443. ;'("['\"]\\([^'\"\n]*\\)['\"]"
  1444. ; 1 font-lock-string-face)
  1445. '("'[^'\n]*'?" . font-lock-string-face)
  1446. ; stuff in brackets, sugg. by <LB>
  1447. '("\\[\\([^]]+\\)\\]"
  1448. 1 font-lock-reference-face)
  1449. ; variable/function definitions
  1450. '("\\(\\<[a-z]+[a-z_0-9()]*\\)[ \t]*="
  1451. 1 font-lock-variable-name-face)
  1452. ; built-in function names
  1453. (cons (concat
  1454. "\\<\\("
  1455. "a\\(bs\\|cosh\?\\|rg\\|sinh\?\\|"
  1456. "tan\\(\\|\[2h\]\\)\\)\\|"
  1457. "bes\\(j\[01\]\\|y\[01\]\\)\\|"
  1458. "c\\(eil\\|o\\(lumn\\|sh\?\\)\\)\\|"
  1459. "e\\(rfc\?\\|xp\\)\\|floor\\|gamma\\|"
  1460. "i\\(beta\\|gamma\\|mag\\|"
  1461. "n\\(t\\|v\\(erf\\|norm\\)\\)\\)\\|"
  1462. "l\\(gamma\\|og\\(\\|10\\)\\)\\|"
  1463. "norm\\|r\\(and\\|eal\\)\\|"
  1464. "s\\(gn\\|inh\?\\|qrt\\)\\|"
  1465. "t\\(anh\?\\|m_\\(hour\\|m\\(day\\|in\\|on\\)\\|"
  1466. "sec\\|wday\\|y\\(day\\|ear\\)\\)\\)\\|"
  1467. "valid"
  1468. "\\)\\>")
  1469. font-lock-function-name-face)
  1470. ; reserved words associated with
  1471. ; plotting <AL>
  1472. '("\\<\\(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)
  1473. '("\\<\\(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)
  1474. ; (s)plot -- also thing (s)plotted
  1475. '("\\<s?plot\\>" . font-lock-keyword-face)
  1476. '("\\<s?plot\\s-+\\([^'\" ]+\\)[) \n,\\\\]"
  1477. 1 font-lock-variable-name-face)
  1478. ; other common commands
  1479. ; miscellaneous commands
  1480. (cons (concat "\\<\\("
  1481. "bind\\|"
  1482. "c\\(d\\|lear\\)\\|exit\\|fit\\|h\\(elp\\|istory\\)\\|load\\|"
  1483. "p\\(ause\\|rint\\|wd\\)\\|quit\\|replot\\|"
  1484. "s\\(ave\\|et\\|how\\)\\|unset"
  1485. "\\)\\>\\|!.*$")
  1486. font-lock-reference-face))
  1487. gnuplot-font-lock-keywords-1 gnuplot-font-lock-keywords
  1488. gnuplot-font-lock-keywords-2 gnuplot-font-lock-keywords) )
  1489. (if (and gnuplot-xemacs-p (featurep 'font-lock))
  1490. (put 'gnuplot-mode 'font-lock-defaults
  1491. '((gnuplot-font-lock-keywords
  1492. gnuplot-font-lock-keywords-1
  1493. gnuplot-font-lock-keywords-2)
  1494. t t ((?_ . "w")) )))
  1495. ;; these two lines get rid of an annoying compile time error
  1496. ;; message. that function gets non-trivially defalias-ed in
  1497. ;; gnuplot-toolbar.el
  1498. ;; (defun gnuplot-make-toolbar-dummy ())
  1499. ;; (defalias 'gnuplot-make-toolbar 'gnuplot-make-toolbar-dummy)
  1500. ;;; --- functions for sending commands to gnuplot
  1501. (defun gnuplot-split-string (string)
  1502. "Break STRING at each carriage return, returning a list of lines."
  1503. (let ((list ()) (line "") (index 0))
  1504. (while (< index (length string))
  1505. (if (char-equal (elt string index) ?\n)
  1506. (setq list (append list (list line))
  1507. line "")
  1508. (setq line (concat line (char-to-string (elt string index)))))
  1509. (setq index (1+ index)) )
  1510. list))
  1511. ;; -- the calls to `sleep-for' are to allow enough time for gnuplot
  1512. ;; to write to the buffer before the next line is inserted
  1513. ;; -- note that the input string is split into lines and each line is
  1514. ;; sent to gnuplot individually. this is a bit slow, but it puts
  1515. ;; each line on the comint history.
  1516. (defun gnuplot-send-string-to-gnuplot (string text)
  1517. "Sends STRING to the gnuplot program.
  1518. If no gnuplot process exists, a new one is created. TEXT indicates
  1519. the type of text being sent to gnuplot and is typically one of
  1520. nil, 'line, 'region, 'buffer, or 'file. TEXT may be useful for
  1521. functions in `gnuplot-after-plot-hook'. `gnuplot-after-plot-hook' is
  1522. called by this function after all of STRING is sent to gnuplot."
  1523. (gnuplot-make-gnuplot-buffer) ; make sure a gnuplot buffer exists
  1524. (or gnuplot-program-version
  1525. (progn
  1526. (message "Determining gnuplot version number (sitting for 2 seconds)")
  1527. (gnuplot-fetch-version-number)
  1528. (sit-for 2)))
  1529. (setq gnuplot-comint-recent-buffer (current-buffer))
  1530. (if (equal gnuplot-display-process 'frame)
  1531. (or (and gnuplot-process-frame
  1532. (frame-live-p gnuplot-process-frame))
  1533. (let ((frame (selected-frame)))
  1534. (setq gnuplot-process-frame (make-frame))
  1535. (select-frame gnuplot-process-frame)
  1536. (switch-to-buffer gnuplot-buffer)
  1537. (delete-other-windows)
  1538. (select-frame frame))) )
  1539. (let ((buffer (current-buffer))
  1540. (gbuffer (get-buffer gnuplot-buffer))
  1541. (list (gnuplot-split-string string)))
  1542. (set-buffer gbuffer)
  1543. (goto-char (point-max))
  1544. ;; bruce asks: what is this next line for?
  1545. (set-marker (process-mark gnuplot-process) (point-marker))
  1546. (sleep-for (* 20 gnuplot-delay))
  1547. (while list
  1548. (insert (car list))
  1549. (comint-send-input)
  1550. (sleep-for gnuplot-delay)
  1551. (setq list (cdr list))
  1552. (goto-char (point-max)))
  1553. (set-buffer buffer)
  1554. (cond ((equal gnuplot-display-process 'window)
  1555. (select-window (display-buffer gbuffer))
  1556. (goto-char (point-max))
  1557. (or (pos-visible-in-window-p (point) (selected-window))
  1558. (recenter 5))
  1559. (other-window 1))
  1560. ((equal gnuplot-display-process 'frame)
  1561. ;;(raise-frame gnuplot-process-frame)
  1562. (select-frame gnuplot-process-frame)
  1563. (display-buffer gbuffer)
  1564. (goto-char (point-max))
  1565. (or (pos-visible-in-window-p (point) (selected-window))
  1566. (recenter 5))))
  1567. ;;(process-send-string gnuplot-program string)
  1568. (setq gnuplot-recently-sent text)
  1569. (run-hooks 'gnuplot-after-plot-hook)))
  1570. (defun gnuplot-send-region-to-gnuplot (&optional begin end text)
  1571. "Sends a selected region to the gnuplot program.
  1572. If BEGIN and END are not specified, point and mark are used. TEXT
  1573. indicates the type of text being sent to gnuplot. This will be
  1574. 'region unless explicitly set by a function calling this one. Other
  1575. typical values are of nil, 'line, 'buffer, or 'file. TEXT may be
  1576. useful for function in `gnuplot-after-plot-hook'."
  1577. (interactive "r")
  1578. (let (string (txt (or text 'region)))
  1579. (cond ((equal major-mode 'gnuplot-mode)
  1580. (setq string (buffer-substring-no-properties begin end))
  1581. (if (string= (substring string -1) "\n") ()
  1582. (setq string (concat string "\n")))
  1583. (gnuplot-send-string-to-gnuplot string txt))
  1584. (t
  1585. (message (concat "You can only send regions from "
  1586. "gnuplot-mode buffers to gnuplot."))))))
  1587. (defun gnuplot-send-line-to-gnuplot ()
  1588. "Sends the current line to the gnuplot program.
  1589. Respects continuation lines.
  1590. This sets `gnuplot-recently-sent' to 'line."
  1591. (interactive)
  1592. (cond ((equal major-mode 'gnuplot-mode)
  1593. (let ((start (save-excursion (beginning-of-line) (point-marker)))
  1594. end
  1595. ;(end (save-excursion (beginning-of-line 2) (point-marker)))
  1596. )
  1597. (save-excursion
  1598. (goto-char start)
  1599. (end-of-line)
  1600. (backward-char 1)
  1601. (while (looking-at "\\\\") ; go to end of last continuation line
  1602. (end-of-line 2)
  1603. (backward-char 1))
  1604. (beginning-of-line 2)
  1605. (setq end (point-marker)))
  1606. (if (not (string-match "\\`\\s-*\\'"
  1607. (buffer-substring-no-properties start end)))
  1608. (gnuplot-send-region-to-gnuplot start end 'line))
  1609. end))
  1610. (t
  1611. (message "You can only send lines in gnuplot-mode buffers to gnuplot.")
  1612. nil)))
  1613. ;; I chose a very easy to type but slightly non-mnemonic key-binding
  1614. ;; for this (C-c C-v). It seems like the kind of thing one would want
  1615. ;; to do repeatedly without incurring RSI. 8^)
  1616. (defun gnuplot-send-line-and-forward (&optional num)
  1617. "Call `gnuplot-send-line-to-gnuplot' and move forward 1 line.
  1618. You can use a numeric prefix to send more than one line. Blank lines and
  1619. lines with only comments are skipped when moving forward."
  1620. (interactive "p")
  1621. (let (end)
  1622. (while (> num 0)
  1623. (setq end (gnuplot-send-line-to-gnuplot))
  1624. (goto-char end)
  1625. (backward-char 1) ; <AR>
  1626. (gnuplot-forward-script-line 1)
  1627. (setq num (1- num)))))
  1628. (defun gnuplot-forward-script-line (&optional num) ; <SE>
  1629. "Move forward my NUM script lines.
  1630. Blank lines and commented lines are not included in the NUM count."
  1631. (interactive "p")
  1632. (while (> num 0)
  1633. (and (not (eobp)) (forward-line 1))
  1634. (while (and (not (eobp))
  1635. (or (looking-at "^\\s-*$")
  1636. (looking-at "^\\s-*#")))
  1637. (forward-line 1))
  1638. (setq num (1- num))) )
  1639. (defun gnuplot-send-buffer-to-gnuplot ()
  1640. "Sends the entire buffer to the gnuplot program.
  1641. This sets `gnuplot-recently-sent' to 'buffer."
  1642. (interactive)
  1643. (if (equal major-mode 'gnuplot-mode)
  1644. (gnuplot-send-region-to-gnuplot (point-min) (point-max) 'buffer)
  1645. (message "You can only send gnuplot-mode buffers to gnuplot.")))
  1646. (defun gnuplot-send-file-to-gnuplot ()
  1647. "Sends a selected file to the gnuplot program using the \"load\" command.
  1648. This sets `gnuplot-recently-sent' to 'file."
  1649. (interactive)
  1650. (let ((string (read-file-name "Name of file to send to gnuplot > " nil nil t)))
  1651. (setq string (concat "load '" (expand-file-name string) "'\n"))
  1652. (message "%S" string)
  1653. (gnuplot-make-gnuplot-buffer) ; make sure a gnuplot buffer exists
  1654. (gnuplot-send-string-to-gnuplot string 'file)))
  1655. ;; suggested by <JS>
  1656. (defun gnuplot-plot-from-comint ()
  1657. "Send the contents of a script to gnuplot from the process buffer.
  1658. This inserts the contents of the most recently used gnuplot script
  1659. into the process buffer and sends those lines to gnuplot. It does
  1660. this by copying the script line by line."
  1661. (interactive)
  1662. (if (equal major-mode 'comint-mode)
  1663. (let (string list (buffer (current-buffer)))
  1664. (set-buffer gnuplot-comint-recent-buffer)
  1665. (setq string (buffer-substring-no-properties (point-min) (point-max))
  1666. string (concat string "\n")
  1667. list (gnuplot-split-string string))
  1668. (set-buffer buffer)
  1669. (while list
  1670. (insert (car list))
  1671. (comint-send-input)
  1672. (sleep-for gnuplot-delay)
  1673. (setq list (cdr list)))
  1674. (comint-send-input))
  1675. (message
  1676. "`gnuplot-plot-from-comint' only works in the gnuplot process buffer")))
  1677. (defun gnuplot-save-and-plot-from-comint ()
  1678. "Send a current script to gnuplot from the process buffer.
  1679. This sends the most recently used gnuplot script to gnuplot using the
  1680. \"load\" command. This function first saves the script buffer to a
  1681. file, prompting for a filename if one is not associated with the script
  1682. buffer. Then it sends a load command to gnuplot using the name of the
  1683. file visited by the script buffer."
  1684. (interactive)
  1685. (if (equal major-mode 'comint-mode)
  1686. (let (fname (buffer (current-buffer)))
  1687. (set-buffer gnuplot-comint-recent-buffer)
  1688. (save-buffer)
  1689. (setq fname (buffer-file-name))
  1690. (set-buffer buffer)
  1691. (goto-char (point-max))
  1692. (insert (format "load '%s'" fname))
  1693. (comint-send-input))
  1694. (message (concat "`gnuplot-save-and-plot-from-comint' only works "
  1695. "in the gnuplot process buffer"))))
  1696. (defun gnuplot-trim-gnuplot-buffer ()
  1697. "Trim lines form the beginning of the *gnuplot* buffer.
  1698. This keeps that buffer from growing excessively in size. Normally,
  1699. this function is attached to `gnuplot-after-plot-hook'"
  1700. (if (> gnuplot-buffer-max-size 0)
  1701. (save-excursion
  1702. (set-buffer gnuplot-buffer)
  1703. (let ((nlines (count-lines (point-min) (point-max)))
  1704. (kill-whole-line t))
  1705. (while (> nlines gnuplot-buffer-max-size)
  1706. (goto-char (point-min))
  1707. (kill-line)
  1708. (setq nlines (1- nlines)))
  1709. (goto-char (point-max)) ))))
  1710. (add-hook 'gnuplot-after-plot-hook 'gnuplot-trim-gnuplot-buffer nil nil)
  1711. ;;; --- functions controlling the gnuplot process
  1712. ;; use of comint-setup-hook suggested by <DB>
  1713. (defun gnuplot-comint-start-function ()
  1714. "Function run when comint/gnuplot started.
  1715. This sets font-lock and keyword completion in the comint/gnuplot
  1716. buffer. Further customization is possible via
  1717. `gnuplot-comint-setup-hook'."
  1718. ;;(if (not (fboundp 'hilit-set-mode-patterns))
  1719. (if (featurep 'font-lock)
  1720. (progn
  1721. (make-variable-buffer-local 'font-lock-defaults)
  1722. (setq font-lock-defaults '(gnuplot-font-lock-keywords t t))
  1723. (if gnuplot-xemacs-p (turn-on-font-lock))))
  1724. ;;(if (featurep 'kw-compl)
  1725. ;; (progn
  1726. ;; (setq kw-compl-list gnuplot-keywords
  1727. ;; kw-compl-upper-case nil)
  1728. ;; (define-key comint-mode-map "\M-\r" 'kw-compl-abbrev)))
  1729. (define-key comint-mode-map "\M-\C-p" 'gnuplot-plot-from-comint)
  1730. (define-key comint-mode-map "\M-\C-f" 'gnuplot-save-and-plot-from-comint)
  1731. (define-key comint-mode-map "\C-d" 'gnuplot-delchar-or-maybe-eof)
  1732. (define-key comint-mode-map "\M-\r" 'gnuplot-complete-keyword)
  1733. (define-key comint-mode-map "\M-\t" 'gnuplot-complete-keyword)
  1734. (run-hooks 'gnuplot-comint-setup-hook))
  1735. (defun gnuplot-make-gnuplot-buffer ()
  1736. "Switch to the gnuplot program buffer or create one if none exists."
  1737. (or (and gnuplot-process (get-process gnuplot-process)
  1738. gnuplot-buffer (get-buffer gnuplot-buffer))
  1739. (progn
  1740. (message "Starting gnuplot plotting program...")
  1741. (setq gnuplot-buffer (make-comint gnuplot-process-name gnuplot-program)
  1742. gnuplot-process (get-process gnuplot-process-name))
  1743. (process-kill-without-query gnuplot-process nil)
  1744. (save-excursion
  1745. (set-buffer gnuplot-buffer)
  1746. (make-local-hook 'kill-buffer-hook)
  1747. (add-hook 'kill-buffer-hook 'gnuplot-close-down nil t)
  1748. (gnuplot-comint-start-function)
  1749. (make-local-variable 'comint-output-filter-functions)
  1750. (setq comint-output-filter-functions
  1751. (append comint-output-filter-functions
  1752. '(comint-postoutput-scroll-to-bottom
  1753. gnuplot-protect-prompt-fn)))
  1754. (message "Starting gnuplot plotting program...Done")))))
  1755. (defun gnuplot-fetch-version-number ()
  1756. ;;(interactive)
  1757. (message "gnuplot-mode %s -- determining gnuplot version ......"
  1758. gnuplot-version)
  1759. (let* ((command (concat "echo \"show version\" | " gnuplot-program))
  1760. (process (start-process-shell-command "gnuplot-version"
  1761. "*gnuplot-version*"
  1762. command)))
  1763. (set-process-sentinel process 'gnuplot-determine-version-number)))
  1764. (defun gnuplot-determine-version-number (process event)
  1765. (save-excursion
  1766. (let (version)
  1767. (if (string-match "SPEEDBAR" (format "%S" (current-buffer))) ;; <WZ>
  1768. (if (fboundp 'speedbar-switch-buffer-attached-frame)
  1769. (speedbar-switch-buffer-attached-frame "*gnuplot-version*")
  1770. (progn
  1771. (speedbar-select-attached-frame)
  1772. (switch-to-buffer "*gnuplot-version*")))
  1773. (switch-to-buffer "*gnuplot-version*"))
  1774. (goto-char (point-min))
  1775. (re-search-forward "[Vv]ersion\\s-+" (point-max) t)
  1776. (if (looking-at "[0-9]\\.[0-9]+")
  1777. (setq version (match-string 0))
  1778. (setq version "3.7"))
  1779. (kill-buffer (get-buffer "*gnuplot-version*"))
  1780. ;;(and (interactive-p) (message "You are using gnuplot version %s" version))
  1781. (setq gnuplot-program-version version
  1782. gnuplot-three-eight-p (>= (string-to-number gnuplot-program-version) 3.8))
  1783. (gnuplot-setup-menu-and-toolbar)
  1784. )))
  1785. (defun gnuplot-setup-menu-and-toolbar ()
  1786. ;; set up the menubar (possibly dependent on version number)
  1787. (gnuplot-setup-menubar)
  1788. ;; set up the toolbar (possibly dependent on version number)
  1789. (if (and gnuplot-xemacs-p gnuplot-toolbar-display-flag)
  1790. (condition-case () ; deal with the toolbar
  1791. (and (require 'toolbar)
  1792. (require 'xpm)
  1793. (gnuplot-make-toolbar-function))
  1794. (error nil)))
  1795. (message "gnuplot-mode %s (gnuplot %s) -- report bugs with %S"
  1796. gnuplot-version gnuplot-program-version
  1797. (substitute-command-keys "\\[gnuplot-bug-report]"))
  1798. )
  1799. ;; (defun gnuplot-determine-gnuplot-version ()
  1800. ;; "Figure out which version of gnuplot we are running."
  1801. ;; (interactive)
  1802. ;; (cond (gnuplot-gnuplot-version
  1803. ;; (setq comint-process-echoes nil ;; t
  1804. ;; gnuplot-program-version gnuplot-gnuplot-version))
  1805. ;; (t
  1806. ;; (let ((counter 0))
  1807. ;; (save-excursion
  1808. ;; (set-buffer gnuplot-buffer)
  1809. ;; (goto-char (point-min))
  1810. ;; ;; it may take a while for emacs to display the gnuplot start-up
  1811. ;; ;; message. since we need this to determine the version number
  1812. ;; ;; and hence the value of `comint-process-echoes', we must wait
  1813. ;; ;; for this to happen.
  1814. ;; (while (and (equal (point-max) (point-min)) (< 10 counter))
  1815. ;; (1+ counter)
  1816. ;; (sleep-for 0.1))
  1817. ;; (if (re-search-forward "[Vv]ersion" (point-max) t)
  1818. ;; (progn
  1819. ;; (cond ((or (looking-at "\\s-*3.8") (looking-at "\\s-*4"))
  1820. ;; (setq comint-process-echoes nil ;; t
  1821. ;; gnuplot-program-version "3.8"))
  1822. ;; ((looking-at "\\s-*3.7")
  1823. ;; (setq comint-process-echoes nil ;; t
  1824. ;; gnuplot-program-version "3.7"))
  1825. ;; (t
  1826. ;; (setq comint-process-echoes nil
  1827. ;; gnuplot-program-version "3.5") )))
  1828. ;; (setq comint-process-echoes gnuplot-echo-command-line-flag)))))))
  1829. (defun gnuplot-protect-prompt-fn (string)
  1830. "Prevent the Gnuplot prompt from being deleted or overwritten.
  1831. STRING is the text as originally inserted in the comint buffer."
  1832. (save-excursion
  1833. (let ((b (progn
  1834. (goto-char (point-max))
  1835. (beginning-of-line)
  1836. (point)))
  1837. e)
  1838. (if (re-search-forward "^gnuplot> " (point-max) t)
  1839. (progn
  1840. (setq e (point))
  1841. (put-text-property b e 'rear-nonsticky '(read-only intangible face))
  1842. (put-text-property b e 'intangible t)
  1843. (put-text-property b e 'face 'gnuplot-prompt-face)
  1844. ;;(put-text-property b e 'read-only t)
  1845. )) )))
  1846. (defun gnuplot-close-down ()
  1847. "Tidy up when deleting the gnuplot buffer."
  1848. (if (eq (process-status gnuplot-process) 'run);; <SE>
  1849. (kill-process gnuplot-process))
  1850. (setq gnuplot-process nil
  1851. gnuplot-buffer nil))
  1852. (defun gnuplot-delchar-or-maybe-eof (arg)
  1853. "Delete ARG characters forward, or (if at eob) send an EOF to subprocess.
  1854. This is very similar to `comint-delchar-or-maybe-eof'."
  1855. (interactive "p")
  1856. (if (eobp)
  1857. (gnuplot-kill-gnuplot-buffer)
  1858. (delete-char arg)))
  1859. (defun gnuplot-kill-gnuplot-buffer ()
  1860. "Kill the gnuplot process and its display buffers."
  1861. (interactive)
  1862. (if (and gnuplot-process
  1863. (eq (process-status gnuplot-process) 'run)) ;; <SE>
  1864. (kill-process gnuplot-process))
  1865. (if (and gnuplot-buffer (get-buffer gnuplot-buffer))
  1866. (progn
  1867. (if (one-window-p) ()
  1868. (delete-window (get-buffer-window gnuplot-buffer)))
  1869. (kill-buffer gnuplot-buffer)))
  1870. (setq gnuplot-process nil
  1871. gnuplot-buffer nil))
  1872. (defun gnuplot-show-gnuplot-buffer ()
  1873. "Switch to the buffer containing the gnuplot process.
  1874. When `gnuplot-display-process' is nil this will switch to
  1875. the gnuplot process buffer. When that variable is non-nil, the
  1876. gnuplot process buffer will be displayed in a window."
  1877. (interactive)
  1878. (if (and gnuplot-buffer (get-buffer gnuplot-buffer))
  1879. (cond ((equal gnuplot-display-process 'window)
  1880. (switch-to-buffer-other-window gnuplot-buffer))
  1881. ((equal gnuplot-display-process 'frame)
  1882. (or (and gnuplot-process-frame
  1883. (frame-live-p gnuplot-process-frame))
  1884. (setq gnuplot-process-frame (make-frame)))
  1885. (raise-frame gnuplot-process-frame)
  1886. (select-frame gnuplot-process-frame)
  1887. (switch-to-buffer gnuplot-buffer))
  1888. (t
  1889. (switch-to-buffer gnuplot-buffer)))
  1890. (message "There is not an active Gnuplot process.")))
  1891. ;;; --- miscellaneous functions: insert file name, indentation, negation
  1892. (defun gnuplot-insert-filename ()
  1893. "Insert a filename at point, prompting for name in the minibuffer.
  1894. This inserts a filename relative to the buffer's default directory.
  1895. Uses completion and the value of `gnuplot-quote-character'.
  1896. Bound to \\[gnuplot-insert-filename]"
  1897. (interactive)
  1898. (insert gnuplot-quote-character
  1899. (file-relative-name (read-file-name "Filename > " "")
  1900. default-directory)
  1901. gnuplot-quote-character) )
  1902. ;; is this more complicated than it need be ...?
  1903. ;; this doesn't quite do plot lists correctly:
  1904. ;; plot sin(x),\
  1905. ;; cos(x) # ok
  1906. ;; set auto # not ok, should be under "p" (but does it matter?)
  1907. (defun gnuplot-indent-line ()
  1908. "Set indentation in gnuplot buffer.
  1909. For most lines, set indentation to previous level of indentation.
  1910. Attempt to add additional indentation for continued plot and splot
  1911. lines."
  1912. (interactive)
  1913. (let ((indent 0))
  1914. (save-excursion
  1915. (save-excursion
  1916. (end-of-line 0)
  1917. (if (bobp) ()
  1918. (re-search-backward "^[ \t]*." (point-min) "to_limit")
  1919. (back-to-indentation)
  1920. (setq indent (current-column))
  1921. (if (looking-at "s?pl\\(o?\\|\\(ot\\)?\\)[ \t]+.?")
  1922. (let ((plus (1- (length (match-string 0)))))
  1923. (end-of-line)
  1924. (backward-char 1)
  1925. (if (looking-at (regexp-quote "\\"))
  1926. (setq indent (+ plus indent)))))))
  1927. (if (= (current-indentation) indent)
  1928. ()
  1929. (beginning-of-line)
  1930. (delete-horizontal-space)
  1931. (insert (make-string indent ? ))))
  1932. (if (looking-at "[ \t]+$")
  1933. (end-of-line))))
  1934. ;; FWIW, here are all the options which can be negated:
  1935. ;; (insert (format "%s"
  1936. ;; (regexp-quote
  1937. ;; (make-regexp
  1938. ;; '("arrow" "autoscale" "border" "clabel" "clip"
  1939. ;; "contour" "dgrid3d" "grid" "hidden3d" "key" "label"
  1940. ;; "linestyle" "logscale" "multiplot" "mxtics"
  1941. ;; "mytics" "mztics" "mx2tics" "my2tics"
  1942. ;; "offsets" "polar" "surface" "timestamp" "title"
  1943. ;; "xdtics" "ydtics" "zdtics" "x2dtics" "y2dtics"
  1944. ;; "xmtics" "ymtics" "zmtics" "x2mtics" "y2mtics"
  1945. ;; "xtics" "ytics" "ztics" "x2tics" "y2tics"
  1946. ;; "xzeroaxis" "yzeroaxis" "zzeroaxis" "x2zeroaxis"
  1947. ;; "y2zeroaxis")))))
  1948. (defun gnuplot-negate-option ()
  1949. "Append \"no\" to or remove \"no\" from the set option on the current line.
  1950. This checks if the set option is one which has a negated form."
  1951. (interactive)
  1952. (let ((begin (save-excursion (beginning-of-line) (point-marker)))
  1953. (end (save-excursion (end-of-line) (point-marker)))
  1954. (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\\)"))
  1955. (save-excursion
  1956. (if (search-backward ";" begin t)
  1957. (progn (forward-char 1) (setq begin (point-marker))))
  1958. (if (search-forward ";" end t)
  1959. (progn (forward-char -1) (setq end (point-marker))))
  1960. (goto-char begin)
  1961. (skip-syntax-forward "-" end)
  1962. (if (looking-at "\\(un\\)?set\\s-+")
  1963. (cond ((and gnuplot-program-version
  1964. (> (string-to-number gnuplot-program-version) 3.7))
  1965. (cond ((looking-at "unset")
  1966. (delete-char 2))
  1967. ((looking-at (concat "set\\s-+\\(" regex "\\)"))
  1968. (insert "un"))
  1969. (t
  1970. (message "There is not a negatable set option on this line"))))
  1971. (t
  1972. (goto-char (match-end 0))
  1973. (if (> (point) end) (goto-char end))
  1974. (cond ((looking-at "no")
  1975. (delete-char 2))
  1976. ((looking-at regex)
  1977. (insert "no"))
  1978. (t
  1979. (message "There is not a negatable set option on this line")))))
  1980. (message "There is not a set option on this line")) )))
  1981. ;; (defun gnuplot-set-binding ()
  1982. ;; "Interactively select a key sequence for binding to a plot function.
  1983. ;; This is only useful in gnuplot 3.8 and for plot terminals which support
  1984. ;; key bindings (i.e. those covered by pm3d)."
  1985. ;; (interactive)
  1986. ;; (let ((keyseq (read-key-sequence "Choose a key sequence now"))
  1987. ;; (command (read-string "Bind to this command > ")))
  1988. ;; (setq keyseq (format "%S" keyseq))
  1989. ;; (string-match "keypress-event\\s-+" keyseq)
  1990. ;; (setq keyseq (substring keyseq (match-end 0) -2))
  1991. ;; ;; need to convert from emacs nomenclature to gnuplot. what a pain.
  1992. ;; (let* ((alist '(("backspace" . "Backspace") ("tab" . "Tab") ("linefeed" . "Linefeed")
  1993. ;; ("clear" . "Clear") ("return" . "Return") ("pause" . "Pause")
  1994. ;; ("scroll-lock" . "Scroll_Lock") ("SysReq" . "sys-req")
  1995. ;; ("escape" . "Escape") ("delete" . "Delete") ("home" . "Home")
  1996. ;; ("left" . "Left") ("right" . "Right") ("up" . "Up") ("down" . "Down")
  1997. ;; ("prior" . "PageUp") ("next" . "PageDown") ("end" . "End")
  1998. ;; ("begin". "Begin")))
  1999. ;; (match (assoc keyseq alist)))
  2000. ;; (if match (setq keyseq (cdr match)))
  2001. ;;
  2002. ;; (insert (format "bind \"%s\" \"%s\"" keyseq command)))))
  2003. (defun gnuplot-customize ()
  2004. "Customize `gnuplot-mode'."
  2005. (interactive)
  2006. (if (fboundp 'customize-group)
  2007. (customize-group "gnuplot")
  2008. (message "The Custom library is not installed.")))
  2009. ;;; --- help from the info file, keyword list + completion, insert function
  2010. ;; set up stuff for info-look (as suggested by <SE>)
  2011. ;; modified with suggestion from <MS>
  2012. (defun gnuplot-setup-info-look ()
  2013. "Setup info-look in the gnuplot buffer.
  2014. Also set the variable `gnuplot-keywords' and do something sensible if
  2015. info-look was not available.
  2016. See the comments in `gnuplot-info-hook'."
  2017. (interactive)
  2018. (setq gnuplot-keywords-pending nil)
  2019. (if (featurep 'info-look)
  2020. (progn
  2021. (cond ((boundp 'info-lookup-symbol-alist) ; older version
  2022. (setq info-lookup-symbol-alist
  2023. (append
  2024. info-lookup-symbol-alist
  2025. '((gnuplot-mode
  2026. "[a-zA-Z][_a-zA-Z0-9]*" nil
  2027. (("(gnuplot)Top" nil "[_a-zA-Z0-9]+")
  2028. ("(gnuplot)Commands" nil "[_a-zA-Z0-9]+")
  2029. ("(gnuplot)Functions" nil "[_a-zA-Z0-9]+")
  2030. ("(gnuplot)plot" nil "[_a-zA-Z0-9]+")
  2031. ("(gnuplot)set-show" nil "[_a-zA-Z0-9]+")
  2032. ("(gnuplot)data-file" nil "[_a-zA-Z0-9]+")
  2033. ("(gnuplot)smooth" nil "[_a-zA-Z0-9]+")
  2034. ("(gnuplot)style" nil "[_a-zA-Z0-9]+")
  2035. ("(gnuplot)terminal" nil "[_a-zA-Z0-9]+")
  2036. ;;("(gnuplot)General Index" nil "[_a-zA-Z0-9]+")
  2037. ) "[_a-zA-Z0-9]+" ))) ))
  2038. (t ; newer version
  2039. (info-lookup-maybe-add-help
  2040. :mode 'gnuplot-mode :topic 'symbol
  2041. :regexp "[a-zA-Z][_a-zA-Z0-9]*"
  2042. :doc-spec '(("(gnuplot)Top" nil "[_a-zA-Z0-9]+")
  2043. ("(gnuplot)Commands" nil "[_a-zA-Z0-9]+")
  2044. ("(gnuplot)Functions" nil "[_a-zA-Z0-9]+")
  2045. ("(gnuplot)plot" nil "[_a-zA-Z0-9]+")
  2046. ("(gnuplot)set-show" nil "[_a-zA-Z0-9]+")
  2047. ("(gnuplot)data-file" nil "[_a-zA-Z0-9]+")
  2048. ("(gnuplot)smooth" nil "[_a-zA-Z0-9]+")
  2049. ("(gnuplot)style" nil "[_a-zA-Z0-9]+")
  2050. ("(gnuplot)terminal" nil "[_a-zA-Z0-9]+")
  2051. ) )))
  2052. ;; this hook is my best way of working with info-look and
  2053. ;; allowing multiple versions of the gnuplot-info file.
  2054. ;; yes, this is a hassle.
  2055. (run-hooks 'gnuplot-info-hook)
  2056. (let ((there (bufferp (get-buffer "*info*"))))
  2057. (info-lookup-setup-mode 'symbol 'gnuplot-mode)
  2058. (or there (and (get-buffer "*info*") (kill-buffer "*info*")))
  2059. ;; why are these buffers here? I think that the general
  2060. ;; user will not want them lying around
  2061. (and (get-buffer "info dir") (kill-buffer "info dir"))
  2062. (and (get-buffer "info dir<2>") (kill-buffer "info dir<2>")))
  2063. (setq gnuplot-keywords (gnuplot-set-keywords-list))
  2064. )
  2065. ;; or do something sensible if info-look is not installed
  2066. (defun info-lookup-interactive-arguments (symbol)
  2067. (message
  2068. "Help is not available. The gnuplot info file could not be found.")
  2069. (list nil nil))) )
  2070. (defun gnuplot-set-keywords-list ()
  2071. "Set `gnuplot-keywords' from `info-lookup-cache'.
  2072. Return a list of keywords."
  2073. (let* ((list (cdr (assoc 'symbol info-lookup-cache)))
  2074. (list (cdr (cdr (assoc 'gnuplot-mode list))))
  2075. (list (car list))
  2076. (store ()) item)
  2077. (while list
  2078. (setq item (car (car list))
  2079. item (format "%s" item) ; keep this line for the sake of
  2080. store (append (list item) store) ; info-look.el w/o my patch
  2081. list (cdr list)))
  2082. (delete "nil" store)
  2083. store ))
  2084. (defun gnuplot-complete-keyword ()
  2085. "Perform completion on keyword preceding point.
  2086. This is a pretty simple minded completion function. It is loosely
  2087. adapted from `lisp-complete-symbol'."
  2088. (interactive)
  2089. (if gnuplot-keywords-pending ; <HW>
  2090. (gnuplot-setup-info-look))
  2091. (let* ((end (point))
  2092. (beg (unwind-protect (save-excursion (backward-sexp 1) (point))))
  2093. (patt (buffer-substring beg end))
  2094. (pattern (if (string-match "\\([^ \t]*\\)\\s-+$" patt)
  2095. (match-string 1 patt) patt))
  2096. (alist (mapcar 'list gnuplot-keywords))
  2097. (completion (try-completion pattern alist)))
  2098. (cond ((eq completion t))
  2099. ((null completion)
  2100. (message "No gnuplot keywords complete \"%s\"" pattern))
  2101. (t
  2102. (when (not (string= pattern completion))
  2103. (delete-region beg end)
  2104. (insert completion))
  2105. (let* ((list (all-completions pattern alist))
  2106. (mess (format "%S could be one of %S" pattern list))
  2107. (orig (current-buffer))
  2108. (buff (get-buffer-create " *gnuplot-completions*")))
  2109. (if (= (length list) 1) (insert " "))
  2110. (if (< (length mess) (frame-width))
  2111. (if (> (length list) 1) (message mess))
  2112. (switch-to-buffer-other-window buff)
  2113. (insert mess)
  2114. (fill-region (point-min) (point-max))
  2115. (goto-char (point-min))
  2116. (enlarge-window
  2117. (+ 2 (- (count-lines (point-min) (point-max))
  2118. (window-height))))
  2119. (sit-for (max (length list) 15))
  2120. (switch-to-buffer orig)
  2121. (kill-buffer buff)
  2122. (delete-other-windows) ))) )))
  2123. (defun gnuplot-info-lookup-symbol (symbol &optional mode)
  2124. "Wrapper for `info-lookup-symbol'.
  2125. Takes SYMBOL and MODE as arguments exactly as `info-lookup-symbol'.
  2126. After doing the info lookup, this displays the info file in a window
  2127. frame as specified by the value of `gnuplot-info-display'. If
  2128. `gnuplot-info-display' is 'window, then the window will be shrunk to
  2129. the size of the info entry if it is smaller than half the height of
  2130. the frame."
  2131. (interactive
  2132. (cond (gnuplot-keywords
  2133. (info-lookup-interactive-arguments 'symbol))
  2134. (gnuplot-keywords-pending ; <HW>
  2135. (gnuplot-setup-info-look)
  2136. (info-lookup-interactive-arguments 'symbol))
  2137. (t
  2138. (list nil (message
  2139. "Help is not available. The gnuplot info file could not be found.")))))
  2140. (if (and (featurep 'info-look) gnuplot-keywords)
  2141. (let ((buff (current-buffer))
  2142. (info-lookup-other-window-flag
  2143. (if gnuplot-info-display t nil)))
  2144. (if symbol () (setq symbol "Commands"))
  2145. (info-lookup-symbol symbol mode)
  2146. (cond ((equal gnuplot-info-display 'window)
  2147. (let ((sw (selected-window))
  2148. (window-min-height 2))
  2149. (other-window 1)
  2150. (enlarge-window
  2151. (min (- (count-lines (point-min) (point-max)) (window-height))
  2152. (- (/ (frame-height) 2) (window-height))))
  2153. (select-window sw)))
  2154. ((equal gnuplot-info-display 'frame)
  2155. (switch-to-buffer buff)
  2156. (delete-other-windows)
  2157. (or (and gnuplot-info-frame
  2158. (frame-live-p gnuplot-info-frame))
  2159. (setq gnuplot-info-frame (make-frame)))
  2160. (select-frame gnuplot-info-frame)
  2161. (raise-frame gnuplot-info-frame)
  2162. (if gnuplot-xemacs-p (setq toolbar-info-frame gnuplot-info-frame))
  2163. (switch-to-buffer "*info*") )) )))
  2164. (defun gnuplot-insert (string)
  2165. "Insert STRING at point and display help for for STRING.
  2166. Help is not shown if `gnuplot-insertions-show-help-flag' is nil. The
  2167. help shown is for STRING unless STRING begins with the word \"set\" or
  2168. \"show\", in which case help is shown for the thing being set or
  2169. shown."
  2170. (interactive)
  2171. (cond ((and (not gnuplot-three-eight-p)
  2172. (string-match "\\(emf\\|p\\(alette\\|m3d\\)\\|vgagl\\)" string))
  2173. (message "%S is an option introduced in gnuplot 3.8 (You are using %s)"
  2174. string gnuplot-program-version) )
  2175. (t
  2176. (insert string)
  2177. (let ((topic string) term)
  2178. (if (string-match
  2179. "\\(set\\|show\\)[ \t]+\\([^ \t]+\\)\\(\\s-+\\([^ \t]+\\)\\)?"
  2180. string)
  2181. (progn
  2182. (setq topic (downcase (match-string 2 string))
  2183. term (match-string 4 string))
  2184. (if (string= topic "terminal") (setq topic (downcase term)))))
  2185. (cond ((and (fboundp 'gnuplot-gui-set-options-and-insert)
  2186. gnuplot-gui-popup-flag)
  2187. (gnuplot-gui-set-options-and-insert))
  2188. (gnuplot-insertions-show-help-flag
  2189. (if gnuplot-keywords-pending ; <HW>
  2190. (gnuplot-setup-info-look))
  2191. (gnuplot-info-lookup-symbol topic)) ) )) ) )
  2192. (defun gnuplot-toggle-info-display ()
  2193. (interactive)
  2194. (setq gnuplot-insertions-show-help-flag (not gnuplot-insertions-show-help-flag))
  2195. (message (if gnuplot-insertions-show-help-flag
  2196. "Help will be displayed after insertions."
  2197. "Help no longer displayed after insertions.")))
  2198. ;;; --- bug reports
  2199. ;; grep '(defcustom' gnuplot.el gnuplot-gui.el | awk '{print $2}'
  2200. (defun gnuplot-bug-report ()
  2201. "Submit a bug report about `gnuplot-mode' by email.
  2202. Please do not send any bug reports about gnuplot itself to the
  2203. maintainer of `gnuplot-mode'."
  2204. (interactive)
  2205. (let ((line (make-string 62 ?-)))
  2206. (require 'reporter)
  2207. (and (y-or-n-p
  2208. "Do you really want to submit an email report about gnuplot? ")
  2209. (y-or-n-p
  2210. (concat "Variable values will be written to the message. "
  2211. "Don't erase them. OK? "))
  2212. (reporter-submit-bug-report
  2213. (format "%s <%s>" gnuplot-maintainer gnuplot-maintainer-email)
  2214. (format "gnuplot-mode (version %s)" gnuplot-version)
  2215. (append ; variables to display values of in mail
  2216. '(gnuplot-mode-hook
  2217. gnuplot-load-hook
  2218. gnuplot-after-plot-hook
  2219. gnuplot-info-hook
  2220. gnuplot-comint-setup-hook
  2221. gnuplot-program
  2222. gnuplot-program-version
  2223. gnuplot-process-name
  2224. gnuplot-gnuplot-buffer
  2225. gnuplot-display-process
  2226. gnuplot-info-display
  2227. gnuplot-echo-command-line-flag
  2228. gnuplot-insertions-show-help-flag
  2229. gnuplot-delay
  2230. gnuplot-quote-character
  2231. gnuplot-keywords-when
  2232. ;;gnuplot-insertions-menu-flag
  2233. ;;gnuplot-insertions-adornments
  2234. ;;gnuplot-insertions-plot-options
  2235. ;;gnuplot-insertions-terminal
  2236. ;;gnuplot-insertions-x-axis
  2237. ;;gnuplot-insertions-x2-axis
  2238. ;;gnuplot-insertions-y-axis
  2239. ;;gnuplot-insertions-y2-axis
  2240. ;;gnuplot-insertions-z-axis
  2241. ;;gnuplot-insertions-parametric-plots
  2242. ;;gnuplot-insertions-polar-plots
  2243. ;;gnuplot-insertions-surface-plots
  2244. gnuplot-toolbar-display-flag
  2245. gnuplot-toolbar-use-toolbar
  2246. gnuplot-gui-popup-flag
  2247. gnuplot-gui-frame-plist
  2248. gnuplot-gui-frame-parameters
  2249. gnuplot-gui-fontname-list
  2250. gnuplot-gui-plot-splot-fit-style
  2251. ;; plus a few more...
  2252. gnuplot-comint-recent-buffer
  2253. gnuplot-version
  2254. Info-directory-list
  2255. exec-path
  2256. features ))
  2257. nil ; pre-hooks
  2258. nil ; post-hooks
  2259. (concat line ; salutation
  2260. "\nInsert your description of the gnuplot-mode bug here.\n"
  2261. "Please be as specific as possible.\n\n"
  2262. "There are several known shortcomings of gnuplot-mode.\n"
  2263. "Many of these have to do with the complicated and inconsistent\n"
  2264. "syntax of gnuplot itself. See the document string for the\n"
  2265. "function `gnuplot-mode' (use `"
  2266. (substitute-command-keys "\\[describe-function]")
  2267. "') for details.\n\n"
  2268. "Note that this bug report form should be used for problems\n"
  2269. "with gnuplot-mode only. Problems with gnuplot itself should\n"
  2270. "be addressed directly to the developers of gnuplot.\n"
  2271. "The maintainer of gnuplot-mode will not field questions about\n"
  2272. "gnuplot itself. Thank you.\n"
  2273. line)
  2274. ))))
  2275. ;;; --- autoloaded functions: gnuplot-mode and gnuplot-make-buffer
  2276. ;;;###autoload
  2277. (defun gnuplot-mode ()
  2278. "Major mode for editing and executing GNUPLOT scripts.
  2279. This was written with version 3.7 of gnuplot in mind but it should
  2280. work fine with version 3.5 and the various 3.6 beta versions.
  2281. Report bugs in `gnuplot-mode' using \\[gnuplot-bug-report].
  2282. ------O------
  2283. The help functions, keyword completion, and several other features
  2284. depend upon having the info file properly installed. The info file
  2285. can be made in the document directory of the gnuplot distribution or
  2286. is available at the `gnuplot-mode' web page:
  2287. http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/
  2288. If the help function does not work properly, you may have an older
  2289. version of the gnuplot info file. Try the suggestion in the document
  2290. string for the variable `gnuplot-info-hook'. See the `gnuplot-mode'
  2291. web page for more details.
  2292. ------O------
  2293. There are several known shortcomings of `gnuplot-mode', version 0.5g
  2294. and up. Many of the shortcomings involve the graphical interface
  2295. (refered to as the GUI) to setting arguments to plot options. Here is
  2296. a list:
  2297. 1. Currently there is no way for `gnuplot-mode' to know if information
  2298. sent to gnuplot was correctly plotted.
  2299. 2. Indentation is sometimes a bit flaky.
  2300. 3. \"plot\", \"splot\", and \"fit\" are handled in the GUI, but are
  2301. a bit flaky. Their arguments may not be read correctly from
  2302. existing text, and continuation lines (common for plot and splot)
  2303. are not supported.
  2304. 4. The GUI does not know how to read from continuation lines.
  2305. 5. Comma separated position arguments to plot options are
  2306. unsupported in the GUI. Colon separated datafile modifiers (used
  2307. for plot, splot, and fit) are not supported either. Arguments
  2308. not yet supported by the GUI generate messages printed in grey
  2309. text.
  2310. 6. The GUI handling of \"hidden3d\" is flaky and \"cntrparam\" is
  2311. unsupported.
  2312. ------O------
  2313. Key bindings:
  2314. \\{gnuplot-mode-map}"
  2315. (interactive)
  2316. (kill-all-local-variables)
  2317. (use-local-map gnuplot-mode-map)
  2318. (setq major-mode 'gnuplot-mode
  2319. mode-name "Gnuplot")
  2320. (set (make-local-variable 'comment-start) "# ")
  2321. (set (make-local-variable 'comment-end) "")
  2322. (set (make-local-variable 'comment-column) 32)
  2323. (set (make-local-variable 'comment-start-skip) "#[ \t]*")
  2324. (set (make-local-variable 'indent-line-function) 'gnuplot-indent-line)
  2325. (set-syntax-table gnuplot-mode-syntax-table)
  2326. (if (or (fboundp 'hilit-set-mode-patterns)
  2327. (equal gnuplot-keywords-when 'immediately)) ; <HW>
  2328. (gnuplot-setup-info-look)) ;; <SE>
  2329. (if (fboundp 'hilit-set-mode-patterns) ; deal with hilit19 (ho hum!)
  2330. (let ((keywords (concat "\\b\\(" (mapconcat 'identity
  2331. gnuplot-keywords "\\|")
  2332. "\\)\\b")))
  2333. (hilit-set-mode-patterns
  2334. 'gnuplot-mode
  2335. `(("#.*$" nil comment)
  2336. ("\\([a-zA-Z0-9_-]+\\)\\(([^)]*)\\)?\\s *=" nil define)
  2337. ,(list keywords 'nil 'keyword)
  2338. (hilit-string-find ?\\ string)
  2339. ))) )
  2340. ;;(if (featurep 'kw-compl) ; old-style keyword completion
  2341. ;; (setq kw-compl-list gnuplot-keywords
  2342. ;; kw-compl-upper-case nil)) ; gnuplot keywords must be lower case
  2343. (if gnuplot-xemacs-p ; deal with font-lock
  2344. (if (fboundp 'turn-on-font-lock) (turn-on-font-lock))
  2345. (progn
  2346. (make-variable-buffer-local 'font-lock-defaults)
  2347. (setq font-lock-defaults '(gnuplot-font-lock-keywords t t))))
  2348. ;; (if (and gnuplot-xemacs-p gnuplot-toolbar-display-flag)
  2349. ;; (condition-case () ; deal with the toolbar
  2350. ;; (and (require 'toolbar)
  2351. ;; (require 'xpm)
  2352. ;; (gnuplot-make-toolbar-function))
  2353. ;; (error nil)))
  2354. (if (fboundp 'widget-create) ; gunplot-gui
  2355. (condition-case ()
  2356. (require 'gnuplot-gui)
  2357. (error nil)))
  2358. (setq gnuplot-first-call nil ; a few more details ...
  2359. gnuplot-comint-recent-buffer (current-buffer)
  2360. comint-process-echoes gnuplot-echo-command-line-flag)
  2361. (run-hooks 'gnuplot-mode-hook)
  2362. ;; the first time we need to figure out which gnuplot we are running
  2363. (if gnuplot-program-version
  2364. (gnuplot-setup-menu-and-toolbar)
  2365. (gnuplot-fetch-version-number)))
  2366. ;;;###autoload
  2367. (defun gnuplot-make-buffer ()
  2368. "Open a new buffer in `gnuplot-mode'.
  2369. When invoked, it switches to a new, empty buffer visiting no file
  2370. and then starts `gnuplot-mode'.
  2371. It is convenient to bind this function to a global key sequence. For
  2372. example, to make the F10 key open a gnuplot script buffer, put the
  2373. following in your .emacs file:
  2374. (autoload 'gnuplot-make-buffer \"gnuplot\"
  2375. \"open a buffer in gnuplot mode\" t)
  2376. (global-set-key [(f10)] 'gnuplot-make-buffer)"
  2377. (interactive)
  2378. (switch-to-buffer gnuplot-gnuplot-buffer)
  2379. (gnuplot-mode))
  2380. (defun gnuplot-show-version ()
  2381. "Show version number in echo area"
  2382. (interactive)
  2383. (message "gnuplot-mode %s -- URL: %s" gnuplot-version gnuplot-maintainer-url))
  2384. (defun gnuplot-show-gnuplot-version ()
  2385. "Show gnuplot program and version number in echo area"
  2386. (interactive)
  2387. (message "You are calling gnuplot %s as %s" gnuplot-program-version gnuplot-program))
  2388. ;;; That's it! ----------------------------------------------------------------
  2389. ;;; --- final chores: provide 'gnuplot and run load-hook
  2390. ;; provide before run-hooks suggested by <DB>
  2391. (provide 'gnuplot)
  2392. (run-hooks 'gnuplot-load-hook)
  2393. ;;;============================================================================
  2394. ;;;
  2395. ;;; gnuplot.el ends here