diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a72e2f..0c29853e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,16 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ## Unreleased +### Added + + * Add `php-topsy-beginning-of-defun-with-class` to display classname with function signature. ([#766]) + ### Removed * Removed Phan-specific features from `php-project` ([#754]) [#754]: https://github.com/emacs-php/php-mode/pull/754 +[#766]: https://github.com/emacs-php/php-mode/pull/766 ## [1.25.0] - 2023-07-24 diff --git a/lisp/php.el b/lisp/php.el index 71c6c09a..67193f03 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -203,6 +203,12 @@ a completion list." :type 'integer :link '(url-link :tag "Built-in web server" "https://www.php.net/manual/features.commandline.webserver.php")) + +(defcustom php-topsy-separator " > " + "Separator string for `php-topsy-beginning-of-defun-with-class'." + :group 'php + :tag "PHP Topsy Separator" + :type 'string) ;;; PHP Keywords (defconst php-magical-constants @@ -655,6 +661,31 @@ Look at the `php-executable' variable instead of the constant \"php\" command." (if (string= class "") "" (concat "\\" class "::")) (if (string= namedfunc "") "" (concat namedfunc "()")))))) +(defun php-topsy-beginning-of-defun-with-class () + "Return function signature and class name string for header line in topsy. + +You can add the function to topsy with the code below: +\(add-to-list 'topsy-mode-functions '(php-mode . php-topsy-beginning-of-defun-with-class))" + (save-excursion + (goto-char (window-start)) + (mapconcat + #'identity + (append + (save-match-data + (save-excursion + (when (re-search-backward php--re-classlike-pattern nil t) + (font-lock-ensure (point) (line-end-position)) + (list (string-trim (buffer-substring (point) (line-end-position))))))) + (progn + (beginning-of-defun) + (font-lock-ensure (point) (line-end-position)) + (list (string-trim + (replace-regexp-in-string + (eval-when-compile (rx bos "