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

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

[elpa] externals/easy-kill 3ca8018 05/14: Check boundary in easy-kill-bo


From: Stefan Monnier
Subject: [elpa] externals/easy-kill 3ca8018 05/14: Check boundary in easy-kill-bounds-of-thing-at-point
Date: Mon, 15 Mar 2021 22:20:16 -0400 (EDT)

branch: externals/easy-kill
commit 3ca8018878e24b3a9066747eb07e570747c036e9
Author: Leo Liu <sdl.web@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>

    Check boundary in easy-kill-bounds-of-thing-at-point
---
 easy-kill.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index e063139..40d537a 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -1,6 +1,6 @@
 ;;; easy-kill.el --- kill & mark things easily       -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2014  Free Software Foundation, Inc.
+;; Copyright (C) 2013-2015  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <sdl.web@gmail.com>
 ;; Version: 0.9.4
@@ -413,11 +413,17 @@ checked."
 
 (defun easy-kill-bounds-of-thing-at-point (thing)
   "Easy Kill wrapper for `bounds-of-thing-at-point'."
-  (pcase (easy-kill-thing-handler
-          (format "easy-kill-bounds-of-%s-at-point" thing)
-          major-mode)
-    ((and (pred functionp) fn) (funcall fn))
-    (_ (bounds-of-thing-at-point thing))))
+  ;; Work around a bug (fixed in 25.1, commit: 7a94f28a) in
+  ;; `thing-at-point-bounds-of-url-at-point' that could return a
+  ;; boundary not containing current point.
+  (cl-flet ((chk (bound)
+              (pcase-let ((`(,b . ,e) bound))
+                (and b e (<= b (point) e) (cons b e)))))
+    (pcase (easy-kill-thing-handler
+            (format "easy-kill-bounds-of-%s-at-point" thing)
+            major-mode)
+      ((and (pred functionp) fn) (chk (funcall fn)))
+      (_ (chk (bounds-of-thing-at-point thing))))))
 
 (defun easy-kill-thing-forward-1 (thing &optional n)
   "Easy Kill wrapper for `forward-thing'."



reply via email to

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