unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* getting the same indentation as flet
@ 2013-06-02 21:42 Nic Ferrier
  2013-06-02 21:48 ` Nic Ferrier
  2013-06-03  0:05 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Nic Ferrier @ 2013-06-02 21:42 UTC (permalink / raw)
  To: emacs-devel

I've written an flet like macro and I'd really like flet like
indentation support for it.

How can I achieve that? Is it achievable just in the macro definition?

I note that the current flet macros (including the new cl- ones) do not
have complex indent declarations to specify how the bindings are to be
indented.

What would be ideal, for macro writing, is if we could declare, not only
`defun' indentation but `let' or `flet' indentation.

Anyone got any clues as to whether that would be possible? I wouldn't
mind looking at doing it if it's doable.


Nic



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

* Re: getting the same indentation as flet
  2013-06-02 21:42 getting the same indentation as flet Nic Ferrier
@ 2013-06-02 21:48 ` Nic Ferrier
  2013-06-03  0:05 ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Nic Ferrier @ 2013-06-02 21:48 UTC (permalink / raw)
  To: emacs-devel

Sorry! It's actually quite easy to get done:

  (setplist 'some-flet-sym (symbol-plist 'flet))

I still wonder if this couldn't be done via declare, like `defun' is.



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

* Re: getting the same indentation as flet
  2013-06-02 21:42 getting the same indentation as flet Nic Ferrier
  2013-06-02 21:48 ` Nic Ferrier
@ 2013-06-03  0:05 ` Stefan Monnier
  2013-06-03  7:31   ` Nic Ferrier
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-06-03  0:05 UTC (permalink / raw)
  To: Nic Ferrier; +Cc: emacs-devel

> I've written an flet like macro and I'd really like flet like
> indentation support for it.

The `flet' indentation specification is: 1
So you can just use that, as in

   (defmacro my-flet (blabla)
     (declare (indent 1))
     ...)

> How can I achieve that? Is it achievable just in the macro definition?

See above.

> I note that the current flet macros (including the new cl- ones) do not
> have complex indent declarations to specify how the bindings are to be
> indented.

Indeed, the specification is very primitive.


        Stefan



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

* Re: getting the same indentation as flet
  2013-06-03  0:05 ` Stefan Monnier
@ 2013-06-03  7:31   ` Nic Ferrier
  2013-06-03  8:55     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Nic Ferrier @ 2013-06-03  7:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> The `flet' indentation specification is: 1
> So you can just use that, as in
>
>    (defmacro my-flet (blabla)
>      (declare (indent 1))
>      ...)

That isn't the flet specification. It may be the cl-flet specification
but the flet specification I have is:

 (lisp-indent-function 1 edebug-form-spec cl-flet 
    byte-obsolete-info ("use either `cl-flet' or `cl-letf'." nil "24.3") 
    common-lisp-indent-function 
     ((&whole 4 &rest (&whole 1 &lambda &body)) &body))

I  guess that's because I've configured common-lisp indent functionality
but I  think the elisp one is similarly good.

cl-flet has no identation. That's just another reason that cl-flet is
not very good.


Nic



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

* Re: getting the same indentation as flet
  2013-06-03  7:31   ` Nic Ferrier
@ 2013-06-03  8:55     ` Stefan Monnier
  2013-06-03  9:01       ` Nic Ferrier
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-06-03  8:55 UTC (permalink / raw)
  To: Nic Ferrier; +Cc: emacs-devel

> That isn't the flet specification. It may be the cl-flet specification
> but the flet specification I have is:

>  (lisp-indent-function 1 edebug-form-spec cl-flet 
>     byte-obsolete-info ("use either `cl-flet' or `cl-letf'." nil "24.3") 
>     common-lisp-indent-function 
>      ((&whole 4 &rest (&whole 1 &lambda &body)) &body))

"lisp-indent-function 1" is the part that affects Elisp indentation.

> I  guess that's because I've configured common-lisp indent functionality
> but I  think the elisp one is similarly good.

