Function: simula-skip-comment-backward

simula-skip-comment-backward is an interactive and byte-compiled function defined in simula.el.gz.

Signature

(simula-skip-comment-backward &optional STOP-AT-END)

Documentation

Search towards bob to find first char that is outside a comment.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/simula.el.gz
(defun simula-skip-comment-backward (&optional stop-at-end)
  "Search towards bob to find first char that is outside a comment."
  (interactive)
  (catch 'simula-out
    (let (context)
      (while t
	(skip-chars-backward " \t\n\f")
	(if (eq (preceding-char) ?\;)
	    (save-excursion
	      (backward-char 1)
	      (setq context (simula-context))
	      (if (and stop-at-end (eq context 2))
		  (setq context nil)))
	  (setq context (simula-context)))
	(cond
	 ((memq context '(nil 3 4))
	  ;; check to see if we found a label
	  (if (and (eq (preceding-char) ?:)
		   (not (memq (following-char) '(?- ?=)))
		   (save-excursion
		     (skip-chars-backward ": \t\fa-zA-Z0-9_")
		     (not (looking-at "virtual\\>"))))
	      (skip-chars-backward ": \t\fa-zA-Z0-9_")
	    (throw 'simula-out nil)))
	 ((eq context 0)
	  ;; since we are inside a comment, it must start somewhere!
	  (while (and (re-search-backward "!\\|\\<comment\\>")
		      (memq (simula-context) '(0 1)))))
	 ((eq context 1)
	  (beginning-of-line)
	  (if (bobp)
	      (throw 'simula-out nil)
	    (backward-char)))
	 ((eq context 2)
	  ;; an END-comment must belong to an END
	  (re-search-backward "\\<end\\>")
	  (forward-word-strictly 1)
	  (throw 'simula-out nil))
	 ;; should be impossible to get here..
	 )))))