Function: lua-last-token-continues-p

lua-last-token-continues-p is a byte-compiled function defined in lua-mode.el.gz.

Signature

(lua-last-token-continues-p)

Documentation

Return non-nil if the last token on this line is a continuation token.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/lua-mode.el.gz
(defun lua-last-token-continues-p ()
  "Return non-nil if the last token on this line is a continuation token."
  (let ((line-begin (line-beginning-position))
        return-value)
    (save-excursion
      (end-of-line)
      (lua-skip-ws-and-comments-backward line-begin)
      (setq return-value (and (re-search-backward lua-cont-eol-regexp line-begin t)
                              (or (match-beginning 1)
                                  (match-beginning 2))))
      (when (and return-value
                 (string-equal (match-string-no-properties 0) "return"))
        ;; "return" keyword is ambiguous and depends on next token
        (unless (save-excursion
                  (goto-char (match-end 0))
                  (forward-comment (point-max))
                  (and
                   ;; Not continuing: at end of file
                   (not (eobp))
                   (or
                    ;; "function" keyword: it is a continuation, e.g.
                    ;;
                    ;;    return
                    ;;       function() return 123 end
                    ;;
                    (looking-at (lua-rx (symbol "function")))
                    ;; Looking at semicolon or any other keyword: not
                    ;; continuation
                    (not (looking-at (lua-rx (or ";" lua-keyword)))))))
          (setq return-value nil)))
      return-value)))