branch: elpa/swift-mode
commit b2d9ccaf8a78947427552cccd4af6796213c3e3d
Author: taku0 <[email protected]>
Commit: taku0 <[email protected]>
Fix small bugs
Make compatible with Emacs 24.4.
Other bugs.
---
swift-mode-beginning-of-defun.el | 10 ++++++----
swift-mode-imenu.el | 41 +++++++++++++++++++++++++---------------
2 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/swift-mode-beginning-of-defun.el b/swift-mode-beginning-of-defun.el
index 1459f53..26f276e 100644
--- a/swift-mode-beginning-of-defun.el
+++ b/swift-mode-beginning-of-defun.el
@@ -512,7 +512,8 @@ If the point is between defuns, narrow depend on
Preceding comments are included if INCLUDE-COMMENTS is non-nil.
Interactively, the behavior depends on ‘narrow-to-defun-include-comments’."
- (interactive (list narrow-to-defun-include-comments))
+ (interactive (list (and (boundp 'narrow-to-defun-include-comments)
+ narrow-to-defun-include-comments)))
(let ((region (swift-mode:narrow-to-generic-block
include-comments
#'swift-mode:end-of-defun
@@ -795,7 +796,7 @@ Otherwise, try to mark the following one."
(funcall move-backward)
(when (/= start (point))
(throw 'swift-mode:found-block
- (list (cons start end)) 'containing))))))
+ (list (cons start end) 'containing)))))))
(list (cons (point-min) (point-max)) 'containing)))))))
(defun swift-mode:extend-region-with-spaces (region)
@@ -1341,7 +1342,8 @@ If the point is between sentences, narrow depend on
Preceding comments are included if INCLUDE-COMMENTS is non-nil.
Interactively, the behavior depends on ‘narrow-to-defun-include-comments’."
- (interactive (list narrow-to-defun-include-comments))
+(interactive (list (and (boundp 'narrow-to-defun-include-comments)
+ narrow-to-defun-include-comments)))
(let ((region (swift-mode:narrow-to-generic-block
include-comments
#'swift-mode:forward-sentence
@@ -1442,7 +1444,7 @@ of ancestors."
;; Ignored: "import" "get" "set" "willSet" "didSet"
(t nil))))
- (if (eq (swift-mode:token:type name-token) identifier)
+ (if (eq (swift-mode:token:type name-token) 'identifier)
name-token
nil)))
diff --git a/swift-mode-imenu.el b/swift-mode-imenu.el
index 742e2e4..f7c168d 100644
--- a/swift-mode-imenu.el
+++ b/swift-mode-imenu.el
@@ -103,8 +103,7 @@ names."
"Scan declarations from current point.
Return found declarations in reverse order."
- (let (previous-token
- next-token
+ (let (next-token
next-type
next-text
name-token
@@ -320,6 +319,16 @@ TYPE is one of `case', `let', or `var'."
items))
(defun swift-mode:scan-function-name-and-parameter-names ()
+ "Parse function name and parameter names.
+
+The point is assumed to be before a function name.
+
+Return tokens of function names and parameter names.
+
+For example, given the following code, this return tokens \"foo\", \"a\",
+and \"c\".
+
+ func foo(a b: Int, c: Int)"
(let* ((name-token
(swift-mode:forward-token-or-list-except-curly-bracket))
next-token
@@ -368,19 +377,21 @@ TYPE is one of `case', `let', or `var'."
"Convert list of DECLARATIONS to alist for `imenu--index-alist'.
Declarations are organized as trees."
- (mapcan
- (lambda (declaration)
- (let* ((name-token (swift-mode:declaration:name-token declaration))
- (name (swift-mode:token:text name-token))
- (position (swift-mode:token:start name-token))
- (children (swift-mode:declaration:children declaration)))
- (cons
- (cons name position)
- (mapcar
- (lambda (pair)
- (cons (concat name "." (car pair)) (cdr pair)))
- (swift-mode:format-for-imenu:flat children)))))
- declarations))
+ (apply
+ 'nconc
+ (mapcar
+ (lambda (declaration)
+ (let* ((name-token (swift-mode:declaration:name-token declaration))
+ (name (swift-mode:token:text name-token))
+ (position (swift-mode:token:start name-token))
+ (children (swift-mode:declaration:children declaration)))
+ (cons
+ (cons name position)
+ (mapcar
+ (lambda (pair)
+ (cons (concat name "." (car pair)) (cdr pair)))
+ (swift-mode:format-for-imenu:flat children)))))
+ declarations)))
(defun swift-mode:format-for-imenu:nested (declarations)
"Convert list of DECLARATIONS to alist for `imenu--index-alist'.