1 ;;; vrml-mode.el --- major mode for editing VRML (.wrl) files
3 ;; Copyright (C) 1994 Free Software Foundation, Inc.
4 ;; Copyright (C) 1996 Ben Wing.
6 ;; Author: Ben Wing <ben@xemacs.org>
7 ;; Keywords: languages vrml modes
9 ;; This file is part of XEmacs.
11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Synched up with: Not in FSF.
30 ;; Mostly bastardized from tcl.el.
33 ;; Put the following forms in your .emacs to enable autoloading of VRML
34 ;; mode, and auto-recognition of ".wrl" files.
36 ;; (autoload 'vrml-mode "vrml" "VRML mode." t)
37 ;; (setq auto-mode-alist (append '(("\\.wrl\\'" . vrml-mode))
48 "Major mode for editing VRML (.wrl) files."
52 (defcustom vrml-indent-level 3
53 "*Indentation of VRML statements with respect to containing block."
57 (defcustom vrml-auto-newline nil
58 "*Non-nil means automatically newline before and after braces
59 inserted in VRML code."
63 (defcustom vrml-tab-always-indent t
64 "*Control effect of TAB key.
65 If t (the default), always indent current line.
66 If nil and point is not in the indentation area at the beginning of
67 the line, a TAB is inserted.
68 Other values cause the first possible action from the following list
71 1. Move from beginning of line to correct indentation.
72 2. Delete an empty comment.
73 3. Move forward to start of comment, indenting if necessary.
74 4. Move forward to end of line, indenting if necessary.
75 5. Create an empty comment.
76 6. Move backward to start of comment, indenting if necessary."
77 :type '(choice (const :tag "on" t)
78 (const :tag "off" nil)
79 (sexp :format "%t\n" :tag "The Works" other))
82 (defcustom vrml-use-hairy-comment-detector t
83 "*If not `nil', then the more complicated, but slower, comment
84 detecting function is used."
88 (defvar vrml-mode-abbrev-table nil
89 "Abbrev table used while in VRML mode.")
90 (define-abbrev-table 'vrml-mode-abbrev-table ())
92 (defvar vrml-mode-map ()
93 "Keymap used in VRML mode.")
94 (if (null vrml-mode-map)
96 (setq vrml-mode-map (make-sparse-keymap))
97 (set-keymap-name vrml-mode-map 'vrml-mode-map)
98 (define-key vrml-mode-map "{" 'vrml-electric-brace)
99 (define-key vrml-mode-map "}" 'vrml-electric-brace)
100 (define-key vrml-mode-map "\e\C-q" 'indent-vrml-exp)
101 (define-key vrml-mode-map "\t" 'vrml-indent-command)
102 (define-key vrml-mode-map "\M-;" 'vrml-indent-for-comment)
105 (defvar vrml-mode-syntax-table nil
106 "Syntax table in use in vrml-mode buffers.")
108 (if vrml-mode-syntax-table
110 (setq vrml-mode-syntax-table (make-syntax-table))
111 (modify-syntax-entry ?\n ">" vrml-mode-syntax-table)
112 (modify-syntax-entry ?\f ">" vrml-mode-syntax-table)
113 (modify-syntax-entry ?\# "<" vrml-mode-syntax-table)
114 (modify-syntax-entry ?\\ "\\" vrml-mode-syntax-table)
115 (modify-syntax-entry ?% "_" vrml-mode-syntax-table)
116 (modify-syntax-entry ?@ "_" vrml-mode-syntax-table)
117 (modify-syntax-entry ?& "_" vrml-mode-syntax-table)
118 (modify-syntax-entry ?* "_" vrml-mode-syntax-table)
119 (modify-syntax-entry ?- "_" vrml-mode-syntax-table)
120 (modify-syntax-entry ?: "_" vrml-mode-syntax-table)
121 (modify-syntax-entry ?! "_" vrml-mode-syntax-table)
122 (modify-syntax-entry ?$ "_" vrml-mode-syntax-table)
123 (modify-syntax-entry ?/ "_" vrml-mode-syntax-table)
124 (modify-syntax-entry ?~ "_" vrml-mode-syntax-table)
125 (modify-syntax-entry ?< "_" vrml-mode-syntax-table)
126 (modify-syntax-entry ?= "_" vrml-mode-syntax-table)
127 (modify-syntax-entry ?> "_" vrml-mode-syntax-table)
128 (modify-syntax-entry ?| "_" vrml-mode-syntax-table)
129 (modify-syntax-entry ?+ "." vrml-mode-syntax-table)
130 (modify-syntax-entry ?\' "\"" vrml-mode-syntax-table))
132 (defcustom vrml-mode-hook nil
133 "Hook run on entry to VRML mode."
137 (defvar vrml-keyword-list
140 "AsciiText" "Cone" "Cube" "Cylinder" "IndexedFaceSet" "IndexedLineSet"
142 ; geometry and material nodes:
143 "Coordinate3" "FontStyle" "Info" "LOD" "Material" "MaterialBinding"
144 "Normal" "NormalBinding" "Texture2" "Texture2Transform"
145 "TextureCoordinate2" "ShapeHints"
146 ; transformation nodes:
147 "MatrixTransform" "Rotation" "Scale" "Transform" "Translation"
149 "OrthographicCamera" "PerspectiveCamera"
151 "DirectionalLight" "PointLight" "SpotLight"
153 "Group" "Separator" "Switch" "TransformSeparator" "WWWAnchor"
156 ;new VRML 2.0 nodes (#### not yet classified)
157 "Anchor" "Appearance" "AudioClip" "Background" "Billboard" "Box"
158 "Collision" "Color" "ColorInterpolator" "Coordinate"
159 "CoordinateInterpolator" "CylinderSensor" "DiskSensor" "ElevationGrid"
160 "Extrusion" "Fog" "FontStyle" "ImageTexture" "Inline" "MovieTexture"
161 "NavigationInfo" "NormalInterpolator" "OrientationInterpolator"
162 "PixelTexture" "PlaneSensor" "PositionInterpolator" "ProximitySensor"
163 "ScalarInterpolator" "Script" "Shape" "Sound" "SphereSensor" "Text"
164 "TextureTransform" "TextureCoordinate" "TimeSensor" "TouchSensor"
165 "Viewpoint" "VisibilitySensor" "WorldInfo"
166 ;VRML 2.0 node fields
167 "eventIn" "eventOut" "field" "exposedField"
168 ;misc. VRML 2.0 keywords (DEF, PROTO, EXTERNPROTO handled below)
169 "USE" "ROUTE" "TO" "IS" "TRUE" "FALSE" "NULL"
172 (defconst vrml-font-lock-keywords
174 ;; Names of functions (and other "defining things").
175 (list "\\(DEF\\|PROTO\\|EXTERNPROTO\\)[ \t\n]+\\([^ \t\n]+\\)"
176 2 'font-lock-function-name-face)
178 ;; Keywords. Only recognized if surrounded by whitespace.
179 ;; FIXME consider using "not word or symbol", not
181 (cons (concat "\\(\\s-\\|^\\)\\("
182 ;; FIXME Use regexp-quote?
183 (mapconcat 'identity vrml-keyword-list "\\|")
187 "Keywords to highlight for VRML. See variable `font-lock-keywords'.")
191 "Major mode for editing VRML code.
192 Expression and list commands understand all VRML brackets.
193 Tab indents for VRML code.
194 Paragraphs are separated by blank lines only.
195 Delete converts tabs to spaces as it moves back.
197 Variables controlling indentation style:
199 Indentation of VRML statements within surrounding block.
201 Variables controlling user interaction with mode (see variable
202 documentation for details):
203 vrml-tab-always-indent
204 Controls action of TAB key.
206 Non-nil means automatically newline before and after braces
207 inserted in VRML code.
209 Turning on VRML mode calls the value of the variable `vrml-mode-hook'
210 with no args, if that value is non-nil. Read the documentation for
211 `vrml-mode-hook' to see what kinds of interesting hook functions
217 (kill-all-local-variables)
218 (use-local-map vrml-mode-map)
219 (setq major-mode 'vrml-mode)
220 (setq mode-name "VRML")
221 (setq local-abbrev-table vrml-mode-abbrev-table)
222 (set-syntax-table vrml-mode-syntax-table)
224 (make-local-variable 'paragraph-start)
225 (make-local-variable 'paragraph-separate)
226 (if (fboundp 'move-to-left-margin)
228 ;; In FSF Emacs 19.29 / XEmacs 19.14, you aren't supposed to
229 ;; start these with a ^.
230 (setq paragraph-start "$\\|
\f")
231 (setq paragraph-separate paragraph-start))
232 (setq paragraph-start (concat "^$\\|" page-delimiter))
233 (setq paragraph-separate paragraph-start))
234 (make-local-variable 'paragraph-ignore-fill-prefix)
235 (setq paragraph-ignore-fill-prefix t)
236 (make-local-variable 'fill-paragraph-function)
237 (setq fill-paragraph-function 'vrml-do-fill-paragraph)
239 (make-local-variable 'indent-line-function)
240 (setq indent-line-function 'vrml-indent-line)
241 (make-local-variable 'require-final-newline)
242 (setq require-final-newline t)
244 (make-local-variable 'comment-start)
245 (setq comment-start "# ")
246 (make-local-variable 'comment-start-skip)
247 (setq comment-start-skip "#+ *")
248 (make-local-variable 'comment-column)
249 (setq comment-column 40)
250 (make-local-variable 'comment-end)
251 (setq comment-end "")
253 (make-local-variable 'outline-regexp)
254 (setq outline-regexp "[^\n\^M]")
255 (make-local-variable 'outline-level)
256 (setq outline-level 'vrml-outline-level)
258 (make-local-variable 'font-lock-keywords)
259 (setq font-lock-keywords vrml-font-lock-keywords)
261 (make-local-variable 'parse-sexp-ignore-comments)
262 (setq parse-sexp-ignore-comments t)
264 (make-local-variable 'defun-prompt-regexp)
265 (setq defun-prompt-regexp "^[^ \t\n#}][^\n}]+}*[ \t]+")
267 ;; Settings for new dabbrev code.
268 (make-local-variable 'dabbrev-case-fold-search)
269 (setq dabbrev-case-fold-search nil)
270 (make-local-variable 'dabbrev-case-replace)
271 (setq dabbrev-case-replace nil)
272 (make-local-variable 'dabbrev-abbrev-skip-leading-regexp)
273 (setq dabbrev-abbrev-skip-leading-regexp "[$!]")
274 (make-local-variable 'dabbrev-abbrev-char-regexp)
275 (setq dabbrev-abbrev-char-regexp "\\sw\\|\\s_")
277 (run-hooks 'vrml-mode-hook))
279 ;; This is used for closing braces. If vrml-auto-newline is set, can
280 ;; insert a newline both before and after the brace, depending on
281 ;; context. FIXME should this be configurable? Does anyone use this?
282 (defun vrml-electric-brace (arg)
283 "Insert character and correct line's indentation."
285 ;; If auto-newlining and there is stuff on the same line, insert a
287 (if vrml-auto-newline
290 (skip-chars-backward " \t")
295 ;; In auto-newline case, must insert a newline after each
296 ;; brace. So an explicit loop is needed.
298 (insert last-command-char)
301 (setq arg (1- arg))))
302 (self-insert-command arg))
307 (defun vrml-indent-command (&optional arg)
308 "Indent current line as VRML code, or in some cases insert a tab character.
309 If vrml-tab-always-indent is t (the default), always indent current line.
310 If vrml-tab-always-indent is nil and point is not in the indentation
311 area at the beginning of the line, a TAB is inserted.
312 Other values of vrml-tab-always-indent cause the first possible action
313 from the following list to take place:
315 1. Move from beginning of line to correct indentation.
316 2. Delete an empty comment.
317 3. Move forward to start of comment, indenting if necessary.
318 4. Move forward to end of line, indenting if necessary.
319 5. Create an empty comment.
320 6. Move backward to start of comment, indenting if necessary."
323 ((not vrml-tab-always-indent)
324 ;; Indent if in indentation area, otherwise insert TAB.
325 (if (<= (current-column) (current-indentation))
327 (self-insert-command arg)))
328 ((eq vrml-tab-always-indent t)
332 ;; "Perl-mode" style TAB command.
333 (let* ((ipoint (point))
337 (comment-p (vrml-in-comment)))
339 ((= ipoint (save-excursion
344 ;; If indenting didn't leave us in column 0, go to the
345 ;; indentation. Otherwise leave point at end of line. This
347 (if (= (point) (save-excursion
351 (back-to-indentation)))
352 ((and comment-p (looking-at "[ \t]*$"))
353 ;; Empty comment, so delete it. We also delete any ";"
354 ;; characters at the end of the line. I think this is
355 ;; friendlier, but I don't know how other people will feel.
357 (skip-chars-backward " \t;")
358 (delete-region (point) eolpoint))
359 ((and comment-p (< ipoint (point)))
360 ;; Before comment, so skip to it.
362 (indent-for-comment))
363 ((/= ipoint eolpoint)
364 ;; Go to end of line (since we're not there yet).
369 (vrml-indent-for-comment))
371 ;; Go to start of comment. We don't leave point where it is
372 ;; because we want to skip comment-start-skip.
374 (indent-for-comment)))))))
376 (defun vrml-indent-line ()
377 "Indent current line as VRML code.
378 Return the amount the indentation changed by."
379 (let ((indent (calculate-vrml-indent nil))
381 (case-fold-search nil)
382 (pos (- (point-max) (point))))
385 (cond ((eq indent nil)
386 (setq indent (current-indentation)))
388 (skip-chars-forward " \t")
389 (if (listp indent) (setq indent (car indent)))
390 (cond ((= (following-char) ?})
391 (setq indent (- indent vrml-indent-level)))
392 ((= (following-char) ?\])
393 (setq indent (- indent 1))))))
394 (skip-chars-forward " \t")
395 (setq shift-amt (- indent (current-column)))
396 (if (zerop shift-amt)
397 (if (> (- (point-max) pos) (point))
398 (goto-char (- (point-max) pos)))
399 (delete-region beg (point))
401 ;; If initial point was within line's indentation,
402 ;; position after the indentation. Else stay at same point in text.
403 (if (> (- (point-max) pos) (point))
404 (goto-char (- (point-max) pos))))
407 (defun calculate-vrml-indent (&optional parse-start)
408 "Return appropriate indentation for current line as VRML code.
409 In usual case returns an integer: the column to indent to.
410 Returns nil if line starts inside a string, t if in a comment."
413 (let* ((indent-point (point))
414 (case-fold-search nil)
419 (goto-char parse-start)
420 (beginning-of-defun))
421 (while (< (point) indent-point)
422 (setq parse-start (point))
423 (setq state (parse-partial-sexp (point) indent-point 0))
424 (setq containing-sexp (car (cdr state))))
425 (cond ((or (nth 3 state) (nth 4 state))
426 ;; Inside comment or string. Return nil or t if should
427 ;; not change this line
429 ((null containing-sexp)
430 ;; Line is at top level.
433 (goto-char containing-sexp)
434 (let* ((expr-start (point)))
435 ;; Find the first statement in the block and indent
436 ;; like it. The first statement in the block might be
437 ;; on the same line, so what we do is skip all
438 ;; "virtually blank" lines, looking for a non-blank
439 ;; one. A line is virtually blank if it only contains
440 ;; a comment and whitespace. We do it this funky way
441 ;; because we want to know if we've found a statement
442 ;; on some line _after_ the line holding the sexp
444 (goto-char containing-sexp)
446 (if (and (< (point) indent-point)
447 (looking-at "[ \t]*\\(#.*\\)?$"))
450 (while (and (< (point) indent-point)
451 (looking-at "[ \t]*\\(#.*\\)?$"))
452 (setq found-next-line t)
454 (if (not (or (= (char-after containing-sexp) ?{)
455 (and (= (char-after containing-sexp) ?\[)
457 (goto-char containing-sexp)
458 (skip-chars-backward " \t\n")
460 (looking-at "children")))))
462 ;; Line is continuation line, or the sexp opener
463 ;; is not a curly brace, or we are looking at
464 ;; an `expr' expression (which must be split
465 ;; specially). So indentation is column of first
466 ;; good spot after sexp opener. If there is no
467 ;; nonempty line before the indentation point, we
468 ;; use the column of the character after the sexp
470 (if (>= (point) indent-point)
472 (goto-char containing-sexp)
474 (skip-chars-forward " \t"))
476 ;; After a curly brace, and not a continuation line.
477 ;; So take indentation from first good line after
478 ;; start of block, unless that line is on the same
479 ;; line as the opening brace. In this case use the
480 ;; indentation of the opening brace's line, plus
481 ;; another indent step. If we are in the body part
482 ;; of an "if" or "while" then the indentation is
483 ;; taken from the line holding the start of the
485 (if (and (< (point) indent-point)
487 (current-indentation)
489 (goto-char expr-start)
490 (goto-char containing-sexp))
491 (+ (current-indentation) vrml-indent-level)))))))))
495 (defun indent-vrml-exp ()
496 "Indent each line of the VRML grouping following point."
498 (let ((indent-stack (list nil))
499 (contain-stack (list (point)))
500 (case-fold-search nil)
501 outer-loop-done inner-loop-done state ostate
502 this-indent last-sexp
508 (setq outer-loop-done nil)
509 (while (and (not (eobp)) (not outer-loop-done))
510 (setq last-depth next-depth)
511 ;; Compute how depth changes over this line
512 ;; plus enough other lines to get to one that
513 ;; does not end inside a comment or string.
514 ;; Meanwhile, do appropriate indentation on comment lines.
515 (setq inner-loop-done nil)
516 (while (and (not inner-loop-done)
517 (not (and (eobp) (setq outer-loop-done t))))
519 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
521 (setq next-depth (car state))
522 (if (and (car (cdr (cdr state)))
523 (>= (car (cdr (cdr state))) 0))
524 (setq last-sexp (car (cdr (cdr state)))))
525 (if (or (nth 4 ostate))
527 (if (or (nth 3 state))
529 (setq inner-loop-done t)))
530 (if (<= next-depth 0)
531 (setq outer-loop-done t))
534 ;; If this line had ..))) (((.. in it, pop out of the levels
535 ;; that ended anywhere in this line, even if the final depth
536 ;; doesn't indicate that they ended.
537 (while (> last-depth (nth 6 state))
538 (setq indent-stack (cdr indent-stack)
539 contain-stack (cdr contain-stack)
540 last-depth (1- last-depth)))
541 (if (/= last-depth next-depth)
542 (setq last-sexp nil))
543 ;; Add levels for any parens that were started in this line.
544 (while (< last-depth next-depth)
545 (setq indent-stack (cons nil indent-stack)
546 contain-stack (cons nil contain-stack)
547 last-depth (1+ last-depth)))
548 (if (null (car contain-stack))
549 (setcar contain-stack
550 (or (car (cdr state))
555 (skip-chars-forward " \t")
558 (if (and (car indent-stack)
559 (>= (car indent-stack) 0))
560 ;; Line is on an existing nesting level.
561 (setq this-indent (car indent-stack))
562 ;; Just started a new nesting level.
563 ;; Compute the standard indent for this level.
564 (let ((val (calculate-vrml-indent
565 (if (car indent-stack)
566 (- (car indent-stack))))))
568 (setq this-indent val))
570 (cond ((not (numberp this-indent)))
571 ((= (following-char) ?})
572 (setq this-indent (- this-indent vrml-indent-level)))
573 ((= (following-char) ?\])
574 (setq this-indent (- this-indent 1))))
575 ;; Put chosen indentation into effect.
576 (or (null this-indent)
580 (delete-region (point) (progn (beginning-of-line) (point)))
586 ;; Auto-fill support.
589 (defun vrml-real-command-p ()
590 "Return nil if point is not at the beginning of a command.
591 A command is the first word on an otherwise empty line, or the
592 first word following an opening brace."
594 (skip-chars-backward " \t")
599 ;; Note -- continued comments are not supported here. I
600 ;; consider those to be a wart on the language.
601 (not (eq ?\\ (preceding-char))))
603 (memq (preceding-char) '(?{))))))
605 ;; FIXME doesn't actually return t. See last case.
606 (defun vrml-real-comment-p ()
607 "Return t if point is just after the `#' beginning a real comment.
608 Does not check to see if previous char is actually `#'.
609 A real comment is either at the beginning of the buffer,
610 preceded only by whitespace on the line, or has a preceding
611 semicolon, opening brace, or opening bracket on the same line."
614 (vrml-real-command-p)))
616 (defun vrml-hairy-scan-for-comment (state end always-stop)
617 "Determine if point is in a comment.
618 Returns a list of the form `(FLAG . STATE)'. STATE can be used
619 as input to future invocations. FLAG is nil if not in comment,
620 t otherwise. If in comment, leaves point at beginning of comment.
621 See also `vrml-simple-scan-for-comment', a simpler version that is
623 (let ((bol (save-excursion
629 (while (and (not last-cstart) (< (point) end))
630 (setq real-comment nil) ;In case we've looped around and it is
632 (setq state (parse-partial-sexp (point) end nil nil state t))
635 ;; If ALWAYS-STOP is set, stop even if we don't have a
636 ;; real comment, or if the comment isn't on the same line
638 (if always-stop (setq last-cstart (point)))
639 ;; If we have a real comment, then set the comment
640 ;; starting point if we are on the same line as the ending
642 (setq real-comment (vrml-real-comment-p))
645 (and (> (point) bol) (setq last-cstart (point)))
646 ;; NOTE Emacs 19 has a misfeature whereby calling
647 ;; parse-partial-sexp with COMMENTSTOP set and with
648 ;; an initial list that says point is in a comment
649 ;; will cause an immediate return. So we must skip
650 ;; over the comment ourselves.
651 (beginning-of-line 2)))
652 ;; Frob the state to make it look like we aren't in a
654 (setcar (nthcdr 4 state) nil))))
656 (goto-char last-cstart))
657 (cons real-comment state)))
659 (defun vrml-hairy-in-comment ()
660 "Return t if point is in a comment, and leave point at beginning
662 (let ((save (point)))
664 (car (vrml-hairy-scan-for-comment nil save nil))))
666 (defun vrml-simple-in-comment ()
667 "Return t if point is in comment, and leave point at beginning
668 of comment. This is faster than `vrml-hairy-in-comment', but is
673 (while (and (< (point) save) (not comment))
674 (search-forward "#" save 'move)
675 (setq comment (vrml-real-comment-p)))
678 (defun vrml-in-comment ()
679 "Return t if point is in comment, and leave point at beginning
681 (if vrml-use-hairy-comment-detector
682 (vrml-hairy-in-comment)
683 (vrml-simple-in-comment)))
685 (defun vrml-do-fill-paragraph (ignore)
686 "fill-paragraph function for VRML mode. Only fills in a comment."
687 (let (in-comment col where)
690 (setq in-comment (vrml-in-comment))
693 (setq where (1+ (point)))
694 (setq col (1- (current-column))))))
697 (back-to-indentation)
698 (= col (current-column)))
699 ;; In a comment. Set the fill prefix, and find the paragraph
700 ;; boundaries by searching for lines that look like
701 ;; comment-only lines.
702 (let ((fill-prefix (buffer-substring (progn
709 (while (looking-at "^[ \t]*#")
712 (setq p-start (point)))
716 (while (looking-at "^[ \t]*#")
718 (setq p-end (point)))
720 ;; Narrow and do the fill.
722 (narrow-to-region p-start p-end)
723 (fill-paragraph ignore)))))
726 (defun vrml-do-auto-fill ()
727 "Auto-fill function for VRML mode. Only auto-fills in a comment."
728 (if (> (current-column) fill-column)
729 (let ((fill-prefix "# ")
732 (setq in-comment (vrml-in-comment))
734 (setq col (1- (current-column)))))
739 (back-to-indentation)
740 (delete-region (point) (save-excursion
743 (indent-to-column col)))))))
745 (defun vrml-indent-for-comment ()
746 "Indent this line's comment to comment column, or insert an empty comment.
747 Is smart about syntax of VRML comments.
748 Parts of this were taken from indent-for-comment (simple.el)."
751 (or (vrml-in-comment)
753 ;; Not in a comment, so we have to insert one. Create an
754 ;; empty comment (since there isn't one on this line).
755 (skip-chars-backward " \t")
756 (let ((eolpoint (point)))
758 (if (/= (point) eolpoint)
764 ;; Point is just after the "#" starting a comment. Move it as
766 (let* ((indent (funcall comment-indent-function))
770 (if (/= begpos indent)
772 (skip-chars-backward " \t" (save-excursion
775 (delete-region (point) begpos)
777 (looking-at comment-start-skip) ; Always true.
778 (goto-char (match-end 0))
779 ;; I don't like the effect of the next two.
780 ;;(skip-chars-backward " \t" (match-beginning 0))
781 ;;(skip-chars-backward "^ \t" (match-beginning 0))
785 ;;;###autoload(add-to-list 'auto-mode-alist '("\\.wrl\\'" . vrml-mode))
787 ;;; vrml-mode.el ends here