From d2f612b4b44d1767c4f7f7c01eb06ab148f74a7c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 1 Apr 2026 11:22:02 -0700 Subject: oni-php: Bring back ‘oni-php-comment-dwim’ --- oni-php/oni-php.el | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'oni-php') diff --git a/oni-php/oni-php.el b/oni-php/oni-php.el index f5ec1f3..36bf76f 100644 --- a/oni-php/oni-php.el +++ b/oni-php/oni-php.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2026.0327.112457 +;; Version: 2026.0331.120917 ;; Package-Requires: (oni-yasnippet oni-flycheck oni-company oni-hydra oni-smartparens ggtags fic-mode company-php rainbow-delimiters rainbow-identifiers) ;; This program is free software; you can redistribute it and/or modify @@ -130,23 +130,23 @@ Do the insert N times." (indent-region start (point)) (goto-char insert-marker)))) -;; (defun oni-php-comment-dwim (func &rest args) -;; "See if a PHP documentation comment should be added and add it. -;; Otherwise call FUNC with ARGS. This is meant as advice around -;; ‘comment-dwim’ to make it smarter for PHP code." -;; (if (and (derived-mode-p 'php-mode) -;; (not (region-active-p)) -;; (looking-back (rx (minimal-match (zero-or-more blank))) (line-beginning-position)) -;; (looking-at (rx (minimal-match (zero-or-more (any whitespace "\n"))) -;; (or (regexp php-beginning-of-defun-regexp) -;; (regexp php--re-classlike-pattern))))) -;; (oni-php-doc-comment) -;; (apply func args))) +(defun oni-php-comment-dwim (func &rest args) + "See if a PHP documentation comment should be added and add it. +Otherwise call FUNC with ARGS. This is meant as advice around +‘comment-dwim’ to make it smarter for PHP code." + (if (and (derived-mode-p 'php-mode) + (not (region-active-p)) + (looking-back (rx (minimal-match (zero-or-more blank))) (line-beginning-position)) + (looking-at (rx (minimal-match (zero-or-more (any whitespace "\n"))) + (or (regexp php-beginning-of-defun-regexp) + (regexp php--re-classlike-pattern))))) + (oni-php-doc-comment) + (apply func args))) (defhydra php-mode-hydra (:color blue) ("a" align-current "Align current selection")) -;; (advice-add 'comment-dwim :around #'oni-php-comment-dwim) +(advice-add 'comment-dwim :around #'oni-php-comment-dwim) (add-hook 'php-mode-hook #'oni-php--set-require-final-newline) (add-hook 'php-mode-hook #'oni-php--whitespace-mode) -- cgit v1.3-2-g0d8e