Skip to content

Commit 699a900

Browse files
committed
Split php.el
1 parent eb84232 commit 699a900

File tree

5 files changed

+190
-152
lines changed

5 files changed

+190
-152
lines changed

Cask

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(package "php-mode" "1.21.2" "Major mode for editing PHP code")
22
(source melpa)
33

4+
(package-file "php.el")
45
(package-file "php-mode.el")
56
(package-file "php-project.el")
67
(package-file "php-mode-debug.el")

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
EMACS ?= emacs
2-
ELS = php-project.el php-mode.el php-mode-debug.el php-mode-test.el
2+
ELS = php.el php-project.el php-mode.el php-mode-debug.el php-mode-test.el
33
AUTOLOADS = php-project-autoloads.el php-mode-autoloads.el
44
ELCS = $(ELS:.el=.elc)
55

@@ -10,7 +10,7 @@ all: autoloads $(ELCS)
1010

1111
autoloads: $(AUTOLOADS)
1212

13-
$(AUTOLOADS): php-project.el php-mode-debug.el php-mode.el
13+
$(AUTOLOADS): php.el php-project.el php-mode-debug.el php-mode.el
1414
$(EMACS) -Q -batch -L . --eval \
1515
"(progn \
1616
(require 'package) \

php-mode-test.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
;; with Emacs >= 24.1.
3131

3232
;;; Code:
33-
33+
(require 'php)
3434
(require 'php-mode)
3535
(require 'php-mode-debug)
3636
(require 'php-project)

php-mode.el

Lines changed: 1 addition & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363

6464
;;; Code:
6565

66+
(require 'php)
6667
(require 'cc-mode)
6768
(require 'cc-langs)
6869

@@ -120,14 +121,6 @@
120121
"Display informations useful for debugging PHP Mode." t)
121122

122123
;; Local variables
123-
;;;###autoload
124-
(defgroup php nil
125-
"Language support for PHP."
126-
:tag "PHP"
127-
:group 'languages
128-
:group 'php
129-
:link '(url-link :tag "Official Site" "https://github.com/emacs-php/php-mode")
130-
:link '(url-link :tag "PHP Mode Wiki" "https://github.com/emacs-php/php-mode/wiki"))
131124

132125
;;;###autoload
133126
(defgroup php-mode nil
@@ -139,11 +132,6 @@
139132
:link '(url-link :tag "Official Site" "https://github.com/emacs-php/php-mode")
140133
:link '(url-link :tag "PHP Mode Wiki" "https://github.com/emacs-php/php-mode/wiki"))
141134

142-
(defcustom php-executable (or (executable-find "php")
143-
"/usr/bin/php")
144-
"The location of the PHP executable."
145-
:type 'string)
146-
147135
(define-obsolete-variable-alias 'php-default-face 'php-mode-default-face "1.20.0")
148136
(defcustom php-mode-default-face 'default
149137
"Default face in `php-mode' buffers."
@@ -178,15 +166,6 @@ Turning this on will open it whenever `php-mode' is loaded."
178166
:group 'php-mode
179167
:type 'boolean)
180168

181-
(defsubst php-in-string-p ()
182-
(nth 3 (syntax-ppss)))
183-
184-
(defsubst php-in-comment-p ()
185-
(nth 4 (syntax-ppss)))
186-
187-
(defsubst php-in-string-or-comment-p ()
188-
(nth 8 (syntax-ppss)))
189-
190169
(defun php-mode-extra-constants-create-regexp (kwds)
191170
"Create regexp for the list of extra constant keywords KWDS."
192171
(concat "[^_$]?\\<\\("
@@ -225,67 +204,6 @@ of constants when set."
225204
:type '(repeat string)
226205
:set 'php-mode-extra-constants-set)
227206

228-
(defun php-create-regexp-for-method (visibility)
229-
"Make a regular expression for methods with the given VISIBILITY.
230-
231-
VISIBILITY must be a string that names the visibility for a PHP
232-
method, e.g. 'public'. The parameter VISIBILITY can itself also
233-
be a regular expression.
234-
235-
The regular expression this function returns will check for other
236-
keywords that can appear in method signatures, e.g. 'final' and
237-
'static'. The regular expression will have one capture group
238-
which will be the name of the method."
239-
(concat
240-
;; Initial space with possible 'abstract' or 'final' keywords
241-
"^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?"
242-
;; 'static' keyword may come either before or after visibility
243-
"\\(?:" visibility "\\(?:\\s-+static\\)?\\|\\(?:static\\s-+\\)?" visibility "\\)\\s-+"
244-
;; Make sure 'function' comes next with some space after
245-
"function\\s-+"
246-
;; Capture the name as the first group and the regexp and make sure
247-
;; by the end we see the opening parenthesis for the parameters.
248-
"\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*("))
249-
250-
(defun php-create-regexp-for-classlike (type)
251-
"Accepts a `TYPE' of a 'classlike' object as a string, such as
252-
'class' or 'interface', and returns a regexp as a string which
253-
can be used to match against definitions for that classlike."
254-
(concat
255-
;; First see if 'abstract' or 'final' appear, although really these
256-
;; are not valid for all values of `type' that the function
257-
;; accepts.
258-
"^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?"
259-
;; The classlike type
260-
type
261-
;; Its name, which is the first captured group in the regexp. We
262-
;; allow backslashes in the name to handle namespaces, but again
263-
;; this is not necessarily correct for all values of `type'.
264-
"\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)"))
265-
266-
(defvar php-imenu-generic-expression
267-
`(("Namespaces"
268-
,(php-create-regexp-for-classlike "namespace") 1)
269-
("Classes"
270-
,(php-create-regexp-for-classlike "class") 1)
271-
("Interfaces"
272-
,(php-create-regexp-for-classlike "interface") 1)
273-
("Traits"
274-
,(php-create-regexp-for-classlike "trait") 1)
275-
("All Methods"
276-
,(php-create-regexp-for-method "\\(?:\\sw\\|\\s_\\)+") 1)
277-
("Private Methods"
278-
,(php-create-regexp-for-method "private") 1)
279-
("Protected Methods"
280-
,(php-create-regexp-for-method "protected") 1)
281-
("Public Methods"
282-
,(php-create-regexp-for-method "public") 1)
283-
("Anonymous Functions"
284-
"\\<\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*=\\s-*function\\s-*(" 1)
285-
("Named Functions"
286-
"^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1))
287-
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
288-
289207
(define-obsolete-variable-alias 'php-do-not-use-semantic-imenu 'php-mode-do-not-use-semantic-imenu "1.20.0")
290208
(defcustom php-mode-do-not-use-semantic-imenu t
291209
"Customize `imenu-create-index-function' for `php-mode'.
@@ -297,32 +215,6 @@ parent. Set this variable to t if you want to use
297215
enabled."
298216
:type 'boolean)
299217

300-
(defcustom php-site-url "https://php.net/"
301-
"Default PHP.net site URL.
302-
303-
The URL to use open PHP manual and search word."
304-
:type 'string)
305-
306-
(defcustom php-manual-url 'en
307-
"URL at which to find PHP manual.
308-
You can replace \"en\" with your ISO language code."
309-
:type '(choice (const :tag "English" 'en)
310-
(const :tag "Brazilian Portuguese" 'pt_BR)
311-
(const :tag "Chinese (Simplified)" 'zh)
312-
(const :tag "French" 'fr)
313-
(const :tag "German" 'de)
314-
(const :tag "Japanese" 'ja)
315-
(const :tag "Romanian" 'ro)
316-
(const :tag "Russian" 'ru)
317-
(const :tag "Spanish" 'es)
318-
(const :tag "Turkish" 'tr)
319-
(string :tag "PHP manual URL")))
320-
321-
(defcustom php-search-url nil
322-
"URL at which to search for documentation on a word."
323-
:type '(choice (string :tag "URL to search PHP documentation")
324-
(const :tag "Use `php-site-url' variable" nil)))
325-
326218
(defcustom php-completion-file ""
327219
"Path to the file which contains the function names known to PHP."
328220
:type 'string)
@@ -1763,46 +1655,6 @@ The output will appear in the buffer *PHP*."
17631655

17641656
(ad-activate 'fixup-whitespace)
17651657

1766-
1767-
(defcustom php-class-suffix-when-insert "::"
1768-
"Suffix for inserted class."
1769-
:group 'php
1770-
:type 'string)
1771-
1772-
(defcustom php-namespace-suffix-when-insert "\\"
1773-
"Suffix for inserted namespace."
1774-
:group 'php
1775-
:type 'string)
1776-
1777-
(defvar php--re-namespace-pattern
1778-
(php-create-regexp-for-classlike "namespace"))
1779-
1780-
(defvar php--re-classlike-pattern
1781-
(php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait"))))
1782-
1783-
(defun php-get-current-element (re-pattern)
1784-
"Return backward matched element by RE-PATTERN."
1785-
(save-excursion
1786-
(when (re-search-backward re-pattern nil t)
1787-
(match-string-no-properties 1))))
1788-
1789-
;;;###autoload
1790-
(defun php-current-class ()
1791-
"Insert current class name if cursor in class context."
1792-
(interactive)
1793-
(let ((matched (php-get-current-element php--re-classlike-pattern)))
1794-
(when matched
1795-
(insert (concat matched php-class-suffix-when-insert)))))
1796-
1797-
;;;###autoload
1798-
(defun php-current-namespace ()
1799-
"Insert current namespace if cursor in namespace context."
1800-
(interactive)
1801-
(let ((matched (php-get-current-element php--re-namespace-pattern)))
1802-
(when matched
1803-
(insert (concat matched php-namespace-suffix-when-insert)))))
1804-
1805-
18061658
;;;###autoload
18071659
(add-to-list 'auto-mode-alist
18081660
(cons

0 commit comments

Comments
 (0)