summaryrefslogtreecommitdiff
path: root/lisp/frame.el
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/frame.el
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/frame.el')
-rw-r--r--lisp/frame.el40
1 files changed, 13 insertions, 27 deletions
diff --git a/lisp/frame.el b/lisp/frame.el
index 0c1fb38c516..077687eeb66 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -27,35 +27,20 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
-;; Dispatch tables for GUI methods.
-
-(defun gui-method--name (base)
- (intern (format "%s-alist" base)))
-
-(defmacro gui-method (name &optional type)
- (macroexp-let2 nil type (or type `window-system)
- `(alist-get ,type ,(gui-method--name name)
- (lambda (&rest _args)
- (error "No method %S for %S frame" ',name ,type)))))
-
-(defmacro gui-method-define (name type fun)
- `(setf (gui-method ,name ',type) ,fun))
-
-(defmacro gui-method-declare (name &optional tty-fun doc)
- (declare (doc-string 3) (indent 2))
- `(defvar ,(gui-method--name name)
- ,(if tty-fun `(list (cons nil ,tty-fun))) ,doc))
-
-(defmacro gui-call (name &rest args)
- `(funcall (gui-method ,name) ,@args))
-
-(gui-method-declare frame-creation-function
- #'tty-create-frame-with-faces
+(cl-defgeneric frame-creation-function (params)
"Method for window-system dependent functions to create a new frame.
The window system startup file should add its frame creation
function to this method, which should take an alist of parameters
as its argument.")
+(cl-defmethod frame-creation-function (params
+ &context (window-system (eql nil)))
+ ;; It's tempting to get rid of tty-create-frame-with-faces and turn it into
+ ;; this method (i.e. move this method to faces.el), but faces.el is loaded
+ ;; much earlier from loadup.el (before cl-generic and even before
+ ;; cl-preloaded), so we'd first have to reorder that part.
+ (tty-create-frame-with-faces params))
+
(defvar window-system-default-frame-alist nil
"Window-system dependent default frame parameters.
The value should be an alist of elements (WINDOW-SYSTEM . ALIST),
@@ -687,7 +672,8 @@ the new frame according to its own rules."
frame)
(unless (get w 'window-system-initialized)
- (funcall (gui-method window-system-initialization w) display)
+ (let ((window-system w)) ;Hack attack!
+ (window-system-initialization display))
(setq x-display-name display)
(put w 'window-system-initialized t))
@@ -704,8 +690,8 @@ the new frame according to its own rules."
;; (setq frame-size-history '(1000))
- (setq frame
- (funcall (gui-method frame-creation-function w) params))
+ (setq frame (let ((window-system w)) ;Hack attack!
+ (frame-creation-function params)))
(normal-erase-is-backspace-setup-frame frame)
;; Inherit the original frame's parameters.
(dolist (param frame-inherited-parameters)