From: "Adrian Robert" <adrian.b.robert@gmail.com>
To: "Alan Mackenzie" <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: cc-mode enhancement for Objective-C
Date: Sun, 14 Oct 2007 09:10:43 +0300 [thread overview]
Message-ID: <55f7df060710132310r7d68c299x405b86d7d7dc1bb4@mail.gmail.com> (raw)
In-Reply-To: <55f7df060710132308t6cb0d145taea3a916e19d6896@mail.gmail.com>
[-- 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
next prev parent reply other threads:[~2007-10-14 6:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2007-10-14 8:29 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55f7df060710132310r7d68c299x405b86d7d7dc1bb4@mail.gmail.com \
--to=adrian.b.robert@gmail.com \
--cc=acm@muc.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.