I want to evaluate certain conditions before allowing a user to copy a text. As far as I know, I need an advice for "kill-ring-save"
. I need to ignore the user request to Copy that text if conditions are not met and allow it if are satisfied. How can I do this?
(UPDATE) -- MORE ABOUT CONSTRAINTS: only in specific mode of Emacs (e.g. NXML mode) this advice should be applied and only when one/more specific conditions are met.
Quick proof of concept; you don't tell what your constraints are, so this is necessarily vague / useless.
The additional major-mode constraint was added in response to comments below. If you want this in every mode, just take out the mode check.