unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* indenting java code
@ 2003-11-03 23:47 Lowell Kirsh
  2003-11-04  0:10 ` Andrew Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Lowell Kirsh @ 2003-11-03 23:47 UTC (permalink / raw)


How can I change the indent level for Java code from 4 spaces to 2 spaces?

Lowell

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

* Re: indenting java code
  2003-11-03 23:47 indenting java code Lowell Kirsh
@ 2003-11-04  0:10 ` Andrew Taylor
  2003-11-04  2:09   ` Lowell Kirsh
  2003-11-04 15:49   ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Taylor @ 2003-11-04  0:10 UTC (permalink / raw)


Lowell Kirsh wrote:

> How can I change the indent level for Java code from 4 spaces to 2 spaces?

(add-hook 'java-mode-hook
           (lambda ()
             (set 'c-basic-offset 2)))

-- 
Andrew

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

* Re: indenting java code
  2003-11-04  0:10 ` Andrew Taylor
@ 2003-11-04  2:09   ` Lowell Kirsh
  2003-11-04 15:49   ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Lowell Kirsh @ 2003-11-04  2:09 UTC (permalink / raw)


Perfect! Thanks.

Lowell


Andrew Taylor wrote:
> Lowell Kirsh wrote:
> 
>> How can I change the indent level for Java code from 4 spaces to 2 
>> spaces?
> 
> 
> (add-hook 'java-mode-hook
>           (lambda ()
>             (set 'c-basic-offset 2)))
> 

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

* Re: indenting java code
  2003-11-04  0:10 ` Andrew Taylor
  2003-11-04  2:09   ` Lowell Kirsh
@ 2003-11-04 15:49   ` Stefan Monnier
  2003-11-05 23:17     ` Dan Anderson
       [not found]     ` <mailman.3280.1068074352.21628.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2003-11-04 15:49 UTC (permalink / raw)


> (add-hook 'java-mode-hook
>            (lambda ()
>              (set 'c-basic-offset 2)))
                ^^^^^
               (setq c-basic-offset 2)

`set' is very bad style here.


        Stefan

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

* Re: indenting java code
  2003-11-04 15:49   ` Stefan Monnier
@ 2003-11-05 23:17     ` Dan Anderson
       [not found]     ` <mailman.3280.1068074352.21628.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Dan Anderson @ 2003-11-05 23:17 UTC (permalink / raw)
  Cc: help-gnu-emacs

> `set' is very bad style here.

Out of curiosity, can you explain why setq is better then set?  

Thanks in advance,

Dan

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

* Re: indenting java code
       [not found]     ` <mailman.3280.1068074352.21628.help-gnu-emacs@gnu.org>
@ 2003-11-06 18:12       ` Kevin Rodgers
  2003-11-06 22:14       ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2003-11-06 18:12 UTC (permalink / raw)


Dan Anderson wrote:

>>`set' is very bad style here.
>>
> 
> Out of curiosity, can you explain why setq is better then set?  


Because it's the convention to only use set when the SYMBOL isn't known
(lexically) and has to be determined by evaluation.

Because (setq foo bar) == (set 'foo bar) == (set (quote foo) bar),
but setq doesn't require the Lisp reader to allocate 2 cons cells
for (quote foo).


-- 
Kevin Rodgers

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

* Re: indenting java code
       [not found]     ` <mailman.3280.1068074352.21628.help-gnu-emacs@gnu.org>
  2003-11-06 18:12       ` Kevin Rodgers
@ 2003-11-06 22:14       ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2003-11-06 22:14 UTC (permalink / raw)


>> `set' is very bad style here.
> Out of curiosity, can you explain why setq is better then set?  

- You can't make `set' lexically scoped.
- You can't (in general) analyse `set' to see if the variable was properly
  declared, etc... so the byte-compiler can't make sanity checks
  or optimizations.
- Basically `set' is in the same category as `eval' which is also
  something to keep the few cases where nothing else works.


        Stefan

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

end of thread, other threads:[~2003-11-06 22:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-03 23:47 indenting java code Lowell Kirsh
2003-11-04  0:10 ` Andrew Taylor
2003-11-04  2:09   ` Lowell Kirsh
2003-11-04 15:49   ` Stefan Monnier
2003-11-05 23:17     ` Dan Anderson
     [not found]     ` <mailman.3280.1068074352.21628.help-gnu-emacs@gnu.org>
2003-11-06 18:12       ` Kevin Rodgers
2003-11-06 22:14       ` Stefan Monnier

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