Function: c-end-of-macro

c-end-of-macro is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-end-of-macro &optional LIM)

Documentation

Go to the end of a preprocessor directive.

More accurately, move the point to the end of the closest following line that doesn't end with a line continuation backslash - no check is done that the point is inside a cpp directive to begin with, although it is assumed that point isn't inside a comment or string.

If LIM is provided, it is a limit position at which point is left if the end of the macro doesn't occur earlier.

Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info.

Aliases

semantic-c-end-of-macro (obsolete since 28.1)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-end-of-macro (&optional lim)
  "Go to the end of a preprocessor directive.
More accurately, move the point to the end of the closest following
line that doesn't end with a line continuation backslash - no check is
done that the point is inside a cpp directive to begin with, although
it is assumed that point isn't inside a comment or string.

If LIM is provided, it is a limit position at which point is left
if the end of the macro doesn't occur earlier.

Note that this function might do hidden buffer changes.  See the
comment at the start of cc-engine.el for more info."
  (save-restriction
    (if lim (narrow-to-region (point-min) lim))
    (if (and (cdr c-macro-cache)
	     (<= (point) (cdr c-macro-cache))
	     (>= (point) (car c-macro-cache)))
	(goto-char (cdr c-macro-cache))
      (unless (and (car c-macro-cache)
		   (<= (point) c-macro-cache-start-pos)
		   (>= (point) (car c-macro-cache)))
	(setq c-macro-cache nil
	      c-macro-cache-start-pos nil
	      c-macro-cache-syntactic nil
	      c-macro-cache-no-comment nil))
      (save-match-data
	(let ((safe-pos (point)))	; a point outside any literal.
	  ;; Move over stuff followed by a multiline block comment lacking
	  ;; escaped newlines each time around this loop.
	  (while
	      (progn
		(while (progn
			 (end-of-line)
			 (when (and (eq (char-before) ?\\)
				    (not (eobp)))
			   (forward-char)
			   t)))
		(let ((s (parse-partial-sexp safe-pos (point))))
		  (when ;; Are we in a block comment?
		      (and (nth 4 s) (not (nth 7 s)))
		    (progn
		      ;; Move to after the block comment.
		      (parse-partial-sexp
		       (point) (point-max) nil nil s 'syntax-table)
		      (setq safe-pos (point)))))))

	  (when (and (car c-macro-cache)
		     (> (point) (car c-macro-cache)) ; in case we have a
					; zero-sized region.
		     (not lim))
	    (setcdr c-macro-cache (point))
	    (setq c-macro-cache-syntactic nil)))))))