Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added the code from http://www.emacswiki.org/emacs/AutoCompleteSource…

  • Loading branch information...
commit ab4056e74c2dbcb50c9960013aa26f68bc5ee940 1 parent c08d322
@tavisrudd authored
Showing with 104 additions and 1 deletion.
  1. +104 −1 dss-completion.el
View
105 dss-completion.el
@@ -117,7 +117,6 @@ advice like this:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; auto-complete mode
-(add-to-list 'load-path (concat dss-vendor-dir "auto-complete"))
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories (concat dss-dotfiles-dir "ac-dict"))
(setq ac-delay 0.1)
@@ -169,8 +168,15 @@ advice like this:
(ac-complete-no-fallback)
(dss/electric-pair))
+(defun dss/ac-electric-char ()
+ (interactive)
+ (ac-complete-no-fallback)
+ (call-interactively 'self-insert-command))
+
(define-key ac-completing-map "(" 'dss/ac-electric-pair)
(define-key ac-completing-map "[" 'dss/ac-electric-pair)
+(define-key ac-completing-map "," 'dss/ac-electric-char)
+;; (define-key ac-completing-map " " 'dss/ac-electric-char)
(define-key ac-completing-map "\r" 'ac-complete-no-fallback)
;; (define-key ac-completing-map (kbd "M-/") 'dabbrev-completion)
(define-key ac-completing-map (kbd "M-/") 'dss/hippie-expand)
@@ -322,4 +328,101 @@ advice like this:
(symbol . "f")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; http://www.emacswiki.org/emacs/AutoCompleteSources#toc2
+
+(defvar ac-org-candidates nil)
+(defvar ac-org-pattern nil)
+(defun ac-org-construct-candidates ()
+ "Pabbrev source for org."
+ (let* ((end (point))
+ (beg1 (save-excursion
+ (skip-chars-backward (org-re "[:alnum:]_@"))
+ (point)))
+ (beg (save-excursion
+ (skip-chars-backward "a-zA-Z0-9_:$")
+ (point)))
+ (confirm (lambda (x) (stringp (car x))))
+ (searchhead (equal (char-before beg) ?*))
+ (struct
+ (when (and (member (char-before beg1) '(?. ?<))
+ (setq a (assoc (buffer-substring beg1 (point))
+ org-structure-template-alist)))
+ (org-complete-expand-structure-template (1- beg1) a)
+ (throw 'exit t)))
+ (tag (and (equal (char-before beg1) ?:)
+ (equal (char-after (point-at-bol)) ?*)))
+ (prop (and (equal (char-before beg1) ?:)
+ (not (equal (char-after (point-at-bol)) ?*))))
+ (texp (equal (char-before beg) ?\\))
+ (link (equal (char-before beg) ?\[))
+ (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
+ beg)
+ "#+"))
+ (startup (string-match "^#\\+STARTUP:.*"
+ (buffer-substring (point-at-bol) (point))))
+ (completion-ignore-case opt)
+ (type nil)
+ (tbl nil)
+ (table (cond
+ (opt
+ (setq type :opt)
+ (require 'org-exp)
+ (append
+ (mapcar
+ (lambda (x)
+ (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
+ (cons (match-string 2 x) (match-string 1 x)))
+ (org-split-string (org-get-current-options) "\n"))
+ (mapcar 'list org-additional-option-like-keywords)))
+ (startup
+ (setq type :startup)
+ org-startup-options)
+ (link (append org-link-abbrev-alist-local
+ org-link-abbrev-alist))
+ (texp
+ (setq type :tex)
+ org-html-entities)
+ ((string-match "\\`\\*+[ \t]+\\'"
+ (buffer-substring (point-at-bol) beg))
+ (setq type :todo)
+ (mapcar 'list org-todo-keywords-1))
+ (searchhead
+ (setq type :searchhead)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward org-todo-line-regexp nil t)
+ (push (list
+ (org-make-org-heading-search-string
+ (match-string 3) t))
+ tbl)))
+ tbl)
+ (tag (setq type :tag beg beg1)
+ (or org-tag-alist (org-get-buffer-tags)))
+ (prop (setq type :prop beg beg1)
+ (mapcar 'list (org-buffer-property-keys nil t t)))
+ (t (progn
+ (call-interactively org-completion-fallback-command)
+ (throw 'exit nil))))))
+ (setq ac-org-pattern (buffer-substring-no-properties beg end))
+ table))
+
+(defvar ac-source-org nil)
+(setq ac-source-org
+ `((sigil . "o")
+ (init . (lambda () (setq ac-org-candidates
+ (condition-case nil
+ (ac-org-construct-candidates)))))
+ (candidates . (lambda ()
+ (all-completions ac-target ac-org-candidates)))))
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun ac-emacs-lisp-mode-setup ()
+ (setq ac-sources '(ac-source-words-in-buffer ac-source-functions ac-source-variables ac-source-symbols ac-source-features ac-source-yasnippet)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'dss-completion)
Please sign in to comment.
Something went wrong with that request. Please try again.