|
From: | Ludwig, Mark |
Subject: | RE: Help on indentation |
Date: | Fri, 30 Mar 2012 13:44:05 +0000 |
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
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 Thanks for your help. I got a hint from `http://www.emacswiki.org/emacs/LineCopyChar' and I added, (defun insert-paren-pair (&optional b)
to my .emacs this won't solve the original problem, but for specific keywords it will suffice. From: Nash Steve <nash11228@gmail.com> 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 |
[Prev in Thread] | Current Thread | [Next in Thread] |