Function: prog--text-at-point-p

prog--text-at-point-p is a byte-compiled function defined in prog-mode.el.gz.

Signature

(prog--text-at-point-p)

Documentation

Return non-nil if point is in text (comment or string).

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/prog-mode.el.gz
(defun prog--text-at-point-p ()
  "Return non-nil if point is in text (comment or string)."
  ;; FIXME: For some reason, the comment-start syntax regexp doesn't
  ;; work for me.  But I kept it around to be safe, and in the hope
  ;; that it can cover cases where comment-start-skip is unset.
  (or (nth 8 (syntax-ppss))
      ;; If point is at the beginning of a comment delimiter,
      ;; syntax-ppss doesn't consider point as being inside a
      ;; comment.
      (save-excursion
        (beginning-of-line)
        (and comment-start-skip
             ;; FIXME: This doesn't work for the case where there
             ;; are two matches of comment-start-skip, and the
             ;; first one is, say, inside a string.  We need to
             ;; call re-search-forward repeatedly until either
             ;; reached EOL or (nth 4 (syntax-ppss)) returns
             ;; non-nil.
             (re-search-forward comment-start-skip (pos-eol) t)
             (nth 8 (syntax-ppss))))
      (save-excursion
        (beginning-of-line)
        (and (re-search-forward "\\s-*\\s<" (line-end-position) t)
             (nth 8 (syntax-ppss))))))