Function: fortran-is-in-string-p

fortran-is-in-string-p is a byte-compiled function defined in fortran.el.gz.

Signature

(fortran-is-in-string-p WHERE)

Documentation

Return non-nil if WHERE (a buffer position) is inside a Fortran string.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
;; From: ralf@up3aud1.gwdg.de (Ralf Fassel)
;; Test if TAB format continuation lines work.
(defun fortran-is-in-string-p (where)
  "Return non-nil if WHERE (a buffer position) is inside a Fortran string."
  (save-excursion
    (goto-char where)
    (cond
     ((bolp) nil)                       ; bol is never inside a string
     ((save-excursion                   ; comment lines too
        (beginning-of-line)
        (looking-at fortran-comment-line-start-skip)) nil)
     (t (let ((parse-state '(0 nil nil nil nil nil 0))
              (quoted-comment-start (if comment-start
                                        (regexp-quote comment-start)))
              (not-done t)
              parse-limit end-of-line)
          ;; Move to start of current statement.
          (fortran-next-statement)
          (fortran-previous-statement)
          ;; Now parse up to WHERE.
          (while not-done
            (if (or ;; Skip to next line if:
                 ;; - comment line?
                 (looking-at fortran-comment-line-start-skip)
                 ;; - at end of line?
                 (eolp)
                 ;; - not in a string and after comment-start?
                 (and (not (nth 3 parse-state))
                      comment-start
                      (equal comment-start
                             (char-to-string (preceding-char)))))
                (if (> (forward-line) 0)
                    (setq not-done nil))
              ;; else:
              ;; If we are at beginning of code line, skip any
              ;; whitespace, labels and tab continuation markers.
              (if (bolp) (skip-chars-forward " \t0-9"))
              ;; If we are in column <= 5 now, check for continuation char.
              (cond ((= 5 (current-column)) (forward-char 1))
                    ((and (< (current-column) 5)
                          (equal fortran-continuation-string
                                 (char-to-string (following-char)))
                          (forward-char 1))))
              ;; Find out parse-limit from here.
              (setq end-of-line (line-end-position))
              (setq parse-limit (min where end-of-line))
              ;; Parse max up to comment-start, if non-nil and in current line.
              (if comment-start
                  (save-excursion
                    (if (re-search-forward quoted-comment-start end-of-line t)
                        (setq parse-limit (min (point) parse-limit)))))
              ;; Now parse if still in limits.
              (if (< (point) where)
                  (setq parse-state (parse-partial-sexp
                                     (point) parse-limit nil nil parse-state))
                (setq not-done nil))))
          ;; Result.
          (nth 3 parse-state))))))