summaryrefslogtreecommitdiff
path: root/lisp/term
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-05-23 11:32:29 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-05-23 11:32:29 -0400
commit919281ddb2eec5b5503c246dfad902d44aa25644 (patch)
tree1204a207b7d24c596caed1beeda629c27ba2f90d /lisp/term
parentdc4484ec6de13a3d75b52c477a3cde59dc8ed46c (diff)
downloademacs-919281ddb2eec5b5503c246dfad902d44aa25644.tar.gz
Replace gui-method macros with cl-generic with &context
* lisp/frame.el (gui-method--name, gui-method, gui-method-define) (gui-method-declare, gui-call): Remove. (frame-creation-function): Use cl-defgeneric. (make-frame): Adjust callers. * lisp/menu-bar.el (menu-bar-edit-menu): Use gui-backend-selection-exists-p. * lisp/select.el (x-get-clipboard): Use gui-backend-get-selection. (gui-backend-get-selection): New cl-generic to replace gui-get-selection method. (gui-backend-set-selection): New cl-generic to replace gui-set-selection method. (gui-selection-owner-p): New cl-generic to replace gui-selection-owner-p method. (gui-backend-selection-exists-p): New cl-generic to replace gui-selection-exists-p method. Adjust all callers. * lisp/server.el (server-create-window-system-frame): Don't ignore window-system spec even when unsupported. * lisp/simple.el (deactivate-mark): Use new gui-backend-* functions. * lisp/startup.el (handle-args-function, window-system-initialization): Use cl-defgeneric. (command-line): Adjust calls accordingly. * lisp/term/ns-win.el (ns-window-system-initialization): Turn into a window-system-initialization method. (handle-args-function, frame-creation-function): Use cl-defmethod. (gui-set-selection, gui-selection-owner-p, gui-selection-exists-p) (gui-get-selection): Use cl-defmethod on the new functions instead. * lisp/term/pc-win.el (w16-get-selection-value): Turn into a gui-backend-get-selection method. (gui-selection-exists-p, gui-selection-owner-p, gui-set-selection): Use cl-defmethod on the new functions instead. (msdos-window-system-initialization): Turn into a window-system-initialization method. (frame-creation-function, handle-args-function): Use cl-defmethod. * lisp/term/w32-win.el (w32-window-system-initialization): Turn into a window-system-initialization method. (handle-args-function, frame-creation-function): Use cl-defmethod. (gui-set-selection, gui-selection-owner-p, gui-selection-exists-p) (gui-get-selection): Use cl-defmethod on the new functions instead. * lisp/term/x-win.el (x-window-system-initialization): Turn into a window-system-initialization method. (handle-args-function, frame-creation-function): Use cl-defmethod. (gui-set-selection, gui-selection-owner-p, gui-selection-exists-p) (gui-get-selection): Use cl-defmethod on the new functions instead. * lisp/term/xterm.el (xterm--set-selection): Turn into a gui-backend-set-selection method. * src/nsselect.m (Fns_selection_exists_p): Remove unused arg `terminal'. (Fns_selection_owner_p): Remove unused arg `terminal'. (Fns_get_selection): Remove unused args `time_stamp' and `terminal'.
Diffstat (limited to 'lisp/term')
-rw-r--r--lisp/term/ns-win.el35
-rw-r--r--lisp/term/pc-win.el73
-rw-r--r--lisp/term/w32-win.el52
-rw-r--r--lisp/term/x-win.el40
-rw-r--r--lisp/term/xterm.el4
5 files changed, 126 insertions, 78 deletions
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index e642ab53447..f603f3e0f6d 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -848,7 +848,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; Do the actual Nextstep Windows setup here; the above code just
;; defines functions and variables that we use now.
-(defun ns-initialize-window-system (&optional _display)
+(cl-defmethod window-system-initialization (&context (window-system (eql ns))
+ &optional _display)
"Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
(cl-assert (not ns-initialized))
@@ -921,10 +922,11 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; Any display name is OK.
(add-to-list 'display-format-alist '(".*" . ns))
-(gui-method-define handle-args-function ns #'x-handle-args)
-(gui-method-define frame-creation-function ns #'x-create-frame-with-faces)
-(gui-method-define window-system-initialization ns
- #'ns-initialize-window-system)
+(cl-defmethod handle-args-function (args &context (window-system (eql ns)))
+ (x-handle-args args))
+
+(cl-defmethod frame-creation-function (params &context (window-system (eql ns)))
+ (x-create-frame-with-faces params))
(declare-function ns-own-selection-internal "nsselect.m" (selection value))
(declare-function ns-disown-selection-internal "nsselect.m" (selection))
@@ -935,13 +937,22 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(declare-function ns-get-selection "nsselect.m"
(selection-symbol target-type &optional time-stamp terminal))
-(gui-method-define gui-set-selection ns
- (lambda (selection value)
- (if value (ns-own-selection-internal selection value)
- (ns-disown-selection-internal selection))))
-(gui-method-define gui-selection-owner-p ns #'ns-selection-owner-p)
-(gui-method-define gui-selection-exists-p ns #'ns-selection-exists-p)
-(gui-method-define gui-get-selection ns #'ns-get-selection)
+(cl-defmethod gui-backend-set-selection (selection value
+ &context (window-system (eql ns)))
+ (if value (ns-own-selection-internal selection value)
+ (ns-disown-selection-internal selection)))
+
+(cl-defmethod gui-backend-selection-owner-p (selection
+ &context (window-system (eql ns)))
+ (ns-selection-owner-p selection))
+
+(cl-defmethod gui-backend-selection-exists-p (selection
+ &context (window-system (eql ns)))
+ (ns-selection-exists-p selection))
+
+(cl-defmethod gui-backend-get-selection (selection-symbol target-type
+ &context (window-system (eql ns)))
+ (ns-get-selection selection-symbol target-type))
(provide 'ns-win)
diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el
index dd4a8ae8d13..b6c7222cdc8 100644
--- a/lisp/term/pc-win.el
+++ b/lisp/term/pc-win.el
@@ -218,8 +218,10 @@ the operating system.")
;; From lisp/term/w32-win.el
;
;;;; Selections
-;
-(defun w16-get-selection-value (_selection-symbol _target-type)
+
+;; gui-get-selection is used in select.el
+(cl-defmethod gui-backend-get-selection (_selection-symbol _target-type
+ &context (window-system (eql pc)))
"Return the value of the current selection.
Consult the selection. Treat empty strings as if they were unset."
;; Don't die if x-get-selection signals an error.
@@ -228,8 +230,13 @@ Consult the selection. Treat empty strings as if they were unset."
(declare-function w16-selection-exists-p "w16select.c")
;; gui-selection-owner-p is used in simple.el.
-(gui-method-define gui-selection-exists-p pc #'w16-selection-exists-p)
-(gui-method-define gui-selection-owner-p pc #'w16-selection-owner-p)
+(cl-defmethod gui-backend-selection-exists-p (selection
+ &context (window-system (eql pc)))
+ (w16-selection-exists-p selection))
+
+(cl-defmethod gui-backend-selection-owner-p (selection
+ &context (window-system (eql pc)))
+ (w16-selection-owner-p selection))
(defun w16-selection-owner-p (_selection)
;; FIXME: Other systems don't obey select-enable-clipboard here.
@@ -250,19 +257,16 @@ Consult the selection. Treat empty strings as if they were unset."
;; gui-set-selection is used in gui-set-selection.
(declare-function w16-set-clipboard-data "w16select.c"
(string &optional ignored))
-(gui-method-define gui-set-selection pc
- (lambda (selection value)
- (if (not value)
- (if (w16-selection-owner-p selection)
- t)
- ;; FIXME: Other systems don't obey
- ;; gui-select-enable-clipboard here.
- (with-demoted-errors "w16-set-clipboard-data: %S"
- (w16-set-clipboard-data value))
- value)))
-
-;; gui-get-selection is used in select.el
-(gui-method-define gui-get-selection pc #'w16-get-selection-value)
+(cl-defmethod gui-backend-set-selection (selection value
+ &context (window-system (eql pc)))
+ (if (not value)
+ (if (w16-selection-owner-p selection)
+ t)
+ ;; FIXME: Other systems don't obey
+ ;; gui-select-enable-clipboard here.
+ (with-demoted-errors "w16-set-clipboard-data: %S"
+ (w16-set-clipboard-data value))
+ value))
;; From src/fontset.c:
(fset 'query-fontset 'ignore)
@@ -310,15 +314,15 @@ This is used by `msdos-show-help'.")
;; Initialization.
;; ---------------------------------------------------------------------------
-;; This function is run, by faces.el:tty-create-frame-with-faces, only
-;; for the initial frame (on each terminal, but we have only one).
+;; This function is run, by the tty method of `frame-creation-function'
+;; (in faces.el), only for the initial frame (on each terminal, but we have
+;; only one).
;; This works by setting the `terminal-initted' terminal parameter to
-;; this function, the first time `tty-create-frame-with-faces' is
-;; called on that terminal. `tty-create-frame-with-faces' is called
-;; directly from startup.el and also by `make-frame' through
-;; `frame-creation-function-alist'. `make-frame' will call this
-;; function if `msdos-create-frame-with-faces' (see below) is not
-;; found in `frame-creation-function-alist', which means something is
+;; this function, the first time `frame-creation-function' is
+;; called on that terminal. `frame-creation-function' is called
+;; directly from startup.el and also by `make-frame'.
+;; `make-frame' should call our own `frame-creation-function' method instead
+;; (see below) so if terminal-init-internal is called it means something is
;; _very_ wrong, because "internal" terminal emulator should not be
;; turned on if our window-system is not `pc'. Therefore, the only
;; Right Thing for us to do here is scream bloody murder.
@@ -328,7 +332,9 @@ Errors out because it is not supposed to be called, ever."
(error "terminal-init-internal called for window-system `%s'"
(window-system)))
-(defun msdos-initialize-window-system (&optional _display)
+;; window-system-initialization is called by startup.el:command-line.
+(cl-defmethod window-system-initialization (&context (window-system (eql pc))
+ &optional _display)
"Initialization function for the `pc' \"window system\"."
(or (eq (window-system) 'pc)
(error
@@ -370,17 +376,14 @@ Errors out because it is not supposed to be called, ever."
(menu-bar-enable-clipboard)
(run-hooks 'terminal-init-msdos-hook))
-;; frame-creation-function-alist is examined by frame.el:make-frame.
-(gui-method-define frame-creation-function
- pc #'msdos-create-frame-with-faces)
-;; window-system-initialization-alist is examined by startup.el:command-line.
-(gui-method-define window-system-initialization
- pc #'msdos-initialize-window-system)
+;; frame-creation-function is called by frame.el:make-frame.
+(cl-defmethod frame-creation-function (params &context (window-system (eql pc)))
+ (msdos-create-frame-with-faces params))
+
;; We don't need anything beyond tty-handle-args for handling
;; command-line argument; see startup.el.
-(gui-method-define handle-args-function pc #'tty-handle-args)
-
-
+(cl-defmethod handle-args-function (args &context (window-system (eql pc)))
+ (tty-handle-args args))
;; ---------------------------------------------------------------------------
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index b0667e6c4f7..8bbc3ddf10d 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -290,7 +290,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(declare-function x-parse-geometry "frame.c" (string))
(defvar x-command-line-resources)
-(defun w32-initialize-window-system (&optional _display)
+(cl-defmethod window-system-initialization (&context (window-system (eql w32))
+ &optional _display)
"Initialize Emacs for W32 GUI frames."
(cl-assert (not w32-initialized))
@@ -376,11 +377,11 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(setq w32-initialized t))
(add-to-list 'display-format-alist '("\\`w32\\'" . w32))
-(gui-method-define handle-args-function w32 #'x-handle-args)
-(gui-method-define frame-creation-function w32
- #'x-create-frame-with-faces)
-(gui-method-define window-system-initialization w32
- #'w32-initialize-window-system)
+(cl-defmethod handle-args-function (args &context (window-system (eql w32)))
+ (x-handle-args args))
+
+(cl-defmethod frame-creation-function (params &context (window-system (eql w32)))
+ (x-create-frame-with-faces params))
;;;; Selections
@@ -406,18 +407,41 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(and (memq selection '(nil PRIMARY SECONDARY))
(get 'x-selections (or selection 'PRIMARY))))
-(gui-method-define gui-set-selection w32 #'w32--set-selection)
-(gui-method-define gui-get-selection w32 #'w32--get-selection)
+(cl-defmethod gui-backend-set-selection (type value
+ &context (window-system (eql w32)))
+ (w32--set-selection type value))
+
+(cl-defmethod gui-backend-get-selection (type data-type
+ &context (window-system (eql w32)))
+ (w32--get-selection type data-type))
+
+(cl-defmethod gui-backend-selection-owner-p (selection
+ &context (window-system (eql w32)))
+ (w32--selection-owner-p selection))
-(gui-method-define gui-selection-owner-p w32 #'w32--selection-owner-p)
-(gui-method-define gui-selection-exists-p w32 #'w32-selection-exists-p)
+(cl-defmethod gui-backend-selection-exists-p (selection
+ &context (window-system (eql w32)))
+ (w32-selection-exists-p selection))
(when (eq system-type 'windows-nt)
;; Make copy&pasting in w32's console interact with the system's clipboard!
- (gui-method-define gui-set-selection nil #'w32--set-selection)
- (gui-method-define gui-get-selection nil #'w32--get-selection)
- (gui-method-define gui-selection-owner-p nil #'w32--selection-owner-p)
- (gui-method-define gui-selection-exists-p nil #'w32-selection-exists-p))
+ ;; We could move those cl-defmethods outside of the `when' and use
+ ;; "&context (system-type (eql windows-nt))" instead!
+ (cl-defmethod gui-backend-set-selection (type value
+ &context (window-system (eql nil)))
+ (w32--set-selection type value))
+
+ (cl-defmethod gui-backend-get-selection (type data-type
+ &context (window-system (eql nil)))
+ (w32--get-selection type data-type))
+
+ (cl-defmethod gui-backend-selection-owner-p (selection
+ &context (window-system (eql nil)))
+ (w32--selection-owner-p selection))
+
+ (cl-defmethod gui-selection-exists-p (selection
+ &context (window-system (eql nil)))
+ (w32-selection-exists-p selection)))
;; The "Windows" keys on newer keyboards bring up the Start menu
;; whether you want it or not - make Emacs ignore these keystrokes
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index f929288d04e..39145ff81e6 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -29,8 +29,7 @@
;; Beginning in Emacs 23, the act of loading this file should not have
;; the side effect of initializing the window system or processing
;; command line arguments (this file is now loaded in loadup.el). See
-;; the variables `handle-args-function-alist' and
-;; `window-system-initialization-alist' for more details.
+;; `handle-args-function' and `window-system-initialization' for more details.
;; startup.el will then examine startup files, and eventually call the hooks
;; which create the first window(s).
@@ -1206,7 +1205,8 @@ This returns an error if any Emacs frames are X frames."
(defvar x-display-name)
(defvar x-command-line-resources)
-(defun x-initialize-window-system (&optional display)
+(cl-defmethod window-system-initialization (&context (window-system (eql x))
+ &optional display)
"Initialize Emacs for X frames and open the first connection to an X server."
(cl-assert (not x-initialized))
@@ -1335,17 +1335,29 @@ This returns an error if any Emacs frames are X frames."
(selection-symbol target-type &optional time-stamp terminal))
(add-to-list 'display-format-alist '("\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" . x))
-(gui-method-define handle-args-function x #'x-handle-args)
-(gui-method-define frame-creation-function x #'x-create-frame-with-faces)
-(gui-method-define window-system-initialization x #'x-initialize-window-system)
-
-(gui-method-define gui-set-selection x
- (lambda (selection value)
- (if value (x-own-selection-internal selection value)
- (x-disown-selection-internal selection))))
-(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)
+(cl-defmethod handle-args-function (args &context (window-system (eql x)))
+ (x-handle-args args))
+
+(cl-defmethod frame-creation-function (params &context (window-system (eql x)))
+ (x-create-frame-with-faces params))
+
+(cl-defmethod gui-backend-set-selection (selection value
+ &context (window-system (eql x)))
+ (if value (x-own-selection-internal selection value)
+ (x-disown-selection-internal selection)))
+
+(cl-defmethod gui-backend-selection-owner-p (selection
+ &context (window-system (eql x)))
+ (x-selection-owner-p selection))
+
+(cl-defmethod gui-backend-selection-exists-p (selection
+ &context (window-system (eql x)))
+ (x-selection-exists-p selection))
+
+(cl-defmethod gui-backend-get-selection (selection-symbol target-type
+ &context (window-system (eql x))
+ &optional time-stamp terminal)
+ (x-get-selection-internal selection-symbol target-type time-stamp terminal))
;; Initiate drag and drop
(add-hook 'after-make-frame-functions 'x-dnd-init-frame)
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 667e4ce63ee..4e48e80e4e9 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -787,9 +787,7 @@ We run the first FUNCTION whose STRING matches the input events."
;; FIXME: This defines the gui method for all terminals, even tho it only
;; supports a subset of them.
-(gui-method-define gui-set-selection nil #'xterm--set-selection)
-
-(defun xterm--set-selection (type data)
+(cl-defmethod gui-backend-set-selection (type data &context (window-system (eql nil)))
"Copy DATA to the X selection using the OSC 52 escape sequence.
TYPE specifies which selection to set; it must be either