summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-align.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2009-04-30 10:36:24 +0000
committerAlan Mackenzie <acm@muc.de>2009-04-30 10:36:24 +0000
commitf0e4b2f240536ea8bc5aa66e559d62083c33e209 (patch)
treea373ad76fe0be8c9d0259914a3ed5712179e0b72 /lisp/progmodes/cc-align.el
parent9e95e9f4b50f69252a8af6754d6710bd84fb812d (diff)
downloademacs-f0e4b2f240536ea8bc5aa66e559d62083c33e209.tar.gz
Enhancements for Objective-C:
cc-vars.el (c-objc-method-arg-min-delta-to-bracket, c-objc-method-arg-unfinished-offset, c-objc-method-parameter-offset): New variables. (c-offsets-alist): Use c-lineup-ObjC-method-call-colons in entry for objc-method-call-cont. cc-langs.el (c-constant-kwds): New ObjC keywords "YES", "NO", "NS_DURING", "NS_HANDLER", "NS_ENDHANDLER". cc-align.el (c-lineup-ObjC-method-call-colons): New function.
Diffstat (limited to 'lisp/progmodes/cc-align.el')
-rw-r--r--lisp/progmodes/cc-align.el44
1 files changed, 42 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el
index ff22eba0c33..c9dd92f46b2 100644
--- a/lisp/progmodes/cc-align.el
+++ b/lisp/progmodes/cc-align.el
@@ -907,8 +907,48 @@ Works with: objc-method-call-cont."
)
(- 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 (c-langelem-pos langelem))
+ (if (eq ?: (char-before))
+ c-objc-method-parameter-offset 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-objc-method-arg-unfinished-offset))))
+
+ (if (>= arg-ralign-colon-ofs c-objc-method-arg-min-delta-to-bracket)
+ (+ arg-ralign-colon-ofs extra)
+ (throw 'no-idea nil))))))
+
(defun c-lineup-ObjC-method-args (langelem)
- "Line up the colons that separate args.
+ "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.
@@ -932,7 +972,7 @@ Works with: objc-method-args-cont."
c-basic-offset)))))
(defun c-lineup-ObjC-method-args-2 (langelem)
- "Line up the colons that separate args.
+ "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.