Strip copies in the substring filter, not via yank-handler - #801
Open
OSadovy wants to merge 1 commit into
Open
Conversation
Rendered output and block-quoted replies carried a yank-handler text property whose lambda stripped properties (and the "> " prefix) at paste time. Unlike the buffer-local filter-buffer-substring-function already installed in shell and viewport buffers, the property rides on the characters into any buffer they reach: it runs agent-shell code on yanks in unrelated buffers for the rest of the session, fires from every insert-for-yank caller (registers, rectangles, cua, xterm paste), and bypasses the user's yank-excluded-properties. Do the same work in agent-shell--filter-buffer-substring instead: return the copy free of text properties, and drop one "> " per line from text tagged agent-shell-block-quote, the property that now marks block-quoted replies. Copies out of agent-shell buffers are unchanged: kill, copy, mouse drag and registers all route through the filter and yield the same plain text as before. Markdown-rendered blockquotes keep their "> " on copy, as they already did, so the source still round-trips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Rendered output and block-quoted replies carry a
yank-handlertext propertywhose lambda strips properties (and the leading
>) at paste time. Theproperty rides on the characters, which has surprising reach:
agent-shell's lambda - for the rest of the session, in buffers unrelated to
agent-shell.
insert-for-yankis not justC-y: registers, rectangles,cua, xtermpaste, and any third-party property-preserving insertion all hit the handler.
M-wyields different content depending on destination:C-ygives
hello, while the OS clipboard and isearch'sC-s C-ykeep thestored
> hello.yank-excluded-propertiesis never consulted for handlertext, so no setting affects any of this.
Change
Delete both
yank-handlerputs and finish the job inagent-shell--filter-buffer-substring, which shell and viewport buffersalready install as
filter-buffer-substring-function- the hook Emacsprovides for deciding what a copy of a buffer yields. Copies now come out
property-free, and one
>per line is dropped from text tagged with aprivate
agent-shell-block-quotemarker (set byagent-shell--block-quotein place of the handler). The decision happens once, at copy time, in buffers
agent-shell owns; paste stays stock Emacs.
Behaviour
M-w,C-w, mouse copy, and registers out of agent-shell buffers paste thesame as before. Markdown-rendered blockquotes still keep their
>on copy,so the source round-trips. Two visible changes, both toward consistency:
OS clipboard and isearch kept the
>that yank removed.agent-shell-markdown-convertAPI, killed fromnon-agent-shell buffers, now paste with stock Emacs semantics. No in-tree
caller does this. Happy to gate it behind a keyword if you'd rather keep
the old behaviour there.
Context
Found while speech-enabling agent-shell with Emacspeak: its speech layer
inserts buffer text via
insert-for-yankprecisely to keep the textproperties it builds voices from, and the handler strips them. Any consumer
using
insert-for-yankfor property-preserving insertion hits the same wall,and a buffer-local filter cannot break them.
Tests: the yank test is rewritten as filter tests - properties stripped,
>dropped from quoted replies, one level per line for nested quotes,markdown blockquotes keep theirs. Full suite passes.
Checklist
M-x checkdocandM-x byte-compile-file.