Question: Using Emacs 25 in a linux environment, I often copy text with the mouse and wish that I could paste the copied text with some command in Emacs, but currently the only way I know of is via the mouse middle click which is bound to mouse-yank-primary.

I've attempted to bind this to a key command, along with setting mouse-yank-at-point set true, but this (as I suspected) requires a mouse event to work correctly and I'm not sure how to get Emacs into believing that a mouse event went off due to a keystroke.

Anyone have any ideas? Or simply know the correct way to yank with the keyboard from the PRIMARY selection?

Answer: 
After looking around thanks to Christian's answer, I found select.el and came up with the following to stick into my .emacs

```
;; Pull from PRIMARY (same as middle mouse click)
(defun get-primary ()
  (interactive)
  (insert
   (gui-get-primary-selection)))
(global-set-key "\C-c\C-y" 'get-primary)

```

Edit: As noted by Stefan, gui-get-primary-selection (and more generically, gui-get-selection) are only available in Emacs 25 and up. In Emacs 25.1 x-get-selection was made obsolete.
Hopefully this helps. It is shamelessly copied from above, but works both on 24 and 25. I have not tested in in other versions.

```
(if (< emacs-major-version 25)This w
    ;; in emacs 24 or previous
    (defun paste-primary-selection ()
      (interactive)
      (insert (x-get-selection 'PRIMARY))
      )
  ;; in emacs 25 and above
  (defun paste-primary-selection ()
    (interactive)
    (insert (gui-get-primary-selection)))
  )
(global-set-key (kbd "S-<insert>") 'paste-primary-selection)

```