Function: c-before-change-check-ml-strings

c-before-change-check-ml-strings is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-before-change-check-ml-strings BEG END)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-before-change-check-ml-strings (beg end)
  ;; This function clears `syntax-table' text properties from multi-line
  ;; strings whose delimiters are about to change in the region (c-new-BEG
  ;; c-new-END).  BEG and END are the standard arguments supplied to any
  ;; before-change function.
  ;;
  ;; Point is undefined on both entry and exit, and the return value has no
  ;; significance.
  ;;
  ;; This function is called as a before-change function solely due to its
  ;; membership of mode-specific value of
  ;; `c-get-state-before-change-functions'.
  (goto-char end)
  (setq c-ml-string-end-delim-disrupted nil)
  ;; We use the following to detect a R"<id>( being swallowed into a string by
  ;; the pending change.
  (setq c-old-END-literality (c-in-literal))
    (goto-char beg)
    (setq c-old-beg-ml (c-ml-string-delims-around-point))
    (setq c-beg-pos (c-position-wrt-ml-delims c-old-beg-ml))
    (setq c-old-1-beg-ml
	  (and (not (or c-old-beg-ml (bobp)))
	       (goto-char (1- beg))
	       (c-ml-string-delims-around-point)))
    (goto-char end)
    (setq c-old-end-ml
	  (if (or (eq end beg)
		  (and c-old-beg-ml
		       (>= end (caar c-old-beg-ml))
		       (or (null (cdr c-old-beg-ml))
			   (< end (caddr c-old-beg-ml)))))
	      c-old-beg-ml
	    (c-ml-string-delims-around-point)))
    (setq c-end-pos (c-position-wrt-ml-delims c-old-end-ml))

  (c-save-buffer-state
      ((term-del (c-ml-string-in-end-delim beg end (car c-old-beg-ml)))
       Rquote close-quote)
    (cond
     ;; We're not changing, or we're obliterating ml strings.
     ((and (null c-beg-pos) (null c-end-pos)))
     ;; We're changing the putative terminating delimiter of an ml string
     ;; containing BEG.
     ((and c-beg-pos term-del
	   (or (null (cdr c-old-beg-ml))
	       (<= (car term-del) (cadr c-old-beg-ml))))
      (setq Rquote (caar c-old-beg-ml)
	    close-quote (cdr term-del))
      (setq c-ml-string-end-delim-disrupted t)
      (c-depropertize-ml-strings-in-region Rquote close-quote)
      (setq c-new-BEG (min c-new-BEG Rquote)
	    c-new-END (max c-new-END close-quote)))
     ;; We're breaking an escaped NL in a raw string in a macro.
     ((and c-old-end-ml
	   (< beg end)
	   (goto-char end) (eq (char-before) ?\\)
	   (c-beginning-of-macro))
      (let ((bom (point))
	    (eom (progn (c-end-of-macro) (point))))
	(c-depropertize-ml-strings-in-region bom eom)
	(setq c-new-BEG (min c-new-BEG bom)
	      c-new-END (max c-new-END eom))))
     ;; We're changing only the contents of a raw string.
     ;; Any critical deletion of "s will be handled in
     ;; `c-after-change-unmark-ml-strings'.
     ((and (equal c-old-beg-ml c-old-end-ml)
	   (eq c-beg-pos 'string) (eq c-end-pos 'string)))
     ((or
       ;; We're removing (at least part of) the R" of the starting delim of a
       ;; raw string:
       (null c-old-beg-ml)
       (and (eq beg (caar c-old-beg-ml))
	    (< beg end))
       ;; Or we're removing the ( of the starting delim of a raw string.
       (and (eq c-beg-pos 'open-delim)
	    (or (null c-old-end-ml)
		(not (eq c-end-pos 'open-delim))
		(not (equal c-old-beg-ml c-old-end-ml))))
       ;; Or we're disrupting a starting delim by typing into it, or removing
       ;; characters from it.
       (and (eq c-beg-pos 'open-delim)
	    (eq c-end-pos 'open-delim)
	    (equal c-old-beg-ml c-old-end-ml)))
      (let ((close (caddr (or c-old-end-ml c-old-beg-ml))))
	(setq Rquote (caar (or c-old-end-ml c-old-beg-ml))
	      close-quote (or close (point-max))))
      (c-depropertize-ml-strings-in-region Rquote close-quote)
      (setq c-new-BEG (min c-new-BEG Rquote)
	    c-new-END (max c-new-END close-quote))))))