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

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

[nongnu] elpa/php-mode b3718d488d 6/9: Copy thing-at-point-bounds-of-str


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode b3718d488d 6/9: Copy thing-at-point-bounds-of-string-at-point function from thingatpt.el
Date: Sat, 1 Oct 2022 23:59:03 -0400 (EDT)

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

    Copy thing-at-point-bounds-of-string-at-point function from thingatpt.el
---
 lisp/php.el | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/lisp/php.el b/lisp/php.el
index 61b9564966..3a79a97ac3 100644
--- a/lisp/php.el
+++ b/lisp/php.el
@@ -461,6 +461,28 @@ can be used to match against definitions for that 
classlike."
         (match-string-no-properties 1)))))
 
 (eval-and-compile
+  (if (eval-when-compile (fboundp 'thing-at-point-bounds-of-string-at-point))
+      (defalias 'php--thing-at-point-bounds-of-string-at-point 
#'thing-at-point-bounds-of-string-at-point)
+    ;; Copyright (C) 1991-1998, 2000-2022 Free Software Foundation, Inc.
+    ;; Follows function is copied from Emacs 28's thingatpt.el.
+    ;; 
https://github.com/emacs-mirror/emacs/commit/2abf143f8185fced544c4f8d144ea710142d7a59
+    (defun php--thing-at-point-bounds-of-string-at-point ()
+      "Return the bounds of the string at point.
+Prefer the enclosing string with fallback on sexp at point.
+\[Internal function used by `bounds-of-thing-at-point'.]"
+      (save-excursion
+        (let ((ppss (syntax-ppss)))
+          (if (nth 3 ppss)
+              ;; Inside the string
+              (ignore-errors
+                (goto-char (nth 8 ppss))
+                (cons (point) (progn (forward-sexp) (point))))
+            ;; At the beginning of the string
+            (if (eq (char-syntax (char-after)) ?\")
+                (let ((bound (bounds-of-thing-at-point 'sexp)))
+                 (and bound
+                      (<= (car bound) (point)) (< (point) (cdr bound))
+                      bound))))))))
   (if (eval-when-compile (fboundp 'c-end-of-token))
       (defalias 'php--c-end-of-token #'c-end-of-token)
     ;; Copyright (C) 1985, 1987, 1992-2022 Free Software Foundation, Inc.



reply via email to

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