Variable: wisent-python-lex-beginning-of-line

wisent-python-lex-beginning-of-line is a variable defined in python.el.gz.

Value

Large value
((and
  (bolp)
  (not
   (wisent-python-implicit-line-joining-p))
  (let
      ((last-indent
	(car wisent-python-indent-stack))
       (last-pos
	(point))
       (curr-indent
	(current-indentation)))
    (skip-syntax-forward "-")
    (cond
     ((or
       (eolp)
       (looking-at semantic-lex-comment-regex))
      (forward-comment
       (point-max))
      (or
       (eobp)
       (beginning-of-line))
      (setq semantic-lex-end-point
	    (point))
      t)
     ((= curr-indent last-indent)
      (setq semantic-lex-end-point
	    (point))
      nil)
     ((> curr-indent last-indent)
      (if
	  (or
	   (not semantic-lex-maximum-depth)
	   (< semantic-lex-current-depth semantic-lex-maximum-depth))
	  (progn
	    (setq semantic-lex-current-depth
		  (1+ semantic-lex-current-depth))
	    (push curr-indent wisent-python-indent-stack)
	    (semantic-lex-push-token
	     (semantic-lex-token 'INDENT last-pos
				 (point))))
	(semantic-lex-push-token
	 (semantic-lex-token 'INDENT_BLOCK
			     (progn
			       (beginning-of-line)
			       (point))
			     (semantic-lex-unterminated-syntax-protection 'INDENT_BLOCK
			       (wisent-python-end-of-block)
			       (point)))))
      t)
     ((progn
	(while
	    (< curr-indent last-indent)
	  (pop wisent-python-indent-stack)
	  (setq semantic-lex-current-depth
		(1- semantic-lex-current-depth)
		last-indent
		(car wisent-python-indent-stack))
	  (semantic-lex-push-token
	   (semantic-lex-token 'DEDENT last-pos
			       (point))))
	(= last-pos
	   (point)))
      nil)))))

Documentation

Detect and create Python indentation tokens at beginning of line.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/wisent/python.el.gz
(define-lex-analyzer wisent-python-lex-beginning-of-line
  "Detect and create Python indentation tokens at beginning of line."
  (and
   (bolp) (not (wisent-python-implicit-line-joining-p))
   (let ((last-indent (car wisent-python-indent-stack))
         (last-pos (point))
         (curr-indent (current-indentation)))
     (skip-syntax-forward "-")
     (cond
      ;; Skip comments and blank lines. No change in indentation.
      ((or (eolp) (looking-at semantic-lex-comment-regex))
       (forward-comment (point-max))
       (or (eobp) (beginning-of-line))
       (setq semantic-lex-end-point (point))
       ;; Loop lexer to handle the next line.
       t)
      ;; No change in indentation.
      ((= curr-indent last-indent)
       (setq semantic-lex-end-point (point))
       ;; Try next analyzers.
       nil)
      ;; Indentation increased
      ((> curr-indent last-indent)
       (if (or (not semantic-lex-maximum-depth)
               (< semantic-lex-current-depth semantic-lex-maximum-depth))
           (progn
             ;; Return an INDENT lexical token
             (setq semantic-lex-current-depth (1+ semantic-lex-current-depth))
             (push curr-indent wisent-python-indent-stack)
             (semantic-lex-push-token
              (semantic-lex-token 'INDENT last-pos (point))))
         ;; Add an INDENT_BLOCK token
         (semantic-lex-push-token
          (semantic-lex-token
           'INDENT_BLOCK
           (progn (beginning-of-line) (point))
           (semantic-lex-unterminated-syntax-protection 'INDENT_BLOCK
             (wisent-python-end-of-block)
             (point)))))
       ;; Loop lexer to handle tokens in current line.
       t)
      ;; Indentation decreased
      ((progn
	 ;; Pop items from indentation stack
	 (while (< curr-indent last-indent)
	   (pop wisent-python-indent-stack)
	   (setq semantic-lex-current-depth (1- semantic-lex-current-depth)
		 last-indent (car wisent-python-indent-stack))
	   (semantic-lex-push-token
	    (semantic-lex-token 'DEDENT last-pos (point))))
	 (= last-pos (point)))
       ;; If pos did not change, then we must return nil so that
       ;; other lexical analyzers can be run.
       nil))))
  ;; All the work was done in the above analyzer matching condition.
  )