[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: antlr-mode.el - need some support by python.el

From: Stefan Monnier
Subject: Re: antlr-mode.el - need some support by python.el
Date: Wed, 03 Jun 2015 11:31:48 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> +FIRST-COLUMN is the column the indentation engine of the sub mode
> +should usually choose for top-level language constructs inside
> +the code chunk (instead of 0).
> +
> +START to END is the region of the code chunk.  See function
> +`prog-widen' for additional info.

These depends on the surrounding outer mode, so that's fine.

> +PREVIOUS-CHUNKS, if non-nil, provides the indentation engine of
> +the sub mode with the virtual context of the code chunk.  Valid
> +values are:
> +
> + - A string containing code which the indentation engine can
> +   consider as standing in front of the code chunk.  For example,
> +   it can contain a function header to make the code chunk
> +   being correctly indented as a function body.
> +
> + - A function called with the start position of the current
> +   chunk.  It will return either the region of the previous chunk
> +   as \(PREV-START . PREV-END) or nil if there is no further
> +   previous chunk.")

This is very unclear, so I'm not sure how an inner-mode could make use
of it.  Who (and how) decides what the values will be?  The outer-mode
or the inner-mode?

> +(defun prog-widen ()
> +  "Remove restrictions (narrowing) from current code chunk or buffer.
> +This function should be used instead of `widen' in any function
> +used by the indentation engine to make it respect the value
> +`prog-indentation-context'.

I don't see a need for "should" here.

> +  (widen)
> +  (let ((chunk (cadr prog-indentation-context)))
> +    (when chunk
> +      (narrow-to-region (car chunk) (or (cdr chunk) (point-max))))))

Better do

     (let ((chunk (cadr prog-indentation-context)))
       (if chunk
           (narrow-to-region (car chunk) (or (cdr chunk) (point-max)))

-- Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]