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

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

[nongnu] elpa/lua-mode 2fc3251 426/468: `lua-funcname-at-point': don't m


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 2fc3251 426/468: `lua-funcname-at-point': don't modify the syntax
Date: Thu, 5 Aug 2021 04:59:22 -0400 (EDT)

branch: elpa/lua-mode
commit 2fc3251424c9048409f218fb9b31dc63771071a6
Author: Nikita Bloshchanevich <nikblos@outlook.com>
Commit: Nikita Bloshchanevich <nikblos@outlook.com>

    `lua-funcname-at-point': don't modify the syntax
    
    Use `re-search-forward' + `re-search-backward', which is much less hacky and
    should be faster, as no syntax table needs to be copied.
---
 lua-mode.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index a5f5d6a..4618a6d 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -2021,10 +2021,13 @@ Create a Lua process if one doesn't already exist."
 
 (defun lua-funcname-at-point ()
   "Get current Name { '.' Name } sequence."
-  ;; FIXME: copying/modifying syntax table for each call may incur a penalty
-  (with-syntax-table (copy-syntax-table)
-    (modify-syntax-entry ?. "_")
-    (current-word t)))
+  (save-excursion
+    (save-match-data
+      (re-search-backward "\\`\\|[^A-Za-z.]")
+      ;; NOTE: `point' will be either at the start of the buffer or on a
+      ;; non-symbol character.
+      (re-search-forward "\\([A-Za-z]+\\(?:.[A-Za-z]+\\)*\\)")
+      (match-string 1))))
 
 (defun lua-search-documentation ()
   "Search Lua documentation for the word at the point."



reply via email to

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