Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Stefan Monnier's patch (2) #739

Merged
merged 3 commits into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.
;; Use the Emacs standard indentation binding. This may upset c-mode
;; which does not follow this at the moment, but I see no better
;; choice.
(define-key map [tab] 'indent-for-tab-command)
(define-key map "\t" nil) ;Hide CC-mode's `TAB' binding.
map)
"Keymap for `php-mode'.")

Expand Down Expand Up @@ -1080,13 +1080,7 @@ Borrow the `interactive-form' from `c-set-style' and use the original
`c-set-style' function to set all declared stylevars.
For compatibility with `c-set-style' pass DONT-OVERRIDE to it.

After setting the stylevars run hooks according to STYLENAME

\"pear\" `php-mode-pear-hook'
\"drupal\" `php-mode-drupal-hook'
\"wordpress\" `php-mode-wordpress-hook'
\"symfony2\" `php-mode-symfony2-hook'
\"psr2\" `php-mode-psr2-hook'"
After setting the stylevars run hook `php-mode-STYLENAME-hook'."
(interactive
(list (let ((completion-ignore-case t)
(prompt (format "Which %s indentation style? "
Expand All @@ -1110,15 +1104,10 @@ After setting the stylevars run hooks according to STYLENAME
;; Restore variables
(cl-loop for (name . value) in backup-vars
do (set (make-local-variable name) value)))

(if (eq (symbol-value 'php-style-delete-trailing-whitespace) t)
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)
(remove-hook 'before-save-hook 'delete-trailing-whitespace t))
(cond ((equal stylename "pear") (run-hooks 'php-mode-pear-hook))
((equal stylename "drupal") (run-hooks 'php-mode-drupal-hook))
((equal stylename "wordpress") (run-hooks 'php-mode-wordpress-hook))
((equal stylename "symfony2") (run-hooks 'php-mode-symfony2-hook))
((equal stylename "psr2") (run-hooks 'php-mode-psr2-hook))))
(if (eq php-style-delete-trailing-whitespace t)
(add-hook 'before-save-hook #'delete-trailing-whitespace nil t)
(remove-hook 'before-save-hook #'delete-trailing-whitespace t))
(run-hooks (intern (format "php-mode-%s-hook" stylename))))

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

(defvar php-mode-syntax-table
Expand Down