]> code.delx.au - gnu-emacs-elpa/blob - packages/yasnippet/extras/imported/objc-mode/.yas-setup.el
Merge commit 'e085a333867959a1b36015a3ad8e12e5bd6550d9' from company
[gnu-emacs-elpa] / packages / yasnippet / extras / imported / objc-mode / .yas-setup.el
1 ;;; .yas-setup.el --- Setup for objc-mode
2
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Code:
19
20 (defun yas-objc-docset-query (query)
21
22 )
23 (defvar yas-objc-method-names (make-vector 1023 0))
24 (defvar yas-objc-class-names (make-vector 1023 0))
25
26 (defvar yas-objc-languages (list))
27 (defvar yas-objc-defkinds (list))
28
29
30 (defun yas-objc-extract-super-list ()
31 (interactive)
32 (setq yas-objc-method-names (make-vector 1023 0)
33 yas-objc-class-names (make-vector 1023 0)
34 yas-objc-languages (list)
35 yas-objc-defkinds (list))
36 (with-temp-buffer
37 (shell-command
38 "/Developer/usr/bin/docsetutil dump -skip-text /Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/"
39 (current-buffer))
40 (goto-char (point-min))
41 (search-forward-regexp "API index contains .* tokens")
42 (while (search-forward-regexp "^\\([^/]*\\)/\\([^/]*\\)/\\([^/]*\\)/\\([^/]*\\)$" nil 'noerror)
43 (intern (match-string 3) yas-objc-class-names)
44 (intern (match-string 4) yas-objc-method-names)
45 (add-to-list 'yas-objc-languages (match-string 1))
46 (add-to-list 'yas-objc-defkinds (match-string 2)))))
47
48 ;; (put (intern-soft (setq chosen (completing-read "Method: " yas-objc-method-names)) yas-objc-method-names)
49 ;; 'someshit
50 ;; 'someday)
51
52 ;; (completing-read "Class: " yas-objc-class-names)
53
54 ;; (get (intern-soft (setq chosen (completing-read "hey: " yas-objc-method-names)) yas-objc-method-names)
55 ;; 'someshit)
56
57 (defun yas-objc-current-method-signature ()
58 (let ((orig-point (point))
59 (start-point nil)
60 sig
61 orig-ppss
62 ppss)
63 (save-excursion
64 (condition-case nil
65 (while (not (eq (point) (point-min))) (backward-sexp))
66 (error nil))
67 (when (eq (preceding-char) ?\[)
68 (setq orig-ppss (syntax-ppss))
69 (forward-sexp)
70 (skip-chars-forward " \t\n")
71 (setq ppss (syntax-ppss))
72 (while (and (>= (car ppss) (car orig-ppss))
73 (search-forward-regexp "[[:alpha:]]+:" nil 'noerror))
74 (setq ppss (syntax-ppss))
75 (when (eq (car ppss) (car orig-ppss))
76 (setq sig
77 (concat (or sig "") (match-string-no-properties 0)))))
78 sig))))
79
80 (defun yas-objc-current-method-signature ()
81 (let ((orig-point (point))
82 (start-point nil)
83 sig
84 orig-ppss
85 ppss)
86 (save-excursion
87 (condition-case nil
88 (while (not (eq (point) (point-max))) (backward-sexp))
89 (error ))
90 (when (eq (preceding-char) ?\[)
91 (setq orig-ppss (syntax-ppss))
92 (forward-sexp)
93 (skip-chars-forward " \t\n")
94 (setq ppss (syntax-ppss))
95 (condition-case nil
96 (while (and (>= (car ppss) (car orig-ppss))
97 (search-forward-regexp "[[:alpha:]]+:" orig-point 'noerror))
98 (setq ppss (syntax-ppss))
99 (when (eq (car ppss) (car orig-ppss))
100 (setq sig
101 (concat (or sig "") (match-string-no-properties 0))))
102 (forward-sexp))
103 (error nil))
104 (save-excursion
105 (backward-word)
106 (concat sig (buffer-substring-no-properties (point) orig-point)))
107 sig))))