PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/skeleton/php-pcre.el

http://github.com/ejmr/php-mode
Lisp | 103 lines | 72 code | 15 blank | 16 comment | 0 complexity | 1124c9eafa2f822adec7f1ae551887c8 MD5 | raw file
  1;; Copyright (C) 2015  David Arroyo Menéndez
  2
  3;; Author: David Arroyo Menéndez <davidam@gnu.org>
  4;; Maintainer: David Arroyo Menéndez <davidam@gnu.org>
  5
  6;; This file is free software; you can redistribute it and/or modify
  7;; it under the terms of the GNU General Public License as published by
  8;; the Free Software Foundation; either version 3, or (at your option)
  9;; any later version.
 10
 11;; This file is distributed in the hope that it will be useful,
 12;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14;; GNU General Public License for more details.
 15
 16;; You should have received a copy of the GNU General Public License
 17;; along with GNU Emacs; see the file COPYING.  If not, write to
 18;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 19;; Boston, MA 02110-1301 USA,
 20
 21;; file:///usr/share/doc/php-doc/html/ref.pcre.html
 22
 23(define-skeleton php-preg_filter
 24  "Insert a preg_filter statement. preg_filter is identical to preg_replace except it only returns the (possibly transformed) subjects where there was a match."
 25  ""
 26  '(setq pattern (skeleton-read "Pattern: "))
 27  '(setq replacement (skeleton-read "Replacement: "))
 28  '(setq subject (skeleton-read "Subject: "))
 29  > "preg_filter(" pattern ", " replacement ", " subject ");" \n)
 30
 31(define-skeleton php-preg_grep
 32  "Insert a preg_grep statement. preg_grep return array entries that match the pattern."
 33  ""
 34  '(setq pattern (skeleton-read "Pattern: "))
 35  '(setq input (skeleton-read "Input: "))
 36  > "preg_grep(" pattern ", " replacement ");" \n)
 37
 38(define-skeleton php-preg_last_error
 39  "Insert a preg_last_error statement. Returns the error code of the last PCRE regex execution"
 40  ""
 41  > "preg_last_error();" \n)
 42
 43
 44(define-skeleton php-preg_match_all
 45  "Insert a preg_match_all statement. Perform a global regular expression match"
 46  ""
 47  '(setq pattern (skeleton-read "Pattern: "))
 48  '(setq subject (skeleton-read "Input string: "))
 49  '(setq matches (skeleton-read "The array of all matches: "))
 50  '(setq flags (skeleton-read "Flags (PREG_PATTERN_ORDER | PREG_SET_ORDER | PREG_OFFSET_CAPTURE)"))
 51  '(setq offset (skeleton-read "Offset: "))
 52  > "preg_match_all(" pattern ", " subject ", " matches ", " flags ", " offset ");" \n
 53)
 54
 55(define-skeleton php-preg_match
 56  "Insert a preg_match statement. Perform a regular expression match"
 57  '(setq pattern (skeleton-read "Pattern: "))
 58  '(setq subject (skeleton-read "Input string: "))
 59  '(setq matches (skeleton-read "The array of all matches: "))
 60  '(setq flags (skeleton-read "Flags (PREG_PATTERN_ORDER | PREG_SET_ORDER | PREG_OFFSET_CAPTURE)"))
 61  '(setq offset (skeleton-read "Offset: "))
 62  > "preg_match(" pattern ", " subject ", " matches ", " flags ", " offset ");" \n
 63)
 64
 65(define-skeleton php-preg_quote
 66  "Insert a preg_quote statement. Quote regular expression characters"
 67  ""
 68  '(setq str (skeleton-read "String: "))
 69  '(setq delimiter (skeleton-read "Delimiter: "))
 70  > "preg_quote(" str ", " delimiter ");" \n
 71)
 72
 73(define-skeleton php-preg_replace_callback
 74  "Insert a preg_replace_callback statement."
 75  ""
 76  '(setq pattern (skeleton-read "Pattern: "))
 77  '(setq callback (skeleton-read "Callback: "))
 78  '(setq subject (skeleton-read "Subject: "))
 79  '(setq limit (skeleton-read "Limit: "))
 80  '(setq count (skeleton-read "Count: "))
 81  > "preg_replace_callback(" pattern ", " callback ", " subject ", " limit ", " count ");" \n
 82)
 83
 84(define-skeleton php-preg_replace
 85  "Insert a preg_replace statement. Perform a regular expression search and replace"
 86  ""
 87  '(setq pattern (skeleton-read "Pattern: "))
 88  '(setq replacement (skeleton-read "Replacement: "))
 89  '(setq subject (skeleton-read "Subject: "))
 90  '(setq limit (skeleton-read "Limit: "))
 91  '(setq count (skeleton-read "Count: "))
 92  > "preg_replace_callback(" pattern ", " replacement ", " subject ", " limit ", " count ");" \n
 93)
 94
 95(define-skeleton php-preg_split
 96  "Insert a preg_split statement. Split string by a regular expression"
 97  ""
 98  '(setq pattern (skeleton-read "Pattern: "))
 99  '(setq subject (skeleton-read "Subject: "))
100  '(setq limit (skeleton-read "Limit: "))
101  '(setq flags (skeleton-read "Flags: "))
102  > "preg_split(" pattern ", " subject ", " limit ", " flags ");" \n
103)