all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help on indentation
@ 2012-03-29 10:58 manish honap
  2012-03-29 18:59 ` Nash Steve
  0 siblings, 1 reply; 7+ messages in thread
From: manish honap @ 2012-03-29 10:58 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

I have following query,

In cc-mode

whenever I type `(', I want emacs to automatically insert space before it,
just for symbols [if | while | for | switch] during typing;


How it can be done ?

Thanks,
Manish

[-- Attachment #2: Type: text/html, Size: 476 bytes --]

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

* Re: Help on indentation
  2012-03-29 10:58 Help on indentation manish honap
@ 2012-03-29 18:59 ` Nash Steve
  2012-03-30  6:00   ` manish honap
  0 siblings, 1 reply; 7+ messages in thread
From: Nash Steve @ 2012-03-29 18:59 UTC (permalink / raw)
  To: manish honap; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

insert-parentheses may help.


On Thu, Mar 29, 2012 at 6:58 AM, manish honap
<manish_honap_vit@yahoo.co.in>wrote:

> I have following query,
>
> In cc-mode
> whenever I type `(', I want emacs to automatically insert space before it,
> just for symbols [if | while | for | switch] during typing;
>
> How it can be done ?
>
> Thanks,
> Manish
>

[-- Attachment #2: Type: text/html, Size: 794 bytes --]

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

* Re: Help on indentation
  2012-03-29 18:59 ` Nash Steve
@ 2012-03-30  6:00   ` manish honap
  2012-03-30 12:35     ` Ludwig, Mark
  2012-03-30 13:44     ` Ludwig, Mark
  0 siblings, 2 replies; 7+ messages in thread
From: manish honap @ 2012-03-30  6:00 UTC (permalink / raw)
  To: Nash Steve; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2472 bytes --]

Thanks for your help.

I got a hint from `http://www.emacswiki.org/emacs/LineCopyChar'
and I added,

(defun insert-paren-pair (&optional b)                                                                                                                      
  (interactive "p")                                                                                                                                         
  (let (p col s)                                                                                                                                            
    (setq p (point))                                                                                                                                        
    (setq col (current-column))                                                                                                                             
    (move-to-column col)                                                                                                                                    
    (goto-char p)                                                                                                                                           
    (insert " ()")                                                                                                                                          
    (goto-char (- (point) 1))))                                                                                                                             
                                                                                                                                                            
(define-key global-map (kbd "M-(") 'insert-paren-pair) 

to my .emacs

this won't solve the original problem, but for specific keywords it will suffice.



________________________________
 From: Nash Steve <nash11228@gmail.com>
To: manish honap <manish_honap_vit@yahoo.co.in> 
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> 
Sent: Friday, 30 March 2012 12:29 AM
Subject: Re: Help on indentation
 

insert-parentheses may help.



On Thu, Mar 29, 2012 at 6:58 AM, manish honap <manish_honap_vit@yahoo.co.in> wrote:

I have following query,
>
>
>In cc-mode
>
>whenever I type `(', I want emacs to automatically insert space before it,
>just for symbols [if | while | for | switch] during typing;
>
>
>
>How it can be done ?
>
>
>Thanks,
>Manish

[-- Attachment #2: Type: text/html, Size: 10770 bytes --]

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

* RE: Help on indentation
  2012-03-30  6:00   ` manish honap
@ 2012-03-30 12:35     ` Ludwig, Mark
  2012-03-31 15:50       ` manish honap
  2012-03-30 13:44     ` Ludwig, Mark
  1 sibling, 1 reply; 7+ messages in thread
From: Ludwig, Mark @ 2012-03-30 12:35 UTC (permalink / raw)
  To: manish honap, Nash Steve; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

It's not at all clear why you needed to do this, since M-( is normally bound to insert-parentheses.  (AFAIK, it has been this way for decades.)

Regarding making the '(' character do this, by convention, it would be an "electric" function, and it's probably not very hard to write.  You might even be happy just binding '(' to insert-parentheses.

Hope this helps,
Mark

From: help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org [mailto:help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org] On Behalf Of manish honap
Sent: Friday, March 30, 2012 1:00 AM
To: Nash Steve
Cc: help-gnu-emacs@gnu.org
Subject: Re: Help on indentation

Thanks for your help.

I got a hint from `http://www.emacswiki.org/emacs/LineCopyChar'
and I added,

(defun insert-paren-pair (&optional b)
  (interactive "p")
  (let (p col s)
    (setq p (point))
    (setq col (current-column))
    (move-to-column col)
    (goto-char p)
    (insert " ()")
    (goto-char (- (point) 1))))

(define-key global-map (kbd "M-(") 'insert-paren-pair)

to my .emacs

this won't solve the original problem, but for specific keywords it will suffice.

________________________________
From: Nash Steve <nash11228@gmail.com>
To: manish honap <manish_honap_vit@yahoo.co.in>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Sent: Friday, 30 March 2012 12:29 AM
Subject: Re: Help on indentation

insert-parentheses may help.

On Thu, Mar 29, 2012 at 6:58 AM, manish honap <manish_honap_vit@yahoo.co.in<mailto:manish_honap_vit@yahoo.co.in>> wrote:
I have following query,

In cc-mode
whenever I type `(', I want emacs to automatically insert space before it,
just for symbols [if | while | for | switch] during typing;

How it can be done ?

Thanks,
Manish



[-- Attachment #2: Type: text/html, Size: 17383 bytes --]

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

* RE: Help on indentation
  2012-03-30  6:00   ` manish honap
  2012-03-30 12:35     ` Ludwig, Mark
@ 2012-03-30 13:44     ` Ludwig, Mark
  2012-03-31 15:52       ` manish honap
  1 sibling, 1 reply; 7+ messages in thread
From: Ludwig, Mark @ 2012-03-30 13:44 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2964 bytes --]

There is curious synchronicity on this topic, because my colleagues are reviewing some of my code this week and are challenging me about the spaces before the argument lists for function calls.  (They mostly use 'vi'....)

Normal Emacs behavior using M-( results in the following (could be Java or C):

   if (foo1 (bar, baz))
      foo2 ();

What we want is:

   if (foo1(bar, baz))
      foo2();

That is, we only want a space to be inserted after a language keyword.  Has anyone hacked this (presumably as part of or in conjunction with CC Mode) for conditionally adding the space before the open parentheses?  The reason I expect it to be related to CC Mode is that it's the fact that "if" is a language keyword that makes the difference, and CC Mode already knows about the keywords.  Looking at insert-parentheses and insert-pair, it seems as though insert-parentheses could be wrapped in something like cc-insert-parentheses to do this.  That's what I'll start doing if no one else pipes up....

Thanks!
Mark

From: Ludwig, Mark
Sent: Friday, March 30, 2012 7:36 AM
To: 'manish honap'; Nash Steve
Cc: help-gnu-emacs@gnu.org
Subject: RE: Help on indentation

It's not at all clear why you needed to do this, since M-( is normally bound to insert-parentheses.  (AFAIK, it has been this way for decades.)

Regarding making the '(' character do this, by convention, it would be an "electric" function, and it's probably not very hard to write.  You might even be happy just binding '(' to insert-parentheses.

Hope this helps,
Mark

From: help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org [mailto:help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org] On Behalf Of manish honap
Sent: Friday, March 30, 2012 1:00 AM
To: Nash Steve
Cc: help-gnu-emacs@gnu.org
Subject: Re: Help on indentation

Thanks for your help.

I got a hint from `http://www.emacswiki.org/emacs/LineCopyChar'
and I added,

(defun insert-paren-pair (&optional b)
  (interactive "p")
  (let (p col s)
    (setq p (point))
    (setq col (current-column))
    (move-to-column col)
    (goto-char p)
    (insert " ()")
    (goto-char (- (point) 1))))

(define-key global-map (kbd "M-(") 'insert-paren-pair)

to my .emacs

this won't solve the original problem, but for specific keywords it will suffice.

________________________________
From: Nash Steve <nash11228@gmail.com>
To: manish honap <manish_honap_vit@yahoo.co.in>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Sent: Friday, 30 March 2012 12:29 AM
Subject: Re: Help on indentation

insert-parentheses may help.

On Thu, Mar 29, 2012 at 6:58 AM, manish honap <manish_honap_vit@yahoo.co.in<mailto:manish_honap_vit@yahoo.co.in>> wrote:
I have following query,

In cc-mode
whenever I type `(', I want emacs to automatically insert space before it,
just for symbols [if | while | for | switch] during typing;

How it can be done ?

Thanks,
Manish



[-- Attachment #2: Type: text/html, Size: 21720 bytes --]

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

* Re: Help on indentation
  2012-03-30 12:35     ` Ludwig, Mark
@ 2012-03-31 15:50       ` manish honap
  0 siblings, 0 replies; 7+ messages in thread
From: manish honap @ 2012-03-31 15:50 UTC (permalink / raw)
  To: Ludwig, Mark, Nash Steve; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 4983 bytes --]

Well when we use `insert-parentheses' it inserts parentheses immediately without any space character like this -

`if()'; but the following binding inserts as `if ()'

Thanks,
Manish


________________________________
 From: "Ludwig, Mark" <ludwig.mark@siemens.com>
To: manish honap <manish_honap_vit@yahoo.co.in>; Nash Steve <nash11228@gmail.com> 
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> 
Sent: Friday, 30 March 2012 6:05 PM
Subject: RE: Help on indentation
 

 
It’s not at all clear why you needed to do this, since M-( is normally bound to insert-parentheses.  (AFAIK, it has been this way for decades.)
 
Regarding making the ‘(‘ character do this, by convention, it would be an “electric” function, and it’s probably not very hard to write.  You might even be happy just binding ‘(‘ to insert-parentheses.
 
Hope this helps,
Mark
 
From:help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org [mailto:help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org] On Behalf Of manish honap
Sent: Friday, March 30, 2012 1:00 AM
To: Nash Steve
Cc: help-gnu-emacs@gnu.org
Subject: Re: Help on indentation
 
Thanks for your help.
 
I got a hint from `http://www.emacswiki.org/emacs/LineCopyChar'
and I added,
 
(defun insert-paren-pair (&optional b)                                                                                                                      
  (interactive "p")                                                                                                                                         
  (let (p col s)                                                                                                                                            
    (setq p (point))                                                                                                                                        
    (setq col (current-column))                                                                                                                             
    (move-to-column col)                                                                                                                                    
    (goto-char p)                                                                                                                                           
    (insert " ()")                                                                                                                                          
    (goto-char (- (point) 1))))                                                                                                                             
                                                                                                                                                            
(define-key global-map (kbd "M-(") 'insert-paren-pair) 
 
to my .emacs
 
this won't solve the original problem, but for specific keywords it will suffice.
 

________________________________
 
From:Nash Steve <nash11228@gmail.com>
To: manish honap <manish_honap_vit@yahoo.co.in> 
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> 
Sent: Friday, 30 March 2012 12:29 AM
Subject: Re: Help on indentation
 
insert-parentheses may help.
 
On Thu, Mar 29, 2012 at 6:58 AM, manish honap <manish_honap_vit@yahoo.co.in> wrote:
I have following query,
 
In cc-mode
whenever I type `(', I want emacs to automatically insert space before it,
just for symbols [if | while | for | switch] during typing;
 
How it can be done ?
 
Thanks,
Manish

[-- Attachment #2: Type: text/html, Size: 17347 bytes --]

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

* Re: Help on indentation
  2012-03-30 13:44     ` Ludwig, Mark
@ 2012-03-31 15:52       ` manish honap
  0 siblings, 0 replies; 7+ messages in thread
From: manish honap @ 2012-03-31 15:52 UTC (permalink / raw)
  To: Ludwig, Mark, help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 6185 bytes --]

I started the topic due to same issue.
I used `paredit.el', but it also did in the same manner you showed - inserting spaces even after function call parenthesis.

Have to check how to modify cc-mode `(' binding...

Thanks,
Manish


________________________________
 From: "Ludwig, Mark" <ludwig.mark@siemens.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> 
Sent: Friday, 30 March 2012 7:14 PM
Subject: RE: Help on indentation
 

 
There is curious synchronicity on this topic, because my colleagues are reviewing some of my code this week and are challenging me about the spaces before the argument lists for function calls.  (They mostly use ‘vi’….)
 
Normal Emacs behavior using M-( results in the following (could be Java or C):
 
   if (foo1 (bar, baz))
      foo2 ();
 
What we want is:
 
   if (foo1(bar, baz))
      foo2();
 
That is, we only want a space to be inserted after a language keyword.  Has anyone hacked this (presumably as part of or in conjunction with CC Mode) for conditionally adding the space before the open parentheses?  The reason I expect it to be related to CC Mode is that it’s the fact that “if” is a language keyword that makes the difference, and CC Mode already knows about the keywords.  Looking at insert-parentheses and insert-pair, it seems as though insert-parentheses could be wrapped in something like cc-insert-parentheses to do this.  That’s what I’ll start doing if no one else pipes up….
 
Thanks!
Mark
 
From:Ludwig, Mark 
Sent: Friday, March 30, 2012 7:36 AM
To: 'manish honap'; Nash Steve
Cc: help-gnu-emacs@gnu.org
Subject: RE: Help on indentation
 
It’s not at all clear why you needed to do this, since M-( is normally bound to insert-parentheses.  (AFAIK, it has been this way for decades.)
 
Regarding making the ‘(‘ character do this, by convention, it would be an “electric” function, and it’s probably not very hard to write.  You might even be happy just binding ‘(‘ to insert-parentheses.
 
Hope this helps,
Mark
 
From:help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org [mailto:help-gnu-emacs-bounces+ludwig.mark=siemens.com@gnu.org] On Behalf Of manish honap
Sent: Friday, March 30, 2012 1:00 AM
To: Nash Steve
Cc: help-gnu-emacs@gnu.org
Subject: Re: Help on indentation
 
Thanks for your help.
 
I got a hint from `http://www.emacswiki.org/emacs/LineCopyChar'
and I added,
 
(defun insert-paren-pair (&optional b)                                                                                                                      
  (interactive "p")                                                                                                                                         
  (let (p col s)                                                                                                                                            
    (setq p (point))                                                                                                                                        
    (setq col (current-column))                                                                                                                             
    (move-to-column col)                                                                                                                                    
    (goto-char p)                                                                                                                                           
    (insert " ()")                                                                                                                                          
    (goto-char (- (point) 1))))                                                                                                                             
                                                                                                                                                            
(define-key global-map (kbd "M-(") 'insert-paren-pair) 
 
to my .emacs
 
this won't solve the original problem, but for specific keywords it will suffice.
 

________________________________
 
From:Nash Steve <nash11228@gmail.com>
To: manish honap <manish_honap_vit@yahoo.co.in> 
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> 
Sent: Friday, 30 March 2012 12:29 AM
Subject: Re: Help on indentation
 
insert-parentheses may help.
 
On Thu, Mar 29, 2012 at 6:58 AM, manish honap <manish_honap_vit@yahoo.co.in> wrote:
I have following query,
 
In cc-mode
whenever I type `(', I want emacs to automatically insert space before it,
just for symbols [if | while | for | switch] during typing;
 
How it can be done ?
 
Thanks,
Manish

[-- Attachment #2: Type: text/html, Size: 20809 bytes --]

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

end of thread, other threads:[~2012-03-31 15:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-29 10:58 Help on indentation manish honap
2012-03-29 18:59 ` Nash Steve
2012-03-30  6:00   ` manish honap
2012-03-30 12:35     ` Ludwig, Mark
2012-03-31 15:50       ` manish honap
2012-03-30 13:44     ` Ludwig, Mark
2012-03-31 15:52       ` manish honap

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.