mirror of
https://github.com/joaotavora/yasnippet.git
synced 2026-02-05 23:12:26 +00:00
tweaking some basic objc snippets
This commit is contained in:
@@ -1,4 +1,24 @@
|
||||
;;; conditions
|
||||
;;; constants
|
||||
(defvar yas/objc-void-regexp "\\(void\\|IBAction\\)")
|
||||
|
||||
|
||||
;;; helper stuff
|
||||
(defun yas/objc-guess-instance-name (text)
|
||||
(if (string-match "NS\\(\\([AEIOQUY]\\)?[^ *]*\\)" text)
|
||||
(if (match-beginning 2)
|
||||
(concat "an" (capitalize (match-string-no-properties 1 text)))
|
||||
(concat "a" (capitalize (match-string-no-properties 1 text))))
|
||||
"arg"))
|
||||
|
||||
(defun yas/objc-guess-member-name (text)
|
||||
"Turns FOOBARBaz to baz"
|
||||
(let ((case-fold-search nil))
|
||||
(if (string-match "[A-Z]+\\([A-Z]\\)\\(.*\\)" text)
|
||||
(concat (downcase (match-string-no-properties 1 text))
|
||||
(match-string-no-properties 2 text))
|
||||
text)))
|
||||
|
||||
;;; cached conditions
|
||||
(yas/define-condition-cache
|
||||
yas/objc-interface-p
|
||||
"Non-nil if point inside an objc @interface declaration."
|
||||
@@ -11,10 +31,10 @@
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/objc-method-body-p
|
||||
"Non-nil if point inside an objc @implementation declaration."
|
||||
"Non-nil if point inside an objc method definition."
|
||||
(yas/objc-in-c-block-like 'objc-method-intro))
|
||||
|
||||
|
||||
;;; helpers for cached conditions
|
||||
(defun yas/objc-in-c-block-like (symbol-or-regexp)
|
||||
(let ((original-point (point))
|
||||
(start-point nil))
|
||||
|
||||
Reference in New Issue
Block a user