Author Topic: paste hooks.  (Read 1883 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
paste hooks.
« on: February 14, 2019, 09:01:09 PM »
I noticed that in IIntelliJ, if I copy a dependency from a POM.xml file and paste it into a Gradle file, IntelliJ will reformat it for me.
Copy this from POM.xml:
Code: [Select]
        <dependency>
            <groupId>net.logstash.logback</groupId>
            <artifactId>logstash-logback-encoder</artifactId>
            <version>4.5.1</version>
        </dependency>
Paste into build.gradle, and it becomes this:
Code: [Select]
compile 'net.logstash.logback:logstash-logback-encoder:4.5.1'
Pretty nifty.

I have suggested before a Paste-special that would let me pick different ways of pasting.

How about paste-hooks?
A paste hook would be a pluggable way to extend Paste operations.
When doing a paste, a hook could be invoked to transform the text before inserting it into the document.

A hook could accept the paste (and do the transform), or reject it and allow the paste to happen normally.
Acceptance could be based some statically defined criteria:
   A defined regex (slick would evaluate this before invoking the hook)
   Source document type (e.g. XML)
   Clipboard formats (text, html, bitmap, whatever)
   Clipboard source (Slickedit, word, etc)
   Target document type (e.g. Groovy)
Or it could be dynamic - the hook gets called to decide for itself.


Paste-special is then just a UI on top of this.
When you do paste-special, Slick would evaluate to see which paste hooks could be applied, and let the user select which one.