Skip to content

Commit

Permalink
Expose a direct-to-paste menu.
Browse files Browse the repository at this point in the history
Fix maybe typo in quoting.
  • Loading branch information
brettviren committed Sep 7, 2014
1 parent 15d6643 commit 541fc57
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lisp/bv-paste.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
(bind-keys global-keymap "W-p" xpasteto)
37 changes: 29 additions & 8 deletions lisp/selection-menu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@
"Focused window before selection-menu is popped-up.")
(defvar selection-actions
'(("Mozilla" "mozilla -remote \'openURL(" ",new-tab)\'" selection-fix-url)
("Google" "mozilla -remote \'openURL(http://www.google.com/search?q=" ",new-tab)\'" selection-clean-url-query-escaping)
("Emacsclient" "emacsclient --no-wait" nil selection-shell-quote-argument)
("Manual" "xterm -e man")
("Dictionary" "xterm -e dict")
("Swap primary and secondary" (lambda (#!rest args) (selection-swap "primary" "secondary")))
("Swap primary and clipboard" (lambda (#!rest args) (selection-swap "primary" "clipboard")))
'(
("Web URL" "web-browser " selection-fix-url)
("Google" "web-browser 'http://www.google.com/search?q="
selection-clean-url-query-escaping "'")
; ("Emacsclient" "emacsclient --no-wait" nil selection-shell-quote-argument)
; ("Manual" "xterm -e man")
; ("Dictionary" "xterm -e dict")
; ("Swap primary and secondary" (lambda (#!rest args) (selection-swap "primary" "secondary")))
; ("Swap primary and clipboard" (lambda (#!rest args) (selection-swap "primary" "clipboard")))
("Paste selection" (lambda (selection) (selection-dump selection)))
))
Expand All @@ -69,7 +71,21 @@
(list (concat "Secondary: " (selection-fix-entry secd))
`(selection-popup-action-menu ,secd))
(list (concat "Clipboard: " (selection-fix-entry clip))
`(selection-popup-action-menu, clip)))))
`(selection-popup-action-menu ,clip)))))

;; like above but immediately paste
(define (paste-menu)
(setq *selection-last-focused-window* (input-focus))
(let ((prim (x-get-selection 'PRIMARY))
(secd (x-get-selection 'SECONDARY))
(clip (x-get-selection 'CLIPBOARD)))
(list
(list (concat "Primary: " (selection-fix-entry prim))
`(selection-dump ,prim))
(list (concat "Secondary: " (selection-fix-entry secd))
`(selection-dump ,secd))
(list (concat "Clipboard: " (selection-fix-entry clip))
`(selection-dump ,clip)))))
(define (selection-popup-action-menu selection)
(setq *selection-last-focused-window* (input-focus))
Expand All @@ -96,6 +112,10 @@
(define (selection-popup-menu)
(interactive)
(popup-menu (selection-menu)))
(define (paste-popup-menu)
(interactive)
(popup-menu (paste-menu)))
(define (selection-shell-quote-argument argument)
"Quote an argument for passing as argument to an inferior
Expand Down Expand Up @@ -164,6 +184,7 @@ services-clean-url-query-escaping)"
"Send the selected selection to the window focused before the
selection menu was popped-up. Based on dump-selections from
Mark Triggs's selection-push.jl."
;(display-message (concat "pasting: " text))
(selection-type-in text *selection-last-focused-window*))
(define (selection-fix-entry text)
Expand Down
7 changes: 6 additions & 1 deletion rc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

(require 'bv-volume)
(require 'bv-paste)

;(require 'bv-paste)
;(bind-keys global-keymap "W-p" xpasteto)
(require 'selection-menu)
(bind-keys global-keymap "W-y" selection-popup-menu)
(bind-keys global-keymap "W-p" paste-popup-menu)

0 comments on commit 541fc57

Please sign in to comment.