unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cc-mode enhancement for Objective-C
@ 2007-10-13  6:43 Adrian Robert
  2007-10-13 19:48 ` Richard Stallman
  2007-10-13 21:13 ` Alan Mackenzie
  0 siblings, 2 replies; 13+ messages in thread
From: Adrian Robert @ 2007-10-13  6:43 UTC (permalink / raw)
  To: emacs-devel

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

Hi,

This patch, against emacs-unicode-2/lisp/progmodes, enhances cc-mode's
handling of Objective-C:

- auto-indent method calls by colons (like XCode)
- syntax highlighting for method calls
- add more constants for font-lock highlighting

The original version was written by Michael Weber, and I updated it
for GNU emacs-21+.  I'd be interested in getting it into the emacs
distribution as it would provide a better out-of-box environment for
Objective-C developers.  I'm unsure if that means it needs to go into
cc-mode's own tree?  I sent a couple of messages a while ago to
cc-mode's own list but they may have been drowned in spam.
(http://article.gmane.org/gmane.emacs.cc-mode-general/2692)

(If there are any Obj-C devs using emacs on this list, perhaps they
could try the patch -- it's also built-in to the Emacs.app
distribution at http://emacs-app.sf.net/ )


Changed files:

cc-align.el (c-lineup-ObjC-method-call-colons): New function to indent
	method calls.

cc-fonts.el (c-complex-decl-matchers: c-font-lock-objc-methods): Add code to
	highlight method calls.

cc-langs.el (c-constant-kwds): Add constant keywords for ObjC boolean types,
	exception macros, and GNUstep ref-counting macros.

cc-menus.el (cc-imenu-objc-function): Drop obsolete calls to
	imenu-progress-message.

cc-vars.el (objc-method-arg-min-delta-to-bracket,
	objc-method-arg-unfinished-offset, objc-method-parameter-offset): New
	variables for customizing (c-lineup-ObjC-method-call).
	(c-offsets-alist): Add ObjC-specific rules.

[-- Attachment #2: objc-enhance_v3.patch --]
[-- Type: application/octet-stream, Size: 5958 bytes --]

Index: cc-align.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-align.el,v
retrieving revision 1.20.2.13
diff -r1.20.2.13 cc-align.el
910a911,953
> (defun c-lineup-ObjC-method-call-colons (langelem)
>   "Line up selector args as Project Builder / XCode: colons of first
>    selector portions on successive lines are aligned.  If no decision can
>    be made return NIL, so that other lineup methods can be tried.  This is
>    typically chained with `c-lineup-ObjC-method-call'.
> 
> Works with: objc-method-call-cont."
>   (save-excursion
>     (catch 'no-idea
>       (let* ((method-arg-len (progn
> 			       (back-to-indentation)
> 			       (if (search-forward ":" (c-point 'eol) 'move)
> 				   (- (point) (c-point 'boi))
> 				 ; no complete argument to indent yet
> 				 (throw 'no-idea nil))))
> 
> 	     (extra (save-excursion 
>                       ; indent parameter to argument if needed
> 		      (back-to-indentation)
> 		      (c-backward-syntactic-ws (cdr langelem))
> 		      (if (eq ?: (char-before))
> 			  (c-get-offset '(objc-method-parameter-offset . nil))
> 			0)))
> 
> 	     (open-bracket-col (c-langelem-col langelem))
> 
> 	     (arg-ralign-colon-ofs (progn
> 			(forward-char) ; skip over '['
> 			; skip over object/class name
> 			; and first argument
> 			(c-forward-sexp 2)
> 			(if (search-forward ":" (c-point 'eol) 'move)
> 			    (- (current-column) open-bracket-col
> 			       method-arg-len extra)
> 			  ; previous arg has no param
>   			  (c-get-offset
> 			   '(objc-method-arg-unfinished-offset . nil))))))
> 
> 	(if (>= arg-ralign-colon-ofs
> 		(c-get-offset '(objc-method-arg-min-delta-to-bracket . nil)))
> 	    (+ arg-ralign-colon-ofs extra)
> 	  (throw 'no-idea nil))))))
> 
912c955
<   "Line up the colons that separate args.
---
>   "Line up the colons that separate args in a method declaration.
936c979
<   "Line up the colons that separate args.
---
>   "Line up the colons that separate args in a method declaration.
Index: cc-fonts.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-fonts.el,v
retrieving revision 1.2.2.17
diff -r1.2.2.17 cc-fonts.el
1322c1322,1350
< 	      c-font-lock-objc-methods))
---
> 
> 	      c-font-lock-objc-methods
> 
> 	      ;; Parts of selector name in messages
> 	      ;; PENDING: perhaps should change to only pick up inside brackets
> 	      ("\\sw*:" 0 font-lock-function-name-face keep t)
> 
> 	      ;; get argument-less selectors' highlighting right
> 	      ;; [[foo _bar_] _baz_] -> bar, baz are highlighted
> 	      ("\\(\\sw+\\)[ \t]*[]]"
> 		(1 (let ((non-ws-before-match (char-before 
> 			      (save-excursion
> 				(goto-char (match-beginning 1))
> 				;; expensive!
> 				(c-backward-syntactic-ws (c-point 'bol))
> 				(point)
> 				))))
> 		      (unless (or (eq ?:  non-ws-before-match)
> 				  (eq ?\[ non-ws-before-match)
> 				  (eq ?> non-ws-before-match))
> 			font-lock-function-name-face)))))
> 	  ;; PENDING: unsure if c-nonlabel-token-key or c-opt-extra-label-key
> 	  ;;          should be used here
> 	  (when (c-lang-const c-opt-extra-label-key)
> 	    `(,(c-make-font-lock-search-function
> 		(c-lang-const c-opt-extra-label-key)
> 		'((c-put-char-property (1- (match-end 0))
> 				       'c-type 'c-decl-end)))))
> 	  )
Index: cc-langs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-langs.el,v
retrieving revision 1.25.2.19
diff -r1.25.2.19 cc-langs.el
2065c2065
<   objc    '("nil" "Nil")
---
>   objc    '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER" "ASSIGN" "RELEASE" "AUTORELEASE" "RETAIN" "DESTROY" "CREATE_AUTORELEASE_POOL" "RECREATE_AUTORELEASE_POOL")
Index: cc-menus.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-menus.el,v
retrieving revision 1.25.2.9
diff -r1.25.2.9 cc-menus.el
332d331
<     (imenu-progress-message stupid 0)
335d333
<       (imenu-progress-message stupid)
387d384
<     (imenu-progress-message stupid 100)
Index: cc-vars.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-vars.el,v
retrieving revision 1.31.2.17
diff -r1.31.2.17 cc-vars.el
914a915,953
> (defcustom-c-stylevar objc-method-arg-min-delta-to-bracket 2
>   "*Minimum number of chars to the opening bracket.
> 
> Consider this ObjC snippet:
> 
> 	[foo blahBlah: fred
> 	|<-x->|barBaz: barney
> 
> If `x' is less than this number then `c-lineup-ObjC-method-call-colons'
> will defer the indentation decision to the next function.  By default
> this is `c-lineup-ObjC-method-call', which would align it like:
> 
> 	[foo blahBlahBlah: fred
> 	     thisIsTooDamnLong: barney
> 
> This behaviour can be overridden by customizing the indentation of
> `objc-method-call-cont' in the \"objc\" style."
>   :type 'integer
>   :group 'c)
> 
> (defcustom-c-stylevar objc-method-arg-unfinished-offset 4
>   "*Offset relative to bracket if first selector is on a new line.
> 
>     [aaaaaaaaa
>     |<-x->|bbbbbbb:  cccccc
>              ddddd: eeee];"
>   :type 'integer
>   :group 'c)
> 
> (defcustom-c-stylevar objc-method-parameter-offset 4
>   "*Offset for selector parameter on a new line (relative to first selector.
> 
>     [aaaaaaa bbbbbbbbbb:
> 	     |<-x->|cccccccc
>                     ddd: eeee
>                    ffff: ggg];"
>   :type 'integer
>   :group 'c)
> 
1100c1139,1144
<        (objc-method-call-cont . c-lineup-ObjC-method-call)
---
>        (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
> 			        c-lineup-ObjC-method-call +))
>        ;; Anchor pos: (used by c-lineup-method-call-colons)
>        (objc-method-arg-min-delta-to-bracket	. *)
>        (objc-method-arg-unfinished-offset	. +)
>        (objc-method-parameter-offset		. +)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: cc-mode enhancement for Objective-C
  2007-10-13  6:43 cc-mode enhancement for Objective-C Adrian Robert
@ 2007-10-13 19:48 ` Richard Stallman
  2007-10-14  5:49   ` Adrian Robert
  2007-10-13 21:13 ` Alan Mackenzie
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2007-10-13 19:48 UTC (permalink / raw)
  To: Adrian Robert; +Cc: emacs-devel

    The original version was written by Michael Weber, and I updated it
    for GNU emacs-21+.

To use this, we would need to get legal papers from him.  Can you
contact him and ask him if he would like to sign a copyright
assignment?

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

* Re: cc-mode enhancement for Objective-C
  2007-10-13  6:43 cc-mode enhancement for Objective-C Adrian Robert
  2007-10-13 19:48 ` Richard Stallman
@ 2007-10-13 21:13 ` Alan Mackenzie
  2007-10-14  6:08   ` Adrian Robert
  1 sibling, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2007-10-13 21:13 UTC (permalink / raw)
  To: Adrian Robert; +Cc: emacs-devel

Hallo, Adrian:

On Sat, Oct 13, 2007 at 09:43:30AM +0300, Adrian Robert wrote:
> Hi,

> This patch, against emacs-unicode-2/lisp/progmodes, enhances cc-mode's
> handling of Objective-C:

> - auto-indent method calls by colons (like XCode)
> - syntax highlighting for method calls
> - add more constants for font-lock highlighting
  
> I'm unsure if that means it needs to go into cc-mode's own tree?  I
> sent a couple of messages a while ago to cc-mode's own list but they
> may have been drowned in spam.

Apologies.  They were indeed so drowned.  This was back in 2005.  It
would be nice to get them into the CC Mode distribution.

> (If there are any Obj-C devs using emacs on this list, perhaps they
> could try the patch -- it's also built-in to the Emacs.app
> distribution at http://emacs-app.sf.net/ )

Could I ask you two little favours?
(i) Please prefix the names of all the variables with "c-"; e.g., change
objc-method-arg-min-delta-to-bracket to
c-objc-method-arg-min-delta-to-bracket.
(ii) Could you resubmit your patch as a context diff.  Do this by
calling, e.g. "diff -c cc-vars.old.el cc-vars.el".  This makes it much
                    ^^
easier, both to read and to apply to file versions which aren't quite the
same as the ones you started with.

> Changed files:

[ .... ]

Thanks!

-- 
Alan Mackenzie (Ittersbach, Germany).

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

* Re: cc-mode enhancement for Objective-C
  2007-10-13 19:48 ` Richard Stallman
@ 2007-10-14  5:49   ` Adrian Robert
  2007-10-15  1:36     ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Adrian Robert @ 2007-10-14  5:49 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

On 10/13/07, Richard Stallman <rms@gnu.org> wrote:
>     The original version was written by Michael Weber, and I updated it
>     for GNU emacs-21+.
>
> To use this, we would need to get legal papers from him.  Can you
> contact him and ask him if he would like to sign a copyright
> assignment?

I did this (back the first time I sent the patch) and he sent in
papers, however I think we did them for the "emacs" project.  Do I
need to ask him again to get it for "cc-mode" instead?

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

* Re: cc-mode enhancement for Objective-C
  2007-10-13 21:13 ` Alan Mackenzie
@ 2007-10-14  6:08   ` Adrian Robert
  2007-10-14  6:10     ` Adrian Robert
  2007-10-14  8:29     ` Alan Mackenzie
  0 siblings, 2 replies; 13+ messages in thread
From: Adrian Robert @ 2007-10-14  6:08 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

On 10/14/07, Alan Mackenzie <acm@muc.de> wrote:
> Hallo, Adrian:

> Could I ask you two little favours?
> (i) Please prefix the names of all the variables with "c-"; e.g., change
> objc-method-arg-min-delta-to-bracket to
> c-objc-method-arg-min-delta-to-bracket.

OK.. it's been a while since I did this patch, so I'm not sure, I
think I may have been following the naming of "objc-method-intro",
"objc-method-args-cont", "objc-method-call-count" in cc-vars.  However
I see these seem to be a different type of variable.  So the different
naming convention should be used?  Or is it best to change the older
three variables to 'c-objc-...'?

For now, here is a context diff version of the patch as-is.


-Adrian

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

* Re: cc-mode enhancement for Objective-C
  2007-10-14  6:08   ` Adrian Robert
@ 2007-10-14  6:10     ` Adrian Robert
  2007-10-14  8:29     ` Alan Mackenzie
  1 sibling, 0 replies; 13+ messages in thread
From: Adrian Robert @ 2007-10-14  6:10 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

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

> For now, here is a context diff version of the patch as-is.

[-- Attachment #2: objc-enhance_v3c.patch --]
[-- Type: application/octet-stream, Size: 9424 bytes --]

Index: cc-align.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-align.el,v
retrieving revision 1.20.2.13
diff -c -r1.20.2.13 cc-align.el
*** cc-align.el	27 Jul 2007 10:51:17 -0000	1.20.2.13
--- cc-align.el	14 Oct 2007 06:04:12 -0000
***************
*** 908,915 ****
  	   )
        (- target-col open-bracket-col extra))))
  
  (defun c-lineup-ObjC-method-args (langelem)
!   "Line up the colons that separate args.
  The colon on the current line is aligned with the one on the first
  line.
  
--- 908,958 ----
  	   )
        (- target-col open-bracket-col extra))))
  
+ (defun c-lineup-ObjC-method-call-colons (langelem)
+   "Line up selector args as Project Builder / XCode: colons of first
+    selector portions on successive lines are aligned.  If no decision can
+    be made return NIL, so that other lineup methods can be tried.  This is
+    typically chained with `c-lineup-ObjC-method-call'.
+ 
+ Works with: objc-method-call-cont."
+   (save-excursion
+     (catch 'no-idea
+       (let* ((method-arg-len (progn
+ 			       (back-to-indentation)
+ 			       (if (search-forward ":" (c-point 'eol) 'move)
+ 				   (- (point) (c-point 'boi))
+ 				 ; no complete argument to indent yet
+ 				 (throw 'no-idea nil))))
+ 
+ 	     (extra (save-excursion 
+                       ; indent parameter to argument if needed
+ 		      (back-to-indentation)
+ 		      (c-backward-syntactic-ws (cdr langelem))
+ 		      (if (eq ?: (char-before))
+ 			  (c-get-offset '(objc-method-parameter-offset . nil))
+ 			0)))
+ 
+ 	     (open-bracket-col (c-langelem-col langelem))
+ 
+ 	     (arg-ralign-colon-ofs (progn
+ 			(forward-char) ; skip over '['
+ 			; skip over object/class name
+ 			; and first argument
+ 			(c-forward-sexp 2)
+ 			(if (search-forward ":" (c-point 'eol) 'move)
+ 			    (- (current-column) open-bracket-col
+ 			       method-arg-len extra)
+ 			  ; previous arg has no param
+   			  (c-get-offset
+ 			   '(objc-method-arg-unfinished-offset . nil))))))
+ 
+ 	(if (>= arg-ralign-colon-ofs
+ 		(c-get-offset '(objc-method-arg-min-delta-to-bracket . nil)))
+ 	    (+ arg-ralign-colon-ofs extra)
+ 	  (throw 'no-idea nil))))))
+ 
  (defun c-lineup-ObjC-method-args (langelem)
!   "Line up the colons that separate args in a method declaration.
  The colon on the current line is aligned with the one on the first
  line.
  
***************
*** 933,939 ****
  	  c-basic-offset)))))
  
  (defun c-lineup-ObjC-method-args-2 (langelem)
!   "Line up the colons that separate args.
  The colon on the current line is aligned with the one on the previous
  line.
  
--- 976,982 ----
  	  c-basic-offset)))))
  
  (defun c-lineup-ObjC-method-args-2 (langelem)
!   "Line up the colons that separate args in a method declaration.
  The colon on the current line is aligned with the one on the previous
  line.
  
Index: cc-fonts.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-fonts.el,v
retrieving revision 1.2.2.17
diff -c -r1.2.2.17 cc-fonts.el
*** cc-fonts.el	27 Jul 2007 10:51:18 -0000	1.2.2.17
--- cc-fonts.el	14 Oct 2007 06:04:14 -0000
***************
*** 1319,1325 ****
  				  nil)))
  		'((c-put-char-property (1- (match-end 1))
  				       'c-type 'c-decl-end)))
! 	      c-font-lock-objc-methods))
  
        ;; Fontify all declarations, casts and normal labels.
        c-font-lock-declarations
--- 1319,1353 ----
  				  nil)))
  		'((c-put-char-property (1- (match-end 1))
  				       'c-type 'c-decl-end)))
! 
! 	      c-font-lock-objc-methods
! 
! 	      ;; Parts of selector name in messages
! 	      ;; PENDING: perhaps should change to only pick up inside brackets
! 	      ("\\sw*:" 0 font-lock-function-name-face keep t)
! 
! 	      ;; get argument-less selectors' highlighting right
! 	      ;; [[foo _bar_] _baz_] -> bar, baz are highlighted
! 	      ("\\(\\sw+\\)[ \t]*[]]"
! 		(1 (let ((non-ws-before-match (char-before 
! 			      (save-excursion
! 				(goto-char (match-beginning 1))
! 				;; expensive!
! 				(c-backward-syntactic-ws (c-point 'bol))
! 				(point)
! 				))))
! 		      (unless (or (eq ?:  non-ws-before-match)
! 				  (eq ?\[ non-ws-before-match)
! 				  (eq ?> non-ws-before-match))
! 			font-lock-function-name-face)))))
! 	  ;; PENDING: unsure if c-nonlabel-token-key or c-opt-extra-label-key
! 	  ;;          should be used here
! 	  (when (c-lang-const c-opt-extra-label-key)
! 	    `(,(c-make-font-lock-search-function
! 		(c-lang-const c-opt-extra-label-key)
! 		'((c-put-char-property (1- (match-end 0))
! 				       'c-type 'c-decl-end)))))
! 	  )
  
        ;; Fontify all declarations, casts and normal labels.
        c-font-lock-declarations
Index: cc-langs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-langs.el,v
retrieving revision 1.25.2.19
diff -c -r1.25.2.19 cc-langs.el
*** cc-langs.el	3 Aug 2007 05:20:32 -0000	1.25.2.19
--- cc-langs.el	14 Oct 2007 06:04:18 -0000
***************
*** 2062,2068 ****
    t       nil
    (c c++) '("NULL" ;; Not a keyword, but practically works as one.
  	    "false" "true")		; Defined in C99.
!   objc    '("nil" "Nil")
    idl     '("TRUE" "FALSE")
    pike    '("UNDEFINED")) ;; Not a keyword, but practically works as one.
  
--- 2062,2068 ----
    t       nil
    (c c++) '("NULL" ;; Not a keyword, but practically works as one.
  	    "false" "true")		; Defined in C99.
!   objc    '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER" "ASSIGN" "RELEASE" "AUTORELEASE" "RETAIN" "DESTROY" "CREATE_AUTORELEASE_POOL" "RECREATE_AUTORELEASE_POOL")
    idl     '("TRUE" "FALSE")
    pike    '("UNDEFINED")) ;; Not a keyword, but practically works as one.
  
Index: cc-menus.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-menus.el,v
retrieving revision 1.25.2.9
diff -c -r1.25.2.9 cc-menus.el
*** cc-menus.el	27 Jul 2007 10:51:14 -0000	1.25.2.9
--- cc-menus.el	14 Oct 2007 06:04:18 -0000
***************
*** 329,338 ****
  	     'buffer-substring-no-properties
  	   'buffer-substring)))
      (goto-char (point-max))
-     (imenu-progress-message stupid 0)
      ;;
      (while (re-search-backward cc-imenu-objc-generic-expression nil t)
-       (imenu-progress-message stupid)
        (setq langnum (if (match-beginning OBJC) 
  			OBJC
  		      (cond
--- 329,336 ----
***************
*** 384,390 ****
  					  methodlist) toplist))
  	      methodlist nil))))
      ;; 
-     (imenu-progress-message stupid 100)
      (if (eq (car toplist) nil)
  	(setq toplist (cdr toplist)))
  
--- 382,387 ----
Index: cc-vars.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-vars.el,v
retrieving revision 1.31.2.17
diff -c -r1.31.2.17 cc-vars.el
*** cc-vars.el	13 Aug 2007 13:47:30 -0000	1.31.2.17
--- cc-vars.el	14 Oct 2007 06:04:20 -0000
***************
*** 912,917 ****
--- 912,956 ----
    :type 'integer
    :group 'c)
  
+ (defcustom-c-stylevar objc-method-arg-min-delta-to-bracket 2
+   "*Minimum number of chars to the opening bracket.
+ 
+ Consider this ObjC snippet:
+ 
+ 	[foo blahBlah: fred
+ 	|<-x->|barBaz: barney
+ 
+ If `x' is less than this number then `c-lineup-ObjC-method-call-colons'
+ will defer the indentation decision to the next function.  By default
+ this is `c-lineup-ObjC-method-call', which would align it like:
+ 
+ 	[foo blahBlahBlah: fred
+ 	     thisIsTooDamnLong: barney
+ 
+ This behaviour can be overridden by customizing the indentation of
+ `objc-method-call-cont' in the \"objc\" style."
+   :type 'integer
+   :group 'c)
+ 
+ (defcustom-c-stylevar objc-method-arg-unfinished-offset 4
+   "*Offset relative to bracket if first selector is on a new line.
+ 
+     [aaaaaaaaa
+     |<-x->|bbbbbbb:  cccccc
+              ddddd: eeee];"
+   :type 'integer
+   :group 'c)
+ 
+ (defcustom-c-stylevar objc-method-parameter-offset 4
+   "*Offset for selector parameter on a new line (relative to first selector.
+ 
+     [aaaaaaa bbbbbbbbbb:
+ 	     |<-x->|cccccccc
+                     ddd: eeee
+                    ffff: ggg];"
+   :type 'integer
+   :group 'c)
+ 
  (defcustom c-default-style '((java-mode . "java") (awk-mode . "awk")
  			     (other . "gnu"))
    "*Style which gets installed by default when a file is visited.
***************
*** 1097,1103 ****
         ;; Anchor pos: Boi.
         (objc-method-args-cont . c-lineup-ObjC-method-args)
         ;; Anchor pos: At the method start (always at boi).
!        (objc-method-call-cont . c-lineup-ObjC-method-call)
         ;; Anchor pos: At the open bracket.
         (extern-lang-open      . 0)
         (namespace-open        . 0)
--- 1136,1147 ----
         ;; Anchor pos: Boi.
         (objc-method-args-cont . c-lineup-ObjC-method-args)
         ;; Anchor pos: At the method start (always at boi).
!        (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
! 			        c-lineup-ObjC-method-call +))
!        ;; Anchor pos: (used by c-lineup-method-call-colons)
!        (objc-method-arg-min-delta-to-bracket	. *)
!        (objc-method-arg-unfinished-offset	. +)
!        (objc-method-parameter-offset		. +)
         ;; Anchor pos: At the open bracket.
         (extern-lang-open      . 0)
         (namespace-open        . 0)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: cc-mode enhancement for Objective-C
  2007-10-14  6:08   ` Adrian Robert
  2007-10-14  6:10     ` Adrian Robert
@ 2007-10-14  8:29     ` Alan Mackenzie
  1 sibling, 0 replies; 13+ messages in thread
From: Alan Mackenzie @ 2007-10-14  8:29 UTC (permalink / raw)
  To: Adrian Robert; +Cc: bug-cc-mode, emacs-devel

Hi, Adrian,

On Sun, Oct 14, 2007 at 09:08:36AM +0300, Adrian Robert wrote:
> On 10/14/07, Alan Mackenzie <acm@muc.de> wrote:

> > Could I ask you two little favours?
> > (i) Please prefix the names of all the variables with "c-"; e.g., change
> > objc-method-arg-min-delta-to-bracket to
> > c-objc-method-arg-min-delta-to-bracket.

> OK.. it's been a while since I did this patch, so I'm not sure, I
> think I may have been following the naming of "objc-method-intro",
> "objc-method-args-cont", "objc-method-call-count" in cc-vars.  However
> I see these seem to be a different type of variable.

`objc-method-intro' is a just a symbol, not a variable.  It means "the
line you pressed C-c C-s on is 'The first line of an Objective-C method
definition'".  These symbols are documented in the manual (CC Mode 5.31
version) on the page "Syntactic Symbols".

> So the different naming convention should be used?  Or is it best to
> change the older three variables to 'c-objc-...'?

"c-" is the naming prefix for _all_ variables and functions within CC
Mode, with the exception of (most of) the mode names c++-mode, objc-mode,
.....

> For now, here is a context diff version of the patch as-is.

Many thanks!  That's a lot easier to look at.  One thing I forgot to ask
you for is a test case - a little file.m, perhaps ~10 lines long, which
exercises the new indentation and fontification.  This will then become
part of the CC Mode test suite.  If you're not familiar with this, have a
look at some of the files in:
<http://cc-mode.cvs.sourceforge.net/cc-mode/cc-mode/tests/>.

> -Adrian

-- 
Alan.

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

* Re: cc-mode enhancement for Objective-C
  2007-10-14  5:49   ` Adrian Robert
@ 2007-10-15  1:36     ` Richard Stallman
  2007-10-15 15:35       ` Adrian Robert
  2007-10-17 11:12       ` Adrian Robert
  0 siblings, 2 replies; 13+ messages in thread
From: Richard Stallman @ 2007-10-15  1:36 UTC (permalink / raw)
  To: Adrian Robert; +Cc: emacs-devel

    I did this (back the first time I sent the patch) and he sent in
    papers, however I think we did them for the "emacs" project.

That's what we would ask for: papers for changes to Emacs.  But I
don't think we received them.  We have nothing on record for a Michael
Weber.

If you can contact him, please ask him to contact
assign@gnu.org so he can ask to restart the process.

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

* Re: cc-mode enhancement for Objective-C
  2007-10-15  1:36     ` Richard Stallman
@ 2007-10-15 15:35       ` Adrian Robert
  2007-10-17 11:12       ` Adrian Robert
  1 sibling, 0 replies; 13+ messages in thread
From: Adrian Robert @ 2007-10-15 15:35 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

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

Here is a new version of the patch with 'c-' prepended to the style
variables, plus a simple test file.  I wasn't sure how to make a
".res" file for it -- if that's documented somewhere let me know.
Both indentation line-up and coloration should be tested (explained in
the comments).

Re: assignment papers, I could have sworn we had finished the process
and Michael's papers were sent in, however I can't find an email
record of that right now, so I'll ask him.

-Adrian

[-- Attachment #2: objc-enhance_v4.patch --]
[-- Type: application/octet-stream, Size: 9442 bytes --]

Index: cc-align.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-align.el,v
retrieving revision 1.20.2.13
diff -c -r1.20.2.13 cc-align.el
*** cc-align.el	27 Jul 2007 10:51:17 -0000	1.20.2.13
--- cc-align.el	14 Oct 2007 06:04:12 -0000
***************
*** 908,915 ****
  	   )
        (- target-col open-bracket-col extra))))
  
  (defun c-lineup-ObjC-method-args (langelem)
!   "Line up the colons that separate args.
  The colon on the current line is aligned with the one on the first
  line.
  
--- 908,958 ----
  	   )
        (- target-col open-bracket-col extra))))
  
+ (defun c-lineup-ObjC-method-call-colons (langelem)
+   "Line up selector args as Project Builder / XCode: colons of first
+    selector portions on successive lines are aligned.  If no decision can
+    be made return NIL, so that other lineup methods can be tried.  This is
+    typically chained with `c-lineup-ObjC-method-call'.
+ 
+ Works with: objc-method-call-cont."
+   (save-excursion
+     (catch 'no-idea
+       (let* ((method-arg-len (progn
+ 			       (back-to-indentation)
+ 			       (if (search-forward ":" (c-point 'eol) 'move)
+ 				   (- (point) (c-point 'boi))
+ 				 ; no complete argument to indent yet
+ 				 (throw 'no-idea nil))))
+ 
+ 	     (extra (save-excursion 
+                       ; indent parameter to argument if needed
+ 		      (back-to-indentation)
+ 		      (c-backward-syntactic-ws (cdr langelem))
+ 		      (if (eq ?: (char-before))
+ 			  (c-get-offset '(c-objc-method-parameter-offset . nil))
+ 			0)))
+ 
+ 	     (open-bracket-col (c-langelem-col langelem))
+ 
+ 	     (arg-ralign-colon-ofs (progn
+ 			(forward-char) ; skip over '['
+ 			; skip over object/class name
+ 			; and first argument
+ 			(c-forward-sexp 2)
+ 			(if (search-forward ":" (c-point 'eol) 'move)
+ 			    (- (current-column) open-bracket-col
+ 			       method-arg-len extra)
+ 			  ; previous arg has no param
+   			  (c-get-offset
+ 			   '(c-objc-method-arg-unfinished-offset . nil))))))
+ 
+ 	(if (>= arg-ralign-colon-ofs
+ 		(c-get-offset '(c-objc-method-arg-min-delta-to-bracket . nil)))
+ 	    (+ arg-ralign-colon-ofs extra)
+ 	  (throw 'no-idea nil))))))
+ 
  (defun c-lineup-ObjC-method-args (langelem)
!   "Line up the colons that separate args in a method declaration.
  The colon on the current line is aligned with the one on the first
  line.
  
***************
*** 933,939 ****
  	  c-basic-offset)))))
  
  (defun c-lineup-ObjC-method-args-2 (langelem)
!   "Line up the colons that separate args.
  The colon on the current line is aligned with the one on the previous
  line.
  
--- 976,982 ----
  	  c-basic-offset)))))
  
  (defun c-lineup-ObjC-method-args-2 (langelem)
!   "Line up the colons that separate args in a method declaration.
  The colon on the current line is aligned with the one on the previous
  line.
  
Index: cc-fonts.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-fonts.el,v
retrieving revision 1.2.2.17
diff -c -r1.2.2.17 cc-fonts.el
*** cc-fonts.el	27 Jul 2007 10:51:18 -0000	1.2.2.17
--- cc-fonts.el	14 Oct 2007 06:04:14 -0000
***************
*** 1319,1325 ****
  				  nil)))
  		'((c-put-char-property (1- (match-end 1))
  				       'c-type 'c-decl-end)))
! 	      c-font-lock-objc-methods))
  
        ;; Fontify all declarations, casts and normal labels.
        c-font-lock-declarations
--- 1319,1353 ----
  				  nil)))
  		'((c-put-char-property (1- (match-end 1))
  				       'c-type 'c-decl-end)))
! 
! 	      c-font-lock-objc-methods
! 
! 	      ;; Parts of selector name in messages
! 	      ;; PENDING: perhaps should change to only pick up inside brackets
! 	      ("\\sw*:" 0 font-lock-function-name-face keep t)
! 
! 	      ;; get argument-less selectors' highlighting right
! 	      ;; [[foo _bar_] _baz_] -> bar, baz are highlighted
! 	      ("\\(\\sw+\\)[ \t]*[]]"
! 		(1 (let ((non-ws-before-match (char-before 
! 			      (save-excursion
! 				(goto-char (match-beginning 1))
! 				;; expensive!
! 				(c-backward-syntactic-ws (c-point 'bol))
! 				(point)
! 				))))
! 		      (unless (or (eq ?:  non-ws-before-match)
! 				  (eq ?\[ non-ws-before-match)
! 				  (eq ?> non-ws-before-match))
! 			font-lock-function-name-face)))))
! 	  ;; PENDING: unsure if c-nonlabel-token-key or c-opt-extra-label-key
! 	  ;;          should be used here
! 	  (when (c-lang-const c-opt-extra-label-key)
! 	    `(,(c-make-font-lock-search-function
! 		(c-lang-const c-opt-extra-label-key)
! 		'((c-put-char-property (1- (match-end 0))
! 				       'c-type 'c-decl-end)))))
! 	  )
  
        ;; Fontify all declarations, casts and normal labels.
        c-font-lock-declarations
Index: cc-langs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-langs.el,v
retrieving revision 1.25.2.19
diff -c -r1.25.2.19 cc-langs.el
*** cc-langs.el	3 Aug 2007 05:20:32 -0000	1.25.2.19
--- cc-langs.el	14 Oct 2007 06:04:18 -0000
***************
*** 2062,2068 ****
    t       nil
    (c c++) '("NULL" ;; Not a keyword, but practically works as one.
  	    "false" "true")		; Defined in C99.
!   objc    '("nil" "Nil")
    idl     '("TRUE" "FALSE")
    pike    '("UNDEFINED")) ;; Not a keyword, but practically works as one.
  
--- 2062,2068 ----
    t       nil
    (c c++) '("NULL" ;; Not a keyword, but practically works as one.
  	    "false" "true")		; Defined in C99.
!   objc    '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER" "ASSIGN" "RELEASE" "AUTORELEASE" "RETAIN" "DESTROY" "CREATE_AUTORELEASE_POOL" "RECREATE_AUTORELEASE_POOL")
    idl     '("TRUE" "FALSE")
    pike    '("UNDEFINED")) ;; Not a keyword, but practically works as one.
  
Index: cc-menus.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-menus.el,v
retrieving revision 1.25.2.9
diff -c -r1.25.2.9 cc-menus.el
*** cc-menus.el	27 Jul 2007 10:51:14 -0000	1.25.2.9
--- cc-menus.el	14 Oct 2007 06:04:18 -0000
***************
*** 329,338 ****
  	     'buffer-substring-no-properties
  	   'buffer-substring)))
      (goto-char (point-max))
-     (imenu-progress-message stupid 0)
      ;;
      (while (re-search-backward cc-imenu-objc-generic-expression nil t)
-       (imenu-progress-message stupid)
        (setq langnum (if (match-beginning OBJC) 
  			OBJC
  		      (cond
--- 329,336 ----
***************
*** 384,390 ****
  					  methodlist) toplist))
  	      methodlist nil))))
      ;; 
-     (imenu-progress-message stupid 100)
      (if (eq (car toplist) nil)
  	(setq toplist (cdr toplist)))
  
--- 382,387 ----
Index: cc-vars.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-vars.el,v
retrieving revision 1.31.2.17
diff -c -r1.31.2.17 cc-vars.el
*** cc-vars.el	13 Aug 2007 13:47:30 -0000	1.31.2.17
--- cc-vars.el	14 Oct 2007 06:04:20 -0000
***************
*** 912,917 ****
--- 912,956 ----
    :type 'integer
    :group 'c)
  
+ (defcustom-c-stylevar c-objc-method-arg-min-delta-to-bracket 2
+   "*Minimum number of chars to the opening bracket.
+ 
+ Consider this ObjC snippet:
+ 
+ 	[foo blahBlah: fred
+ 	|<-x->|barBaz: barney
+ 
+ If `x' is less than this number then `c-lineup-ObjC-method-call-colons'
+ will defer the indentation decision to the next function.  By default
+ this is `c-lineup-ObjC-method-call', which would align it like:
+ 
+ 	[foo blahBlahBlah: fred
+ 	     thisIsTooDamnLong: barney
+ 
+ This behaviour can be overridden by customizing the indentation of
+ `objc-method-call-cont' in the \"objc\" style."
+   :type 'integer
+   :group 'c)
+ 
+ (defcustom-c-stylevar c-objc-method-arg-unfinished-offset 4
+   "*Offset relative to bracket if first selector is on a new line.
+ 
+     [aaaaaaaaa
+     |<-x->|bbbbbbb:  cccccc
+              ddddd: eeee];"
+   :type 'integer
+   :group 'c)
+ 
+ (defcustom-c-stylevar c-objc-method-parameter-offset 4
+   "*Offset for selector parameter on a new line (relative to first selector.
+ 
+     [aaaaaaa bbbbbbbbbb:
+ 	     |<-x->|cccccccc
+                     ddd: eeee
+                    ffff: ggg];"
+   :type 'integer
+   :group 'c)
+ 
  (defcustom c-default-style '((java-mode . "java") (awk-mode . "awk")
  			     (other . "gnu"))
    "*Style which gets installed by default when a file is visited.
***************
*** 1097,1103 ****
         ;; Anchor pos: Boi.
         (objc-method-args-cont . c-lineup-ObjC-method-args)
         ;; Anchor pos: At the method start (always at boi).
!        (objc-method-call-cont . c-lineup-ObjC-method-call)
         ;; Anchor pos: At the open bracket.
         (extern-lang-open      . 0)
         (namespace-open        . 0)
--- 1136,1147 ----
         ;; Anchor pos: Boi.
         (objc-method-args-cont . c-lineup-ObjC-method-args)
         ;; Anchor pos: At the method start (always at boi).
!        (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
! 			        c-lineup-ObjC-method-call +))
!        ;; Anchor pos: (used by c-lineup-method-call-colons)
!        (c-objc-method-arg-min-delta-to-bracket	. *)
!        (c-objc-method-arg-unfinished-offset	. +)
!        (c-objc-method-parameter-offset		. +)
         ;; Anchor pos: At the open bracket.
         (extern-lang-open      . 0)
         (namespace-open        . 0)

[-- Attachment #3: testObjCmethodCallAlign.m --]
[-- Type: application/octet-stream, Size: 413 bytes --]

/* Tests lineup of colons in method calls, and fontification thereof. */

#import <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
  int bar, baz;
  id someObject = [[NSObject alloc] init];

  // colons should be lined up in same column, and selector portions should
  // be in font-lock-function-name-face
  [someObject someMethodWithArg1: bar
                            arg2: baz];

  return 0;
}

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: cc-mode enhancement for Objective-C
  2007-10-15  1:36     ` Richard Stallman
  2007-10-15 15:35       ` Adrian Robert
@ 2007-10-17 11:12       ` Adrian Robert
  2007-10-17 20:49         ` Richard Stallman
  1 sibling, 1 reply; 13+ messages in thread
From: Adrian Robert @ 2007-10-17 11:12 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

On 10/15/07, Richard Stallman <rms@gnu.org> wrote:
>     I did this (back the first time I sent the patch) and he sent in
>     papers, however I think we did them for the "emacs" project.
>
> That's what we would ask for: papers for changes to Emacs.  But I
> don't think we received them.  We have nothing on record for a Michael
> Weber.

Hi,

OK, I checked with him and he did send the papers in.  Jonas Jacobson
from FSF sent confirmation on 2005/10/14.  I can forward you the
details directly if that would help with locating them.

(Also my own papers were sent in around that time as well.)

Adrian

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

* Re: cc-mode enhancement for Objective-C
  2007-10-17 11:12       ` Adrian Robert
@ 2007-10-17 20:49         ` Richard Stallman
  2007-10-23  6:33           ` Adrian Robert
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2007-10-17 20:49 UTC (permalink / raw)
  To: Adrian Robert; +Cc: emacs-devel

    OK, I checked with him and he did send the papers in.  Jonas Jacobson
    from FSF sent confirmation on 2005/10/14.

No wonder they were not in my copy of the file yet.

In that case, this can be installed.

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

* Re: cc-mode enhancement for Objective-C
  2007-10-17 20:49         ` Richard Stallman
@ 2007-10-23  6:33           ` Adrian Robert
       [not found]             ` <55f7df060711230243i27c14a3fj44cce23ec26d76e8@mail.gmail.com>
  0 siblings, 1 reply; 13+ messages in thread
From: Adrian Robert @ 2007-10-23  6:33 UTC (permalink / raw)
  To: emacs-devel; +Cc: Alan Mackenzie

On 10/17/07, Richard Stallman <rms@gnu.org> wrote:
>     OK, I checked with him and he did send the papers in.  Jonas Jacobson
>     from FSF sent confirmation on 2005/10/14.
>
> No wonder they were not in my copy of the file yet.
>
> In that case, this can be installed.

OK, great.  Alan, did my revised patch and test file come through OK?
Let me know if anything looks off or if you need other changes or
additions.

thanks,
Adrian

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

* Re: cc-mode enhancement for Objective-C
       [not found]             ` <55f7df060711230243i27c14a3fj44cce23ec26d76e8@mail.gmail.com>
@ 2008-03-05  5:01               ` Adrian Robert
  0 siblings, 0 replies; 13+ messages in thread
From: Adrian Robert @ 2008-03-05  5:01 UTC (permalink / raw)
  To: Alan Mackenzie, emacs- devel

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

Hello again,

I'm attaching a new version of this patch diff'ed against the GNU
emacs trunk as of today (2008/03/05).  If there is anything I can do
to enhance the chances of this being accepted, please let me know.

thanks,
Adrian




On 11/23/07, Adrian Robert <adrian.b.robert@gmail.com> wrote:
> Hi,
>
>  Just checking again on the status of this.  If there is anything I can
>  do to help please let me know.
>
>
>  Adrian
>
>
>
>  On 10/23/07, Adrian Robert <adrian.b.robert@gmail.com> wrote:
>  > On 10/17/07, Richard Stallman <rms@gnu.org> wrote:
>  > >     OK, I checked with him and he did send the papers in.  Jonas Jacobson
>  > >     from FSF sent confirmation on 2005/10/14.
>  > >
>  > > No wonder they were not in my copy of the file yet.
>  > >
>  > > In that case, this can be installed.
>  >
>  > OK, great.  Alan, did my revised patch and test file come through OK?
>  > Let me know if anything looks off or if you need other changes or
>  > additions.
>  >
>  > thanks,
>  > Adrian
>  >
>

[-- Attachment #2: objc-enhance_v5.patch --]
[-- Type: application/octet-stream, Size: 9584 bytes --]

Index: cc-align.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-align.el,v
retrieving revision 1.20.2.14
diff -c -r1.20.2.14 cc-align.el
*** cc-align.el	9 Jan 2008 01:19:45 -0000	1.20.2.14
--- cc-align.el	5 Mar 2008 04:57:52 -0000
***************
*** 908,915 ****
  	   )
        (- target-col open-bracket-col extra))))
  
  (defun c-lineup-ObjC-method-args (langelem)
!   "Line up the colons that separate args.
  The colon on the current line is aligned with the one on the first
  line.
  
--- 908,958 ----
  	   )
        (- target-col open-bracket-col extra))))
  
+ (defun c-lineup-ObjC-method-call-colons (langelem)
+   "Line up selector args as Project Builder / XCode: colons of first
+    selector portions on successive lines are aligned.  If no decision can
+    be made return NIL, so that other lineup methods can be tried.  This is
+    typically chained with `c-lineup-ObjC-method-call'.
+ 
+ Works with: objc-method-call-cont."
+   (save-excursion
+     (catch 'no-idea
+       (let* ((method-arg-len (progn
+ 			       (back-to-indentation)
+ 			       (if (search-forward ":" (c-point 'eol) 'move)
+ 				   (- (point) (c-point 'boi))
+ 				 ; no complete argument to indent yet
+ 				 (throw 'no-idea nil))))
+ 
+ 	     (extra (save-excursion 
+                       ; indent parameter to argument if needed
+ 		      (back-to-indentation)
+ 		      (c-backward-syntactic-ws (cdr langelem))
+ 		      (if (eq ?: (char-before))
+ 			  (c-get-offset '(c-objc-method-parameter-offset . nil))
+ 			0)))
+ 
+ 	     (open-bracket-col (c-langelem-col langelem))
+ 
+ 	     (arg-ralign-colon-ofs (progn
+ 			(forward-char) ; skip over '['
+ 			; skip over object/class name
+ 			; and first argument
+ 			(c-forward-sexp 2)
+ 			(if (search-forward ":" (c-point 'eol) 'move)
+ 			    (- (current-column) open-bracket-col
+ 			       method-arg-len extra)
+ 			  ; previous arg has no param
+   			  (c-get-offset
+ 			   '(c-objc-method-arg-unfinished-offset . nil))))))
+ 
+ 	(if (>= arg-ralign-colon-ofs
+ 		(c-get-offset '(c-objc-method-arg-min-delta-to-bracket . nil)))
+ 	    (+ arg-ralign-colon-ofs extra)
+ 	  (throw 'no-idea nil))))))
+ 
  (defun c-lineup-ObjC-method-args (langelem)
!   "Line up the colons that separate args in a method declaration.
  The colon on the current line is aligned with the one on the first
  line.
  
***************
*** 933,939 ****
  	  c-basic-offset)))))
  
  (defun c-lineup-ObjC-method-args-2 (langelem)
!   "Line up the colons that separate args.
  The colon on the current line is aligned with the one on the previous
  line.
  
--- 976,982 ----
  	  c-basic-offset)))))
  
  (defun c-lineup-ObjC-method-args-2 (langelem)
!   "Line up the colons that separate args in a method declaration.
  The colon on the current line is aligned with the one on the previous
  line.
  
Index: cc-fonts.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-fonts.el,v
retrieving revision 1.2.2.19
diff -c -r1.2.2.19 cc-fonts.el
*** cc-fonts.el	9 Jan 2008 01:19:45 -0000	1.2.2.19
--- cc-fonts.el	5 Mar 2008 04:58:08 -0000
***************
*** 1319,1325 ****
  				  nil)))
  		'((c-put-char-property (1- (match-end 1))
  				       'c-type 'c-decl-end)))
! 	      c-font-lock-objc-methods))
  
        ;; Fontify all declarations, casts and normal labels.
        c-font-lock-declarations
--- 1319,1353 ----
  				  nil)))
  		'((c-put-char-property (1- (match-end 1))
  				       'c-type 'c-decl-end)))
! 
! 	      c-font-lock-objc-methods
! 
! 	      ;; Parts of selector name in messages
! 	      ;; PENDING: perhaps should change to only pick up inside brackets
! 	      ("\\sw*:" 0 font-lock-function-name-face keep t)
! 
! 	      ;; get argument-less selectors' highlighting right
! 	      ;; [[foo _bar_] _baz_] -> bar, baz are highlighted
! 	      ("\\(\\sw+\\)[ \t]*[]]"
! 		(1 (let ((non-ws-before-match (char-before 
! 			      (save-excursion
! 				(goto-char (match-beginning 1))
! 				;; expensive!
! 				(c-backward-syntactic-ws (c-point 'bol))
! 				(point)
! 				))))
! 		      (unless (or (eq ?:  non-ws-before-match)
! 				  (eq ?\[ non-ws-before-match)
! 				  (eq ?> non-ws-before-match))
! 			font-lock-function-name-face)))))
! 	  ;; PENDING: unsure if c-nonlabel-token-key or c-opt-extra-label-key
! 	  ;;          should be used here
! 	  (when (c-lang-const c-opt-extra-label-key)
! 	    `(,(c-make-font-lock-search-function
! 		(c-lang-const c-opt-extra-label-key)
! 		'((c-put-char-property (1- (match-end 0))
! 				       'c-type 'c-decl-end)))))
! 	  )
  
        ;; Fontify all declarations, casts and normal labels.
        c-font-lock-declarations
Index: cc-langs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-langs.el,v
retrieving revision 1.25.2.23
diff -c -r1.25.2.23 cc-langs.el
*** cc-langs.el	30 Jan 2008 07:56:53 -0000	1.25.2.23
--- cc-langs.el	5 Mar 2008 04:58:24 -0000
***************
*** 2078,2084 ****
    t       nil
    (c c++) '("NULL" ;; Not a keyword, but practically works as one.
  	    "false" "true")		; Defined in C99.
!   objc    '("nil" "Nil")
    idl     '("TRUE" "FALSE")
    java    '("true" "false" "null") ; technically "literals", not keywords
    pike    '("UNDEFINED")) ;; Not a keyword, but practically works as one.
--- 2078,2084 ----
    t       nil
    (c c++) '("NULL" ;; Not a keyword, but practically works as one.
  	    "false" "true")		; Defined in C99.
