Skip to content

Scripting API: copySelection(...) documentation unclear #3437

@Chealer

Description

@Chealer

The scripting API provides a copySelection(...) function, which is presented as 3 different functions in the documentation, all specified as follows (except for variation in synopsis):

copySelection(text)

Equivalent to the copy function with the same arguments, but for Linux mouse selection.

Throws:
Error() – Thrown if selection fails to be set.

This is unclear, mostly because:

  1. Most variants accept a single argument.
  2. It is not really specific to Linux (BSD seems to be somewhat supported).
  3. It is not specific to mouses.

The following clarifies:

diff --git a/docs/scripting-api.rst b/docs/scripting-api.rst
--- docs/scripting-api.rst
+++ docs/scripting-api.rst
@@ -295,9 +295,9 @@
    :rtype: bool
 
 .. js:function:: copy(text)
 
-   Sets clipboard plain text.
+   Sets the system clipboard to the specified string (of plain text).
 
    Same as ``copy(mimeText, text)``.
 
    :throws Error: Thrown if clipboard fails to be set.
@@ -362,24 +362,27 @@
        popup('Copied Text', text)
 
 .. js:function:: copySelection(text)
 
-   Equivalent to the ``copy`` function with the same arguments, but for `Linux
-   mouse selection`_.
+   On X11, equivalent to the ``copy`` function with the same argument, but modifying the ``PRIMARY`` selection atom rather than ``CLIPBOARD`` (see `Linux
+   mouse selection`_).
+   On other platforms, has no effect (no-op).
 
    :throws Error: Thrown if selection fails to be set.
 
 .. js:function:: /*data*/ copySelection(mimeType, data, [mimeType, data]...)
 
-   Equivalent to the ``copy`` function with the same arguments, but for `Linux
-   mouse selection`_.
+   On X11, equivalent to the ``copy`` function with the same arguments, but modifying the ``PRIMARY`` selection atom rather than ``CLIPBOARD`` (see `Linux
+   mouse selection`_).
+   On other platforms, has no effect (no-op).
 
    :throws Error: Thrown if selection fails to be set.
 
 .. js:function:: /*item*/ copySelection(Item)
 
-   Equivalent to the ``copy`` function with the same arguments, but for `Linux
-   mouse selection`_.
+   On X11, equivalent to the ``copy`` function with the same argument, but modifying the ``PRIMARY`` selection atom rather than ``CLIPBOARD`` (see `Linux
+   mouse selection`_).
+   On other platforms, has no effect (no-op).
 
    :throws Error: Thrown if selection fails to be set.
 
 .. js:function:: paste()

License This report (including all messages and attachments I add to it) is offered under the terms of CC0 1.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions