Permalink
Browse files

Merge remote-tracking branch 'refs/remotes/auto-complete/master'

Conflicts:
	auto-complete.el
	doc/manual.txt
  • Loading branch information...
2 parents c320e1c + 03ac748 commit 1320beddf503b8b7d212d9a6536452a71d349b86 @purcell committed Sep 13, 2012
Showing with 778 additions and 58 deletions.
  1. +22 −17 auto-complete-config.el
  2. +46 −11 auto-complete.el
  3. +679 −0 dict/haskell-mode
  4. +3 −0 dict/java-mode
  5. +28 −30 doc/manual.txt
View
@@ -21,7 +21,7 @@
;;; Commentary:
-;;
+;;
;;; Code:
@@ -141,21 +141,26 @@
(defun ac-yasnippet-candidates ()
(with-no-warnings
- (if (fboundp 'yas/get-snippet-tables)
- ;; >0.6.0
- (apply 'append (mapcar 'ac-yasnippet-candidate-1
- (condition-case nil
- (yas/get-snippet-tables major-mode)
- (wrong-number-of-arguments
- (yas/get-snippet-tables)))))
- (let ((table
- (if (fboundp 'yas/snippet-table)
- ;; <0.6.0
- (yas/snippet-table major-mode)
- ;; 0.6.0
- (yas/current-snippet-table))))
- (if table
- (ac-yasnippet-candidate-1 table))))))
+ (cond (;; 0.8 onwards
+ (fboundp 'yas-active-keys)
+ (all-completions ac-prefix (yas-active-keys)))
+ (;; >0.6.0
+ (fboundp 'yas/get-snippet-tables)
+ (apply 'append (mapcar 'ac-yasnippet-candidate-1
+ (condition-case nil
+ (yas/get-snippet-tables major-mode)
+ (wrong-number-of-arguments
+ (yas/get-snippet-tables)))))
+ )
+ (t
+ (let ((table
+ (if (fboundp 'yas/snippet-table)
+ ;; <0.6.0
+ (yas/snippet-table major-mode)
+ ;; 0.6.0
+ (yas/current-snippet-table))))
+ (if table
+ (ac-yasnippet-candidate-1 table)))))))
(ac-define-source yasnippet
'((depends yasnippet)
@@ -191,7 +196,7 @@
(require 'semantic/ia nil t)))
(candidates . (ac-semantic-candidates ac-prefix))
(document . ac-semantic-doc)
- (prefix . c-dot-ref)
+ (prefix . cc-member)
(requires . 0)
(symbol . "m")))
View
@@ -221,7 +221,12 @@
(defcustom ac-trigger-commands-on-completing
'(delete-backward-char
backward-delete-char
- backward-delete-char-untabify)
+ backward-delete-char-untabify
+ ;; autopair
+ autopair-backspace
+ ;; paredit
+ paredit-backward-delete
+ paredit-backward-delete-word)
"Trigger commands that specify whether `auto-complete' should continue or not."
:type '(repeat symbol)
:group 'auto-complete)
@@ -230,7 +235,8 @@
"Non-nil means `auto-complete' will start by typing this key.
If you specify this TAB, for example, `auto-complete' will start by typing TAB,
and if there is no completions, an original command will be fallbacked."
- :type 'string
+ :type '(choice (const :tag "None" nil)
+ (string :tag "Key"))
:group 'auto-complete
:set (lambda (symbol value)
(set-default symbol value)
@@ -283,6 +289,11 @@ a prefix doen't contain any upper case letters."
:type 'boolean
:group 'auto-complete)
+(defcustom ac-disable-inline nil
+ "Non-nil disable inline completion visibility"
+ :type 'boolean
+ :group 'auto-complete)
+
(defface ac-completion-face
'((t (:foreground "darkgray" :underline t)))
"Face for inline completion"
@@ -400,7 +411,6 @@ If there is no common part, this will be nil.")
(define-key map "\r" 'ac-complete)
(define-key map [return] 'ac-complete)
(define-key map (kbd "M-TAB") 'auto-complete)
- (define-key map "\C-s" 'ac-isearch)
(define-key map "\M-n" 'ac-next)
(define-key map "\M-p" 'ac-previous)
@@ -435,6 +445,7 @@ If there is no common part, this will be nil.")
(set-keymap-parent map ac-completing-map)
(define-key map "\C-n" 'ac-next)
(define-key map "\C-p" 'ac-previous)
+ (define-key map "\C-s" 'ac-isearch)
(define-key map [mouse-1] 'ac-mouse-1)
(define-key map [down-mouse-1] 'ac-ignore)
(define-key map [mouse-4] 'ac-mouse-4)
@@ -455,7 +466,8 @@ If there is no common part, this will be nil.")
(file . ac-prefix-file)
(valid-file . ac-prefix-valid-file)
(c-dot . ac-prefix-c-dot)
- (c-dot-ref . ac-prefix-c-dot-ref))
+ (c-dot-ref . ac-prefix-c-dot-ref)
+ (cc-member . ac-prefix-cc-member))
"Prefix definitions for common use.")
(defvar ac-end-definitions
@@ -662,6 +674,16 @@ If there is no common part, this will be nil.")
(if ac-use-dictionary-as-stop-words
(member word (ac-buffer-dictionary)))))
+(defun ac-prefix-default ()
+ "Same as `ac-prefix-symbol' but ignore a number prefix."
+ (let ((start (ac-prefix-symbol)))
+ (when start
+ (loop with end = (point)
+ for pos from start below end
+ for c = (char-after pos)
+ if (not (and (<= ?0 c) (<= c ?9)))
+ return start))))
+
(defun ac-prefix-symbol ()
"Start position of symbol at point."
(require 'thingatpt)
@@ -704,6 +726,11 @@ If there is no common part, this will be nil.")
(if (re-search-backward "\\(?:\\.\\|->\\)\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t)
(match-beginning 1)))
+(defun ac-prefix-cc-member ()
+ "C-like languages member(.)(->)(::) prefix."
+ (when (re-search-backward "\\(?:\\.\\|->\\|::\\)\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t)
+ (match-beginning 1)))
+
(defun ac-define-prefix (name prefix)
"Define new prefix definition.
You can use it in source definition like (prefix . `NAME')."
@@ -794,7 +821,7 @@ You can use it in source definition like (end . `NAME')."
:symbol t
:scroll-bar t
:margin-left 1
- :keymap ac-menu-map ; for mouse bindings
+ :keymap ac-menu-map
)))
(defun ac-menu-delete ()
@@ -1078,7 +1105,8 @@ You can use it in source definition like (end . `NAME')."
(ac-activate-completing-map))
(setq ac-completing nil)
(ac-deactivate-completing-map))
- (ac-inline-update)
+ (unless ac-disable-inline
+ (ac-inline-update))
(popup-set-list ac-menu ac-candidates)
(if (and (not ac-fuzzy-enable)
(<= (length ac-candidates) 1))
@@ -1289,7 +1317,7 @@ that have been made before in this function."
(and menu
(popup-child-point menu parent-offset))
(point))
- nil 0
+ nil 300
popup-tip-max-width
nil nil
(and (not around) 0))
@@ -1340,7 +1368,7 @@ that have been made before in this function."
(point (marker-position (car ac-last-completion))))
(when (stringp doc)
(if (ac-quick-help-use-pos-tip-p)
- (with-no-warnings (pos-tip-show doc nil point nil 0))
+ (with-no-warnings (pos-tip-show doc nil point nil 300))
(popup-tip doc
:point point
:around t
@@ -1612,10 +1640,16 @@ that have been made before in this function."
(string-match "self-insert-command" (symbol-name command))
(string-match "electric" (symbol-name command)))))
+(defun ac-fallback-key-sequence ()
+ (setq unread-command-events
+ (append (this-single-command-raw-keys)
+ unread-command-events))
+ (read-key-sequence-vector ""))
+
(defun ac-fallback-command (&optional except-command)
(let* ((auto-complete-mode nil)
- (keys (this-command-keys-vector))
- (command (if keys (key-binding keys))))
+ (keys (ac-fallback-key-sequence))
+ (command (and keys (key-binding keys))))
(when (and (commandp command)
(not (eq command except-command)))
(setq this-command command)
@@ -1652,7 +1686,8 @@ that have been made before in this function."
(not isearch-mode))
(setq ac-last-point (point))
(ac-start :requires (unless ac-completing ac-auto-start))
- (ac-inline-update))
+ (unless ac-disable-inline
+ (ac-inline-update)))
(error (ac-error var))))
(defun ac-setup ()
Oops, something went wrong.

0 comments on commit 1320bed

Please sign in to comment.