Recently I came across some text mentioning the X11 Secondary selection. I know X11 has Primary and Clipboard selections, and only those two are ever used in standard desktop apps. So what is this secondary selection?
(As an aside, the selection names are usually written in all-caps. I’ve opted not to do this, for readability purposes. Also, the primary selection is sometimes confusingly referred to as “primary clipboard”.)
There were a few red herrings that I found while searching the Web. The most straightforward explanation was from Vim’s documentation, saying that the secondary selection is “ill-defined”.
Then it occurred to me to read the X11 specification itself. Well, I couldn’t find the actual spec, but I found a 1990 paper on the design of X11. Check the Selections section (16th page on the PDF, labelled page 14 in the document), specifically the one on secondary selections (page 18 PDF, 16 document). Here’s a snippet:
‘A single global selection is insufficient in some user interface models, which may need the notion of the “current” selection yet also need to be able to communicate other information between applications, using the same request-reply model of the primary selection.
‘For example the user may want to swap the value of two items on the screen. He can make primary and secondary selections and then press a swap button.’
So there we go. The secondary selection is literally a secondary selection that you can use in addition to the primary selection. How you create and use the selection is application-dependent, but it’s a near-extinct feature that perhaps only exists in Emacs today.