GNU bug report logs - #11107
24.0.94; indentation in objc-mode

Previous Next

Packages: cc-mode, emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Wed, 28 Mar 2012 01:57:02 UTC

Severity: normal

Found in version 24.0.94

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11107 in the body.
You can then email your comments to 11107 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org:
bug#11107; Package emacs. (Wed, 28 Mar 2012 01:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org. (Wed, 28 Mar 2012 01:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.94; indentation in objc-mode
Date: Wed, 28 Mar 2012 09:23:32 +0800
[kk.m (text/plain, attachment)]
[Message part 2 (text/plain, inline)]
1. Emacs -q
2. Open the attach file
3. Eval in the file buffer:
   - (c-set-style "bsd")
   - (setq c-basic-offset 4)

Try indenting the file, you will see : in the message name not aligned
properly as shown in this picture.
[objc-bug.png (image/png, attachment)]
[Message part 4 (text/plain, inline)]
Leo

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11107; Package emacs,cc-mode. (Thu, 29 Mar 2012 14:09:01 GMT) Full text and rfc822 format available.

Message #8 received at 11107 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Leo <sdl.web <at> gmail.com>
Cc: bug-cc-mode <at> gnu.org, 11107 <at> debbugs.gnu.org
Subject: Re: bug#11107: 24.0.94; indentation in objc-mode
Date: Thu, 29 Mar 2012 13:35:28 +0000
Hello, Leo.

On Wed, Mar 28, 2012 at 09:23:32AM +0800, Leo wrote:
> -(IBAction)loginClicked:(id)sender
> {
>     if (![username.text isEqualToString:@""]&&![password.text isEqualToString:@""]&&![companyCode.text isEqualToString:@""]) {
>         if ([username.text isMatchedByRegex:@"[a-zA-Z0-9]+"]&&[password.text isMatchedByRegex:@"[a-zA-Z0-9]+"]&&[companyCode.text isMatchedByRegex:@"[a-zA-Z0-9]+"]) {
>             ;
>         } else {
>             UIAlertView *alert = [[[UIAlertView alloc]
>                                       initWithTitle:@""
>                                             message:@""
>                                            delegate:self
>                                       cancelButtonTitle:@""
>                                       otherButtonTitles:nil] autorelease];
>             [alert show];
>         }
>     } else {
>         UIAlertView *alert = [[[UIAlertView alloc]
>                                    initWithTitle:@""
>                                          message:@""
>                                         delegate:self
>                                   cancelButtonTitle:@""
>                                   otherButtonTitles:nil] autorelease];
>         [alert show];
>     }
> }


> 1. Emacs -q
> 2. Open the attach file
> 3. Eval in the file buffer:
>    - (c-set-style "bsd")
>    - (setq c-basic-offset 4)

> Try indenting the file, you will see : in the message name not aligned
> properly as shown in this picture.

What is happening here is this:

cancelButtonTitle would, if its : were lined up, not be sufficiently
indented from the enclosing [.  Here "sufficiently indented" is
determined by the variable c-objc-method-arg-min-delta-to-bracket, whose
default value is 2.  On failing that test, the line gets indented
c-basic-offset columns after that [.

The simplest WAY TO FIX THIS is to give a lower value to
c-objc-method-arg-min-delta-to-bracket (honestly, I didn't invent that
name ;-), probably a negative number.  You can set this variable via
M-x customize-variable, or your favourite other method.

There is actually a lineup-function c-lineup-ObjC-method-args which
should do exactly what you want, but sadly it doesn't work at all.  I'll
need to fix it sometime.

########################################################################
OPTIONAL SECTION

If you're interested in what's going on here, do C-c C-o on the
cancelButtonTitle line, then hit <CR>.  You get
(default (c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)).
The "default" means "execute the functions in the following list until
one returns non-nil".  The first one returns nil on the
cancelButtonTitle.  The second one returns 4, the relative indentation
used.

All this is detailed in the CC Mode manual in the chapter "Customizing
indentation" and its subsections, in particular "Line-Up Functions"
together with its subsections.
#########################################################################

-- 
Alan Mackenzie (Nuremberg, Germany).




Reply sent to Leo <sdl.web <at> gmail.com>:
You have taken responsibility. (Mon, 02 Apr 2012 05:40:01 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Mon, 02 Apr 2012 05:40:01 GMT) Full text and rfc822 format available.

Message #13 received at 11107-done <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 11107-done <at> debbugs.gnu.org
Subject: Re: bug#11107: 24.0.94; indentation in objc-mode
Date: Sun, 01 Apr 2012 05:19:36 +0800
On 2012-03-29 21:35 +0800, Alan Mackenzie wrote:
> What is happening here is this:

Thank you for the excellent explanation. I have closed this nonbug.

Leo




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 30 Apr 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 109 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.