pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Lisp pastebin - collaborative debugging tool View Help


Posted by Marco Pessotto on Thu 7 Feb 18:49
report spam | download | new post

  1. ;;; pov-mode.el --- major mode for Povray scene files
  2. ;;
  3. ;; Author: Peter Boettcher <pwb@andrew.cmu.edu>
  4. ;; Maintainer: Peter Toneby <woormie@acc.umu.se>
  5. ;; Created: 04 March 1994
  6. ;; Modified: 05 Feb 2008
  7. ;; Version: 2.10-pl1
  8. ;; Keywords: pov, povray
  9. ;;
  10. ;; Modified by: Marco Pessotto <marco.erika@gmail.com>
  11. ;; 1/5/2008
  12. ;; Workaround for Emacs 22
  13. ;; Peter Toneby no more maintains pov-mode :-(
  14. ;;
  15. ;; LCD Archive Entry:
  16. ;; povray|Peter Toneby|woormie@acc.umu.se|
  17. ;; Major mode for Povray scene files|
  18. ;; 08-Sep-2003|2.10|~/lib/emacs/pov-mode.el|
  19. ;;
  20. ;; Copyright (C) 1997 Peter W. Boettcher
  21. ;;
  22. ;; This program is free software; you can redistribute it and/or modify
  23. ;; it under the terms of the GNU General Public License as published by
  24. ;; the Free Software Foundation; either version 2, or (at your option)
  25. ;; any later version.
  26. ;; This program is distributed in the hope that it will be useful,
  27. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  29. ;; GNU General Public License for more details.
  30. ;;
  31. ;; You should have received a copy of the GNU General Public License
  32. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  33. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  34. ;;
  35. ;;; Commentary:
  36. ;;
  37. ;; This major mode for GNU Emacs provides support for editing Povray
  38. ;; scene files, rendering and viewing them.  It automatically indents
  39. ;; blocks, both {} and #if #end.  It also provides context-sensitive
  40. ;; keyword completion and font-lock highlighting, as well as the
  41. ;; ability to look up those keywords in the povray docu.
  42. ;;
  43. ;; It should work for either Xemacs or FSF Emacs, versions >= 20;
  44. ;; however, only Xemacs can display pictures.
  45. ;;
  46. ;; To automatically load pov-mode every time Emacs starts up, put the
  47. ;; following line into your .emacs file:
  48. ;;
  49. ;;      (require 'pov-mode)
  50. ;;
  51. ;; Of course pov-mode has to be somewhere in your load-path for emacs
  52. ;; to find it (Use C-h v load-path to see which directories are in the
  53. ;; load-path).
  54. ;;
  55. ;; NOTE: To achieve any sort of reasonable performance, YOU MUST
  56. ;;   byte-compile this package.  In emacs, type M-x byte-compile
  57. ;;   and then enter the name of this file.
  58. ;;
  59. ;; You can customize the behaviour of pov-mode and via the
  60. ;; customization menu or by simply entering M-x customize-group pov.
  61. ;; In many or even most cases, however, it should be completely
  62. ;; sufficient to to rely on the default settings.
  63. ;;
  64. ;; To learn about the basics, just load a pov-file and press C-h m.
  65. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  66.  
  67. ;;
  68. ;;Modified by: Peter Boettcher <pwb@andrew.cmu.edu>
  69. ;;  5/8/97:
  70. ;;    Added font-lock support for Emacs/XEmacs 19
  71. ;;    Indent under `#declare Object=' lines
  72. ;;    Corrected comment syntax
  73. ;;    Got rid of more remnants from postscript mode
  74. ;;    General cleanup
  75. ;;    Arbitrarily chose version 1.2
  76. ;; 5/8/97:  Version 1.21
  77. ;;    fontify-insanely was ignored.  fixed.
  78. ;;
  79. ;; 9/24/97: Version 1.3
  80. ;;    Added indentation for Pov 3 syntax (#if #else, etc)
  81. ;;    Preliminary context-sensitive keyword completion
  82. ;;
  83. ;; 1/13/98 by Peter Boettcher <pwb@andrew.cmu.edu>
  84. ;;    Explicitly placed package under GPL
  85. ;;    Reorganized comment sections and change log to follow GNU standards
  86. ;;    Added simple code for jumping to pov documentation (Thanks to
  87. ;;         Benjamin Strautin <bis@acpub.duke.edu> for this code)
  88. ;;
  89. ;; Modified by: Peter Toneby <woormie@acc.umu.se>
  90. ;;  22/3/99: Version 1.99beata1
  91. ;;    Added support for Pov3.1s new keywords. (not all, I think...)
  92. ;;    Removed atmosphere (and atmosphere_*) (stupid me...)
  93. ;;
  94. ;; Modified by: Peter Toneby <woormie@acc.umu.se>
  95. ;;  23/4/99: Version 1.99beata2
  96. ;;    Added support for all new keyword, BUT
  97. ;;    Added atmosphere (and atmosphere_*) again
  98. ;;    Got Pete Boettchers blessing to continue (but with a note
  99. ;;      that said that I should have talked to him first, I'm sorry
  100. ;;      for not doing that). Pete also said he was willing to let
  101. ;;      me continue the maintainance of this file.
  102. ;;    I can't get the pov-keyword-help to work, anyone with knowledge
  103. ;;      about elisp can send me a fix for it.
  104. ;;    The keyword expansion doesn't work for all keywords,
  105. ;;      I need to add lots of stuff and read through the docs
  106. ;;      to get everything correct.
  107. ;;
  108. ;; Modified by: Alexander Schmolck <aschmolck@gmx.de>
  109. ;; 2000-01-31: Version 2beataXXX
  110. ;;    Added working keyword lookup in povuser.txt
  111. ;;    Added rendering and viewing from within Emacs and with an external viewer
  112. ;;    Added customization and made installation simpler
  113. ;;    Added a few other minor details
  114. ;;
  115. ;; Modified by: Peter Toneby <woormie@acc.umu.se>
  116. ;; 2000-05-24: Version 2
  117. ;;    Changed the keyword lookup a little, povuser.txt didn't open as
  118. ;;       expected when having set the pov-home-dir and pov-help-file
  119. ;;       manually.
  120. ;;
  121. ;; Modified by: Peter Toneby <woormie@acc.umu.se>
  122. ;; 2000-08-10: Version 2.5b1
  123. ;;    Added povray-font-lock-faces.
  124. ;;    Made sure font-lock works properly on:
  125. ;;        XEmacs 19.15p7
  126. ;;        XEmacs 20.0
  127. ;;        XEmacs 21.1p10
  128. ;;        Emacs 19.29.1
  129. ;;        Emacs 20.7.2
  130. ;;    Added all 3.1 keywords except track, since I don't know what it
  131. ;;        is, I have also dropped the 3.0 specific keywords that
  132. ;;        shouldn't be used anymore.
  133. ;;    Fixed some completion stuff, I think I have added all keywords to
  134. ;;        the completions.
  135. ;;    Added configureation for all faces. To bad I can't get the defaults
  136. ;;        to work properly on dark backgrounds, I don't know why that is.
  137. ;;    Added a toolbar, it replaces to standard XEmacs toolbar, I think
  138. ;;        that is the best thing to do, but I retain the standard useful
  139. ;;        functionality.
  140. ;;    Fixed an error in the external viewer, it used variables that were
  141. ;;        not available in the same scope as the sentinel.
  142. ;;    Added basic imenu support, currently only #local and #declare,
  143. ;;        but I will try to add objects, cameras and lightsources later.
  144. ;; 2000-09-12 Version 2.5.b2
  145. ;;    Added basic support for megapov
  146. ;;    Bob Pepin fixed a bug in test to select external/internal viewer.
  147. ;;    fortsätt på kapitel 5.6
  148. ;; 2001-04-05 Version 2.6
  149. ;;    Added the capability to open standard include files by pressing
  150. ;;        C-c i. It opens the file entered ro.
  151. ;;    Fixed leeking color in emacs (Robert Kleemann)
  152. ;;    Changed the rendertoolbarbutton to show a popup dialog with buttons
  153. ;;        for the different qualities.
  154. ;; 2001-12-07 Version 2.7
  155. ;;    Fixed font-locks for Emacs 21
  156. ;; 2002-06-19 Version 2.8
  157. ;;    Fixed loading for Emacs 21-2, missed a test for customizations
  158. ;;    Added most parts of a patch from  Christoph Hormann that cleaned
  159. ;;        up the Regexp mess, and added all (or at least most) of the
  160. ;;        keywords for 3.5 Parts of that patch are still missing, I'll
  161. ;;        get around to those sometime...
  162. ;; 2002-08-07 Version 2.9
  163. ;;    Added Insert menu, it uses the directory structure of the winpov
  164. ;;        insert menu.
  165. ;;    Moved the toolbar icons out to separate xpm-files.
  166. ;;    Added some missing keyword expansions
  167. ;;    Fixed so that box, cylinder... has their own face, object-face,
  168. ;;        removed unused faces
  169. ;;    Cleaned up the code, removed unused stuff.
  170. ;;    It works in versions 21, can't test in 20, font-lock is borked for me.
  171. ;; 2002-08-10 Version 2.9.1
  172. ;;    Fixed so that tollbar icons are searched for, not hard coded.
  173. ;; 2003-08-29 Version 2.10
  174. ;;    Fixed references to povray.el.
  175. ;;    Fixed cut-n-pasted comment for font-pov-operator-face.
  176. ;;    Fixed the insert menus, they missed the last items, thanks to Hartwig
  177. ;;        Bosse for the heads up, and a fix.
  178. ;; 2003-08-29 Version 2.11 (This is a future version)
  179. ;;    Fix a bug with rendering so that the active buffer is changed to the
  180. ;;        correct buffer, found by Hartwig Bosse.
  181. ;;
  182. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  183. ;;
  184. ;; Original Author:     Kevin O. Grover <grover@isri.unlv.edu>
  185. ;;        Cre Date:     04 March 1994
  186. ;; This file derived from postscript mode by Chris Maio
  187. ;;
  188. ;;  Please send bug reports/comments/suggestions to Peter Toneby
  189. ;;        woormie@acc.umu.se
  190. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  191. ;;
  192. ;; TODO list:
  193. ;; * Vector operations (add <0, .5, 1> to every vector in region)
  194. ;; * Clean up completion code
  195. ;; * TAGS, to jump to #declared objects elsewhere in the code
  196. ;; * c-mode like electric parens (?)
  197. ;; * clean up viewing and rendering code
  198. ;; * should render or view be decided on filedates? If so, what
  199. ;;     image file-name extensions should be checked?
  200. ;;     I think PNG is default for UNIX, not sure.
  201. ;;     I could make this a customizeation option.
  202. ;; * imenu support
  203. ;;     started, but needs to be fixed so it handles nested menus.
  204. ;; * Make sure the scopes are correct
  205. ;; * Make hooks for menus, so they are userselectable
  206. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  207.  
  208. ;; Better safe than sorry, lets fail if you are using a (very?) old
  209. ;; version of (X)Emacs.
  210. (if (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version)))
  211.         (and (= emacs-major-version 19) (< emacs-minor-version 14))
  212.       (and (= emacs-major-version 19) (< emacs-minor-version 29)))
  213.     (error "`font-pov' was written for Emacs 19.29/XEmacs 19.14 or later"))
  214.  
  215. (defvar font-pov-is-XEmacs19
  216.   (and (not (null (save-match-data
  217.                     (string-match "XEmacs\\|Lucid" emacs-version))))
  218.        (= 19 emacs-major-version)))
  219. (defvar font-pov-is-XEmacs20
  220.   (and (not (null (save-match-data
  221.                     (string-match "XEmacs\\|Lucid" emacs-version))))
  222.        (<= 20 emacs-major-version)))
  223. (defvar font-pov-is-XEmacs21
  224.   (and (not (null (save-match-data
  225.                     (string-match "XEmacs\\|Lucid" emacs-version))))
  226.        (<= 21 emacs-major-version)))
  227.  
  228. (defvar font-pov-is-XEmacs20-2
  229.   (or (and font-pov-is-XEmacs20 (<= 2 emacs-minor-version))
  230.       font-pov-is-XEmacs21))
  231.  
  232. (defvar font-pov-is-Emacs19
  233.   (and (not font-pov-is-XEmacs19)
  234.        (not font-pov-is-XEmacs20)
  235.        (= 19 emacs-major-version)))
  236. (defvar font-pov-is-Emacs20
  237.   (and (not font-pov-is-XEmacs19)
  238.        (not font-pov-is-XEmacs20)
  239.        (= 20 emacs-major-version)))
  240. (defvar font-pov-is-Emacs21
  241.   (and (not font-pov-is-XEmacs19)
  242.        (not font-pov-is-XEmacs20)
  243.        (not font-pov-is-XEmacs21)
  244.        (= 21 emacs-major-version)))
  245. (defvar font-pov-is-Emacs22
  246.   (and (not font-pov-is-XEmacs19)
  247.        (not font-pov-is-XEmacs20)
  248.        (not font-pov-is-XEmacs21)
  249.        (= 22 emacs-major-version)))
  250.  
  251. (defvar font-pov-is-Emacs
  252.   (or font-pov-is-Emacs19
  253.       font-pov-is-Emacs20
  254.       font-pov-is-Emacs21
  255.       font-pov-is-Emacs22))
  256.  
  257.  
  258. (require 'cl)
  259. (require 'font-lock) ;;[TODO] Not nice to reqire it, the user should
  260.                      ;;       have a choise...
  261.  
  262. (defconst pov-mode-version '2.10
  263.   "The povray mode version.")
  264.  
  265. (defvar pov-tab-width 8)
  266. (defvar pov-autoindent-endblocks t)
  267.  
  268. ;;Create fontfaces
  269. (defvar font-pov-number-face 'font-pov-number-face
  270.   "Face to use for PoV numbers.")
  271.  
  272. (defvar font-pov-variable-face 'font-pov-variable-face
  273.   "Face to use for PoV variables.")
  274.  
  275. (defvar font-pov-directive-face 'font-pov-directive-face
  276.   "Face to use for PoV directives.")
  277.  
  278. (defvar font-pov-object-face 'font-pov-object-face
  279.   "Face to use for PoV objects.")
  280.  
  281. ;(defvar font-pov-object-modifier-face 'font-pov-object-modifier-face
  282. ;  "Face to use for PoV objects.")
  283.  
  284. ;(defvar font-pov-texture-face 'font-pov-texture-face
  285. ;  "Face to use for PoV objects.")
  286.  
  287. (defvar font-pov-operator-face 'font-pov-operator-face
  288.   "Face to use for PoV operators.")
  289.  
  290. (defvar font-pov-csg-face 'font-pov-csg-face
  291.   "Face to use for PoV csg keywords.")
  292.  
  293. ;(defvar font-pov-string-face nil
  294. ;  "Face to use for strings.  This is set by font-PoV.")
  295.  
  296. (defvar font-pov-macro-name-face nil
  297.   "Face to use for strings.  This is set by font-PoV.")
  298.  
  299. (defvar font-pov-keyword-face nil
  300.   "Face to use for misc keywords.  This is set by font-PoV.")
  301.  
  302. (defvar pov-insertmenu-location nil
  303.   "Location of the InsertMenu directory structure.")
  304.  
  305. (defvar pov-icons-location nil
  306.   "Location of the menubaricons.")
  307.  
  308. ; Seems like Emacs lacks these functions (locate-data-[directory|file])...
  309. (unless (fboundp 'locate-data-directory)
  310.   (defun locate-data-directory (name &optional dirs)
  311.     (if dirs
  312.         (if (file-directory-p (expand-file-name name (car dirs)))
  313.             (expand-file-name name (car dirs))
  314.           (locate-data-directory name (cdr dirs)))
  315.       (expand-file-name name data-directory))))
  316.  
  317. (unless (fboundp 'locate-data-file)
  318.   (defun locate-data-file (name &optional dirs)
  319.     (print dirs)
  320.     (if dirs
  321.         (if (file-regular-p (expand-file-name name (car dirs)))
  322.             (expand-file-name name (car dirs))
  323.           (locate-data-file name (cdr dirs)))
  324.       (expand-file-name name data-directory))))
  325.  
  326. ;; This is because FSFEmacs has a ridiculusly low max-lisp-eval-depth
  327. (when (> 1000 max-lisp-eval-depth)
  328.   (customize-set-value 'max-lisp-eval-depth 1000))
  329.  
  330. ;; Yup XEmacs didn't get cutomizations until 20.2.
  331. (cond ((or font-pov-is-XEmacs20-2 (or font-pov-is-Emacs20 font-pov-is-Emacs21 font-pov-is-Emacs22))
  332.       (defgroup  pov nil
  333.         "*Major mode for editing povray 3.X scence files <http://www.povray.org>."
  334.         :group 'languages)
  335.  
  336.       (defcustom povray-command "povray"
  337.         "*Command used to invoke the povray."
  338.         :type 'string
  339.         :group 'pov)
  340.  
  341.       (defcustom pov-external-viewer-command "xv"
  342.         "*The external viewer to call."
  343.         :type 'string
  344.         :group 'pov)
  345.  
  346.       (defcustom pov-external-view-options "%s"
  347.         "*The options for the viewer; %s is replaced with the name of the rendered image."
  348.         :type 'string
  349.         :group 'pov)
  350.  
  351.       ;;allow user to customize external or internal viewer as defaults if she
  352.       ;;is using Xemacs; for FSF Emacs assume external, since it can't
  353.       ;;handle pictures anyway
  354.       ;(if  (and (boundp 'running-xemacs) running-xemacs)
  355.       (defcustom pov-default-view-internal t
  356.         "*Should the pictures be displayed internally by default?"
  357.         :type 'boolean
  358.         :group 'pov)
  359.       ;(defvar pov-default-view-internal nil))
  360.  
  361.       (defcustom pov-run-default "+i%s"
  362.         "*The default options for the Render command (%s is replaced by the filename)."
  363.         :type 'string
  364.         :group 'pov
  365.         )
  366.       (defcustom pov-run-test "res120 -Q3 +i%s"
  367.         "*The default options for the Test Render command (%s is replaced by the filename)."
  368.         :type 'string
  369.         :group 'pov
  370.         )
  371.       (defcustom pov-run-low "res320 +i%s"
  372.         "*The default options for the Test Render command (%s is replaced by the filename)."
  373.         :type 'string
  374.         :group 'pov
  375.         )
  376.       (defcustom pov-run-mid "res640 +i%s"
  377.         "*The default options for the Medium Res Render command (%s is replaced by the filename)."
  378.         :type 'string
  379.         :group 'pov
  380.         )
  381.       (defcustom pov-run-high "res800 +i%s"
  382.         "*The default options for the High Res Render command (%s is replaced by the filename)."
  383.         :type 'string
  384.         :group 'pov
  385.         )
  386.       (defcustom pov-run-highest "res1k +i%s"
  387.         "*The default options for the Higest Res Render command (%s is replaced by the filename)."
  388.         :type 'string
  389.         :group 'pov
  390.         )
  391.       (defvar pov-external-view
  392.         "External view")
  393.       (defvar pov-internal-view
  394.         "Internal view")
  395.       (defvar pov-command-alist (list (list "Render"
  396.                                             povray-command pov-run-default
  397.                                             '()) ;history for the command
  398.                                       (list "Test quality render"
  399.                                             povray-command pov-run-test
  400.                                             '())
  401.                                       (list "Low quality render"
  402.                                             povray-command pov-run-low
  403.                                             '())
  404.                                       (list "Medium quality render"
  405.                                             povray-command pov-run-highest
  406.                                             '())
  407.                                       (list "High quality render"
  408.                                             povray-command pov-run-high
  409.                                             '())
  410.                                       (list pov-external-view
  411.                                             pov-external-viewer-command
  412.                                             pov-external-view-options
  413.                                             '())
  414.                                       (list pov-internal-view
  415.                                             (list pov-internal-view)
  416.                                             '()))
  417.         "the commands to run")
  418.  
  419.       (defcustom pov-home-dir "SHARELIBSPOVRAY"
  420.         "*The directory in which the povray files reside."
  421.         :type 'directory
  422.         :group 'pov)
  423.  
  424.       (defcustom pov-include-dir "SHARELIBSPOVRAY/include"
  425.         "*The directory in which the povray includefiles reside."
  426.         :type 'directory
  427.         :group 'pov)
  428.  
  429.       (defcustom pov-help-file "povuser.txt"
  430.         "*The name of the helpfile."
  431.         :type  'file
  432.         :group 'pov)
  433.  
  434.       (defcustom pov-associate-pov-and-inc-with-pov-mode-flag t
  435.         "*If t then files ending with .pov and .inc will automatically start
  436. pov-mode when loaded, unless those file-endings are already in use."
  437.         :type 'boolean
  438.         :group 'pov)
  439.  
  440.       (defcustom pov-fontify-insanely t
  441.         "*Non-nil means colorize every povray keyword.  This may take a while on large files.  Maybe disable this on slow systems."
  442.         :type 'boolean
  443.         :group 'pov)
  444.  
  445.       (defcustom pov-imenu-in-menu t
  446.         "*Non-nil means have #locals and #declares in a menu called PoV in the menubar. This may take a while on large files.  Maybe disable this on slow systems."
  447.         :type 'boolean
  448.         :group 'pov)
  449. ;; CH
  450.       (defcustom pov-imenu-only-macros t
  451.         "*Non-nil means to restrict imenu to macro declarations."
  452.         :type 'boolean
  453.         :group 'pov)
  454. ;; /end CH
  455.       (defcustom pov-indent-level 2
  456.         "*Indentation to be used inside of PoVray blocks or arrays."
  457.         :type 'integer
  458.         :group 'pov)
  459.  
  460.       (defcustom pov-autoindent-endblocks t
  461.         "*When non-nil, automatically reindents when you type break, end, or else."
  462.         :type 'boolean
  463.         :group 'pov
  464.         )
  465.  
  466.       (defcustom pov-indent-under-declare 2
  467.         "*Indentation under a `#declare Object=' line."
  468.         :type 'integer
  469.         :group 'pov)
  470.  
  471.       (defcustom pov-tab-width 8
  472.         "*Tab stop width for PoV mode."
  473.         :type 'integer
  474.         :group 'pov)
  475.  
  476.       (defcustom pov-turn-on-font-lock t
  477.         "*Turn on syntax highlighting automatically"
  478.         :type 'boolean
  479.         :group 'pov)
  480.  
  481.       (defcustom font-pov-csg-face t
  482.         "*What color does CSG-object have"
  483.         :type 'face
  484.         :group 'pov)
  485.  
  486.       (defcustom font-pov-object-face t
  487.         "*What color does objects have"
  488.         :type 'face
  489.         :group 'pov)
  490.  
  491.       (defcustom font-pov-variable-face t
  492.         "*What color does variables (in declarations) have"
  493.         :type 'face
  494.         :group 'pov)
  495.  
  496. ;      (defcustom font-pov-string-face t
  497. ;       "*What color does strings have"
  498. ;       :type 'face
  499. ;       :group 'pov)
  500.  
  501. ;      (defcustom font-pov-texture-face t
  502. ;       "*What color does textures have"
  503. ;       :type 'face
  504. ;       :group 'pov)
  505.  
  506. ;      (defcustom font-pov-object-modifier-face t
  507. ;       "*What color does object modifiers have"
  508. ;       :type 'face
  509. ;       :group 'pov)
  510.  
  511.       (defcustom font-pov-directive-face t
  512.         "*What color does (#)-directives have"
  513.         :type 'face
  514.         :group 'pov)
  515.  
  516.       (defcustom font-pov-number-face t
  517.         "*What color does numbers have"
  518.         :type 'face
  519.         :group 'pov)
  520.  
  521.       (defcustom font-pov-keyword-face t
  522.         "*What color does keywords have"
  523.         :type 'face
  524.         :group 'pov)
  525.       )
  526. )
  527.  
  528. ; Find where the menubar icons are placed, should be where pov-mode is...
  529. ;; (setq pov-icons-location
  530. ;;       (file-name-directory (locate-data-file "povrender.xpm"
  531. ;;                                           (cons (file-name-directory (locate-library "pov-mode"))
  532. ;;                                                 (if font-pov-is-Emacs data-directory data-directory-list)))))
  533.  
  534. ;;FIX ME
  535.  
  536. (setq pov-icons-location "EMACSLISPLIBRARY/povrender.xpm")
  537.  
  538.  
  539. ;; Lets play with the Toolbar, we want to add buttons for
  540. ;; rendering and showing images, lets place them on the rightmost
  541. ;; position of the toolbar.
  542. (cond ((or font-pov-is-XEmacs20 font-pov-is-XEmacs21)
  543.        (defvar toolbar-render-icon
  544.          (if (featurep 'xpm)
  545.              (let ((rendericon (concat pov-icons-location "povrender.xpm")))
  546.                (toolbar-make-button-list (make-image-instance (vector 'xpm :file rendericon))))
  547.          ))
  548.        (defvar toolbar-look-icon
  549.          (if (featurep 'xpm)
  550.              (let ((viewicon (concat pov-icons-location "povview.xpm")))
  551.                (toolbar-make-button-list (make-image-instance (vector 'xpm :file viewicon))))
  552.            ))
  553.        (defvar pov-toolbar
  554.          '(
  555.            [toolbar-file-icon    toolbar-open    t "Open a file"]
  556.            [toolbar-folder-icon  toolbar-dired   t "Edit a directory"]
  557.            [toolbar-disk-icon    toolbar-save    t "Save buffer"]
  558.            [toolbar-printer-icon toolbar-print   t "Print buffer"]
  559.            [toolbar-cut-icon     toolbar-cut     t "Kill region"]
  560.            [toolbar-copy-icon    toolbar-copy    t "Copy region"]
  561.            [toolbar-paste-icon   toolbar-paste   t "Paste from clipboard"]
  562.            [toolbar-undo-icon    toolbar-undo    t "Undo edit"]
  563.            [toolbar-spell-icon   toolbar-ispell  t "Check spelling"]
  564.            [toolbar-replace-icon toolbar-replace t "Search & Replace"]
  565.            nil
  566.            [toolbar-render-icon  (pov-render-dialog) t "Configured Render the file"]
  567. ;          [toolbar-render-icon
  568. ;           (pov-render-file "Render" (buffer-file-name) nil)
  569. ;           t "Quick Render the file"]
  570.            [toolbar-look-icon
  571.             (if pov-default-view-internal
  572.                 (pov-display-image-xemacs pov-image-file)
  573.               (pov-display-image-externally pov-image-file nil))
  574.             t "Show the rendered file"]
  575.            ))
  576.        (defvar pov-render-dialog-desc
  577.          '("Render Image"
  578.            ["Test render"   (pov-render-file "Test quality render"   (buffer-file-name) nil) t]
  579.            ["Low render"    (pov-render-file "Low quality render"    (buffer-file-name) nil) t]
  580.            ["Medium render" (pov-render-file "Medium quality render" (buffer-file-name) nil) t]
  581.            ["High render"   (pov-render-file "High quality render"   (buffer-file-name) nil) t]
  582.            ["Render"        (pov-render-file "Render"                (buffer-file-name) nil) t]
  583.            ["Cancel"        (pov-render-file "Render"                (buffer-file-name) nil) t]
  584.            ))
  585.        ))
  586.  
  587. (defun pov-toolbar ()
  588.   (interactive)
  589.   (set-specifier default-toolbar (cons (current-buffer) pov-toolbar)))
  590.  
  591. ;; Menubar stuff, buttonmenu will be nice to have too.
  592.  
  593.  
  594. ;; Abbrev support
  595. (defvar pov-mode-abbrev-table nil
  596.   "Abbrev table in use in pov-mode buffers.")
  597. (define-abbrev-table 'pov-mode-abbrev-table ())
  598.  
  599. (cond ((or font-pov-is-XEmacs20-2 font-pov-is-Emacs20)
  600.        (when pov-turn-on-font-lock
  601.          (turn-on-font-lock))
  602.        ;; associate *.pov and *.inc with pov if flag is set and no other
  603.        ;; modes already have
  604.        (cond (pov-associate-pov-and-inc-with-pov-mode-flag
  605.               (when (not (assoc "\\.pov\\'" auto-mode-alist))
  606.                 (setq auto-mode-alist
  607.                       (append '(("\\.pov\\'" . pov-mode)) auto-mode-alist)))
  608.               (when (not (assoc "\\.inc\\'" auto-mode-alist))
  609.                 (setq auto-mode-alist
  610.                       (append '(("\\.inc\\'" . pov-mode)) auto-mode-alist)))))
  611.        ))
  612.  
  613. ;;END AS
  614.  
  615. (defvar font-pov-do-multi-line t
  616.   "*Set this to nil to disable the multi-line fontification prone to infinite loop bugs.")
  617.  
  618. (defun font-pov-setup ()
  619.   "Setup this buffer for PoV font-lock."
  620.   (cond
  621.    ((or font-pov-is-Emacs20 font-pov-is-Emacs21 font-pov-is-Emacs22)
  622.     ;; Tell Font Lock about the support.
  623.     (make-local-variable 'font-lock-defaults))
  624.    ((or font-pov-is-XEmacs19 font-pov-is-XEmacs20)
  625.     ;; Cool patch from Christoph Wedler...
  626.     (let (instance)
  627.       (mapcar (function
  628.                (lambda (property)
  629.                  (setq instance
  630.                        (face-property-instance 'font-pov-number-face property nil 0 t))
  631.                  (if (numberp instance)
  632.                      (setq instance
  633.                            (face-property-instance 'default property nil 0)))
  634.                  ;(or (numberp instance)
  635.                  ;    (set-face-property 'font-lock-string-face property
  636.                 ;                       instance (current-buffer)))))
  637.                  ))
  638.               (built-in-face-specifiers))))
  639.    (font-pov-is-Emacs19
  640.     (make-local-variable 'font-lock-defaults))))
  641.  
  642. (cond
  643.  ((or font-pov-is-Emacs20 font-pov-is-XEmacs20-2 font-pov-is-Emacs21 font-pov-is-Emacs22)
  644.   (defface font-pov-object-face
  645.     '((((class grayscale) (background light)) (:foreground "DimGray" :bold t))
  646.       (((class grayscale) (background dark))  (:foreground "LightGray" :bold t))
  647.       (((class color) (background light))    (:foreground "DarkOliveGreen" :bold t))
  648.       (((class color) (background dark))     (:foreground "White" :bold t ))
  649.       (t (:bold t)))
  650.     "Font Lock mode face used for objects."
  651.     :group 'font-pov-faces)
  652.  
  653.   (defface font-pov-directive-face
  654.     '((((class grayscale) (background light)) (:foreground "DimGray"))
  655.       (((class grayscale) (background dark))  (:foreground "LightGray"))
  656.       (((class color) (background light))     (:foreground "DarkRed"))
  657.       (((class color) (background dark))      (:foreground "lightgreen"))
  658.       (t (:italic t)))
  659.     "Font Lock mode face used to highlight PoV directives."
  660.     :group 'font-pov-faces)
  661.  
  662.   (defface font-pov-number-face
  663.     '((((class grayscale) (background light))(:foreground "DimGray" :underline t))
  664.       (((class grayscale) (background dark)) (:foreground "LightGray" :underline t))
  665.       (((class color) (background light))    (:foreground "SaddleBrown"))
  666.       (((class color) (background dark))     (:foreground "wheat"))
  667.       (t (:underline t)))
  668.     "Font Lock mode face used to highlight numbers in PoV."
  669.     :group 'font-pov-faces)
  670.  
  671.   (defface font-pov-variable-face
  672.     '((((class grayscale) (background light)) (:foreground "DimGray"))
  673.       (((class grayscale) (background dark))  (:foreground "LightGray"))
  674.       (((class color) (background light))     (:foreground "ForestGreen"))
  675.       (((class color) (background dark))      (:foreground "gray80"))
  676.       )
  677.     "Font Lock mode face used to highlight variabledeclarations in PoV."
  678.     :group 'font-pov-faces)
  679.  
  680.   (defface font-pov-csg-face
  681.     '((((class grayscale) (background light)) (:foreground "DimGray"))
  682.       (((class grayscale) (background dark))  (:foreground "LightGray"))
  683.       (((class color) (background light))     (:foreground "Blue"))
  684.       (((class color) (background dark))      (:foreground "red"))
  685.       )
  686.     "Font Lock mode face used to highlight CSGs in PoV."
  687.     :group 'font-pov-faces)
  688.  
  689. ;; -- C.H. --
  690.  
  691.   (defface font-pov-macro-name-face
  692.     '((((class grayscale) (background light)) (:foreground "DimGray" :bold t))
  693.       (((class grayscale) (background dark))  (:foreground "LightGray" :bold t))
  694.       (((class color) (background light))     (:foreground "Blue2" :bold t))
  695.       (((class color) (background dark))      (:foreground "gray80" :bold t))
  696.       )
  697.     "Font Lock mode face used to highlight macro declarations in PoV."
  698.     :group 'font-pov-faces)
  699.  
  700.   (defface font-pov-keyword-face
  701.     '((((class grayscale) (background light)) (:foreground "DimGray"))
  702.       (((class grayscale) (background dark))  (:foreground "LightGray"))
  703.       (((class color) (background light))     (:foreground "Blue4"))
  704.       (((class color) (background dark))      (:foreground "Blue"))
  705.       )
  706.     "Font Lock mode face used to highlight general keywords in PoV."
  707.     :group 'font-pov-faces)
  708.  
  709. ;; -- end C.H. --
  710.  
  711.  
  712.   (defface font-pov-operator-face
  713.     '((((class grayscale)(background light)) (:foreground "DimGray" :bold t))
  714.       (((class grayscale)(background dark))  (:foreground "LightGray" :bold t))
  715.       (((class color)(background light))     (:foreground "Limegreen" :bold t ))
  716.       (((class color)(background dark))      (:foreground "Limegreen" :bold t ))
  717.       (t (:bold t)))
  718.     "Font Lock mode face used to highlight operators in PoV."
  719.     :group 'font-pov-faces))
  720.  
  721.  (font-pov-is-Emacs19
  722.   (unless (assq 'font-pov-variable-face font-lock-face-attributes)
  723.     (cond
  724.      ;; FIXME: Add better conditions for grayscale.
  725.      ((memq font-lock-display-type '(mono monochrome grayscale greyscale
  726.                                           grayshade greyshade))
  727.       (setq font-lock-face-attributes
  728.             (append
  729.              font-lock-face-attributes
  730.              (list '(font-pov-variable-face nil nil t nil nil)
  731.                    '(font-pov-macro-name-face nil nil t nil nil)  ;; C.H.
  732.                    '(font-pov-keyword-face nil nil nil t nil)     ;; C.H.
  733.                    '(font-pov-object-face nil nil nil t nil)
  734.                    '(font-pov-number-face nil nil nil nil t)
  735.                    (list
  736.                     'font-pov-operator-face
  737.                     (cdr (assq 'background-color (frame-parameters)))
  738.                     (cdr (assq 'foreground-color (frame-parameters)))
  739.                     nil nil nil)))))
  740.      ((eq font-lock-background-mode 'light) ; light color background
  741.       (setq font-lock-face-attributes
  742.             (append
  743.              font-lock-face-attributes
  744.              ;;;FIXME: These won't follow font-lock-type-face's changes.
  745.              ;;;       Should I change to a (copy-face) scheme?
  746.              '((font-pov-variable-face "DarkOliveGreen" nil t nil nil)
  747.                (font-pov-macro-name-face "DarkOliveGreen" nil t nil nil)  ;; C.H.
  748.                (font-pov-keyword-face "grey50")                           ;; C.H.
  749.                (font-pov-number-face "DarkOliveGreen" nil nil t nil)
  750.                (font-pov-object-face