Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/emacs-for-python/completion/ac-ropemacs-config.el
990 views
1
;; ropemacs Integration with auto-completion
2
;; Feature that can be added:
3
;; - (document . rope-get-doc) to get the doc for the symbol completed!
4
;; - Calltips (complete after a trigger (, maybe)
5
6
(defun ac-ropemacs-candidates ()
7
(mapcar (lambda (completion)
8
(concat ac-prefix completion))
9
(rope-completions)))
10
11
(defun ac-nropemacs-get-doc (symbol)
12
"Return the doc at point, currently it doesn't use symbol"
13
(rope-get-doc))
14
15
16
(ac-define-source nropemacs
17
'((candidates . ac-ropemacs-candidates)
18
(symbol . "p")))
19
20
(ac-define-source nropemacs-dot
21
'((candidates . ac-ropemacs-candidates)
22
(symbol . "p")
23
(prefix . c-dot)
24
(requires . 0)))
25
26
(defun ac-nropemacs-setup ()
27
(setq ac-sources (append '(ac-source-nropemacs
28
ac-source-nropemacs-dot) ac-sources)))
29
30
;; extended ropemacs
31
32
(defun ac-eropemacs-candidates ()
33
(mapcar (lambda (proposal)
34
(destructuring-bind (name doc type) proposal
35
(list (concat ac-prefix name) doc
36
(if type (substring type 0 1) nil))))
37
(rope-extended-completions)))
38
39
(defun ac-eropemacs-document (item) (car item))
40
(defun ac-eropemacs-symbol (item) (cadr item))
41
42
(ac-define-source extended-ropemacs
43
'((candidates . ac-eropemacs-candidates)
44
;; (document . ac-eropemacs-document)
45
(symbol . ac-eropemacs-symbol)))
46
47
(ac-define-source extended-ropemacs-dot
48
'((candidates . ac-eropemacs-candidates)
49
;; (document . ac-eropemacs-document)
50
(symbol . ac-eropemacs-symbol)
51
(prefix . c-dot)
52
(requires . 0)))
53
54
(defun ac-eropemacs-setup ()
55
(setq ac-sources (append '(ac-source-extended-ropemacs
56
ac-source-extended-ropemacs-dot) ac-sources)))
57
58
(defun ac-ropemacs-setup ()
59
(if (functionp 'rope-extended-completions)
60
(add-hook 'python-mode-hook 'ac-eropemacs-setup)
61
(add-hook 'python-mode-hook 'ac-nropemacs-setup)))
62
63