emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/php-mode 2bad994c17 1/5: Add php-topsy-beginning-of-defun-


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode 2bad994c17 1/5: Add php-topsy-beginning-of-defun-with-class for Topsy
Date: Sat, 18 Nov 2023 01:00:12 -0500 (EST)

branch: elpa/php-mode
commit 2bad994c1727388ca5b1313f63c9604ebe959daf
Author: USAMI Kenta <tadsan@zonu.me>
Commit: USAMI Kenta <tadsan@zonu.me>

    Add php-topsy-beginning-of-defun-with-class for Topsy
---
 CHANGELOG.md |  5 +++++
 lisp/php.el  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 74a72e2fce..0c29853eb2 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 71c6c09a30..67193f03b2 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 "<?php"))
+                ""
+                (buffer-substring (point) (line-end-position)))))))
+     php-topsy-separator)))
+
 ;;;###autoload
 (defun php-run-builtin-web-server (router-or-dir hostname port &optional 
document-root)
   "Run PHP Built-in web server.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]