1 ;;; .yas-setup.el --- Setup for objc-mode
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
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.
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.
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/>.
20 (defun yas-objc-docset-query (query)
23 (defvar yas-objc-method-names (make-vector 1023 0))
24 (defvar yas-objc-class-names (make-vector 1023 0))
26 (defvar yas-objc-languages (list))
27 (defvar yas-objc-defkinds (list))
30 (defun yas-objc-extract-super-list ()
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))
38 "/Developer/usr/bin/docsetutil dump -skip-text /Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/"
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)))))
48 ;; (put (intern-soft (setq chosen (completing-read "Method: " yas-objc-method-names)) yas-objc-method-names)
52 ;; (completing-read "Class: " yas-objc-class-names)
54 ;; (get (intern-soft (setq chosen (completing-read "hey: " yas-objc-method-names)) yas-objc-method-names)
57 (defun yas-objc-current-method-signature ()
58 (let ((orig-point (point))
65 (while (not (eq (point) (point-min))) (backward-sexp))
67 (when (eq (preceding-char) ?\[)
68 (setq orig-ppss (syntax-ppss))
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))
77 (concat (or sig "") (match-string-no-properties 0)))))
80 (defun yas-objc-current-method-signature ()
81 (let ((orig-point (point))
88 (while (not (eq (point) (point-max))) (backward-sexp))
90 (when (eq (preceding-char) ?\[)
91 (setq orig-ppss (syntax-ppss))
93 (skip-chars-forward " \t\n")
94 (setq ppss (syntax-ppss))
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))
101 (concat (or sig "") (match-string-no-properties 0))))
106 (concat sig (buffer-substring-no-properties (point) orig-point)))