"common-lisp-indent-function ((&whole 4 &rest (&whole 1 &lambda &body)) &body)"
is the part that affects cl-indent, IIUC, indeed.

> cl-flet has no identation. That's just another reason that cl-flet is
> not very good.

Patches welcome,


        Stefan



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

* Re: getting the same indentation as flet
  2013-06-03  8:55     ` Stefan Monnier
@ 2013-06-03  9:01       ` Nic Ferrier
  2013-06-03 13:43         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Nic Ferrier @ 2013-06-03  9:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> That isn't the flet specification. It may be the cl-flet specification
>> but the flet specification I have is:
>
>>  (lisp-indent-function 1 edebug-form-spec cl-flet 
>>     byte-obsolete-info ("use either `cl-flet' or `cl-letf'." nil "24.3") 
>>     common-lisp-indent-function 
>>      ((&whole 4 &rest (&whole 1 &lambda &body)) &body))
>
> "lisp-indent-function 1" is the part that affects Elisp indentation.
>
>> I  guess that's because I've configured common-lisp indent functionality
>> but I  think the elisp one is similarly good.
>
> "common-lisp-indent-function ((&whole 4 &rest (&whole 1 &lambda &body)) &body)"
> is the part that affects cl-indent, IIUC, indeed.
>
>> cl-flet has no identation. That's just another reason that cl-flet is
>> not very good.
>
> Patches welcome,

I doubt you'd accept a patch to make cl-flet back into something that is
dynamically bound (which is what I care about with cl-flet).

But here's the trivial patch for the cl-flet indentation:

diff -c -L /home/nferrier/emacs-local-20130401/share/emacs/24.3/lisp/emacs-lisp/cl-macs.el.gz.\~1\~ -L /home/nferrier/emacs-local-20130401/share/emacs/24.3/lisp/emacs-lisp/cl-macs.el.gz /tmp/jka-com8047btu /tmp/jka-com8047aBE
*** /home/nferrier/emacs-local-20130401/share/emacs/24.3/lisp/emacs-lisp/cl-macs.el.gz.~1~
--- /home/nferrier/emacs-local-20130401/share/emacs/24.3/lisp/emacs-lisp/cl-macs.el.gz
***************
*** 1657,1663 ****
  Like `cl-labels' but the definitions are not recursive.
  
  \(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
!   (declare (indent 1) (debug ((&rest (cl-defun)) cl-declarations body)))
    (let ((binds ()) (newenv macroexpand-all-environment))
      (dolist (binding bindings)
        (let ((var (make-symbol (format "--cl-%s--" (car binding)))))
--- 1657,1664 ----
  Like `cl-labels' but the definitions are not recursive.
  
  \(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
!   (declare (indent ((&whole 4 &rest (&whole 1 &lambda &body)) &body))
!            (debug ((&rest (cl-defun)) cl-declarations body)))
    (let ((binds ()) (newenv macroexpand-all-environment))
      (dolist (binding bindings)
        (let ((var (make-symbol (format "--cl-%s--" (car binding)))))

Diff finished.  Mon Jun  3 09:58:56 2013



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

* Re: getting the same indentation as flet
  2013-06-03  9:01       ` Nic Ferrier
@ 2013-06-03 13:43         ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2013-06-03 13:43 UTC (permalink / raw)
  To: Nic Ferrier; +Cc: emacs-devel

> !   (declare (indent ((&whole 4 &rest (&whole 1 &lambda &body)) &body))
> !            (debug ((&rest (cl-defun)) cl-declarations body)))

 "Invalid function ((&whole 4 &rest (&whole 1 &lambda &body)) &body)"

It needs to work also when cl-indent is not loaded.


        Stefan



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

end of thread, other threads:[~2013-06-03 13:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-02 21:42 getting the same indentation as flet Nic Ferrier
2013-06-02 21:48 ` Nic Ferrier
2013-06-03  0:05 ` Stefan Monnier
2013-06-03  7:31   ` Nic Ferrier
2013-06-03  8:55     ` Stefan Monnier
2013-06-03  9:01       ` Nic Ferrier
2013-06-03 13:43         ` Stefan Monnier

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).