!   objc    '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER" "ASSIGN" "RELEASE" "AUTORELEASE" "RETAIN" "DESTROY" "CREATE_AUTORELEASE_POOL" "RECREATE_AUTORELEASE_POOL")
    idl     '("TRUE" "FALSE")
    java    '("true" "false" "null") ; technically "literals", not keywords
    pike    '("UNDEFINED")) ;; Not a keyword, but practically works as one.
Index: cc-menus.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-menus.el,v
retrieving revision 1.25.2.11
diff -c -r1.25.2.11 cc-menus.el
*** cc-menus.el	9 Jan 2008 01:19:40 -0000	1.25.2.11
--- cc-menus.el	5 Mar 2008 04:58:24 -0000
***************
*** 331,340 ****
  	     'buffer-substring-no-properties
  	   'buffer-substring)))
      (goto-char (point-max))
-     (imenu-progress-message stupid 0)
      ;;
      (while (re-search-backward cc-imenu-objc-generic-expression nil t)
-       (imenu-progress-message stupid)
        (setq langnum (if (match-beginning OBJC) 
  			OBJC
  		      (cond
--- 331,338 ----
***************
*** 386,392 ****
  					  methodlist) toplist))
  	      methodlist nil))))
      ;; 
-     (imenu-progress-message stupid 100)
      (if (eq (car toplist) nil)
  	(setq toplist (cdr toplist)))
  
