-
I am trying to write a command that deletes the delimiters of a "thing" and then selects the inner contents of the "thing". When I run this command, I see that the delimiters are deleted and the selection is made, but the selection only lasts for a second before being undone. On Emacs 28.1, without the call to Is this the wrong way to select a region during a command? Is it expected that the selection is undone when the command ends? (defun my-meow-delete-surrounds (thing)
"Delete what defines the chosen thing."
(interactive (list (meow-thing-prompt "Thing: ")))
(pcase-let* ((`(,bounds-beg . ,bounds-end) (meow--parse-bounds-of-thing-char thing))
(`(,inner-beg . ,inner-end) (meow--parse-inner-of-thing-char thing))
(beg-dist (- inner-beg bounds-beg)))
(delete-region bounds-beg inner-beg)
(delete-region (- inner-end beg-dist)
(- bounds-end beg-dist))
(message "Start: %d, end: %d" bounds-beg (- inner-end beg-dist))
(meow--select-range nil (cons bounds-beg (- inner-end beg-dist))))) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I've narrowed this down to something that The selection works fine if This happens in Emacs 28 and 29. I will ask about this to see if this is intentional. |
Beta Was this translation helpful? Give feedback.
-
Answer is to wrap modifications to the buffer with setting Example from other reply: (defun my-meow-delete-surrounds (thing)
"Delete the delimiters that define the chosen thing, then select what remains."
(interactive (list (meow-thing-prompt "Thing: ")))
(pcase-let* ((`(,bounds-beg . ,bounds-end) (meow--parse-bounds-of-thing-char thing))
(`(,inner-beg . ,inner-end) (meow--parse-inner-of-thing-char thing))
(beg-dist (- inner-beg bounds-beg)))
(let ((deactivate-mark nil))
(delete-region bounds-beg inner-beg)
(delete-region (- inner-end beg-dist)
(- bounds-end beg-dist)))
(meow--select-range nil (cons bounds-beg (- inner-end beg-dist))))) |
Beta Was this translation helpful? Give feedback.
Answer is to wrap modifications to the buffer with setting
deactivate-mark
to nil.Example from other reply: