all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* indentation of functions inside flet
@ 2012-01-20 10:50 egnarts-ms
  2012-01-20 14:13 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: egnarts-ms @ 2012-01-20 10:50 UTC (permalink / raw)
  To: Emacs-devel


Function definitions established by "flet", "flet*" and "labels" are not
aligned (indented) the same way as those established with usual "defun". 
Instead, certainly, they are indented according to what the function name
specifies, like the following:

(flet ((some-func (a b)
                        (* a b)))
  (body-form-1)
  (body-form-2)
  ...)

In most cases function names (like "some-func" in this example) do not have
the "lisp-indent-function" symprop attached, and even if they happen to
have--that is also not what we want.

So it would be nice if Lisp mode indented such function definitions like
defuns.  I wonder, has anyone cared about this before me (I'm sure someone
has) and are there any improvements to the Lisp mode available ?

(I managed to introduce a change to "lisp-indent-function" function which
does the job, but I'm not sure whether my patch can be considered a decent
one.)
-- 
View this message in context: http://old.nabble.com/indentation-of-functions-inside-flet-tp33173596p33173596.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.




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

* Re: indentation of functions inside flet
  2012-01-20 10:50 indentation of functions inside flet egnarts-ms
@ 2012-01-20 14:13 ` Stefan Monnier
  2012-01-20 14:37   ` egnarts-ms
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2012-01-20 14:13 UTC (permalink / raw)
  To: egnarts-ms; +Cc: Emacs-devel

> So it would be nice if Lisp mode indented such function definitions like
> defuns.  I wonder, has anyone cared about this before me (I'm sure someone
> has) and are there any improvements to the Lisp mode available ?

It would be nice if CL macros were indented better, I agree.
Note that the way to do it is to put the bulk of the code in cl(-*).el and
only change lisp-mode.el so as to provide hooks that CL needs.


        Stefan



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

* Re: indentation of functions inside flet
  2012-01-20 14:13 ` Stefan Monnier
@ 2012-01-20 14:37   ` egnarts-ms
  2012-01-20 16:17     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: egnarts-ms @ 2012-01-20 14:37 UTC (permalink / raw)
  To: Emacs-devel



Stefan Monnier wrote:
> 
>> So it would be nice if Lisp mode indented such function definitions like
>> defuns.  I wonder, has anyone cared about this before me (I'm sure
>> someone
>> has) and are there any improvements to the Lisp mode available ?
> 
> It would be nice if CL macros were indented better, I agree.
> Note that the way to do it is to put the bulk of the code in cl(-*).el and
> only change lisp-mode.el so as to provide hooks that CL needs.
> 
> 
>         Stefan
> 

Basically, what is wrong with the current indentation mechanism is its
short-sightedness.

We have a possibility to specify how to indent macro forms, by attaching
"lisp-indent-function" property to macro symbols, usually with (declare
(indent ...)) declaration.  But the key moment is this: indentation analysis
is limited to only the immediate enclosing list.  Once we want to indent at
some point, we find out what is the innermost containing sexp, then we take
its car and analyze it.  So the car of immediate parent fully determines the
indentation pattern.  No further upward search is performed.

For most cases this behavior is perfectly OK, but, as we see, for
"flet"-like forms this is not the case.
-- 
View this message in context: http://old.nabble.com/indentation-of-functions-inside-flet-tp33173596p33174731.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.




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

* Re: indentation of functions inside flet
  2012-01-20 14:37   ` egnarts-ms
@ 2012-01-20 16:17     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-01-20 16:17 UTC (permalink / raw)
  To: egnarts-ms; +Cc: Emacs-devel

>>> So it would be nice if Lisp mode indented such function definitions like
>>> defuns.  I wonder, has anyone cared about this before me (I'm sure
>>> someone
>>> has) and are there any improvements to the Lisp mode available ?
>> It would be nice if CL macros were indented better, I agree.
>> Note that the way to do it is to put the bulk of the code in cl(-*).el and
>> only change lisp-mode.el so as to provide hooks that CL needs.
> Basically, what is wrong with the current indentation mechanism is its
> short-sightedness.

I don't disagree.  But all it means is that the lisp-indent-function
hook is not flexible enough and needs to be spiced up, so that CL can
use it to get better indentation.
Maybe we can steal some code from the SLIME guys for that.



        Stefan



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

end of thread, other threads:[~2012-01-20 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20 10:50 indentation of functions inside flet egnarts-ms
2012-01-20 14:13 ` Stefan Monnier
2012-01-20 14:37   ` egnarts-ms
2012-01-20 16:17     ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.