--- 384,389 ----
Index: cc-vars.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-vars.el,v
retrieving revision 1.31.2.21
diff -c -r1.31.2.21 cc-vars.el
*** cc-vars.el	30 Jan 2008 07:56:54 -0000	1.31.2.21
--- cc-vars.el	5 Mar 2008 04:58:31 -0000
***************
*** 940,945 ****
--- 940,984 ----
    :type 'integer
    :group 'c)
  
+ (defcustom-c-stylevar c-objc-method-arg-min-delta-to-bracket 2
+   "*Minimum number of chars to the opening bracket.
+ 
+ Consider this ObjC snippet:
+ 
+ 	[foo blahBlah: fred
+ 	|<-x->|barBaz: barney
+ 
+ If `x' is less than this number then `c-lineup-ObjC-method-call-colons'
+ will defer the indentation decision to the next function.  By default
+ this is `c-lineup-ObjC-method-call', which would align it like:
+ 
+ 	[foo blahBlahBlah: fred
+ 	     thisIsTooDamnLong: barney
+ 
+ This behaviour can be overridden by customizing the indentation of
+ `objc-method-call-cont' in the \"objc\" style."
+   :type 'integer
+   :group 'c)
+ 
+ (defcustom-c-stylevar c-objc-method-arg-unfinished-offset 4
+   "*Offset relative to bracket if first selector is on a new line.
+ 
+     [aaaaaaaaa
+     |<-x->|bbbbbbb:  cccccc
+              ddddd: eeee];"
+   :type 'integer
+   :group 'c)
+ 
+ (defcustom-c-stylevar c-objc-method-parameter-offset 4
+   "*Offset for selector parameter on a new line (relative to first selector.
+ 
+     [aaaaaaa bbbbbbbbbb:
+ 	     |<-x->|cccccccc
+                     ddd: eeee
+                    ffff: ggg];"
+   :type 'integer
+   :group 'c)
+ 
  (defcustom c-default-style '((java-mode . "java") (awk-mode . "awk")
  			     (other . "gnu"))
    "*Style which gets installed by default when a file is visited.
***************
*** 1125,1131 ****
         ;; Anchor pos: Boi.
         (objc-method-args-cont . c-lineup-ObjC-method-args)
         ;; Anchor pos: At the method start (always at boi).
!        (objc-method-call-cont . c-lineup-ObjC-method-call)
         ;; Anchor pos: At the open bracket.
         (extern-lang-open      . 0)
         (namespace-open        . 0)
--- 1164,1175 ----
         ;; Anchor pos: Boi.
         (objc-method-args-cont . c-lineup-ObjC-method-args)
         ;; Anchor pos: At the method start (always at boi).
!        (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
! 			        c-lineup-ObjC-method-call +))
!        ;; Anchor pos: (used by c-lineup-method-call-colons)
!        (c-objc-method-arg-min-delta-to-bracket	. *)
!        (c-objc-method-arg-unfinished-offset	. +)
!        (c-objc-method-parameter-offset		. +)
         ;; Anchor pos: At the open bracket.
         (extern-lang-open      . 0)
         (namespace-open        . 0)

[-- Attachment #3: testObjCmethodCallAlign.m --]
[-- Type: application/octet-stream, Size: 413 bytes --]

/* Tests lineup of colons in method calls, and fontification thereof. */

#import <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
  int bar, baz;
  id someObject = [[NSObject alloc] init];

  // colons should be lined up in same column, and selector portions should
  // be in font-lock-function-name-face
  [someObject someMethodWithArg1: bar
                            arg2: baz];

  return 0;
}

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

end of thread, other threads:[~2008-03-05  5:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-13  6:43 cc-mode enhancement for Objective-C Adrian Robert
2007-10-13 19:48 ` Richard Stallman
2007-10-14  5:49   ` Adrian Robert
2007-10-15  1:36     ` Richard Stallman
2007-10-15 15:35       ` Adrian Robert
2007-10-17 11:12       ` Adrian Robert
2007-10-17 20:49         ` Richard Stallman
2007-10-23  6:33           ` Adrian Robert
     [not found]             ` <55f7df060711230243i27c14a3fj44cce23ec26d76e8@mail.gmail.com>
2008-03-05  5:01               ` Adrian Robert
2007-10-13 21:13 ` Alan Mackenzie
2007-10-14  6:08   ` Adrian Robert
2007-10-14  6:10     ` Adrian Robert
2007-10-14  8:29     ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).