emacs-diffs
[Top][All Lists]
Advanced

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

master f937a0f3f8: Prevent selection converter from signalling if buffer


From: Po Lu
Subject: master f937a0f3f8: Prevent selection converter from signalling if buffer is narrowed
Date: Sat, 13 Aug 2022 05:49:53 -0400 (EDT)

branch: master
commit f937a0f3f8b387cf8668e16c677860d5f707144f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Prevent selection converter from signalling if buffer is narrowed
    
    * lisp/select.el (xselect-convert-to-string): If positions are
    outside the accessible portion of the buffer, don't return
    anything.
---
 lisp/select.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/select.el b/lisp/select.el
index e407c22436..5b9cca80a3 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -673,9 +673,12 @@ two markers or an overlay.  Otherwise, it is nil."
   (let ((str (cond ((stringp value) value)
                   ((setq value (xselect--selection-bounds value))
                    (with-current-buffer (nth 2 value)
-                     (buffer-substring (nth 0 value)
-                                       (nth 1 value)))))))
-    (xselect--encode-string type str t)))
+                      (when (and (>= (nth 0 value) (point-min))
+                                 (<= (nth 1 value) (point-max)))
+                       (buffer-substring (nth 0 value)
+                                          (nth 1 value))))))))
+    (when str
+      (xselect--encode-string type str t))))
 
 (defun xselect-convert-to-length (_selection _type value)
   (let ((len (cond ((stringp value)



reply via email to

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