all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* defun in global-set-key
@ 2004-11-14 14:40 Rodrigo Canellas
  0 siblings, 0 replies; 4+ messages in thread
From: Rodrigo Canellas @ 2004-11-14 14:40 UTC (permalink / raw)


hi,


I defined this in '.emacs' this function:

(defun indent-all (interactive) ()
  (mark-whole-buffer)
  (indent-region)
  )

and associated to a key:

(global-set-key [f2] 'indent-all)


But when I load a file and press F2, the whole buffer is selected, but the 
'indent-region' fails, and a long and uncompreensible message is displayed in 
the mini-buffer. 

Does anyone know what am I doing wrong?

Thanks, 
  Rodrigo 

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

* Re: defun in global-set-key
       [not found] <mailman.2652.1100443955.8225.help-gnu-emacs@gnu.org>
@ 2004-11-14 15:47 ` Pascal Bourguignon
  2004-11-14 19:11 ` Thien-Thi Nguyen
  2004-11-15  9:10 ` Joakim Hove
  2 siblings, 0 replies; 4+ messages in thread
From: Pascal Bourguignon @ 2004-11-14 15:47 UTC (permalink / raw)


Rodrigo Canellas <r.canellas@terra.com.br> writes:

> hi,
> 
> 
> I defined this in '.emacs' this function:
> 
> (defun indent-all (interactive) ()
>   (mark-whole-buffer)
>   (indent-region)
>   )
> 
> and associated to a key:
> 
> (global-set-key [f2] 'indent-all)
> 
> 
> But when I load a file and press F2, the whole buffer is selected, but the 
> 'indent-region' fails, and a long and uncompreensible message is displayed in 
> the mini-buffer. 
> 
> Does anyone know what am I doing wrong?

interactive is a declaration. That must be written after the arguments
and documentation string:

(defun indent-all ()
    "Will idnent the whole buffer."
    (interactive)
    (mark-whole-buffer)
    (indent-region))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.

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

* Re: defun in global-set-key
       [not found] <mailman.2652.1100443955.8225.help-gnu-emacs@gnu.org>
  2004-11-14 15:47 ` defun in global-set-key Pascal Bourguignon
@ 2004-11-14 19:11 ` Thien-Thi Nguyen
  2004-11-15  9:10 ` Joakim Hove
  2 siblings, 0 replies; 4+ messages in thread
From: Thien-Thi Nguyen @ 2004-11-14 19:11 UTC (permalink / raw)


Rodrigo Canellas <r.canellas@terra.com.br> writes:

> (defun indent-all (interactive) ()
>   (mark-whole-buffer)
>   (indent-region)
>   )

you can also try:

(global-set-key [f2]
  (defun indent-all () (interactive)
    (indent-region (point-min) (point-max))))

thi

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

* Re: defun in global-set-key
       [not found] <mailman.2652.1100443955.8225.help-gnu-emacs@gnu.org>
  2004-11-14 15:47 ` defun in global-set-key Pascal Bourguignon
  2004-11-14 19:11 ` Thien-Thi Nguyen
@ 2004-11-15  9:10 ` Joakim Hove
  2 siblings, 0 replies; 4+ messages in thread
From: Joakim Hove @ 2004-11-15  9:10 UTC (permalink / raw)



Rodrigo Canellas <r.canellas@terra.com.br> writes:


> Does anyone know what am I doing wrong?

A debugging tip:

Try out your function with M-x indent-all before binding it to a
key. In your case you would then see that the problem was with the
function defenition, and not with the keybinding. 


Joakim

-- 
Joakim Hove
hove AT ift uib no
Tlf: +47 (55 5)8 27 90 
Fax: +47 (55 5)8 94 40
http://www.ift.uib.no/~hove/

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

end of thread, other threads:[~2004-11-15  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2652.1100443955.8225.help-gnu-emacs@gnu.org>
2004-11-14 15:47 ` defun in global-set-key Pascal Bourguignon
2004-11-14 19:11 ` Thien-Thi Nguyen
2004-11-15  9:10 ` Joakim Hove
2004-11-14 14:40 Rodrigo Canellas

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.