/
pov-mode.el
2335 lines (2106 loc) · 87.1 KB
/
pov-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; pov-mode.el --- major mode for Povray scene files
;;
;; Author: Peter Boettcher <pwb@andrew.cmu.edu>
;; Maintainer: Marco Pessotto <marco.erika@gmail.com>
;; Created: 04 March 1994
;; Modified: 16 Feb 2008
;; Version: 2.15
;; Keywords: pov, povray
;;
;;
;; LCD Archive Entry:
;; povray|Peter Toneby|woormie@acc.umu.se|
;; Major mode for Povray scene files|
;; 08-Sep-2003|2.10|~/lib/emacs/pov-mode.el|
;;
;; Copyright (C) 1997 Peter W. Boettcher
;;
;;
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;;;
;;; Commentary:
;;
;; This major mode for GNU Emacs provides support for editing Povray
;; scene files, rendering and viewing them. It automatically indents
;; blocks, both {} and #if #end. It also provides context-sensitive
;; keyword completion and font-lock highlighting, as well as the
;; ability to look up those keywords in the povray docu.
;;
;; It should work for either Xemacs or FSF Emacs, versions >= 20;
;; At the present, pov-mode have internal display of picture with Xemacs
;; and GNU Emacs 22
;;
;; To automatically load pov-mode every time Emacs starts up, put the
;; following line into your .emacs file:
;;
;; (require 'pov-mode)
;;
;; or better:
;;
;; (autoload 'pov-mode "/path/to/pov-mode.el" ;; please modify this
;; "PoVray scene file mode" t)
;; (setq auto-mode-alist
;; (append '(("\\.pov$" . pov-mode)
;; ("\\.inc$" . pov-mode))
;; auto-mode-alist))
;;
;; Of course pov-mode has to be somewhere in your load-path for emacs
;; to find it (Use C-h v load-path to see which directories are in the
;; load-path).
;;
;; NOTE: To achieve any sort of reasonable performance, you should
;; byte-compile this package. In emacs, type M-x byte-compile-file
;; and then enter the name of this file.
;;
;; You can customize the behaviour of pov-mode and via the
;; customization menu or by simply entering M-x customize-group pov.
;; So, try this!
;;
;;
;; To learn about the basics, just load a pov-file and press C-h m.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;
;;Modified by: Peter Boettcher <pwb@andrew.cmu.edu>
;; 5/8/97:
;; Added font-lock support for Emacs/XEmacs 19
;; Indent under `#declare Object=' lines
;; Corrected comment syntax
;; Got rid of more remnants from postscript mode
;; General cleanup
;; Arbitrarily chose version 1.2
;; 5/8/97: Version 1.21
;; fontify-insanely was ignored. fixed.
;;
;; 9/24/97: Version 1.3
;; Added indentation for Pov 3 syntax (#if #else, etc)
;; Preliminary context-sensitive keyword completion
;;
;; 1/13/98 by Peter Boettcher <pwb@andrew.cmu.edu>
;; Explicitly placed package under GPL
;; Reorganized comment sections and change log to follow GNU standards
;; Added simple code for jumping to pov documentation (Thanks to
;; Benjamin Strautin <bis@acpub.duke.edu> for this code)
;;
;; Modified by: Peter Toneby <woormie@acc.umu.se>
;; 22/3/99: Version 1.99beata1
;; Added support for Pov3.1s new keywords. (not all, I think...)
;; Removed atmosphere (and atmosphere_*) (stupid me...)
;;
;; Modified by: Peter Toneby <woormie@acc.umu.se>
;; 23/4/99: Version 1.99beata2
;; Added support for all new keyword, BUT
;; Added atmosphere (and atmosphere_*) again
;; Got Pete Boettchers blessing to continue (but with a note
;; that said that I should have talked to him first, I'm sorry
;; for not doing that). Pete also said he was willing to let
;; me continue the maintainance of this file.
;; I can't get the pov-keyword-help to work, anyone with knowledge
;; about elisp can send me a fix for it.
;; The keyword expansion doesn't work for all keywords,
;; I need to add lots of stuff and read through the docs
;; to get everything correct.
;;
;; Modified by: Alexander Schmolck <aschmolck@gmx.de>
;; 2000-01-31: Version 2beataXXX
;; Added working keyword lookup in povuser.txt
;; Added rendering and viewing from within Emacs and with an external viewer
;; Added customization and made installation simpler
;; Added a few other minor details
;;
;; Modified by: Peter Toneby <woormie@acc.umu.se>
;; 2000-05-24: Version 2
;; Changed the keyword lookup a little, povuser.txt didn't open as
;; expected when having set the pov-home-dir and pov-help-file
;; manually.
;;
;; Modified by: Peter Toneby <woormie@acc.umu.se>
;; 2000-08-10: Version 2.5b1
;; Added povray-font-lock-faces.
;; Made sure font-lock works properly on:
;; XEmacs 19.15p7
;; XEmacs 20.0
;; XEmacs 21.1p10
;; Emacs 19.29.1
;; Emacs 20.7.2
;; Added all 3.1 keywords except track, since I don't know what it
;; is, I have also dropped the 3.0 specific keywords that
;; shouldn't be used anymore.
;; Fixed some completion stuff, I think I have added all keywords to
;; the completions.
;; Added configureation for all faces. To bad I can't get the defaults
;; to work properly on dark backgrounds, I don't know why that is.
;; Added a toolbar, it replaces to standard XEmacs toolbar, I think
;; that is the best thing to do, but I retain the standard useful
;; functionality.
;; Fixed an error in the external viewer, it used variables that were
;; not available in the same scope as the sentinel.
;; Added basic imenu support, currently only #local and #declare,
;; but I will try to add objects, cameras and lightsources later.
;; 2000-09-12 Version 2.5.b2
;; Added basic support for megapov
;; Bob Pepin fixed a bug in test to select external/internal viewer.
;; fortsätt på kapitel 5.6
;; 2001-04-05 Version 2.6
;; Added the capability to open standard include files by pressing
;; C-c i. It opens the file entered ro.
;; Fixed leeking color in emacs (Robert Kleemann)
;; Changed the rendertoolbarbutton to show a popup dialog with buttons
;; for the different qualities.
;; 2001-12-07 Version 2.7
;; Fixed font-locks for Emacs 21
;; 2002-06-19 Version 2.8
;; Fixed loading for Emacs 21-2, missed a test for customizations
;; Added most parts of a patch from Christoph Hormann that cleaned
;; up the Regexp mess, and added all (or at least most) of the
;; keywords for 3.5 Parts of that patch are still missing, I'll
;; get around to those sometime...
;; 2002-08-07 Version 2.9
;; Added Insert menu, it uses the directory structure of the winpov
;; insert menu.
;; Moved the toolbar icons out to separate xpm-files.
;; Added some missing keyword expansions
;; Fixed so that box, cylinder... has their own face, object-face,
;; removed unused faces
;; Cleaned up the code, removed unused stuff.
;; It works in versions 21, can't test in 20, font-lock is borked for me.
;; 2002-08-10 Version 2.9.1
;; Fixed so that tollbar icons are searched for, not hard coded.
;; 2003-08-29 Version 2.10
;; Fixed references to povray.el.
;; Fixed cut-n-pasted comment for font-pov-operator-face.
;; Fixed the insert menus, they missed the last items, thanks to Hartwig
;; Bosse for the heads up, and a fix.
;; 2003-08-29 Version 2.11 (This is a future version)
;; Fix a bug with rendering so that the active buffer is changed to the
;; correct buffer, found by Hartwig Bosse.
;;
;; Modified by: Marco Pessotto <marco.erika@gmail.com>
;; 2008-01-05
;; Workaround for Emacs 22 (on which pov-mode was not working)
;; 2008-02-10
;; Really fix the defcustom menu for faces
;; Upgraded to GPL 3
;; Provides a setup.sh script that fixes some vars
;; 2008-02-11
;; Added internal view for GNU Emacs 22
;; 2008-02-13
;; Fixed faces to be consistent with other languages
;; (as much as possible). If you don't like, customize it via
;; M-x customize-group pov. Beware! It has not been tested on Xemacs
;; nor earlier versions of GNU emacs
;; 2008-02-16 Version 2.14
;; Rewrited from scratch the pov-keyword-help function
;; and commented out the old one, because the povuser.txt no more
;; exists. Now the pov-mode.el open an external browser to find
;; the documentation. Try this and let me know! Browser can be
;; choosen in the M-x customize-group pov menu. However, don't
;; modify the name of directory and file names if this feature
;; works. You'll mess up things. This has been tested on the
;; documentation for pov-ray 3.6 (official binaries for linux).
;; Your documentation (for Mac or for previous or later version
;; of PoV-ray) may be somewhere else. Please let me know.
;; 2008-02-17 Version 2.15
;; Created the tool-bar for GNU Emacs 22.1 (and maybe for previous releases
;; If you are running GNU Emacs < 22 and the toolbar works (with 2 icons,
;; for view and for rendering, let me know)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Original Author: Kevin O. Grover <grover@isri.unlv.edu>
;; Cre Date: 04 March 1994
;; This file derived from postscript mode by Chris Maio
;;
;; Please send bug reports/comments/suggestions and of course patches to
;; Marco Pessotto
;; marco.erika@gmail.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; TODO list: ==OLD==
;; * Vector operations (add <0, .5, 1> to every vector in region)
;; * Clean up completion code
;; * TAGS, to jump to #declared objects elsewhere in the code
;; * c-mode like electric parens (?)
;; * clean up viewing and rendering code
;; * should render or view be decided on filedates? If so, what
;; image file-name extensions should be checked?
;; I think PNG is default for UNIX, not sure. ;; It is
;; I could make this a customizeation option.
;; * imenu support
;; started, but needs to be fixed so it handles nested menus.
;; * Make sure the scopes are correct
;; * Make hooks for menus, so they are userselectable
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO list (mp)
;; * portability
;; * upgrade to PoV-ray 3.6
;; *fix the bug with: Mark set
;; imenu--truncate-items: Wrong type argument: listp, 635
;; imenu--cleanup: Wrong type argument: listp, 635
;; Auto-saving...
;; Workaround: setq pov-imenu-only-macros t (via M-x customize)
;;;; Better safe than sorry, lets fail if you are using a (very?) old
;; version of (X)Emacs.
(if (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version)))
(and (= emacs-major-version 19) (< emacs-minor-version 14))
(and (= emacs-major-version 19) (< emacs-minor-version 29)))
(error "`font-pov' was written for Emacs 19.29/XEmacs 19.14 or later"))
(defvar font-pov-is-XEmacs19
(and (not (null (save-match-data
(string-match "XEmacs\\|Lucid" emacs-version))))
(= 19 emacs-major-version)))
(defvar font-pov-is-XEmacs20
(and (not (null (save-match-data
(string-match "XEmacs\\|Lucid" emacs-version))))
(<= 20 emacs-major-version)))
(defvar font-pov-is-XEmacs21
(and (not (null (save-match-data
(string-match "XEmacs\\|Lucid" emacs-version))))
(<= 21 emacs-major-version)))
(defvar font-pov-is-XEmacs20-2
(or (and font-pov-is-XEmacs20 (<= 2 emacs-minor-version))
font-pov-is-XEmacs21))
(defvar font-pov-is-Emacs19
(and (not font-pov-is-XEmacs19)
(not font-pov-is-XEmacs20)
(= 19 emacs-major-version)))
(defvar font-pov-is-Emacs20
(and (not font-pov-is-XEmacs19)
(not font-pov-is-XEmacs20)
(= 20 emacs-major-version)))
(defvar font-pov-is-Emacs21
(and (not font-pov-is-XEmacs19)
(not font-pov-is-XEmacs20)
(not font-pov-is-XEmacs21)
(= 21 emacs-major-version)))
(defvar font-pov-is-Emacs22
(and (not font-pov-is-XEmacs19)
(not font-pov-is-XEmacs20)
(not font-pov-is-XEmacs21)
(= 22 emacs-major-version)))
(defvar font-pov-is-Emacs
(or font-pov-is-Emacs19
font-pov-is-Emacs20
font-pov-is-Emacs21
font-pov-is-Emacs22))
;;; font-pov-is-Emacs returns t, font-pov-is-Emacs22 t, anything else nil
(require 'cl)
(require 'font-lock) ;;[TODO] Not nice to reqire it, the user should
;; have a choise...
(defconst pov-mode-version '2.15 ;; this is the only occurence
"The povray mode version.")
(defvar pov-tab-width 8)
(defvar pov-autoindent-endblocks t)
;;Create fontfaces
;;(defvar font-pov-number-face 'font-pov-number-face
;; "Face to use for PoV numbers.")
;;
;;(defvar font-pov-variable-face 'font-pov-variable-face
;; "Face to use for PoV variables.")
;;
;;(defvar font-pov-directive-face 'font-pov-directive-face
;; "Face to use for PoV directives.")
;;
;;(defvar font-pov-object-face 'font-pov-object-face
;; "Face to use for PoV objects.") ;; we define this variable later. Why here?
;;
;(defvar font-pov-object-modifier-face 'font-pov-object-modifier-face
; "Face to use for PoV objects.")
;(defvar font-pov-texture-face 'font-pov-texture-face
; "Face to use for PoV objects.")
;;(defvar font-pov-csg-face 'font-pov-csg-face
;; "Face to use for PoV csg keywords.")
;;
;(defvar font-pov-string-face nil
; "Face to use for strings. This is set by font-PoV.")
;; (defvar font-pov-macro-name-face nil
;; "Face to use for strings. This is set by font-PoV.")
;;(defvar font-pov-keyword-face nil
;; "Face to use for misc keywords. This is set by font-PoV.")
;;
; Seems like Emacs lacks these functions (locate-data-[directory|file])...
;; MP: I don't use these functions because I set it externally with the setup.sh script
;; I'm going to comment out this
;; (unless (fboundp 'locate-data-directory)
;; (defun locate-data-directory (name &optional dirs)
;; (if dirs
;; (if (file-directory-p (expand-file-name name (car dirs)))
;; (expand-file-name name (car dirs))
;; (locate-data-directory name (cdr dirs)))
;; (expand-file-name name data-directory))))
;;
;; (unless (fboundp 'locate-data-file)
;; (defun locate-data-file (name &optional dirs)
;; (print dirs)
;; (if dirs
;; (if (file-regular-p (expand-file-name name (car dirs)))
;; (expand-file-name name (car dirs))
;; (locate-data-file name (cdr dirs)))
;; (expand-file-name name data-directory))))
;;
;; This is because FSFEmacs has a ridiculusly low max-lisp-eval-depth
(when (> 1000 max-lisp-eval-depth)
(customize-set-value 'max-lisp-eval-depth 1000))
;; Yup XEmacs didn't get cutomizations until 20.2.
;; I'm going to drop emacsen that don't support customizations
(cond ((or font-pov-is-XEmacs20-2 (or font-pov-is-Emacs20 font-pov-is-Emacs21 font-pov-is-Emacs22))
(defgroup pov nil
"*Major mode for editing povray 3.X scence files <http://www.povray.org>."
:group 'languages)
(defcustom povray-command "povray"
"*Command used to invoke the povray."
:type 'string
:group 'pov)
(defcustom pov-external-viewer-command "display" ;; It seems that ImageMagick is quite popular
"*The external viewer to call."
:type 'string
:group 'pov)
(defcustom pov-external-view-options "%s"
"*The options for the viewer; %s is replaced with the name of the rendered image."
:type 'string
:group 'pov)
(defcustom pov-default-view-internal t
"*Should the pictures be displayed internally by default?"
:type 'boolean
:group 'pov
)
(defcustom pov-run-default "+i%s"
"*The default options for the Render command (%s is replaced by the filename)."
:type 'string
:group 'pov
)
(defcustom pov-run-test "res120 -Q3 +i%s"
"*The default options for the Test Render command (%s is replaced by the filename)."
:type 'string
:group 'pov
)
(defcustom pov-run-low "res320 +i%s"
"*The default options for the Test Render command (%s is replaced by the filename)."
:type 'string
:group 'pov
)
(defcustom pov-run-mid "res640 +i%s"
"*The default options for the Medium Res Render command (%s is replaced by the filename)."
:type 'string
:group 'pov
)
(defcustom pov-run-high "res800 +i%s"
"*The default options for the High Res Render command (%s is replaced by the filename)."
:type 'string
:group 'pov
)
(defcustom pov-run-highest "res1k +i%s"
"*The default options for the Higest Res Render command (%s is replaced by the filename)."
:type 'string
:group 'pov
)
(defcustom pov-icons-location "EMACSLISPLIBRARY/"
"*Location of the menubaricons."
:type 'directory
:group 'pov
)
(defcustom pov-insertmenu-location "EMACSLISPLIBRARY/InsertMenu/"
"*Path to the InsertMenu directory"
:type 'directory
:group 'pov
)
(defcustom pov-external-browser "firefox"
"*The name of the command for the external browser"
:type 'string
:group 'pov
)
(defvar pov-external-view
"External view")
(defvar pov-internal-view
"Internal view")
(defvar pov-command-alist (list (list "Render"
povray-command pov-run-default
'()) ;history for the command
(list "Test quality render"
povray-command pov-run-test
'())
(list "Low quality render"
povray-command pov-run-low
'())
(list "Medium quality render"
povray-command pov-run-mid
'())
(list "High quality render"
povray-command pov-run-high
'())
(list "Highest quality render"
povray-command pov-run-highest
'())
(list pov-external-view
pov-external-viewer-command
pov-external-view-options
'())
(list pov-internal-view
(list pov-internal-view)
'()))
"the commands to run")
;;;;;;;; fix fix fix me ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcustom pov-home-dir "SHARELIBSPOVRAY/"
"*The directory in which the povray files reside."
:type 'directory
:group 'pov)
(defcustom pov-include-dir "SHARELIBSPOVRAY/include/"
"*The directory in which the povray includefiles reside."
:type 'directory
:group 'pov)
(defcustom pov-documentation-directory "POVRAYHTMLDOCDIR/"
"*The directory that contains the html documentation of povray"
:type 'directory
:group 'pov
)
(defcustom pov-documentation-index "idx.html"
"This file sould contain the general index for *all* the documentation"
:type 'file
:group 'pov
)
(defcustom pov-documentation-keyword-index "s_97.html"
"*This file (tested on povlinux-3.6) should contain the index for the keywords (section 3)"
:type 'file
:group 'pov
)
;; (defcustom pov-help-file "povuser.txt"
;; "*The name of the helpfile." ; but there is not a helpfile anymore
;; :type 'file
;; :group 'pov)
(defcustom pov-associate-pov-and-inc-with-pov-mode-flag t
"*If t then files ending with .pov and .inc will automatically start
pov-mode when loaded, unless those file-endings are already in use."
:type 'boolean
:group 'pov)
(defcustom pov-fontify-insanely t
"*Non-nil means colorize every povray keyword.
This may take a while on large files. Maybe disable this on slow systems."
:type 'boolean
:group 'pov)
(defcustom pov-imenu-in-menu t
"*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."
:type 'boolean
:group 'pov)
;; this maybe mess up things FIX-ME
;; CH
(defcustom pov-imenu-only-macros t
"*Non-nil means to restrict imenu to macro declarations."
:type 'boolean
:group 'pov)
;; /end CH
(defcustom pov-indent-level 2
"*Indentation to be used inside of PoVray blocks or arrays."
:type 'integer
:group 'pov)
(defcustom pov-autoindent-endblocks t
"*When non-nil, automatically reindents when you type break,
end, or else."
:type 'boolean
:group 'pov
)
(defcustom pov-indent-under-declare 2
"*Indentation under a `#declare Object=' line."
:type 'integer
:group 'pov)
(defcustom pov-tab-width 8
"*Tab stop width for PoV mode."
:type 'integer
:group 'pov)
(defcustom pov-turn-on-font-lock t
"*Turn on syntax highlighting automatically"
:type 'boolean
:group 'pov)
(defcustom font-pov-csg-face 'font-lock-function-name-face
"*What color does CSG-object have. Also try
font-pov-csg-face"
:type 'face
:group 'pov)
(defcustom font-pov-object-face 'font-lock-type-face
"*What color does objects have. Also try
font-pov-object-face"
:type 'face
:group 'pov)
(defcustom font-pov-variable-face 'font-lock-variable-name-face ; should
; be
; OK
"*What color does variables (in declarations) have. Also try
font-pov-variable-face"
:type 'face
:group 'pov)
(defcustom font-pov-macro-name-face 'default
"*Face to use for #macro names. Just black and white. Try also
font-pov-macro-name-face"
:type 'face
:group 'pov
)
(defcustom font-pov-operator-face 'default
"*Face to use for PoV operators. Just black and white. You should try
font-pov-operator-face or font-lock-builtin-face to get the most of the
syntax coloring "
:type 'face
:group 'pov)
(defcustom font-pov-directive-face 'font-lock-preprocessor-face ; OK
"*What color does (#)-directives have. Also try
font-pov-directive-face"
:type 'face
:group 'pov)
(defcustom font-pov-number-face 'default
"*What color does numbers have. Just black and white. Try
font-pov-number-face or font-lock-constant-face to view colored number"
:type 'face
:group 'pov)
(defcustom font-pov-keyword-face 'font-lock-keyword-face
"*What color does keywords have. Also try
font-pov-keyword-face"
:type 'face
:group 'pov)
)
)
; (defcustom font-pov-string-face t
; "*What color does strings have"
; :type 'face
; :group 'pov)
; (defcustom font-pov-texture-face t
; "*What color does textures have"
; :type 'face
; :group 'pov)
; (defcustom font-pov-object-modifier-face t
; "*What color does object modifiers have"
; :type 'face
; :group 'pov)
;; (if font-pov-standard-colors
;; (setq font-pov-keyword-face 'font-lock-keyword-face
;; font-pov-object-face 'font-lock-function-name-face))
;; `(,pov-comment-face-regexp 0 font-lock-comment-face) OK
;; `(,pov-object-face-regexp 1 font-lock-function-name-face)
;; `(,pov-constant-face-regexp 0 font-lock-constant-face)
;; `(,pov-include-face-regexp 1 font-lock-include-face)
;; `(,pov-define-face-regexp 0 font-lock-reference-face)
;; `(,pov-keyword-face-regexp 1 font-lock-keyword-face) ok
; Find where the menubar icons are placed, should be where pov-mode is...
;; (setq pov-icons-location
;; (file-name-directory (locate-data-file "povrender.xpm"
;; (cons (file-name-directory (locate-library "pov-mode"))
;; (if font-pov-is-Emacs data-directory data-directory-list)))))
;; Lets play with the Toolbar, we want to add buttons for
;; rendering and showing images, lets place them on the rightmost
;; position of the toolbar.
(cond ((or font-pov-is-XEmacs20 font-pov-is-XEmacs21) ;; this is only for Xemacs
(defvar toolbar-render-icon
(if (featurep 'xpm)
(let ((rendericon (concat pov-icons-location "povrender.xpm")))
(toolbar-make-button-list (make-image-instance (vector 'xpm :file rendericon))))
))
(defvar toolbar-look-icon
(if (featurep 'xpm)
(let ((viewicon (concat pov-icons-location "povview.xpm")))
(toolbar-make-button-list (make-image-instance (vector 'xpm :file viewicon))))
))
(defvar pov-toolbar
'(
[toolbar-file-icon toolbar-open t "Open a file"]
[toolbar-folder-icon toolbar-dired t "Edit a directory"]
[toolbar-disk-icon toolbar-save t "Save buffer"]
[toolbar-printer-icon toolbar-print t "Print buffer"]
[toolbar-cut-icon toolbar-cut t "Kill region"]
[toolbar-copy-icon toolbar-copy t "Copy region"]
[toolbar-paste-icon toolbar-paste t "Paste from clipboard"]
[toolbar-undo-icon toolbar-undo t "Undo edit"]
[toolbar-spell-icon toolbar-ispell t "Check spelling"]
[toolbar-replace-icon toolbar-replace t "Search & Replace"]
nil
[toolbar-render-icon (pov-render-dialog) t "Configured Render the file"]
; [toolbar-render-icon
; (pov-render-file "Render" (buffer-file-name) nil)
; t "Quick Render the file"]
[toolbar-look-icon
(if pov-default-view-internal
(pov-display-image-xemacs pov-image-file)
(pov-display-image-externally pov-image-file nil))o
t "Show the rendered file"]
))
(defvar pov-render-dialog-desc
'("Render Image"
["Test render" (pov-render-file "Test quality render" (buffer-file-name) nil) t]
["Low render" (pov-render-file "Low quality render" (buffer-file-name) nil) t]
["Medium render" (pov-render-file "Medium quality render" (buffer-file-name) nil) t]
["High render" (pov-render-file "High quality render" (buffer-file-name) nil) t]
["Render" (pov-render-file "Render" (buffer-file-name) nil) t]
["Cancel" (pov-render-file "Render" (buffer-file-name) nil) t]
))
)
;;;;;;;;; SHALL WE BREAK? ;;;;;;;;;;;;;;
;; ((font-pov-is-Emacs22)
;; (defvar toolbar-render-icon
;; (if (featurep 'xpm)
;; (let ((rendericon (concat pov-icons-location "povrender.xpm")))
;; (toolbar-make-button-list (make-image-instance (vector 'xpm :file rendericon))))
;; ))
;; (defvar toolbar-look-icon
;; (if (featurep 'xpm)
;; (let ((viewicon (concat pov-icons-location "povview.xpm")))
;; (toolbar-make-button-list (make-image-instance (vector 'xpm :file viewicon))))
;; ))
;; (defvar pov-toolbar
;; '(
;; [toolbar-file-icon toolbar-open t "Open a file"]
;; [toolbar-folder-icon toolbar-dired t "Edit a directory"]
;; [toolbar-disk-icon toolbar-save t "Save buffer"]
;; [toolbar-printer-icon toolbar-print t "Print buffer"]
;; [toolbar-cut-icon toolbar-cut t "Kill region"]
;; [toolbar-copy-icon toolbar-copy t "Copy region"]
;; [toolbar-paste-icon toolbar-paste t "Paste from clipboard"]
;; [toolbar-undo-icon toolbar-undo t "Undo edit"]
;; [toolbar-spell-icon toolbar-ispell t "Check spelling"]
;; [toolbar-replace-icon toolbar-replace t "Search & Replace"]
;; nil
;; [toolbar-render-icon (pov-render-dialog) t "Configured Render the file"]
;;; [toolbar-render-icon
;;; (pov-render-file "Render" (buffer-file-name) nil)
;;; t "Quick Render the file"]
;; [toolbar-look-icon
;; (if pov-default-view-internal
;; (pov-display-image-xemacs pov-image-file)
;; (pov-display-image-externally pov-image-file nil))
;; t "Show the rendered file"]
;; ))
;; (defvar pov-render-dialog-desc
;; '("Render Image"
;; ["Test render" (pov-render-file "Test quality render" (buffer-file-name) nil) t]
;; ["Low render" (pov-render-file "Low quality render" (buffer-file-name) nil) t]
;; ["Medium render" (pov-render-file "Medium quality render" (buffer-file-name) nil) t]
;; ["High render" (pov-render-file "High quality render" (buffer-file-name) nil) t]
;; ["Render" (pov-render-file "Render" (buffer-file-name) nil) t]
;; ["Cancel" (pov-render-file "Render" (buffer-file-name) nil) t]
;; ))
;; ))
;;
) ; end cond
(defun pov-toolbar ()
(interactive)
(set-specifier default-toolbar (cons (current-buffer) pov-toolbar)))
;; Menubar stuff, buttonmenu will be nice to have too.
;; Abbrev support
(defvar pov-mode-abbrev-table nil
"Abbrev table in use in pov-mode buffers.")
(define-abbrev-table 'pov-mode-abbrev-table ())
(cond ((or font-pov-is-XEmacs20-2 font-pov-is-Emacs20)
(when pov-turn-on-font-lock
(turn-on-font-lock))
;; associate *.pov and *.inc with pov if flag is set and no other
;; modes already have
(cond (pov-associate-pov-and-inc-with-pov-mode-flag
(when (not (assoc "\\.pov\\'" auto-mode-alist))
(setq auto-mode-alist
(append '(("\\.pov\\'" . pov-mode)) auto-mode-alist)))
(when (not (assoc "\\.inc\\'" auto-mode-alist))
(setq auto-mode-alist
(append '(("\\.inc\\'" . pov-mode)) auto-mode-alist)))))
))
;;END AS
(defvar font-pov-do-multi-line t
"*Set this to nil to disable the multi-line fontification prone to infinite loop bugs.")
(defun font-pov-setup ()
"Setup this buffer for PoV font-lock."
(cond
((or font-pov-is-Emacs20 font-pov-is-Emacs21 font-pov-is-Emacs22)
;; Tell Font Lock about the support.
(make-local-variable 'font-lock-defaults))
((or font-pov-is-XEmacs19 font-pov-is-XEmacs20)
;; Cool patch from Christoph Wedler...
(let (instance)
(mapcar (function
(lambda (property)
(setq instance
(face-property-instance 'font-pov-number-face property nil 0 t))
(if (numberp instance)
(setq instance
(face-property-instance 'default property nil 0)))
;(or (numberp instance)
; (set-face-property 'font-lock-string-face property
; instance (current-buffer)))))
))
(built-in-face-specifiers))))
(font-pov-is-Emacs19
(make-local-variable 'font-lock-defaults))))
(cond
((or font-pov-is-Emacs20 font-pov-is-XEmacs20-2 font-pov-is-Emacs21 font-pov-is-Emacs22)
(defface font-pov-object-face
'((((class grayscale) (background light)) (:foreground "DimGray" :bold t))
(((class grayscale) (background dark)) (:foreground "LightGray" :bold t))
(((class color) (background light)) (:foreground "DarkOliveGreen" :bold t))
(((class color) (background dark)) (:foreground "White" :bold t ))
(t (:bold t)))
"Font Lock mode face used for objects."
:group 'font-pov-faces)
(defface font-pov-directive-face
'((((class grayscale) (background light)) (:foreground "DimGray"))
(((class grayscale) (background dark)) (:foreground "LightGray"))
(((class color) (background light)) (:foreground "DarkRed"))
(((class color) (background dark)) (:foreground "lightgreen"))
(t (:italic t)))
"Font Lock mode face used to highlight PoV directives."
:group 'font-pov-faces)
(defface font-pov-number-face
'((((class grayscale) (background light))(:foreground "DimGray" :underline t))
(((class grayscale) (background dark)) (:foreground "LightGray" :underline t))
(((class color) (background light)) (:foreground "SaddleBrown"))
(((class color) (background dark)) (:foreground "wheat"))
(t (:underline t)))
"Font Lock mode face used to highlight numbers in PoV."
:group 'font-pov-faces)
(defface font-pov-variable-face
'((((class grayscale) (background light)) (:foreground "DimGray"))
(((class grayscale) (background dark)) (:foreground "LightGray"))
(((class color) (background light)) (:foreground "ForestGreen"))
(((class color) (background dark)) (:foreground "gray80"))
)
"Font Lock mode face used to highlight variabledeclarations in PoV."
:group 'font-pov-faces)
(defface font-pov-csg-face
'((((class grayscale) (background light)) (:foreground "DimGray"))
(((class grayscale) (background dark)) (:foreground "LightGray"))
(((class color) (background light)) (:foreground "Blue"))
(((class color) (background dark)) (:foreground "red"))
)
"Font Lock mode face used to highlight CSGs in PoV."
:group 'font-pov-faces)
;; -- C.H. --
(defface font-pov-macro-name-face
'((((class grayscale) (background light)) (:foreground "DimGray" :bold t))
(((class grayscale) (background dark)) (:foreground "LightGray" :bold t))
(((class color) (background light)) (:foreground "Blue2" :bold t))
(((class color) (background dark)) (:foreground "gray80" :bold t))
)
"Font Lock mode face used to highlight macro declarations in PoV."
:group 'font-pov-faces)
(defface font-pov-keyword-face
'((((class grayscale) (background light)) (:foreground "DimGray"))
(((class grayscale) (background dark)) (:foreground "LightGray"))
(((class color) (background light)) (:foreground "Blue4"))
(((class color) (background dark)) (:foreground "Blue"))
)
"Font Lock mode face used to highlight general keywords in PoV."
:group 'font-pov-faces)
;; -- end C.H. --
(defface font-pov-operator-face
'((((class grayscale)(background light)) (:foreground "DimGray" :bold t))
(((class grayscale)(background dark)) (:foreground "LightGray" :bold t))
(((class color)(background light)) (:foreground "Limegreen" :bold t ))
(((class color)(background dark)) (:foreground "Limegreen" :bold t ))
(t (:bold t)))
"Font Lock mode face used to highlight operators in PoV."
:group 'font-pov-faces))
(font-pov-is-Emacs19
(unless (assq 'font-pov-variable-face font-lock-face-attributes)
(cond
;; FIXME: Add better conditions for grayscale.
((memq font-lock-display-type '(mono monochrome grayscale greyscale
grayshade greyshade))
(setq font-lock-face-attributes
(append
font-lock-face-attributes
(list '(font-pov-variable-face nil nil t nil nil)
'(font-pov-macro-name-face nil nil t nil nil) ;; C.H.
'(font-pov-keyword-face nil nil nil t nil) ;; C.H.
'(font-pov-object-face nil nil nil t nil)
'(font-pov-number-face nil nil nil nil t)
(list
'font-pov-operator-face
(cdr (assq 'background-color (frame-parameters)))
(cdr (assq 'foreground-color (frame-parameters)))
nil nil nil)))))
((eq font-lock-background-mode 'light) ; light color background
(setq font-lock-face-attributes
(append
font-lock-face-attributes
;;;FIXME: These won't follow font-lock-type-face's changes.
;;; Should I change to a (copy-face) scheme?
'((font-pov-variable-face "DarkOliveGreen" nil t nil nil)
(font-pov-macro-name-face "DarkOliveGreen" nil t nil nil) ;; C.H.
(font-pov-keyword-face "grey50") ;; C.H.
(font-pov-number-face "DarkOliveGreen" nil nil t nil)
(font-pov-object-face "grey50")
(font-pov-directive-face "red" nil t nil nil)))))
(t ; dark color background
(setq font-lock-face-attributes
(append
font-lock-face-attributes
'((font-pov-varible-face "OliveDrab" nil t nil nil)
(font-pov-macro-name-face "OliveDrab" nil t nil nil) ;; C.H.
(font-pov-keyword-face "grey60") ;; C.H.
(font-pov-number-face "OliveDrab" nil nil t nil)
;; good are > LightSeaGreen, LightCoral, coral, orchid, orange
(font-pov-object-face "grey60")
(font-pov-directive-face "red" nil t nil nil))))))))
(t
;;; XEmacs < version 20.2
(make-face 'font-pov-variable-face "Face to use for PoV variables.")
(make-face 'font-pov-macro-name-face "Face to use for PoV macros.") ;; C.H.
(make-face 'font-pov-keyword-face "Face to use for PoV keywords.") ;; C.H.
(make-face 'font-pov-directive-face "Face to use for PoV directives.")
(make-face 'font-pov-number-face "Face to use for PoV numbers.")
(make-face 'font-pov-operator-face "Face to use for PoV operators.")
(make-face 'font-pov-csg-face "Face to use for PoV csg.")
(make-face 'font-pov-object-face "Face to use for PoV objects.")
(make-face-bold 'font-pov-object-face)
;; XEmacs uses a tag-list thingy to determine if we are using color
;; or mono (and I assume a dark background).
(set-face-foreground 'font-pov-object-face "green4" 'global nil 'append)
(set-face-foreground 'font-pov-number-face "green" 'global nil 'append)
(set-face-foreground 'font-pov-variable-face "red" 'global nil 'append)
(set-face-foreground 'font-pov-macro-name-face "blue2" 'global nil 'append) ;; C.H.
(set-face-foreground 'font-pov-keyword-face "blue4" 'global nil 'append) ;; C.H.
))
(font-pov-setup) ;; Setup and register the fonts...
(defun pov-make-tabs (stop)
(and (< stop 132) (cons stop (pov-make-tabs (+ stop pov-tab-width)))))
(defconst pov-tab-stop-list (pov-make-tabs pov-tab-width)
"Tab stop list for PoV mode")
(defvar pov-mode-map nil
"Keymap used in PoV mode buffers")
(defvar pov-mode-syntax-table nil
"PoV mode syntax table")
(defconst pov-comment-start-regexp "//\\|/\\*"
"Dual comment value for `comment-start-regexp'.")
(defvar pov-comment-syntax-string ". 124b"
"PoV hack to handle Emacs/XEmacs foo")
(defvar pov-begin-re "\\<#\\(if\\(n?def\\)?\\|case\\|range\\|switch\\|while\\)\\>")
(defvar pov-end-re "\\<#break\\|#end\\>")
(defvar pov-else-re "\\<#else\\>")
(defvar pov-begin-end-re (concat
pov-begin-re
"\\|"
pov-end-re
"\\|"
pov-else-re))
(defun pov-setup-syntax-table nil
(if (or (string-match "Lucid" emacs-version)
(string-match "XEmacs" emacs-version))
(setq pov-comment-syntax-string ". 1456"))
(if pov-mode-syntax-table