]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent selection converter from signalling if buffer is narrowed
authorPo Lu <luangruo@yahoo.com>
Sat, 13 Aug 2022 09:49:31 +0000 (17:49 +0800)
committerPo Lu <luangruo@yahoo.com>
Sat, 13 Aug 2022 09:49:42 +0000 (17:49 +0800)
* lisp/select.el (xselect-convert-to-string): If positions are
outside the accessible portion of the buffer, don't return
anything.

lisp/select.el

index e407c224367833b2d072c9d375c9177e43033779..5b9cca80a38769d7ca3f7e99d1e82497d9414698 100644 (file)
@@ -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)