Liking cljdoc? Tell your friends :D

parinfer.indent-mode

Corrects parens based on indentation. See http://shaunlebron.github.io/parinfer/#indent-mode

Corrects parens based on indentation.
See http://shaunlebron.github.io/parinfer/#indent-mode
raw docstring

block-delim-trailclj/s

(block-delim-trail {:keys [delim-trail line-no cursor-line cursor-x
                           cursor-in-comment?]
                    :as state})

The presence of the cursor can block the removal of some part of the delim trail.

The presence of the cursor can block the removal of some part of the delim trail.
raw docstring

close-delimsclj/s

(close-delims state)
(close-delims state indent-x)

Update the state by inferring closing delimiters. Do this by using the given indentation level.

Example:

(defn foo [a b ret ;; <--- When we process r, we detect indentation, then...

(defn foo [a b] ;; <--- ... we insert a ] after b since [ is after r on the x-axis. ret ;; <--- A ) is inserted after ret if no further indented lines found.

Update the state by inferring closing delimiters.
Do this by using the given indentation level.

Example:

(defn foo [a b
   ret           ;; <---  When we process `r`, we detect indentation, then...

(defn foo [a b]  ;; <---  ... we insert a `]` after `b` since `[` is after `r` on the x-axis.
   ret           ;; <---  A `)` is inserted after `ret` if no further indented lines found.
raw docstring

commit-cached-stateclj/s

(commit-cached-state state key-)

Cache a subset of the state after some event. This is used by process-text-change.

Cache a subset of the state after some event.
This is used by process-text-change.
raw docstring

fill-rest-with-cacheclj/s

(fill-rest-with-cache prev-state state last-i)

fill the rest of the lines with info from cache.

fill the rest of the lines with info from cache.
raw docstring

finalize-stateclj/s

(finalize-state {:keys [stack] :as state})

format-textclj/s

(format-text text)
(format-text text options)

Fully process the given text using Indent Mode.

'text' is the full text.

'options' is an optional map with supported keys: :cursor-x - x position of the cursor (zero-based) :cursor-line - line number of the cursor (zero-based)

Returns a map: :text - full text output :valid? - indicates if the input was valid :state - cached state to be passed to format-text-change

Fully process the given text using Indent Mode.

'text' is the full text.

'options' is an optional map with supported keys:
  :cursor-x     - x position of the cursor (zero-based)
  :cursor-line  - line number of the cursor (zero-based)

Returns a map:
  :text     - full text output
  :valid?   - indicates if the input was valid
  :state    - cached state to be passed to `format-text-change`
raw docstring

format-text-changeclj/s

(format-text-change text prev-state change)
(format-text-change text prev-state change options)

Process changed lines in a previously processed text using Indent Mode.

'text' is the full text (including the change).

'prev-state' is the state after processing 'text' before the 'change' occurred.

  • found in the :state key of the result returned by format-text or this function.

'change' is a map:

KEY | DESCRIPTION | TYPE -----------+--------------------------+------------------------------------ :line-no | line range to replace | a num or min,max line range :new-line | new line(s) to insert | a string or seq if multiple lines

'options' is an optional map with supported keys: :cursor-x - x position of the cursor (zero-based) :cursor-line - line number of the cursor (zero-based)

Returns a map: :text - full text output :valid? - indicates if the input was valid :state - cached state to be passed to format-text-change

Process changed lines in a previously processed text using Indent Mode.

'text' is the full text (including the change).

'prev-state' is the state after processing 'text' before the 'change' occurred.
  - found in the :state key of the result returned by `format-text` or this function.

'change' is a map:

  KEY        |  DESCRIPTION             |  TYPE
  -----------+--------------------------+------------------------------------
  :line-no   |  line range to replace   |  a num or min,max line range
  :new-line  |  new line(s) to insert   |  a string or seq if multiple lines

'options' is an optional map with supported keys:
  :cursor-x     - x position of the cursor (zero-based)
  :cursor-line  - line number of the cursor (zero-based)

Returns a map:
  :text     - full text output
  :valid?   - indicates if the input was valid
  :state    - cached state to be passed to `format-text-change`
raw docstring

get-cached-stateclj/s

(get-cached-state state)

initial-cached-stateclj/s

(initial-cached-state {:keys [lines postline-states postindent-states]
                       :as prev-state}
                      options
                      i)

build an initial state based on our starting line and previous cache.

build an initial state based on our starting line and previous cache.
raw docstring

initial-stateclj/s

An initial state of our running state.

An initial state of our running state.
raw docstring

process-charclj/s

(process-char {:keys [lines line-no] :as state} ch)

Update the state by processing the given character and its position.

Update the state by processing the given character and its position.
raw docstring

process-char*clj/s

(process-char* state)

process-indentclj/s

(process-indent {:keys [stack track-indent? lines line-no x-pos ch] :as state})

Update the state by handling a possible indentation trigger.

Example:

(defn foo [a b ret ;; <--- When we process r, we detect indentation, then ;; we start backtracking to insert closing delimiters on a previous line.

(defn foo [a b] ) ;; <--- If a line starts with a closing delimiter, it is not ;; considered an indentation trigger. In fact, we skip ;; the character completely, removing it from the line.

Update the state by handling a possible indentation trigger.

Example:

(defn foo [a b
   ret           ;; <---  When we process `r`, we detect indentation, then
                 ;;       we start backtracking to insert closing delimiters on a previous line.


(defn foo [a b]
   )             ;; <---  If a line starts with a closing delimiter, it is not
                 ;;       considered an indentation trigger.  In fact, we skip
                 ;;       the character completely, removing it from the line.
raw docstring

process-lineclj/s

(process-line line)
(process-line {:keys [stack lines line-no cursor-line] :as state} line)

Update the state by processing the given line of text.

Update the state by processing the given line of text.
raw docstring

process-textclj/s

(process-text text)
(process-text text options)

Fully processes the given text. Returns new state. See format-text for usage.

Fully processes the given text.  Returns new state.
See `format-text` for usage.
raw docstring

process-text-changeclj/s

(process-text-change prev-state change)
(process-text-change prev-state {:keys [line-no new-line] :as change} options)

Processes the given change for the given state. Returns new state. See format-text-change for usage.

Processes the given change for the given state.  Returns new state.
See `format-text-change` for usage.
raw docstring

process-unchanged-line*clj/s

(process-unchanged-line* prev-state state [old-i line cache])

process a line that comes after those that have changed. 'reduced' will halt further processing.

process a line that comes after those that have changed.
'reduced' will halt further processing.
raw docstring

process-unchanged-linesclj/s

(process-unchanged-lines prev-state state start-i)

process the lines after those that have changed.

process the lines after those that have changed.
raw docstring

remove-delim-trailclj/s

(remove-delim-trail {:keys [delim-trail insert line-no lines backup stack]
                     :as state})

Update the state by removing our marked delim trail. We remove the delims from the appropriate line of text, while also restoring their matching delims onto the stack.

Example:

(foo (+ 2 3) [(bar)] ) ;; a potential comment ^ ^^ ^^^^ | | | |____________| +-- Remove these from the text. | +-- Restore these onto the delim stack. (fyi, we originally popped them off to validate the closing delims. now we need them back to infer closing delims for indented lines.)

Update the state by removing our marked delim trail.
We remove the delims from the appropriate line of text,
while also restoring their matching delims onto the stack.

Example:

(foo (+ 2 3) [(bar)] )    ;; a potential comment
^            ^^   ^^^^
|            |     |
|____________|     +-- Remove these from the text.
       |
       +-- Restore these onto the delim stack.
           (fyi, we originally popped them off to validate
            the closing delims. now we need them back to
            infer closing delims for indented lines.)
raw docstring

restore-insert-lineclj/s

(restore-insert-line {:keys [insert line-no] :as state})

restore the text of a line before trailing delimiters were inserted

restore the text of a line before trailing delimiters were inserted
raw docstring

safe-subvecclj/s

(safe-subvec v i)

save-preinsert-lineclj/s

(save-preinsert-line {:keys [line-no insert lines] :as state})

Save the text of a line before trailing delims were inserted. This allows to restore them when skipping to changed lines in process-text-change.

Save the text of a line before trailing delims were inserted.
This allows to restore them when skipping to changed lines in
process-text-change.
raw docstring

update-delim-trailclj/s

(update-delim-trail {:keys [stack delim-trail backup x-pos ch cursor-line
                            line-no cursor-x cursor-in-comment?]
                     :as state})

Update the state's delim trail as we scan across a line. We eventually remove the delim trail since the indented content below can cause the delims to move.

Example:

(foo (+ 2 3) [(bar)] ) ;; a potential comment ^^^^ | +-- trailing delims that we will remove (notice whitespace will also be removed)

Update the state's delim trail as we scan across a line.
We eventually remove the delim trail since the indented
content below can cause the delims to move.

Example:

(foo (+ 2 3) [(bar)] )    ;; a potential comment
                  ^^^^
                   |
                   +-- trailing delims that we will remove
                        (notice whitespace will also be removed)
raw docstring

update-insertion-ptclj/s

(update-insertion-pt
  {:keys [track-indent? cursor-line lines line-no stack x-pos ch] :as state})

Update the state's trailing delimiter insertion point as we scan the line.

Example:

(defn foo [a b] ret) ^^^^^ ^^^ ^^ ^ ^^^ | +-- final insertion point candidate

Special rules allow the user to freely position the trailing delimiters while editing a line.

Update the state's trailing delimiter insertion point as we scan the line.

Example:

(defn foo [a b] ret)
^^^^^ ^^^ ^^ ^  ^^^
                  |
                  +-- final insertion point candidate

Special rules allow the user to freely position the trailing
delimiters while editing a line.

raw docstring

update-lineclj/s

(update-line {:keys [ch line-no] :as state})

Update the state by adding processed character to the line.

Update the state by adding processed character to the line.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close