Function: c-awk-calculate-NL-prop-prev-line

c-awk-calculate-NL-prop-prev-line is a byte-compiled function defined in cc-awk.el.gz.

Signature

(c-awk-calculate-NL-prop-prev-line &optional DO-LIM)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-awk.el.gz
(defun c-awk-calculate-NL-prop-prev-line (&optional do-lim)
  ;; Calculate and set the value of the c-awk-NL-prop on the immediately
  ;; preceding EOL.  This may also involve doing the same for several
  ;; preceding EOLs.
  ;;
  ;; NOTE that if the property was already set, we return it without
  ;; recalculation.  (This is by accident rather than design.)
  ;;
  ;; Return the property which got set (or was already set) on the previous
  ;; line.  Return nil if we hit BOB.
  ;;
  ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
  ;;
  ;; This function might do hidden buffer changes.
  (save-excursion
    (save-match-data
      (beginning-of-line)
      (let* ((pos (point))
             (nl-prop (c-awk-back-to-contentful-text-or-NL-prop)))
        ;; We are either (1) at a BOL (with nl-prop containing the previous
        ;; line's c-awk-NL-prop) or (2) after contentful text on a line.  At
        ;; the BOB counts as case (1), so we test next for bolp rather than
        ;; non-nil nl-prop.
        (when (not (bolp))
          (setq nl-prop
                (cond
                 ;; Incomplete statement which doesn't require escaped EOL?
                 ((or (c-awk-after-if-for-while-condition-p do-lim)
                      (c-awk-after-function-decl-param-list)
                      (c-awk-after-continue-token))
                  ?\{)
                 ;; Escaped EOL (where there's also something to continue)?
                 ((and (looking-at "[ \t]*\\\\$")
                       (not (c-awk-after-rbrace-or-statement-semicolon)))
                  ?\\)
		 ;; A statement was completed on this line.  How?
		 ((memq (char-before) '(?\; ?\}))  ?\})	; Real ; or }
                 (t ?\$)))            ; A virtual semicolon.
          (end-of-line)
          (c-put-char-property (point) 'c-awk-NL-prop nl-prop)
          (forward-line))

        ;; We are now at a (possibly empty) sequence of content-free lines.
        ;; Set c-awk-NL-prop on each of these lines's EOL.
        (while (< (point) pos)         ; one content-free line each iteration.
          (cond              ; recalculate nl-prop from previous line's value.
           ((memq nl-prop '(?\} ?\$ nil)) (setq nl-prop ?\#))
           ((eq nl-prop ?\\)
            (if (not (looking-at "[ \t]*\\\\$")) (setq nl-prop ?\$)))
           ;; ?\# (empty line) and ?\{ (open stmt) don't change.
           )
          (forward-line)
          (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop))
        nl-prop))))