summaryrefslogtreecommitdiffstats
path: root/emacs.d/lisp/yasnippet/extras/imported/objc-mode/.yas-setup.el
blob: a072e99638021c35cf84922521a7013f7dd7c885 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(defun yas/objc-docset-query (query)
  
  )
(defvar yas/objc-method-names (make-vector 1023 0))
(defvar yas/objc-class-names (make-vector 1023 0))

(defvar yas/objc-languages (list))
(defvar yas/objc-defkinds (list))


(defun yas/objc-extract-super-list ()
  (interactive)
  (setq yas/objc-method-names (make-vector 1023 0)
        yas/objc-class-names (make-vector 1023 0)
        yas/objc-languages (list)
        yas/objc-defkinds (list))
  (with-temp-buffer
    (shell-command
     "/Developer/usr/bin/docsetutil dump -skip-text /Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/"
     (current-buffer))
    (goto-char (point-min))
    (search-forward-regexp "API index contains .* tokens")
    (while (search-forward-regexp "^\\([^/]*\\)/\\([^/]*\\)/\\([^/]*\\)/\\([^/]*\\)$" nil 'noerror)
      (intern (match-string 3) yas/objc-class-names)
      (intern (match-string 4) yas/objc-method-names)
      (add-to-list 'yas/objc-languages (match-string 1))
      (add-to-list 'yas/objc-defkinds (match-string 2)))))

(put (intern-soft (setq chosen (completing-read "Method: " yas/objc-method-names)) yas/objc-method-names)
     'someshit
     'someday)

(completing-read "Class: " yas/objc-class-names)

(get (intern-soft (setq chosen (completing-read "hey: " yas/objc-method-names)) yas/objc-method-names)
     'someshit)

(defun yas/objc-current-method-signature ()
  (let ((orig-point (point))
        (start-point nil)
        sig
        orig-ppss
        ppss)
    (save-excursion
      (condition-case nil
          (while (not (eq (point) (point-min))) (backward-sexp))
        (error nil))
      (when (eq (preceding-char) ?\[)
        (setq orig-ppss (syntax-ppss))
        (forward-sexp)
        (skip-chars-forward " \t\n")
        (setq ppss (syntax-ppss))
        (while (and (>= (car ppss) (car orig-ppss))
                    (search-forward-regexp "[[:alpha:]]+:" nil 'noerror))
          (setq ppss (syntax-ppss))
          (when (eq (car ppss) (car orig-ppss))
            (setq sig
                  (concat (or sig "") (match-string-no-properties 0)))))
          sig))))

(defun yas/objc-current-method-signature ()
  (let ((orig-point (point))
        (start-point nil)
        sig
        orig-ppss
        ppss)
    (save-excursion
      (condition-case nil
          (while (not (eq (point) (point-max))) (backward-sexp))
        (error ))
      (when (eq (preceding-char) ?\[)
        (setq orig-ppss (syntax-ppss))
        (forward-sexp)
        (skip-chars-forward " \t\n")
        (setq ppss (syntax-ppss))
        (condition-case nil
            (while (and (>= (car ppss) (car orig-ppss))
                        (search-forward-regexp "[[:alpha:]]+:" orig-point 'noerror))
              (setq ppss (syntax-ppss))
              (when (eq (car ppss) (car orig-ppss))
                (setq sig
                      (concat (or sig "") (match-string-no-properties 0))))
              (forward-sexp))
          (error nil))
        (save-excursion
          (backward-word)
          (concat sig (buffer-substring-no-properties (point) orig-point)))
        sig))))