From 6c68d871fbbb9bd2c270fc5cb162c8be58666736 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 7 Apr 2026 09:15:36 -0700 Subject: oni-php: Add auto-insert template for .php files --- oni-php/oni-php.el | 35 ++++++++++++++++++++++++++++++++--- oni-php/snippets/php-mode/namespace | 6 +----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/oni-php/oni-php.el b/oni-php/oni-php.el index b9a5c79..612d645 100644 --- a/oni-php/oni-php.el +++ b/oni-php/oni-php.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2026.0406.114757 +;; Version: 2026.0406.154601 ;; 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 @@ -177,6 +177,23 @@ Otherwise call FUNC with ARGS. This is meant as advice around (oni-php-doc-comment)) (t (apply func args)))) +(defun oni-php-generate-namespace () + (string-join + (mapcar + (lambda (s) + (let ((case-fold-search nil)) + (if (string-match-p (rx upper-case) s) + s + (capitalize s)))) + (cdr (split-string + (directory-file-name + (file-name-directory + (file-relative-name + buffer-file-name + (project-root (project-current))))) + "/"))) + "\\")) + (defhydra php-mode-hydra (:color blue) ("a" align-current "Align current selection")) @@ -251,13 +268,25 @@ Otherwise call FUNC with ARGS. This is meant as advice around (add-to-list 'grep-files-aliases '("php" . "*.php *.inc *.module"))) (with-eval-after-load 'autoinsert - (setf (map-elt auto-insert-alist (rx "Test.php" eos)) + (setf (map-elt auto-insert-alist (rx ".php" eos)) + '(nil + " _ "\n" + "}\n") + (map-elt auto-insert-alist (rx "Test.php" eos)) '(nil "