+2014-10-10 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * select.el (gui-selection-exists-p-alist): New method.
+ * menu-bar.el (menu-bar-edit-menu, clipboard-yank):
+ * simple.el (deactivate-mark): Use it.
+ * term/x-win.el (gui-selection-exists-p):
+ * term/w32-win.el (gui-selection-exists-p):
+ * term/pc-win.el (gui-selection-exists-p):
+ * term/ns-win.el (gui-selection-exists-p): Provide a backend instance.
+
2014-10-10 Glenn Morris <rgm@gnu.org>
* info.el (Info-fontify-maximum-menu-size): Bump to 400k. (Bug#16227)
[paste-from-menu])
;; ns-win.el said: Change text to be more consistent with
;; surrounding menu items `paste', etc."
- `(menu-item ,(if (featurep 'ns) "Select and Paste"
- "Paste from Kill Menu") yank-menu
+ `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu")
+ yank-menu
:enable (and (cdr yank-menu) (not buffer-read-only))
:help "Choose a string from the kill ring and paste it"))
(bindings--define-key menu [paste]
'(menu-item "Paste" yank
:enable (and (or
- ;; Emacs compiled --without-x (or --with-ns)
- ;; doesn't have x-selection-exists-p.
- (and (fboundp 'x-selection-exists-p)
- (x-selection-exists-p 'CLIPBOARD))
+ (gui-call gui-selection-exists-p 'CLIPBOARD)
(if (featurep 'ns) ; like paste-from-menu
(cdr yank-menu)
kill-ring))
'(and mark-active (not buffer-read-only)))
(put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
(put 'clipboard-yank 'menu-enable
- '(and (or (not (fboundp 'x-selection-exists-p))
- (x-selection-exists-p)
- (x-selection-exists-p 'CLIPBOARD))
+ '(and (or (gui-call gui-selection-exists-p 'PRIMARY)
+ (gui-call gui-selection-exists-p 'CLIPBOARD))
(not buffer-read-only)))
(defun clipboard-yank ()
Called with one argument: (SELECTION).
The arg should be the name of the selection in question, typically one of
the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
-(Those are literal upper-case symbol names, since that's what X expects.)
-For convenience, the symbol nil is the same as `PRIMARY',
-and t is the same as `SECONDARY'.")
+(Those are literal upper-case symbol names, since that's what X expects.)")
+
+(gui-method-declare gui-selection-exists-p #'ignore
+ "Whether there is an owner for the given X Selection.
+Called with one argument: (SELECTION).
+The arg should be the name of the selection in question, typically one of
+the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+(Those are literal upper-case symbol names, since that's what X expects.)")
(defun gui-set-selection (type data)
"Make an X selection of type TYPE and value DATA.
(signal 'mark-inactive nil)))
;; Behind display-selections-p.
-(declare-function x-selection-exists-p "xselect.c"
- (&optional selection terminal))
(defun deactivate-mark (&optional force)
"Deactivate the mark.
;; deactivation should not clobber it (Bug#11772).
((and (/= (region-beginning) (region-end))
(or (gui-call gui-selection-owner-p 'PRIMARY)
- (null (gui-selection-exists-p 'PRIMARY))))
+ (null (gui-call gui-selection-exists-p 'PRIMARY))))
(gui-set-selection 'PRIMARY
(funcall region-extract-function nil)))))
(when mark-active (force-mode-line-update)) ;Refresh toolbar (bug#16382).
(gui-method-define gui-own-selection ns #'ns-own-selection-internal)
(gui-method-define gui-disown-selection ns #'ns-disown-selection-internal)
(gui-method-define gui-selection-owner-p ns #'ns-selection-owner-p)
+(gui-method-define gui-selection-exists-p ns #'x-selection-exists-p)
(gui-method-define gui-get-selection ns #'x-get-selection-internal) ;FIXME:name!
(provide 'ns-win)
(w16-get-clipboard-data))))
;; gui-selection-owner-p is used in simple.el.
+(gui-method-define gui-selection-exists-p pc #'x-selection-exists-p)
(gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p)
(defun w16-selection-owner-p (_selection)
;; FIXME: Other systems don't obey gui-select-enable-clipboard here.
(lambda (selection)
(and (memq selection '(nil PRIMARY SECONDARY))
(get 'x-selections (or selection 'PRIMARY)))))
+(gui-method-define gui-selection-exists-p w32 #'x-selection-exists-p)
;; The "Windows" keys on newer keyboards bring up the Start menu
;; whether you want it or not - make Emacs ignore these keystrokes
(gui-method-define gui-own-selection x #'x-own-selection-internal)
(gui-method-define gui-disown-selection x #'x-disown-selection-internal)
(gui-method-define gui-selection-owner-p x #'x-selection-owner-p)
+(gui-method-define gui-selection-exists-p x #'x-selection-exists-p)
(gui-method-define gui-get-selection x #'x-get-selection-internal)
;; Initiate drag and drop