* indent-according-to-mode
@ 2006-07-31 18:37 Gary Wessle
2006-07-31 20:13 ` indent-according-to-mode Dieter Wilhelm
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Gary Wessle @ 2006-07-31 18:37 UTC (permalink / raw)
hi
how can I get this function to work on a region? or the whole buffer?
I tried to mark a region and M-x indent-according-to-mode but did not
indent this c++ code.
C-M-q did not work either after I selected the region using M-h C-f
GNU Emacs 21.4.1
thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: indent-according-to-mode
2006-07-31 18:37 indent-according-to-mode Gary Wessle
@ 2006-07-31 20:13 ` Dieter Wilhelm
[not found] ` <mailman.4725.1154387246.9609.help-gnu-emacs@gnu.org>
2006-08-02 11:39 ` indent-according-to-mode kala
2 siblings, 0 replies; 7+ messages in thread
From: Dieter Wilhelm @ 2006-07-31 20:13 UTC (permalink / raw)
Cc: help-gnu-emacs
Gary Wessle <phddas@yahoo.com> writes:
indent-according-to-mode is only for a line (check it out: C-h f when
the cursor is over the function name).
> how can I get this function to work on a region?
M-C-\ (C-h k M-C-\)
> or the whole buffer?
C-x h M-C-\
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: indent-according-to-mode
[not found] ` <mailman.4725.1154387246.9609.help-gnu-emacs@gnu.org>
@ 2006-08-01 0:18 ` Gary Wessle
2006-08-01 1:10 ` indent-according-to-mode wenbinye
2006-08-01 15:30 ` indent-according-to-mode Kevin Rodgers
0 siblings, 2 replies; 7+ messages in thread
From: Gary Wessle @ 2006-08-01 0:18 UTC (permalink / raw)
Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
> Gary Wessle <phddas@yahoo.com> writes:
>
> indent-according-to-mode is only for a line (check it out: C-h f when
> the cursor is over the function name).
>
> > how can I get this function to work on a region?
>
> M-C-\ (C-h k M-C-\)
>
> > or the whole buffer?
>
> C-x h M-C-\
this in my .emacs is causing a problem, could you point it out?
thanks
(global-set-key [f5] (kbd "M-h M-C-\"))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: indent-according-to-mode
2006-08-01 0:18 ` indent-according-to-mode Gary Wessle
@ 2006-08-01 1:10 ` wenbinye
2006-08-01 15:32 ` indent-according-to-mode Kevin Rodgers
2006-08-01 15:30 ` indent-according-to-mode Kevin Rodgers
1 sibling, 1 reply; 7+ messages in thread
From: wenbinye @ 2006-08-01 1:10 UTC (permalink / raw)
You can do like this:
C-x ( M-h C-M-\ C-x )
C-x C-k b my-indent-paragraph
M-x insert-kbd-macro
The code will insert to current buffer:
(fset 'my-indent-paragraph
(lambda (&optional arg) "Keyboard macro." (interactive "p")
(kmacro-exec-ring-item (quote ("\350\234" 0 "%d")) arg)))
Then you can write this to .emacs:
(defun my-indent-paragraph (&optional arg)
"Keyboard macro."
(interactive "p")
(kmacro-exec-ring-item (quote ("\350\234" 0 "%d")) arg)))
(global-set-key (kbd "<f5>") 'my-indent-region)
or just:
(global-set-key (kbd "<f5>")
(lambda (&optional arg) "Keyboard macro." (interactive "p")
(kmacro-exec-ring-item (quote ("\350\234" 0 "%d")) arg)))
For documents, see info emacs: Keyboad macros
Gary Wessle wrote:
> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
> > Gary Wessle <phddas@yahoo.com> writes:
> >
> > indent-according-to-mode is only for a line (check it out: C-h f when
> > the cursor is over the function name).
> >
> > > how can I get this function to work on a region?
> >
> > M-C-\ (C-h k M-C-\)
> >
> > > or the whole buffer?
> >
> > C-x h M-C-\
>
> this in my .emacs is causing a problem, could you point it out?
>
> thanks
>
> (global-set-key [f5] (kbd "M-h M-C-\"))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: indent-according-to-mode
2006-08-01 0:18 ` indent-according-to-mode Gary Wessle
2006-08-01 1:10 ` indent-according-to-mode wenbinye
@ 2006-08-01 15:30 ` Kevin Rodgers
1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2006-08-01 15:30 UTC (permalink / raw)
Gary Wessle wrote:
> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
>> Gary Wessle <phddas@yahoo.com> writes:
>>
>> indent-according-to-mode is only for a line (check it out: C-h f when
>> the cursor is over the function name).
>>
>>> how can I get this function to work on a region?
>> M-C-\ (C-h k M-C-\)
>>
>>> or the whole buffer?
>> C-x h M-C-\
>
> this in my .emacs is causing a problem, could you point it out?
>
> thanks
>
> (global-set-key [f5] (kbd "M-h M-C-\"))
The backslash escapes the following double quote, so you've got an
unterminated string. You need to escape the backslash with another
backslash:
(global-set-key [f5] (kbd "M-h M-C-\\"))
--
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: indent-according-to-mode
2006-08-01 1:10 ` indent-according-to-mode wenbinye
@ 2006-08-01 15:32 ` Kevin Rodgers
0 siblings, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2006-08-01 15:32 UTC (permalink / raw)
wenbinye@gmail.com wrote:
> You can do like this:
> C-x ( M-h C-M-\ C-x )
> C-x C-k b my-indent-paragraph
> M-x insert-kbd-macro
>
> The code will insert to current buffer:
> (fset 'my-indent-paragraph
> (lambda (&optional arg) "Keyboard macro." (interactive "p")
> (kmacro-exec-ring-item (quote ("\350\234" 0 "%d")) arg)))
>
> Then you can write this to .emacs:
> (defun my-indent-paragraph (&optional arg)
> "Keyboard macro."
> (interactive "p")
> (kmacro-exec-ring-item (quote ("\350\234" 0 "%d")) arg)))
> (global-set-key (kbd "<f5>") 'my-indent-region)
>
> or just:
> (global-set-key (kbd "<f5>")
> (lambda (&optional arg) "Keyboard macro." (interactive "p")
> (kmacro-exec-ring-item (quote ("\350\234" 0 "%d")) arg)))
What is all that "\350\234" cruft?
--
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: indent-according-to-mode
2006-07-31 18:37 indent-according-to-mode Gary Wessle
2006-07-31 20:13 ` indent-according-to-mode Dieter Wilhelm
[not found] ` <mailman.4725.1154387246.9609.help-gnu-emacs@gnu.org>
@ 2006-08-02 11:39 ` kala
2 siblings, 0 replies; 7+ messages in thread
From: kala @ 2006-08-02 11:39 UTC (permalink / raw)
Hi Gary Wessle-2.
I'm writing Linux kernel level c-code, and thus have to use Linux kernel
indentation (8 characters.) I'm using GNU Emacs 21.4.1, and the following
works for me. Write in the .emacs-file:
;; use Linux kernel style (indendation of 8 characters etc.) for all C like
languages.
(defun my-c-mode-common-hook ()
(c-set-style "linux"))
;; Add a hook to common mode.
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;; Bind F5-key to indent a region of code according to the current
indentation style
(global-set-key [f5] 'indent-region)
Now in emacs you can indent a region by moving to the beginning of the
region and pressing CTRL + SPACE and then moving to the end of the region
and pressing F5.
Following indentation styles are available:
bsd, cc-mode, ellemtel, gnu, java, k&r, linux, python, stroustrup, user,
whitesmith.
Hope this was a useful piece of advice to you.
--
View this message in context: http://www.nabble.com/indent-according-to-mode-tf2029327.html#a5612101
Sent from the Emacs - Help forum at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-08-02 11:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-31 18:37 indent-according-to-mode Gary Wessle
2006-07-31 20:13 ` indent-according-to-mode Dieter Wilhelm
[not found] ` <mailman.4725.1154387246.9609.help-gnu-emacs@gnu.org>
2006-08-01 0:18 ` indent-according-to-mode Gary Wessle
2006-08-01 1:10 ` indent-according-to-mode wenbinye
2006-08-01 15:32 ` indent-according-to-mode Kevin Rodgers
2006-08-01 15:30 ` indent-according-to-mode Kevin Rodgers
2006-08-02 11:39 ` indent-according-to-mode kala
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.