unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Functionality to check current indentation status
@ 2010-01-13 12:55 Deniz Dogan
  2010-01-13 13:02 ` Lennart Borgman
  2010-01-13 15:22 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Deniz Dogan @ 2010-01-13 12:55 UTC (permalink / raw
  To: Emacs-Devel devel

Is there any generic functionality for checking whether a specific
line is indented appropriately according to major-mode? I mean other
than indenting it and seeing whether anything was modified.

If not, it would be useful for e.g. a minor-mode which would highlight
lines that are not correctly indented, or for binding TAB to some
imaginary function indent-or-expand-abbrev, which would indent the
line if not already correct, otherwise call `expand-abbrev'.

-- 
Deniz Dogan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Functionality to check current indentation status
  2010-01-13 12:55 Functionality to check current indentation status Deniz Dogan
@ 2010-01-13 13:02 ` Lennart Borgman
  2010-01-13 14:55   ` Deniz Dogan
  2010-01-13 15:22 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2010-01-13 13:02 UTC (permalink / raw
  To: Deniz Dogan; +Cc: Emacs-Devel devel

On Wed, Jan 13, 2010 at 1:55 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com> wrote:
> Is there any generic functionality for checking whether a specific
> line is indented appropriately according to major-mode? I mean other
> than indenting it and seeing whether anything was modified.

current-indentation

> If not, it would be useful for e.g. a minor-mode which would highlight
> lines that are not correctly indented, or for binding TAB to some
> imaginary function indent-or-expand-abbrev, which would indent the
> line if not already correct, otherwise call `expand-abbrev'.

This is implemented in for example tabkey2-mode, but you always have
to type on TAB for indentation first. I think it would be too
confusing otherwise.

Tabkey2 has a list of completion functions and try to use the relevant
one. And let you change it just before you hit TAB again if you need
to.

See EmacsWiki for other alternatives.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Functionality to check current indentation status
  2010-01-13 13:02 ` Lennart Borgman
@ 2010-01-13 14:55   ` Deniz Dogan
  2010-01-13 14:59     ` Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Deniz Dogan @ 2010-01-13 14:55 UTC (permalink / raw
  To: Lennart Borgman; +Cc: Emacs-Devel devel

2010/1/13 Lennart Borgman <lennart.borgman@gmail.com>:
> On Wed, Jan 13, 2010 at 1:55 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com> wrote:
>> Is there any generic functionality for checking whether a specific
>> line is indented appropriately according to major-mode? I mean other
>> than indenting it and seeing whether anything was modified.
>
> current-indentation
>

Thanks, but that only returns the current indentation with no
indication of whether indenting again will change anything. I'm
looking for something which will "automagically" understand the
language and return e.g. nil if and only if the current indentation is
incorrect. Having looked into indent.el I'm guessing something like
this doesn't exist today.

Naturally, such a function wouldn't work well in all modes, e.g.
Haskell modes where several different levels of indentation can be
correct, but in a lot of modes it would make sense, in my opinion.
(Basically any language where the syntax doesn't depend on the
presence of whitespaces.)

>> If not, it would be useful for e.g. a minor-mode which would highlight
>> lines that are not correctly indented, or for binding TAB to some
>> imaginary function indent-or-expand-abbrev, which would indent the
>> line if not already correct, otherwise call `expand-abbrev'.
>
> This is implemented in for example tabkey2-mode, but you always have
> to type on TAB for indentation first. I think it would be too
> confusing otherwise.
>
> Tabkey2 has a list of completion functions and try to use the relevant
> one. And let you change it just before you hit TAB again if you need
> to.
>
> See EmacsWiki for other alternatives.
>

Thank you, I'll look into it.

-- 
Deniz Dogan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Functionality to check current indentation status
  2010-01-13 14:55   ` Deniz Dogan
@ 2010-01-13 14:59     ` Lennart Borgman
  0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2010-01-13 14:59 UTC (permalink / raw
  To: Deniz Dogan; +Cc: Emacs-Devel devel

On Wed, Jan 13, 2010 at 3:55 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com> wrote:
> 2010/1/13 Lennart Borgman <lennart.borgman@gmail.com>:
>> On Wed, Jan 13, 2010 at 1:55 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com> wrote:
>>> Is there any generic functionality for checking whether a specific
>>> line is indented appropriately according to major-mode? I mean other
>>> than indenting it and seeing whether anything was modified.
>>
>> current-indentation
>>
>
> Thanks, but that only returns the current indentation with no
> indication of whether indenting again will change anything. I'm
> looking for something which will "automagically" understand the
> language and return e.g. nil if and only if the current indentation is
> incorrect. Having looked into indent.el I'm guessing something like
> this doesn't exist today.

You can do it by indenting and then undoing. See mumamo.el for an example.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Functionality to check current indentation status
  2010-01-13 12:55 Functionality to check current indentation status Deniz Dogan
  2010-01-13 13:02 ` Lennart Borgman
@ 2010-01-13 15:22 ` Stefan Monnier
  2010-01-13 15:53   ` Lennart Borgman
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-01-13 15:22 UTC (permalink / raw
  To: Deniz Dogan; +Cc: Emacs-Devel devel

> Is there any generic functionality for checking whether a specific
> line is indented appropriately according to major-mode? I mean other
> than indenting it and seeing whether anything was modified.

No.  The generic indentation code only knows of indent-line-function
which performs the re-indent rather than returning the
indentation amount.
And yes, I think this was a mistake in its design.

> If not, it would be useful for e.g. a minor-mode which would highlight
> lines that are not correctly indented, or for binding TAB to some
> imaginary function indent-or-expand-abbrev, which would indent the
> line if not already correct, otherwise call `expand-abbrev'.

You may take a look at the indent-for-tab-command code, especially the
part that implements the new completion behavior (conditional on
tab-always-indent being set to `complete').


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Functionality to check current indentation status
  2010-01-13 15:22 ` Stefan Monnier
@ 2010-01-13 15:53   ` Lennart Borgman
  0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2010-01-13 15:53 UTC (permalink / raw
  To: Stefan Monnier; +Cc: Emacs-Devel devel, Deniz Dogan

On Wed, Jan 13, 2010 at 4:22 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>
> You may take a look at the indent-for-tab-command code, especially the
> part that implements the new completion behavior (conditional on
> tab-always-indent being set to `complete').

Sounds promising, but I have not seen it yet. Did you add a table of
completion functions, or?




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-13 15:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-13 12:55 Functionality to check current indentation status Deniz Dogan
2010-01-13 13:02 ` Lennart Borgman
2010-01-13 14:55   ` Deniz Dogan
2010-01-13 14:59     ` Lennart Borgman
2010-01-13 15:22 ` Stefan Monnier
2010-01-13 15:53   ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).