From 380ef3e4b3907c5f4a203947f38bebe4c0498c4c Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 8 Mar 2017 13:41:14 +0100 Subject: Upgrade mod-php and yasnippet --- .emacs.d/lisp/php-mode.el | 39 ++++++++++++++++++++++++++++++--------- .emacs.d/lisp/yasnippet.el | 22 +++++++++++++--------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index cd35d7d..da5da0a 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el @@ -257,14 +257,33 @@ can be used to match against definitions for that classlike." "^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1)) "Imenu generic expression for PHP Mode. See `imenu-generic-expression'.") -(defcustom php-manual-url "http://www.php.net/manual/en/" +(defcustom php-site-url "http://php.net/" + "Default PHP.net site URL. + +The URL to use open PHP manual and search word. +You can find a mirror site closer to you." + :type 'string + :link '(url-link :tag "List of Mirror Sites" "http://php.net/mirrors.php")) + +(defcustom php-manual-url 'en "URL at which to find PHP manual. You can replace \"en\" with your ISO language code." - :type 'string) - -(defcustom php-search-url "http://www.php.net/" + :type '(choice (const :tag "English" 'en) + (const :tag "Brazilian Portuguese" 'pt_BR) + (const :tag "Chinese (Simplified)" 'zh) + (const :tag "French" 'fr) + (const :tag "German" 'de) + (const :tag "Japanese" 'ja) + (const :tag "Romanian" 'ro) + (const :tag "Russian" 'ru) + (const :tag "Spanish" 'es) + (const :tag "Turkish" 'tr) + (string :tag "PHP manual URL"))) + +(defcustom php-search-url nil "URL at which to search for documentation on a word." - :type 'string) + :type '(choice (string :tag "URL to search PHP documentation") + (const :tag "Use `php-site-url' variable" nil))) (defcustom php-completion-file "" "Path to the file which contains the function names known to PHP." @@ -1309,12 +1328,12 @@ With a prefix argument, prompt (with completion) for a word to search for." t))) (defsubst php-search-web-documentation (word) - (php-browse-documentation-url (concat php-search-url - (replace-regexp-in-string "_" "-" (downcase word))))) + "Return URL to search PHP manual search by `WORD'." + (php-browse-documentation-url (concat (or php-search-url php-site-url) word))) ;; Define function documentation function (defun php-search-documentation (word) - "Search PHP documentation for the word at point. + "Search PHP documentation for the `WORD' at point. If `php-manual-path' has a non-empty string value then the command will first try searching the local documentation. If the requested @@ -1335,7 +1354,9 @@ a completion list." (defun php-browse-manual () "Bring up manual for PHP." (interactive) - (browse-url php-manual-url)) + (browse-url (if (stringp php-manual-url) + php-manual-url + (format "%smanual/%s/" php-site-url php-manual-url)))) (defconst php-phpdoc-type-keywords (list "string" "integer" "int" "boolean" "bool" "float" diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 7b871b9..76e1d25 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el @@ -1352,7 +1352,7 @@ Returns (TEMPLATES START END). This function respects ((debug error) (cdr oops))))) (defun yas--eval-for-effect (form) - (yas--safely-run-hook (apply-partially #'eval form))) + (yas--safely-call-fun (apply-partially #'eval form))) (defun yas--read-lisp (string &optional nil-on-error) "Read STRING as a elisp expression and return it. @@ -3336,18 +3336,19 @@ This renders the snippet as ordinary text." (setq yas--snippets-to-move nil)) (defun yas--safely-call-fun (fun) + "Call FUN and catch any errors." (condition-case error (funcall fun) ((debug error) - (yas--message 2 "Error running %s: %s" - (if (symbolp fun) fun "a hook") + (yas--message 2 "Error running %s: %s" fun (error-message-string error))))) (defun yas--safely-run-hook (hook) + "Call HOOK's functions. +HOOK should be a symbol, a hook variable, as in `run-hooks'." (let ((debug-on-error (and (not (memq yas-good-grace '(t hooks))) debug-on-error))) - (if (functionp hook) (yas--safely-call-fun hook) - (mapc #'yas--safely-call-fun hook)))) + (yas--safely-call-fun (apply-partially #'run-hooks hook)))) (defun yas--check-commit-snippet () "Check if point exited the currently active field of the snippet. @@ -3355,7 +3356,9 @@ This renders the snippet as ordinary text." If so cleans up the whole snippet up." (let* ((snippets (yas-active-snippets 'all)) (snippets-left snippets) - (snippet-exit-transform nil) + (snippet-exit-transform) + ;; Record the custom snippet `yas-after-exit-snippet-hook' + ;; set in the expand-env field. (snippet-exit-hook yas-after-exit-snippet-hook)) (dolist (snippet snippets) (let ((active-field (yas--snippet-active-field snippet))) @@ -3383,9 +3386,10 @@ If so cleans up the whole snippet up." (t nil))))) (unless (or (null snippets) snippets-left) - (if snippet-exit-transform - (yas--eval-for-effect snippet-exit-transform)) - (yas--safely-run-hook snippet-exit-hook)))) + (when snippet-exit-transform + (yas--eval-for-effect snippet-exit-transform)) + (let ((yas-after-exit-snippet-hook snippet-exit-hook)) + (yas--safely-run-hook 'yas-after-exit-snippet-hook))))) ;; Apropos markers-to-points: ;; -- cgit v1.3