unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Incorrect indentation after :name
@ 2005-07-03 15:59 Lennart Borgman
  2005-07-03 16:39 ` Juanma Barranquero
  2005-07-04 14:48 ` Stefan Monnier
  0 siblings, 2 replies; 39+ messages in thread
From: Lennart Borgman @ 2005-07-03 15:59 UTC (permalink / raw)


This gets incorrectly indented after :background.

          (put-text-property 0 (length s)
                             'face '(:background "red"
                                                 :foreground "black"
                                                 :height 1.5) s)

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

* Re: Incorrect indentation after :name
  2005-07-03 15:59 Incorrect indentation after :name Lennart Borgman
@ 2005-07-03 16:39 ` Juanma Barranquero
  2005-07-03 16:52   ` Lennart Borgman
  2005-07-03 17:10   ` Luc Teirlinck
  2005-07-04 14:48 ` Stefan Monnier
  1 sibling, 2 replies; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-03 16:39 UTC (permalink / raw)
  Cc: emacs-devel

On 7/3/05, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:

> This gets incorrectly indented after :background.
> 
>           (put-text-property 0 (length s)
>                              'face '(:background "red"
>                                                  :foreground "black"
>                                                  :height 1.5) s)

What do you mean? After C-M-q (indent-pp-sexp), it is:

  (put-text-property 0 (length s)
                     'face '(:background "red"
                             :foreground "black"
                             :height 1.5) s)

which seems OK to me.

-- 
                    /L/e/k/t/u

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

* Re: Incorrect indentation after :name
  2005-07-03 16:39 ` Juanma Barranquero
@ 2005-07-03 16:52   ` Lennart Borgman
  2005-07-03 17:16     ` Juanma Barranquero
  2005-07-03 17:10   ` Luc Teirlinck
  1 sibling, 1 reply; 39+ messages in thread
From: Lennart Borgman @ 2005-07-03 16:52 UTC (permalink / raw)
  Cc: emacs-devel

Juanma Barranquero wrote:

>On 7/3/05, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
>
>  
>
>>This gets incorrectly indented after :background.
>>
>>          (put-text-property 0 (length s)
>>                             'face '(:background "red"
>>                                                 :foreground "black"
>>                                                 :height 1.5) s)
>>    
>>
>
>What do you mean? After C-M-q (indent-pp-sexp), it is:
>
>  (put-text-property 0 (length s)
>                     'face '(:background "red"
>                             :foreground "black"
>                             :height 1.5) s)
>
>which seems OK to me.
>
It would be ok with me, but that is not what I see ;-)

:foreground is right under "red". Tested with emacs -Q.

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

* Re: Incorrect indentation after :name
  2005-07-03 16:39 ` Juanma Barranquero
  2005-07-03 16:52   ` Lennart Borgman
@ 2005-07-03 17:10   ` Luc Teirlinck
  1 sibling, 0 replies; 39+ messages in thread
From: Luc Teirlinck @ 2005-07-03 17:10 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

I see the same thing Lennart sees, in `emacs -q -nbc', both with C-M-q
and line by line, using TAB (in the *scratch* buffer).

Sincerely,

Luc.

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

* Re: Incorrect indentation after :name
  2005-07-03 16:52   ` Lennart Borgman
@ 2005-07-03 17:16     ` Juanma Barranquero
  2005-07-03 22:29       ` Drew Adams
  0 siblings, 1 reply; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-03 17:16 UTC (permalink / raw)
  Cc: emacs-devel

On 7/3/05, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:

> It would be ok with me, but that is not what I see ;-)
> 
> :foreground is right under "red". Tested with emacs -Q.

Sorry, you're right. I forgot that I have this on my .emacs. The
`lisp-indent-function' bit is the one that "fixes" the problem. Of
course, one of the first things I do in .emacs is loading CL.

