Function: smie-indent-comment

smie-indent-comment is a byte-compiled function defined in smie.el.gz.

Signature

(smie-indent-comment)

Documentation

Compute indentation of a comment.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/smie.el.gz
(defun smie-indent-comment ()
  "Compute indentation of a comment."
  ;; Don't do it for virtual indentations.  We should normally never be "in
  ;; front of a comment" when doing virtual-indentation anyway.  And if we are
  ;; (as can happen in octave-mode), moving forward can lead to inf-loops.
  (and (smie-indent--bolp)
       (let ((pos (point)))
         (save-excursion
           (beginning-of-line)
           (and (re-search-forward comment-start-skip (line-end-position) t)
                (eq pos (or (match-end 1) (match-beginning 0))))))
       (save-excursion
         (forward-comment (point-max))
         (skip-chars-forward " \t\r\n")
         (unless
             ;; Don't align with a closer, since the comment is "within" the
             ;; closed element.  Don't align with EOB either.
             (save-excursion
               (let ((next (funcall smie-forward-token-function)))
                 (or (if (zerop (length next))
                         (or (eobp) (eq (car (syntax-after (point))) 5)))
                     (rassoc next smie-closer-alist))))
	   ;; FIXME: We assume here that smie-indent-calculate will compute the
           ;; indentation of the next token based on text before the comment,
           ;; but this is not guaranteed, so maybe we should let
           ;; smie-indent-calculate return some info about which buffer
           ;; position was used as the "indentation base" and check that this
           ;; base is before `pos'.
           (smie-indent-calculate)))))