summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-08-13 17:49:31 +0800
committerPo Lu <luangruo@yahoo.com>2022-08-13 17:49:42 +0800
commitf937a0f3f8b387cf8668e16c677860d5f707144f (patch)
tree768ae9f60e1998dde4a9eb979dbfa53c143e5c90 /lisp/select.el
parent6de88b6b0261a549637270c0474998ac76eb65a9 (diff)
downloademacs-f937a0f3f8b387cf8668e16c677860d5f707144f.tar.gz
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.
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/select.el b/lisp/select.el
index e407c224367..5b9cca80a38 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)