Skip to content

Commit e515cc9

Browse files
authored
Merge pull request #739 from emacs-php/apply-monnier-patch
Apply Stefan Monnier's patch (2)
2 parents 1e4e93c + 9e952d4 commit e515cc9

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

Diff for: lisp/php-mode.el

+7-19
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.
365365
;; Use the Emacs standard indentation binding. This may upset c-mode
366366
;; which does not follow this at the moment, but I see no better
367367
;; choice.
368-
(define-key map [tab] 'indent-for-tab-command)
368+
(define-key map "\t" nil) ;Hide CC-mode's `TAB' binding.
369369
map)
370370
"Keymap for `php-mode'.")
371371

@@ -1080,13 +1080,7 @@ Borrow the `interactive-form' from `c-set-style' and use the original
10801080
`c-set-style' function to set all declared stylevars.
10811081
For compatibility with `c-set-style' pass DONT-OVERRIDE to it.
10821082
1083-
After setting the stylevars run hooks according to STYLENAME
1084-
1085-
\"pear\" `php-mode-pear-hook'
1086-
\"drupal\" `php-mode-drupal-hook'
1087-
\"wordpress\" `php-mode-wordpress-hook'
1088-
\"symfony2\" `php-mode-symfony2-hook'
1089-
\"psr2\" `php-mode-psr2-hook'"
1083+
After setting the stylevars run hook `php-mode-STYLENAME-hook'."
10901084
(interactive
10911085
(list (let ((completion-ignore-case t)
10921086
(prompt (format "Which %s indentation style? "
@@ -1110,15 +1104,10 @@ After setting the stylevars run hooks according to STYLENAME
11101104
;; Restore variables
11111105
(cl-loop for (name . value) in backup-vars
11121106
do (set (make-local-variable name) value)))
1113-
1114-
(if (eq (symbol-value 'php-style-delete-trailing-whitespace) t)
1115-
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)
1116-
(remove-hook 'before-save-hook 'delete-trailing-whitespace t))
1117-
(cond ((equal stylename "pear") (run-hooks 'php-mode-pear-hook))
1118-
((equal stylename "drupal") (run-hooks 'php-mode-drupal-hook))
1119-
((equal stylename "wordpress") (run-hooks 'php-mode-wordpress-hook))
1120-
((equal stylename "symfony2") (run-hooks 'php-mode-symfony2-hook))
1121-
((equal stylename "psr2") (run-hooks 'php-mode-psr2-hook))))
1107+
(if (eq php-style-delete-trailing-whitespace t)
1108+
(add-hook 'before-save-hook #'delete-trailing-whitespace nil t)
1109+
(remove-hook 'before-save-hook #'delete-trailing-whitespace t))
1110+
(run-hooks (intern (format "php-mode-%s-hook" stylename))))
11221111

11231112
(defun php-mode--disable-delay-set-style (&rest _args)
11241113
"Disable `php-mode-set-style-delay' on after hook. ARGS be ignore."
@@ -1143,8 +1132,7 @@ After setting the stylevars run hooks according to STYLENAME
11431132
"Reset PHP-irrelevant variables set by Cc Mode initialization."
11441133
(setq-local c-mode-hook nil)
11451134
(setq-local java-mode-hook nil)
1146-
(when (eval-when-compile (boundp 'flymake-diagnostic-functions))
1147-
(remove-hook 'flymake-diagnostic-functions 'flymake-cc t))
1135+
(remove-hook 'flymake-diagnostic-functions 'flymake-cc t)
11481136
t)
11491137

11501138
(defvar php-mode-syntax-table

0 commit comments

Comments
 (0)