(add-hook 'emacs-lisp-mode-hook
          #'(lambda ()
              (turn-on-eldoc-mode)
              (unless (assoc-string "cl-indent" load-history) (load
"cl-indent" nil t))
              (set (make-local-variable 'lisp-indent-function)
'common-lisp-indent-function)
              (setq lisp-indent-maximum-backtracking 10)
              (put 'define-derived-mode 'common-lisp-indent-function
'(4 4 4 2 &body))
              (put 'if 'common-lisp-indent-function '(nil nil &body))))

-- 
                    /L/e/k/t/u

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

* RE: Incorrect indentation after :name
  2005-07-03 17:16     ` Juanma Barranquero
@ 2005-07-03 22:29       ` Drew Adams
  2005-07-03 22:44         ` Juanma Barranquero
  0 siblings, 1 reply; 39+ messages in thread
From: Drew Adams @ 2005-07-03 22:29 UTC (permalink / raw)


    (add-hook 'emacs-lisp-mode-hook
              #'(lambda ()
                  (turn-on-eldoc-mode)
                  (unless (assoc-string "cl-indent" load-history) (load
    "cl-indent" nil t))
                  (set (make-local-variable 'lisp-indent-function)
    'common-lisp-indent-function)
                  (setq lisp-indent-maximum-backtracking 10)
                  (put 'define-derived-mode 'common-lisp-indent-function
    '(4 4 4 2 &body))
                  (put 'if 'common-lisp-indent-function '(nil nil &body))))

I like it. Why isn't this indentation the default for emacs-lisp-mode and
lisp-interaction-mode (and maybe lisp-mode)?

Do most people prefer the first of these? The second seems clearer to me
(list vs function call).

1. '(foo bar   and (foo bar
         toto)          toto)

2. '(foo bar   and (foo bar
     toto)              toto)

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

* Re: Incorrect indentation after :name
  2005-07-03 22:29       ` Drew Adams
@ 2005-07-03 22:44         ` Juanma Barranquero
  0 siblings, 0 replies; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-03 22:44 UTC (permalink / raw)
  Cc: emacs-devel

On 7/4/05, Drew Adams <drew.adams@oracle.com> wrote:

> Do most people prefer the first of these?

Second is much better IMO.

-- 
                    /L/e/k/t/u

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

* Re: Incorrect indentation after :name
  2005-07-03 15:59 Incorrect indentation after :name Lennart Borgman
  2005-07-03 16:39 ` Juanma Barranquero
@ 2005-07-04 14:48 ` Stefan Monnier
  2005-07-04 21:22   ` David Ponce
                     ` (2 more replies)
  1 sibling, 3 replies; 39+ messages in thread
From: Stefan Monnier @ 2005-07-04 14:48 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> "Lennart" == Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> This gets incorrectly indented after :background.

>           (put-text-property 0 (length s)
>                              'face '(:background "red"
>                                                  :foreground "black"
>                                                  :height 1.5) s)

I've been using the patch below for several years now quite happily.
If people like it, I'll glad it install it,


        Stefan


--- orig/lisp/emacs-lisp/lisp-mode.el
+++ mod/lisp/emacs-lisp/lisp-mode.el
@@ -895,12 +887,18 @@
   (let ((normal-indent (current-column)))
     (goto-char (1+ (elt state 1)))
     (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
-    (if (and (elt state 2)
-             (not (looking-at "\\sw\\|\\s_")))
-        ;; car of form doesn't seem to be a symbol
-        (progn
-          (if (not (> (save-excursion (forward-line 1) (point))
-                      calculate-lisp-indent-last-sexp))
+    (let ((function (and (or (not (elt state 2))
+			     (looking-at "\\(\\sw\\|\\s_\\)+"))
+			 (match-string 0))))
+      (if (or (not function)
+	      (and (> (point) (1+ (point-min)))
+		   (or (save-excursion (backward-char 2) (looking-at "'("))
+		       (keywordp (intern-soft function)))
+		   (not (fboundp (intern-soft function)))))
+	  ;; car of form doesn't seem to be a function
+	  (progn
+	    (if (not (> (save-excursion (forward-line 1) (point))
+			calculate-lisp-indent-last-sexp))
 		(progn (goto-char calculate-lisp-indent-last-sexp)
 		       (beginning-of-line)
 		       (parse-partial-sexp (point)

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

* Re: Incorrect indentation after :name
  2005-07-04 14:48 ` Stefan Monnier
@ 2005-07-04 21:22   ` David Ponce
  2005-07-05  0:40   ` Juanma Barranquero
  2005-07-05  4:35   ` Richard M. Stallman
  2 siblings, 0 replies; 39+ messages in thread
From: David Ponce @ 2005-07-04 21:22 UTC (permalink / raw)
  Cc: emacs-devel

Hi Stefan,

 >>This gets incorrectly indented after :background.
 >
 >
 >>          (put-text-property 0 (length s)
 >>                             'face '(:background "red"
 >>                                                 :foreground "black"
 >>                                                 :height 1.5) s)
 >
 >
 > I've been using the patch below for several years now quite happily.
 > If people like it, I'll glad it install it,

I tried your patch and I must say that I like it!  It would be nice if
you could install it.  I will use your patched version otherwise.

Thanks.
David

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

* Re: Incorrect indentation after :name
  2005-07-04 14:48 ` Stefan Monnier
  2005-07-04 21:22   ` David Ponce
@ 2005-07-05  0:40   ` Juanma Barranquero
  2005-07-05  4:35   ` Richard M. Stallman
  2 siblings, 0 replies; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-05  0:40 UTC (permalink / raw)
  Cc: emacs-devel

> I've been using the patch below for several years now quite happily.
> If people like it, I'll glad it install it,

It is certainly much nicer than the default. You've got my vote.

-- 
                    /L/e/k/t/u

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

* Re: Incorrect indentation after :name
  2005-07-04 14:48 ` Stefan Monnier
  2005-07-04 21:22   ` David Ponce
  2005-07-05  0:40   ` Juanma Barranquero
@ 2005-07-05  4:35   ` Richard M. Stallman
  2005-07-05  5:21     ` Stefan Monnier
  2 siblings, 1 reply; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-05  4:35 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    +      (if (or (not function)
    +	      (and (> (point) (1+ (point-min)))
    +		   (or (save-excursion (backward-char 2) (looking-at "'("))
    +		       (keywordp (intern-soft function)))
    +		   (not (fboundp (intern-soft function)))))

The problem is, this will do the wrong thing when you edit
a call to a function defined in a file that isn't loaded.

It might be better to check for a quote in front of
the current list or a surrounding list.  That could work reliably.

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

* Re: Incorrect indentation after :name
  2005-07-05  4:35   ` Richard M. Stallman
@ 2005-07-05  5:21     ` Stefan Monnier
  2005-07-05  7:07       ` Lars Brinkhoff
                         ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Stefan Monnier @ 2005-07-05  5:21 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

>     +      (if (or (not function)
>     +	      (and (> (point) (1+ (point-min)))
>     +		   (or (save-excursion (backward-char 2) (looking-at "'("))
>     +		       (keywordp (intern-soft function)))
>     +		   (not (fboundp (intern-soft function)))))

> The problem is, this will do the wrong thing when you edit
> a call to a function defined in a file that isn't loaded.

> It might be better to check for a quote in front of
> the current list or a surrounding list.  That could work reliably.

I do check for a quote.  The check for `fboundp' is to try and "correctly"
indent things like

       '(with-current-buffer buf
          (do-something))

which occur sometimes in macros.


        Stefan

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

* Re: Incorrect indentation after :name
  2005-07-05  5:21     ` Stefan Monnier
@ 2005-07-05  7:07       ` Lars Brinkhoff
  2005-07-05 19:11         ` Richard M. Stallman
  2005-07-05 13:49       ` Drew Adams
  2005-07-05 19:11       ` Richard M. Stallman
  2 siblings, 1 reply; 39+ messages in thread
From: Lars Brinkhoff @ 2005-07-05  7:07 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:
> The check for `fboundp' is to try and "correctly" indent things like
>
>        '(with-current-buffer buf
>           (do-something))
>
> which occur sometimes in macros.

Somewhat related to this, I have a patch to improve indentation of
macros that are defined with defmacro* and uses &body.  The macro must
be loaded for my code to do its job.

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

* RE: Incorrect indentation after :name
  2005-07-05  5:21     ` Stefan Monnier
  2005-07-05  7:07       ` Lars Brinkhoff
@ 2005-07-05 13:49       ` Drew Adams
  2005-07-05 16:09         ` Paul Pogonyshev
  2005-07-05 19:11       ` Richard M. Stallman
  2 siblings, 1 reply; 39+ messages in thread
From: Drew Adams @ 2005-07-05 13:49 UTC (permalink / raw)


    I do check for a quote.  The check for `fboundp' is to try and
    "correctly" indent things like
           '(with-current-buffer buf
              (do-something))
    which occur sometimes in macros.

I would rather have it treat lists as lists, regardless of whether the lists
might represent programs (e.g. even in macros and arg to eval). So, to me,
dumb checking for a quote or backquote would be good. IOW, I like the
behavior given by Juanma's hook code using common-lisp-indent-function. But
I can imagine people might feel differently about this.

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

* Re: Incorrect indentation after :name
  2005-07-05 13:49       ` Drew Adams
@ 2005-07-05 16:09         ` Paul Pogonyshev
  0 siblings, 0 replies; 39+ messages in thread
From: Paul Pogonyshev @ 2005-07-05 16:09 UTC (permalink / raw)


Drew Adams wrote:
>     I do check for a quote.  The check for `fboundp' is to try and
>     "correctly" indent things like
>            '(with-current-buffer buf
>               (do-something))
>     which occur sometimes in macros.
>
> I would rather have it treat lists as lists, regardless of whether the
> lists might represent programs (e.g. even in macros and arg to eval). So,
> to me, dumb checking for a quote or backquote would be good. IOW, I like
> the behavior given by Juanma's hook code using common-lisp-indent-function.
> But I can imagine people might feel differently about this.

I too think a dumb check is better.  Not because I like functions being
indented like lists, but because, as RMS noted, `fboundp' would give
inconsistent results depending on whether a function has been evaluated
or not.

Paul

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

* Re: Incorrect indentation after :name
  2005-07-05  7:07       ` Lars Brinkhoff
@ 2005-07-05 19:11         ` Richard M. Stallman
  2005-07-05 19:44           ` Lars Brinkhoff
  0 siblings, 1 reply; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-05 19:11 UTC (permalink / raw)
  Cc: emacs-devel

    Somewhat related to this, I have a patch to improve indentation of
    macros that are defined with defmacro* and uses &body.  The macro must
    be loaded for my code to do its job.

Could we manage to make this work without loading the macro?
Perhaps by providing another place to find the information?

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

* Re: Incorrect indentation after :name
  2005-07-05  5:21     ` Stefan Monnier
  2005-07-05  7:07       ` Lars Brinkhoff
  2005-07-05 13:49       ` Drew Adams
@ 2005-07-05 19:11       ` Richard M. Stallman
  2005-07-06  0:20         ` Luc Teirlinck
  2 siblings, 1 reply; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-05 19:11 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    I do check for a quote.  The check for `fboundp' is to try and "correctly"
    indent things like

	   '(with-current-buffer buf
	      (do-something))

    which occur sometimes in macros.

I see.  In that case, the mistakes would be few enough that I think
your patch is a good idea.

However, it would be even better if develop a textual convention for
indicating function calls that appear in quotes.  That would enable
Emacs to detect them reliably.

Perhaps--put a space between the quote and the open-paren?

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

* Re: Incorrect indentation after :name
  2005-07-05 19:11         ` Richard M. Stallman
@ 2005-07-05 19:44           ` Lars Brinkhoff
  2005-07-07  5:36             ` Richard M. Stallman
  0 siblings, 1 reply; 39+ messages in thread
From: Lars Brinkhoff @ 2005-07-05 19:44 UTC (permalink / raw)
  Cc: emacs-devel

"Richard M. Stallman" <rms@gnu.org> writes:
>     Somewhat related to this, I have a patch to improve indentation of
>     macros that are defined with defmacro* and uses &body.  The macro must
>     be loaded for my code to do its job.
>
> Could we manage to make this work without loading the macro?
> Perhaps by providing another place to find the information?

The code works by checking the position of &body inside the macro
argument list, and setting the lisp-indent-function property of the
macro name to that number.

This is the gist of the patch:

Index: lisp/emacs-lisp/cl-macs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/cl-macs.el,v
retrieving revision 1.53
diff -u -F^(def -r1.53 cl-macs.el
--- lisp/emacs-lisp/cl-macs.el	4 Jul 2005 17:33:35 -0000	1.53
+++ lisp/emacs-lisp/cl-macs.el	5 Jul 2005 19:37:39 -0000
@@ -202,8 +202,15 @@ (defmacro defmacro* (name args &rest bod
 
 \(fn NAME ARGLIST [DOCSTRING] BODY...)"
   (let* ((res (cl-transform-lambda (cons args body) name))
-	 (form (list* 'defmacro name (cdr res))))
-    (if (car res) (list 'progn (car res) form) form)))
+	 (form `((defmacro ,name ,@(cdr res)))))
+    (if (memq '&body args)
+	(push `(put ',name 'lisp-indent-function ,(position '&body args))
+	      form))
+    (if (car res)
+	(push (car res) form))
+    (if (cdr form)
+	(cons 'progn form)
+	(car form))))
 
 (defmacro function* (func)
   "Introduce a function.

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

* Re: Incorrect indentation after :name
  2005-07-05 19:11       ` Richard M. Stallman
@ 2005-07-06  0:20         ` Luc Teirlinck
  2005-07-06  1:29           ` drkm
  2005-07-06 17:55           ` Richard M. Stallman
  0 siblings, 2 replies; 39+ messages in thread
From: Luc Teirlinck @ 2005-07-06  0:20 UTC (permalink / raw)
  Cc: lennart.borgman.073, monnier, emacs-devel

Richard Stallman wrote:

	      '(with-current-buffer buf
		 (do-something))

       which occur sometimes in macros.

   I see.  In that case, the mistakes would be few enough

If I understood correctly, it would misindent quoted lists whose first
element is a function.  Lists of functions are not rare (hooks, for
example).

Sincerely,

Luc.

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

* Re: Incorrect indentation after :name
  2005-07-06  0:20         ` Luc Teirlinck
@ 2005-07-06  1:29           ` drkm
  2005-07-06  1:43             ` Luc Teirlinck
  2005-07-06 17:55           ` Richard M. Stallman
  1 sibling, 1 reply; 39+ messages in thread
From: drkm @ 2005-07-06  1:29 UTC (permalink / raw)


Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> If I understood correctly, it would misindent quoted lists whose first
> element is a function.  Lists of functions are not rare (hooks, for
> example).

  Is it safe to directly set a hook to a function list?  Or have
we to use 'add-hook'?  In an other hand, it's anoying indentation
is wrong with 'eval-after-load'.

--drkm

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

* Re: Incorrect indentation after :name
  2005-07-06  1:29           ` drkm
@ 2005-07-06  1:43             ` Luc Teirlinck
  0 siblings, 0 replies; 39+ messages in thread
From: Luc Teirlinck @ 2005-07-06  1:43 UTC (permalink / raw)
  Cc: emacs-devel

   Is it safe to directly set a hook to a function list?  Or have
   we to use 'add-hook'?

_Normally_, you have to use add-hook.  But, for instance, you may have
to set it to an explicit list in a defcustom, to get the standard
value right.  Lists of functions are also used in defvars and in other
situations, see for instance comint-output-filter-functions (just one
example out of many).

Sincerely,

Luc.

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

* Re: Incorrect indentation after :name
  2005-07-06  0:20         ` Luc Teirlinck
  2005-07-06  1:29           ` drkm
@ 2005-07-06 17:55           ` Richard M. Stallman
  2005-07-06 18:30             ` David Kastrup
  1 sibling, 1 reply; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-06 17:55 UTC (permalink / raw)
  Cc: lennart.borgman.073, monnier, emacs-devel

    If I understood correctly, it would misindent quoted lists whose first
    element is a function.  Lists of functions are not rare (hooks, for
    example).

The incorrect indentation in those cases won't be horrible.

However, if we can develop a good convention for distinguishing the
two cases (quoted code, and quoted non-code), we could get the right
results every time.

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

* Re: Incorrect indentation after :name
  2005-07-06 17:55           ` Richard M. Stallman
@ 2005-07-06 18:30             ` David Kastrup
  2005-07-07  3:09               ` Stefan Monnier
  2005-07-07  5:36               ` Richard M. Stallman
  0 siblings, 2 replies; 39+ messages in thread
From: David Kastrup @ 2005-07-06 18:30 UTC (permalink / raw)
  Cc: lennart.borgman.073, Luc Teirlinck, monnier, emacs-devel

"Richard M. Stallman" <rms@gnu.org> writes:

>     If I understood correctly, it would misindent quoted lists whose first
>     element is a function.  Lists of functions are not rare (hooks, for
>     example).
>
> The incorrect indentation in those cases won't be horrible.
>
> However, if we can develop a good convention for distinguishing the
> two cases (quoted code, and quoted non-code), we could get the right
> results every time.

I'd somewhat visually prefer
   '( function and function )
vs '(function of something)

I seems more readable than your proposal
   '(function and function)
   ' (function of something)
and it also does not need to also take a look at ` and maybe even
(quote ...) (which is the rendition of printed Lisp expressions).

Of course, this proposal has the disadvantage that the probably more
common case of a function (or non-function!) list needs extra
formatting, so it is probably not useful in practice.

However, if we _combine_ both proposals with an added criterion, we
might arrive at the following rule set:

'( func and func ) is a list in any context
' (func of something) is a quoted function call in any context
'(func maybe) is a list, except in macro definitions where it is a
quoted function.

Maybe this is too complicated.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Incorrect indentation after :name
  2005-07-06 18:30             ` David Kastrup
@ 2005-07-07  3:09               ` Stefan Monnier
  2005-07-07 17:01                 ` Drew Adams
  2005-07-07 21:30                 ` Richard M. Stallman
  2005-07-07  5:36               ` Richard M. Stallman
  1 sibling, 2 replies; 39+ messages in thread
From: Stefan Monnier @ 2005-07-07  3:09 UTC (permalink / raw)
  Cc: lennart.borgman.073, Luc Teirlinck, rms, emacs-devel

> I'd somewhat visually prefer
>    '( function and function )
> vs '(function of something)

Let's not try to be too clever.  After all, there's also the other
cases like:

 (quote (function and function))   vs   (quote (function of something))

and

 '(... (function and function) ...)   vs   '(... (function of something) ...)

and ...


        Stefan

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

* Re: Incorrect indentation after :name
  2005-07-06 18:30             ` David Kastrup
  2005-07-07  3:09               ` Stefan Monnier
@ 2005-07-07  5:36               ` Richard M. Stallman
  1 sibling, 0 replies; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-07  5:36 UTC (permalink / raw)
  Cc: lennart.borgman.073, teirllm, monnier, emacs-devel

    I'd somewhat visually prefer
       '( function and function )

I really dislike spaces inside of parens, so I would not want to
choose that.  However, I'm not insisting on the space before the
open-paren as the convention.

    and it also does not need to also take a look at `

I am having trouble parsing that text, but I suppose we would want to
apply the same convention to both quote and backquote.

						       and maybe even
    (quote ...) (which is the rendition of printed Lisp expressions).

I don't think it is necessary to apply this convention to (quote ...).
This convention would only be relevant for hand-editing of source
code.  If you are hand-editing and you care about making the code
pretty, you surely should replace (quote ...) with a singlequote.

    Of course, this proposal has the disadvantage that the probably more
    common case of a function (or non-function!) list needs extra
    formatting, so it is probably not useful in practice.

I can't understand "function (or non-function!) list".  Sorry.

    However, if we _combine_ both proposals with an added criterion, we
    might arrive at the following rule set:

I don't see a need for three conventions--it seems to me that two
would be enough.  One would say "this list is an expression", and the
other would say "this list is not an expression".  Given those two,
there is no need for a third convention that would say "maybe this is
an expression--please guess".  You, the programmer, always know
whether a given quoted list is an expression, and you can choose among
the two conventions accordingly.

If you disagree with that argument, could you explain why?

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

* Re: Incorrect indentation after :name
  2005-07-05 19:44           ` Lars Brinkhoff
@ 2005-07-07  5:36             ` Richard M. Stallman
  2005-07-07  8:25               ` Lars Brinkhoff
  0 siblings, 1 reply; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-07  5:36 UTC (permalink / raw)
  Cc: emacs-devel

    The code works by checking the position of &body inside the macro
    argument list, and setting the lisp-indent-function property of the
    macro name to that number.

It is clever, and adapting it to macros that are not loaded
would not be easy.

Meanwhile, the (declare (indent ...)) construct has the same problem.
It is part of the macro definition, so it won't be available unless
the macro is loaded.  For macros that aren't standardly loaded,
explicitly putting on a lisp-indent-function property was better
in that it could be available when the macro isn't.

However, we could make autoload.el, when a defmacro is autoloaded,
generate a form that puts the appropriate property onto the macro
name.  That could go in loaddefs.  It could look for a `declare' form,
and if there is none, it could then try your approach of looking for
&body.

We could also put code like this into the standard definition
of defmacro, in eval.c, for use on non-autoloaded macros.

(You made the change in the cl version of defmacro.  That version that
is not normally used.)

Want to do this?

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

* Re: Incorrect indentation after :name
  2005-07-07  5:36             ` Richard M. Stallman
@ 2005-07-07  8:25               ` Lars Brinkhoff
  2005-07-08  4:35                 ` Richard M. Stallman
  0 siblings, 1 reply; 39+ messages in thread
From: Lars Brinkhoff @ 2005-07-07  8:25 UTC (permalink / raw)
  Cc: emacs-devel

Richard M. Stallman wrote:
> Lars Brinkhoff wrote:
> > The code works by checking the position of &body inside the macro
> > argument list, and setting the lisp-indent-function property of
> > the macro name to that number.
>
> It is clever, and adapting it to macros that are not loaded would
> not be easy. [...] However, we could make autoload.el, when a
> defmacro is autoloaded, generate a form that puts the appropriate
> property onto the macro name.  That could go in loaddefs.
>
> Want to do this?

That seems interesting, and I would like to look into it, but I don't
have much time right now.  I would have to get back to it in September.

> You made the change in the cl version of defmacro.  That version
> that is not normally used.

That's because the Emacs Lisp version of defmacro doesn't accept the
&body lambda list keyword.  Maybe it should?

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

* RE: Incorrect indentation after :name
  2005-07-07  3:09               ` Stefan Monnier
@ 2005-07-07 17:01                 ` Drew Adams
  2005-07-07 17:49                   ` Lawrence Mitchell
  2005-07-07 21:30                 ` Richard M. Stallman
  1 sibling, 1 reply; 39+ messages in thread
From: Drew Adams @ 2005-07-07 17:01 UTC (permalink / raw)


    Let's not try to be too clever.

I agree. I think the behavior given by Juanma's hook code using
common-lisp-indent-function gives good results:

(add-hook 'emacs-lisp-mode-hook
          #'(lambda ()
              (unless (assoc-string "cl-indent" load-history)
                 (load "cl-indent" nil t))
              (set (make-local-variable 'lisp-indent-function)
                   'common-lisp-indent-function)
              (setq lisp-indent-maximum-backtracking 10)
              (put 'define-derived-mode
                   'common-lisp-indent-function
                   '(4 4 4 2 &body))
              (put 'if 'common-lisp-indent-function
                   '(nil nil &body))))

What about just integrating that behavior (i.e. without loading cl-indent)?

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

* Re: Incorrect indentation after :name
  2005-07-07 17:01                 ` Drew Adams
@ 2005-07-07 17:49                   ` Lawrence Mitchell
  2005-07-07 18:35                     ` Drew Adams
  2005-07-07 18:49                     ` Juanma Barranquero
  0 siblings, 2 replies; 39+ messages in thread
From: Lawrence Mitchell @ 2005-07-07 17:49 UTC (permalink / raw)


Drew Adams wrote:

[...]

>               (put 'if 'common-lisp-indent-function
>                    '(nil nil &body))))

This breaks the standard indentation of IF in lisp-mode buffers.

-- 
Lawrence Mitchell <wence@gmx.li>

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

* RE: Incorrect indentation after :name
  2005-07-07 17:49                   ` Lawrence Mitchell
@ 2005-07-07 18:35                     ` Drew Adams
  2005-07-07 21:47                       ` Lawrence Mitchell
  2005-07-07 18:49                     ` Juanma Barranquero
  1 sibling, 1 reply; 39+ messages in thread
From: Drew Adams @ 2005-07-07 18:35 UTC (permalink / raw)


    >               (put 'if 'common-lisp-indent-function
    >                    '(nil nil &body))))

    This breaks the standard indentation of IF in lisp-mode buffers.

I don't see that (with emacs -q). What are you seeing?

I assume that you meant adding the above to lisp-mode-hook instead of
emac-lisp-mode-hook, but either way I see this, which is also the vanilla
indentation of IF in lisp-mode:

(if foo
    bar
  toto
  titi)

In GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600)
 of 2005-06-26 on NONIQPC
X server distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc
(3.3) --cflags -I../../jpeg-6b-3/include -I../../libpng-1.2.8/include -I../.
./tiff-3.6.1-2/include -I../../xpm-nox-4.2.0/include -I../../zlib-1.2.2/incl
ude'

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

* Re: Incorrect indentation after :name
  2005-07-07 17:49                   ` Lawrence Mitchell
  2005-07-07 18:35                     ` Drew Adams
@ 2005-07-07 18:49                     ` Juanma Barranquero
  2005-07-08  4:36                       ` Richard M. Stallman
  1 sibling, 1 reply; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-07 18:49 UTC (permalink / raw)


On 7/7/05, Lawrence Mitchell <wence@gmx.li> wrote:

> This breaks the standard indentation of IF in lisp-mode buffers.

If you mean that `if's are:

(if x
    (a)
  (b)
  (c))

instead of:

(if x
    (a)
    (b)
    (c))

I would consider this a clear advantage.

Anyway, I'm not proposing my customizations to be adopted, I'm happy
having them on .emacs...

-- 
                    /L/e/k/t/u

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

* Re: Incorrect indentation after :name
  2005-07-07  3:09               ` Stefan Monnier
  2005-07-07 17:01                 ` Drew Adams
@ 2005-07-07 21:30                 ` Richard M. Stallman
  1 sibling, 0 replies; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-07 21:30 UTC (permalink / raw)
  Cc: lennart.borgman.073, teirllm, emacs-devel

    Let's not try to be too clever.  After all, there's also the other
    cases like:

     (quote (function and function))   vs   (quote (function of something))

That case is not important, for reasons I explained before.

    and

     '(... (function and function) ...)   vs   '(... (function of something) ...)

You are talking about constants which are not expressions but which
contain expressions.  They do occur, but in practice, would indenting
them as expressions ever give bad results?

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

* Re: Incorrect indentation after :name
  2005-07-07 18:35                     ` Drew Adams
@ 2005-07-07 21:47                       ` Lawrence Mitchell
  2005-07-07 22:21                         ` Drew Adams
  0 siblings, 1 reply; 39+ messages in thread
From: Lawrence Mitchell @ 2005-07-07 21:47 UTC (permalink / raw)


Drew Adams wrote:

>     >               (put 'if 'common-lisp-indent-function
>     >                    '(nil nil &body))))

>     This breaks the standard indentation of IF in lisp-mode buffers.

By standard, I mean the accepted way of indenting IF in common
lisp.

> I don't see that (with emacs -q). What are you seeing?

> I assume that you meant adding the above to lisp-mode-hook instead of
> emac-lisp-mode-hook, but either way I see this, which is also the vanilla
> indentation of IF in lisp-mode:

Well, (put 'if 'common-lisp-indent-function '(nil nil &body)) is
not mode-local, so it will affect indentation of IF in all modes
that use common-lisp-indent-function to indent.

Emacs lisp IF is (if TEST THEN &REST ELSE), while common lisp IF
is (if TEST THEN ELSE).  The conventional mode of indenting IF in
Emacs lisp is:
(if test
    then
  else)

whereas in common lisp:

(if test
    then
    else)

(since only the one else-form is allowed).  It is this latter
indentation that is affected by the above suggestion.

[...]

-- 
Lawrence Mitchell <wence@gmx.li>

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

* RE: Incorrect indentation after :name
  2005-07-07 21:47                       ` Lawrence Mitchell
@ 2005-07-07 22:21                         ` Drew Adams
  0 siblings, 0 replies; 39+ messages in thread
From: Drew Adams @ 2005-07-07 22:21 UTC (permalink / raw)


    >     >               (put 'if 'common-lisp-indent-function
    >     >                    '(nil nil &body))))
    >     This breaks the standard indentation of IF in lisp-mode buffers.
    By standard, I mean the accepted way of indenting IF in common
    lisp.

Do we care about breaking the common-lisp standard for indentation of Emacs
Lisp? I don't care if we break it. (But see below - I see now that you are
not talking about Emacs-Lisp code.)

    it will affect indentation of IF in all modes
    that use common-lisp-indent-function to indent.
    in common lisp:
    (if test
        then
        else)

OK, I understand. The `put' affects also the common-lisp standard
indentation for `if', and that indentation is not appropriate for
Common-Lisp `if'.

My suggestion was not to simply add the above code, but to integrate its
behavior. You're right that it would be preferable to integrate it only for
the proper modes - so that it doesn't affect editing of common-lisp code,
for instance.

Currently, it looks as if common-lisp-mode is an alias for lisp-mode.
Because there are syntax differences between Emacs Lisp and Common Lisp,
perhaps it would be better not to have this simple alias, and to allow for
behavioral differences (e.g. indentation).

Lisp-interaction-mode and emacs-lisp-mode are built on lisp-mode, and they
both should, I think, have the indentation support appropriate to
emacs-lisp. (Not sure about the status of lisp-interaction-mode - in
*scratch*, at least, it is best to have Emacs-Lisp indentation support.)

IOW, the idea is to have this indentation for Emacs Lisp, including in
*scratch* (which is in lisp-interaction-mode). Yes, it would be wrong to
impose this on Common-Lisp (or other Lisp) code also.

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

* Re: Incorrect indentation after :name
  2005-07-07  8:25               ` Lars Brinkhoff
@ 2005-07-08  4:35                 ` Richard M. Stallman
  0 siblings, 0 replies; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-08  4:35 UTC (permalink / raw)
  Cc: emacs-devel

    That's because the Emacs Lisp version of defmacro doesn't accept the
    &body lambda list keyword.  Maybe it should?

We could do that if it is important.  But that should be after the
coming release.  Let's not think about it now.

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

* Re: Incorrect indentation after :name
  2005-07-07 18:49                     ` Juanma Barranquero
@ 2005-07-08  4:36                       ` Richard M. Stallman
  2005-07-11  9:29                         ` Juanma Barranquero
  0 siblings, 1 reply; 39+ messages in thread
From: Richard M. Stallman @ 2005-07-08  4:36 UTC (permalink / raw)
  Cc: emacs-devel

    If you mean that `if's are:

    (if x
	(a)
      (b)
      (c))

    instead of:

    (if x
	(a)
	(b)
	(c))

    I would consider this a clear advantage.

I am not sure which of the two you are preferring.  However, I can
state that the first pattern above is the way Emacs is supposed to
indent an if expression.

This is not going to be changed--please let's not spend time talking
about such a change.

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

* Re: Incorrect indentation after :name
  2005-07-08  4:36                       ` Richard M. Stallman
@ 2005-07-11  9:29                         ` Juanma Barranquero
  2005-07-11 10:59                           ` David Kastrup
  0 siblings, 1 reply; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-11  9:29 UTC (permalink / raw)
  Cc: emacs-devel

On 7/8/05, Richard M. Stallman <rms@gnu.org> wrote:

> I am not sure which of the two you are preferring.  However, I can
> state that the first pattern above is the way Emacs is supposed to
> indent an if expression.

That's the one I prefer (the first one).

> This is not going to be changed--please let's not spend time talking
> about such a change.

I was not talking about such a change. Someone else was talking about
making a change which would not affect elisp `if's, but would have the
side effect that Common Lisp `if's edited with `lisp-indent-function'
set to `common-lisp-indent-function' would indent like the elisp
`if's, instead of both the THEN and ELSE parts at the same indentation
depth as they currently do. Apparently, Lawrence Mitchell didn't like
that.

I was merely stating that I think the Emacs way to indent `if' seems
*much* better to me even for Common Lisp `if's.

-- 
                    /L/e/k/t/u

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

* Re: Incorrect indentation after :name
  2005-07-11  9:29                         ` Juanma Barranquero
@ 2005-07-11 10:59                           ` David Kastrup
  2005-07-11 13:00                             ` Juanma Barranquero
  0 siblings, 1 reply; 39+ messages in thread
From: David Kastrup @ 2005-07-11 10:59 UTC (permalink / raw)
  Cc: rms, emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> I was not talking about such a change. Someone else was talking
> about making a change which would not affect elisp `if's, but would
> have the side effect that Common Lisp `if's edited with
> `lisp-indent-function' set to `common-lisp-indent-function' would
> indent like the elisp `if's, instead of both the THEN and ELSE parts
> at the same indentation depth as they currently do. Apparently,
> Lawrence Mitchell didn't like that.
>
> I was merely stating that I think the Emacs way to indent `if' seems
> *much* better to me even for Common Lisp `if's.

But one would argue that with the maintainer of the Common Lisp mode
and indentation routines instead of overriding an existing hook.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Incorrect indentation after :name
  2005-07-11 10:59                           ` David Kastrup
@ 2005-07-11 13:00                             ` Juanma Barranquero
  0 siblings, 0 replies; 39+ messages in thread
From: Juanma Barranquero @ 2005-07-11 13:00 UTC (permalink / raw)
  Cc: rms, emacs-devel

On 7/11/05, David Kastrup <dak@gnu.org> wrote:

> But one would argue that with the maintainer of the Common Lisp mode
> and indentation routines instead of overriding an existing hook.

??

I was not pushing for or against any change at all...

-- 
                    /L/e/k/t/u

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

end of thread, other threads:[~2005-07-11 13:00 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-03 15:59 Incorrect indentation after :name Lennart Borgman
2005-07-03 16:39 ` Juanma Barranquero
2005-07-03 16:52   ` Lennart Borgman
2005-07-03 17:16     ` Juanma Barranquero
2005-07-03 22:29       ` Drew Adams
2005-07-03 22:44         ` Juanma Barranquero
2005-07-03 17:10   ` Luc Teirlinck
2005-07-04 14:48 ` Stefan Monnier
2005-07-04 21:22   ` David Ponce
2005-07-05  0:40   ` Juanma Barranquero
2005-07-05  4:35   ` Richard M. Stallman
2005-07-05  5:21     ` Stefan Monnier
2005-07-05  7:07       ` Lars Brinkhoff
2005-07-05 19:11         ` Richard M. Stallman
2005-07-05 19:44           ` Lars Brinkhoff
2005-07-07  5:36             ` Richard M. Stallman
2005-07-07  8:25               ` Lars Brinkhoff
2005-07-08  4:35                 ` Richard M. Stallman
2005-07-05 13:49       ` Drew Adams
2005-07-05 16:09         ` Paul Pogonyshev
2005-07-05 19:11       ` Richard M. Stallman
2005-07-06  0:20         ` Luc Teirlinck
2005-07-06  1:29           ` drkm
2005-07-06  1:43             ` Luc Teirlinck
2005-07-06 17:55           ` Richard M. Stallman
2005-07-06 18:30             ` David Kastrup
2005-07-07  3:09               ` Stefan Monnier
2005-07-07 17:01                 ` Drew Adams
2005-07-07 17:49                   ` Lawrence Mitchell
2005-07-07 18:35                     ` Drew Adams
2005-07-07 21:47                       ` Lawrence Mitchell
2005-07-07 22:21                         ` Drew Adams
2005-07-07 18:49                     ` Juanma Barranquero
2005-07-08  4:36                       ` Richard M. Stallman
2005-07-11  9:29                         ` Juanma Barranquero
2005-07-11 10:59                           ` David Kastrup
2005-07-11 13:00                             ` Juanma Barranquero
2005-07-07 21:30                 ` Richard M. Stallman
2005-07-07  5:36               ` Richard M. Stallman

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