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

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

[nongnu] elpa/anzu 04ac39641e 143/288: Merge pull request #32 from syohe


From: ELPA Syncer
Subject: [nongnu] elpa/anzu 04ac39641e 143/288: Merge pull request #32 from syohex/fix-at-cursor-beginning-point
Date: Thu, 6 Jan 2022 03:58:47 -0500 (EST)

branch: elpa/anzu
commit 04ac39641e9b476d5556d83457f52891c44e3fe5
Merge: 2a3d8d76d2 e567375313
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>

    Merge pull request #32 from syohex/fix-at-cursor-beginning-point
    
    Improve case when bounds-og-thing-at-point returns nil
---
 anzu.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/anzu.el b/anzu.el
index 9a427d16ca..b944fe5adb 100644
--- a/anzu.el
+++ b/anzu.el
@@ -525,15 +525,22 @@
 
 (defun anzu--thing-begin (thing)
   (let ((bound (bounds-of-thing-at-point thing)))
-    (and bound (car bound))))
-
-(defun anzu--thing-end (thing)
+    (if bound
+        (car bound)
+      (let ((fallback-bound (bounds-of-thing-at-point 'symbol)))
+        (if fallback-bound
+            (car fallback-bound)
+          (point))))))
+
+(defsubst anzu--thing-end (thing)
   (let ((bound (bounds-of-thing-at-point thing)))
-    (and bound (cdr bound))))
+    (if bound
+        (cdr bound)
+      (point-max))))
 
 (defun anzu--region-begin (use-region thing backward)
   (cond (current-prefix-arg (line-beginning-position))
-        (thing (or (anzu--thing-begin thing) (point)))
+        (thing (anzu--thing-begin thing))
         (use-region (region-beginning))
         (backward (point-min))
         (t (point))))
@@ -546,7 +553,7 @@
 (defun anzu--region-end (use-region thing)
   (cond (current-prefix-arg
          (anzu--line-end-position (prefix-numeric-value current-prefix-arg)))
-        (thing (or (anzu--thing-end thing) (point-max)))
+        (thing (anzu--thing-end thing))
         (use-region (region-end))
         (t (point-max))))
 



reply via email to

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