-
There is (make-overlay start end 'region :temporary t) In src/overlays.lisp, an overlay is an object: (defclass overlay ()
((temporary
:initarg :temporary
:reader overlay-temporary-p)
(start
:initarg :start
:reader overlay-start
:type point)
(end
:initarg :end
:reader overlay-end
:type point)
(attribute
:initarg :attribute
:reader overlay-attribute
:writer set-overlay-attribute
:type (or null attribute))
(buffer
:initarg :buffer
:reader overlay-buffer
:type buffer)
(plist
:initform nil
:accessor overlay-plist
:type list)
(alivep
:initform t
:accessor overlay-alive-p
:type boolean))) Its (defmethod initialize-instance ((overlay overlay) &key &allow-other-keys)
(let ((overlay (call-next-method)))
(with-slots (start end attribute) overlay
(when (point< end start) (rotatef start end))
(setf attribute (ensure-attribute attribute t)))
(unless (overlay-temporary-p overlay)
(push overlay (buffer-value (overlay-buffer overlay) 'overlays)))
overlay)) so it is displayed automatically. Now, how to set a visual selection programmatically? I want to write a function Only calling see also the command |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Since you have added “temporary” to make-overlay, the renderer might not be recognizing it. |
Beta Was this translation helpful? Give feedback.
-
For visual selection does this example give you what you need: (define-command mark-and-forward-char (n) (:universal)
(unless (buffer-mark-p (current-buffer))
(set-cursor-mark (current-point) (current-point)))
(lem:character-offset (current-point) n)) This is a command from my init that enables shift-right. Incidentally @cxxxr - would this be useful as a PR? I feel that shift arrow keys generally select stuff in most editors, so this would make LEM feel a little less weird. |
Beta Was this translation helpful? Give feedback.
-
(define-command select-paragraph () ()
"Visually select paragraph."
(unless (buffer-mark-p (current-buffer))
(backward-paragraph)
(character-offset (current-point) 1) ;; forward one char
(set-cursor-mark (current-point) (current-point))
(forward-paragraph)
(character-offset (current-point) -1))) ;; backward one char
|
Beta Was this translation helpful? Give feedback.
For visual selection does this example give you what you need:
This is a command from my init that enables shift-right.
Incidentally @cxxxr - would this be useful as a PR? I feel that shift arrow keys generally select stuff in most editors, so this would make LEM feel a little less weird.