2016-11-06 00:33:43 -07:00
|
|
|
;;; ns-win.el --- lisp side of interface with NeXT/Open/GNUstep/macOS window system -*- lexical-binding: t -*-
|
2008-07-16 02:29:39 +00:00
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
;; Copyright (C) 1993-1994, 2005-2020 Free Software Foundation, Inc.
|
2008-07-16 02:29:39 +00:00
|
|
|
|
2009-01-10 22:08:37 +00:00
|
|
|
;; Authors: Carl Edman
|
|
|
|
;; Christian Limpach
|
|
|
|
;; Scott Bender
|
|
|
|
;; Christophe de Dinechin
|
|
|
|
;; Adrian Robert
|
2008-07-16 02:29:39 +00:00
|
|
|
;; Keywords: terminals
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2008-07-21 16:23:55 +00:00
|
|
|
;; ns-win.el: this file is loaded from ../lisp/startup.el when it
|
|
|
|
;; recognizes that Nextstep windows are to be used. Command line
|
|
|
|
;; switches are parsed and those pertaining to Nextstep are processed
|
|
|
|
;; and removed from the command line. The Nextstep display is opened
|
|
|
|
;; and hooks are set for popping up the initial window.
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;; startup.el will then examine startup files, and eventually call the hooks
|
|
|
|
;; which create the first window (s).
|
|
|
|
|
2008-07-21 16:23:55 +00:00
|
|
|
;; A number of other Nextstep convenience functions are defined in
|
|
|
|
;; this file, which works in close coordination with src/nsfns.m.
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;;; Code:
|
2012-09-17 03:55:05 -08:00
|
|
|
(eval-when-compile (require 'cl-lib))
|
2010-10-25 19:59:05 -07:00
|
|
|
(or (featurep 'ns)
|
2016-11-06 00:33:43 -07:00
|
|
|
(error "%s: Loading ns-win.el but not compiled for GNUstep/macOS"
|
2017-12-12 00:00:33 -08:00
|
|
|
invocation-name))
|
2008-07-16 20:06:14 +00:00
|
|
|
|
2010-10-26 23:48:04 -07:00
|
|
|
;; Documentation-purposes only: actually loaded in loadup.el.
|
2008-07-15 18:15:18 +00:00
|
|
|
(require 'frame)
|
|
|
|
(require 'mouse)
|
|
|
|
(require 'faces)
|
|
|
|
(require 'menu-bar)
|
|
|
|
(require 'fontset)
|
2013-12-19 11:25:48 +01:00
|
|
|
(require 'dnd)
|
2015-12-25 10:55:38 +01:00
|
|
|
(require 'ucs-normalize)
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2009-02-04 03:38:06 +00:00
|
|
|
(defgroup ns nil
|
2016-11-06 00:33:43 -07:00
|
|
|
"GNUstep/macOS specific features."
|
2009-02-04 03:38:06 +00:00
|
|
|
:group 'environment)
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;;;; Command line argument handling.
|
|
|
|
|
2010-10-25 20:58:19 -07:00
|
|
|
(defvar x-invocation-args)
|
2014-03-15 19:12:54 +01:00
|
|
|
;; Set in term/common-win.el; currently unused by Nextstep's x-open-connection.
|
|
|
|
(defvar x-command-line-resources)
|
2008-07-17 02:36:16 +00:00
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
;; nsterm.m.
|
|
|
|
(defvar ns-input-file)
|
|
|
|
|
2012-04-26 08:43:28 -04:00
|
|
|
(defun ns-handle-nxopen (_switch &optional temp)
|
2010-10-26 23:48:04 -07:00
|
|
|
(setq unread-command-events (append unread-command-events
|
|
|
|
(if temp '(ns-open-temp-file)
|
|
|
|
'(ns-open-file)))
|
2010-10-25 20:58:19 -07:00
|
|
|
ns-input-file (append ns-input-file (list (pop x-invocation-args)))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defun ns-handle-nxopentemp (switch)
|
2010-10-26 23:48:04 -07:00
|
|
|
(ns-handle-nxopen switch t))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2012-04-26 08:43:28 -04:00
|
|
|
(defun ns-ignore-1-arg (_switch)
|
2010-10-25 20:58:19 -07:00
|
|
|
(setq x-invocation-args (cdr x-invocation-args)))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2008-08-13 23:40:02 +00:00
|
|
|
(defun ns-parse-geometry (geom)
|
2008-08-11 01:24:31 +00:00
|
|
|
"Parse a Nextstep-style geometry string GEOM.
|
2008-07-15 18:15:18 +00:00
|
|
|
Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
|
|
|
|
The properties returned may include `top', `left', `height', and `width'."
|
2008-07-21 16:23:55 +00:00
|
|
|
(when (string-match "\\([0-9]+\\)\\( \\([0-9]+\\)\\( \\([0-9]+\\)\
|
|
|
|
\\( \\([0-9]+\\) ?\\)?\\)?\\)?"
|
|
|
|
geom)
|
|
|
|
(apply
|
|
|
|
'append
|
|
|
|
(list
|
|
|
|
(list (cons 'top (string-to-number (match-string 1 geom))))
|
|
|
|
(if (match-string 3 geom)
|
|
|
|
(list (cons 'left (string-to-number (match-string 3 geom)))))
|
|
|
|
(if (match-string 5 geom)
|
|
|
|
(list (cons 'height (string-to-number (match-string 5 geom)))))
|
|
|
|
(if (match-string 7 geom)
|
|
|
|
(list (cons 'width (string-to-number (match-string 7 geom)))))))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;;;; Keyboard mapping.
|
|
|
|
|
2010-10-25 19:59:05 -07:00
|
|
|
(define-obsolete-variable-alias 'ns-alternatives-map 'x-alternatives-map "24.1")
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2008-07-21 16:23:55 +00:00
|
|
|
;; Here are some Nextstep-like bindings for command key sequences.
|
2009-03-29 00:00:30 +00:00
|
|
|
(define-key global-map [?\s-,] 'customize)
|
2019-11-06 00:49:02 +01:00
|
|
|
(define-key global-map [?\s-'] 'next-window-any-frame)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [?\s-`] 'other-frame)
|
2010-07-13 13:41:49 +03:00
|
|
|
(define-key global-map [?\s-~] 'ns-prev-frame)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [?\s--] 'center-line)
|
|
|
|
(define-key global-map [?\s-:] 'ispell)
|
|
|
|
(define-key global-map [?\s-?] 'info)
|
|
|
|
(define-key global-map [?\s-^] 'kill-some-buffers)
|
2017-04-12 23:14:20 +03:00
|
|
|
(define-key global-map [?\s-&] 'kill-current-buffer)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [?\s-C] 'ns-popup-color-panel)
|
|
|
|
(define-key global-map [?\s-D] 'dired)
|
|
|
|
(define-key global-map [?\s-E] 'edit-abbrevs)
|
|
|
|
(define-key global-map [?\s-L] 'shell-command)
|
|
|
|
(define-key global-map [?\s-M] 'manual-entry)
|
|
|
|
(define-key global-map [?\s-S] 'ns-write-file-using-panel)
|
|
|
|
(define-key global-map [?\s-a] 'mark-whole-buffer)
|
|
|
|
(define-key global-map [?\s-c] 'ns-copy-including-secondary)
|
|
|
|
(define-key global-map [?\s-d] 'isearch-repeat-backward)
|
|
|
|
(define-key global-map [?\s-e] 'isearch-yank-kill)
|
|
|
|
(define-key global-map [?\s-f] 'isearch-forward)
|
|
|
|
(define-key global-map [?\s-g] 'isearch-repeat-forward)
|
|
|
|
(define-key global-map [?\s-h] 'ns-do-hide-emacs)
|
|
|
|
(define-key global-map [?\s-H] 'ns-do-hide-others)
|
2017-08-24 21:08:16 +01:00
|
|
|
(define-key global-map [?\M-\s-h] 'ns-do-hide-others)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [?\s-j] 'exchange-point-and-mark)
|
2017-04-12 23:14:20 +03:00
|
|
|
(define-key global-map [?\s-k] 'kill-current-buffer)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [?\s-l] 'goto-line)
|
|
|
|
(define-key global-map [?\s-m] 'iconify-frame)
|
|
|
|
(define-key global-map [?\s-n] 'make-frame)
|
|
|
|
(define-key global-map [?\s-o] 'ns-open-file-using-panel)
|
|
|
|
(define-key global-map [?\s-p] 'ns-print-buffer)
|
|
|
|
(define-key global-map [?\s-q] 'save-buffers-kill-emacs)
|
|
|
|
(define-key global-map [?\s-s] 'save-buffer)
|
|
|
|
(define-key global-map [?\s-t] 'ns-popup-font-panel)
|
|
|
|
(define-key global-map [?\s-u] 'revert-buffer)
|
|
|
|
(define-key global-map [?\s-v] 'yank)
|
|
|
|
(define-key global-map [?\s-w] 'delete-frame)
|
|
|
|
(define-key global-map [?\s-x] 'kill-region)
|
|
|
|
(define-key global-map [?\s-y] 'ns-paste-secondary)
|
|
|
|
(define-key global-map [?\s-z] 'undo)
|
2018-05-31 21:28:09 +01:00
|
|
|
(define-key global-map [?\s-+] 'text-scale-adjust)
|
|
|
|
(define-key global-map [?\s-=] 'text-scale-adjust)
|
|
|
|
(define-key global-map [?\s--] 'text-scale-adjust)
|
|
|
|
(define-key global-map [?\s-0] 'text-scale-adjust)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [?\s-|] 'shell-command-on-region)
|
|
|
|
(define-key global-map [s-kp-bar] 'shell-command-on-region)
|
2018-02-05 19:46:48 +00:00
|
|
|
(define-key global-map [?\C-\s- ] 'ns-do-show-character-palette)
|
2008-07-16 20:06:14 +00:00
|
|
|
;; (as in Terminal.app)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [s-right] 'ns-next-frame)
|
|
|
|
(define-key global-map [s-left] 'ns-prev-frame)
|
|
|
|
|
|
|
|
(define-key global-map [home] 'beginning-of-buffer)
|
|
|
|
(define-key global-map [end] 'end-of-buffer)
|
|
|
|
(define-key global-map [kp-home] 'beginning-of-buffer)
|
|
|
|
(define-key global-map [kp-end] 'end-of-buffer)
|
2011-10-01 16:32:01 -04:00
|
|
|
(define-key global-map [kp-prior] 'scroll-down-command)
|
|
|
|
(define-key global-map [kp-next] 'scroll-up-command)
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2010-10-26 23:48:04 -07:00
|
|
|
;; Allow shift-clicks to work similarly to under Nextstep.
|
2008-08-07 03:10:08 +00:00
|
|
|
(define-key global-map [S-mouse-1] 'mouse-save-then-kill)
|
|
|
|
(global-unset-key [S-down-mouse-1])
|
|
|
|
|
2008-07-21 16:23:55 +00:00
|
|
|
;; Special Nextstep-generated events are converted to function keys. Here
|
2010-10-26 16:20:00 +03:00
|
|
|
;; are the bindings for them. Note, these keys are actually declared in
|
|
|
|
;; x-setup-function-keys in common-win.
|
Unify shutdown handling under NS, via ns-power-off key event (where appropriate) and save-buffers-kill-emacs.
remove NS-specific preferences window that used to show NS-specific preferences.
Integrate preferences in Lisp accessible customization system where possible.
Remove ns-expand-space, because it can be set only during fontloading (i.e. not at runtime),
and because of redundancy with line-spacing frame parameter.
Remove loading of most and saving of all NS resources (from org.gnu.Emacs.plist).
nsterm.m (ns_shutdown_properly, -terminate): remove global state variable as it was never reset
(ns_term_init): remove initialization of Lisp-settable defaults and ns_expand_space
(-setPanelFromDefaultValues): remove ns_expand_space.
(-showPreferencesWindow): send new KEY_NS_SHOW_PREFS key.
nsfont.m (nsfont_open): remove ns_expand_space, assume -0.5 i.e. no additional spacing, similar to Carbon port.
nsterm.h: define KEY_NS_SHOW_PREFS key.
nsfns.m (ns-popup-prefs-panel): remove.
term/ns-win.el (ns-expand-space): remove.
(ns-show-prefs event): run `customize'.
(ns-power-off): run `save-buffers-kill-emacs', but ask user whether to save files (as is standard)
(clipboard-yank, clipboard-kill-ring-save, clipboard-kill-region)
(menu-bar-enable-clipboard): do not undefine these.
(ns-save-preferences,ns-save-options,ns-show-preferences-help): remove.
2009-03-14 21:19:56 +00:00
|
|
|
(define-key global-map [ns-power-off] 'save-buffers-kill-emacs)
|
2008-07-15 18:15:18 +00:00
|
|
|
(define-key global-map [ns-open-file] 'ns-find-file)
|
|
|
|
(define-key global-map [ns-open-temp-file] [ns-open-file])
|
|
|
|
(define-key global-map [ns-change-font] 'ns-respond-to-change-font)
|
|
|
|
(define-key global-map [ns-open-file-line] 'ns-open-file-select-line)
|
|
|
|
(define-key global-map [ns-spi-service-call] 'ns-spi-service-call)
|
2010-12-03 12:48:24 +01:00
|
|
|
(define-key global-map [ns-new-frame] 'make-frame)
|
2009-01-25 19:50:16 +00:00
|
|
|
(define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
|
2010-12-03 12:48:24 +01:00
|
|
|
(define-key global-map [ns-show-prefs] 'customize)
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
|
2008-07-18 16:54:12 +00:00
|
|
|
;; Set up a number of aliases and other layers to pretend we're using
|
|
|
|
;; the Choi/Mitsuharu Carbon port.
|
|
|
|
|
|
|
|
(defvaralias 'mac-allow-anti-aliasing 'ns-antialias-text)
|
|
|
|
(defvaralias 'mac-command-modifier 'ns-command-modifier)
|
2010-11-21 14:09:34 +01:00
|
|
|
(defvaralias 'mac-right-command-modifier 'ns-right-command-modifier)
|
2008-07-18 16:54:12 +00:00
|
|
|
(defvaralias 'mac-control-modifier 'ns-control-modifier)
|
2010-11-21 14:09:34 +01:00
|
|
|
(defvaralias 'mac-right-control-modifier 'ns-right-control-modifier)
|
2008-07-18 16:54:12 +00:00
|
|
|
(defvaralias 'mac-option-modifier 'ns-option-modifier)
|
2010-10-11 21:18:08 +02:00
|
|
|
(defvaralias 'mac-right-option-modifier 'ns-right-option-modifier)
|
2008-07-18 16:54:12 +00:00
|
|
|
(defvaralias 'mac-function-modifier 'ns-function-modifier)
|
2008-11-15 22:29:59 +00:00
|
|
|
(declare-function ns-do-applescript "nsfns.m" (script))
|
2008-07-27 19:20:38 +00:00
|
|
|
(defalias 'do-applescript 'ns-do-applescript)
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;;;; Services
|
2008-07-17 02:36:16 +00:00
|
|
|
(declare-function ns-perform-service "nsfns.m" (service send))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-define-service (path)
|
|
|
|
(let ((mapping [menu-bar services])
|
|
|
|
(service (mapconcat 'identity path "/"))
|
|
|
|
(name (intern
|
2008-07-16 20:06:14 +00:00
|
|
|
(subst-char-in-string
|
|
|
|
?\s ?-
|
|
|
|
(mapconcat 'identity (cons "ns-service" path) "-")))))
|
|
|
|
;; This defines the function.
|
|
|
|
(defalias name
|
2012-04-26 08:43:28 -04:00
|
|
|
(lambda (arg)
|
|
|
|
(interactive "p")
|
|
|
|
(let* ((in-string
|
|
|
|
(cond ((stringp arg) arg)
|
|
|
|
(mark-active
|
|
|
|
(buffer-substring (region-beginning) (region-end)))))
|
|
|
|
(out-string (ns-perform-service service in-string)))
|
|
|
|
(cond
|
|
|
|
((stringp arg) out-string)
|
|
|
|
((and out-string (or (not in-string)
|
|
|
|
(not (string= in-string out-string))))
|
|
|
|
(if mark-active (delete-region (region-beginning) (region-end)))
|
|
|
|
(insert out-string)
|
|
|
|
(setq deactivate-mark nil))))))
|
2008-07-15 18:15:18 +00:00
|
|
|
(cond
|
|
|
|
((lookup-key global-map mapping)
|
|
|
|
(while (cdr path)
|
|
|
|
(setq mapping (vconcat mapping (list (intern (car path)))))
|
|
|
|
(if (not (keymapp (lookup-key global-map mapping)))
|
|
|
|
(define-key global-map mapping
|
|
|
|
(cons (car path) (make-sparse-keymap (car path)))))
|
|
|
|
(setq path (cdr path)))
|
|
|
|
(setq mapping (vconcat mapping (list (intern (car path)))))
|
|
|
|
(define-key global-map mapping (cons (car path) name))))
|
|
|
|
name))
|
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
;; nsterm.m
|
|
|
|
(defvar ns-input-spi-name)
|
|
|
|
(defvar ns-input-spi-arg)
|
|
|
|
|
2008-08-11 01:23:07 +00:00
|
|
|
(declare-function dnd-open-file "dnd" (uri action))
|
|
|
|
|
2017-05-04 20:32:40 +02:00
|
|
|
;; Handles multiline strings that are passed to the "open-file" service.
|
|
|
|
(defun ns-open-file-service (filenames)
|
|
|
|
"Open multiple files when selecting a multiline string FILENAMES."
|
|
|
|
(let ((filelist (split-string filenames "[\n\r]+" t "[ \u00A0\t]+")))
|
|
|
|
;; The path strings are trimmed for spaces, nbsp and tabs.
|
|
|
|
(dolist (filestring filelist)
|
|
|
|
(dnd-open-file filestring nil))))
|
|
|
|
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-spi-service-call ()
|
2008-07-18 17:45:01 +00:00
|
|
|
"Respond to a service request."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
|
|
|
(cond ((string-equal ns-input-spi-name "open-selection")
|
|
|
|
(switch-to-buffer (generate-new-buffer "*untitled*"))
|
|
|
|
(insert ns-input-spi-arg))
|
|
|
|
((string-equal ns-input-spi-name "open-file")
|
2017-05-04 20:32:40 +02:00
|
|
|
(ns-open-file-service ns-input-spi-arg))
|
2008-07-15 18:15:18 +00:00
|
|
|
((string-equal ns-input-spi-name "mail-selection")
|
|
|
|
(compose-mail)
|
|
|
|
(rfc822-goto-eoh)
|
|
|
|
(forward-line 1)
|
|
|
|
(insert ns-input-spi-arg))
|
|
|
|
((string-equal ns-input-spi-name "mail-to")
|
|
|
|
(compose-mail ns-input-spi-arg))
|
2015-09-20 09:40:35 -07:00
|
|
|
(t (error "Service %s not recognized" ns-input-spi-name))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
|
2009-02-24 21:11:53 +00:00
|
|
|
;; Composed key sequence handling for Nextstep system input methods.
|
|
|
|
;; (On Nextstep systems, input methods are provided for CJK
|
|
|
|
;; characters, etc. which require multiple keystrokes, and during
|
|
|
|
;; entry a partial ("working") result is typically shown in the
|
|
|
|
;; editing window.)
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defface ns-working-text-face
|
|
|
|
'((t :underline t))
|
|
|
|
"Face used to highlight working text during compose sequence insert."
|
|
|
|
:group 'ns)
|
|
|
|
|
|
|
|
(defvar ns-working-overlay nil
|
2009-02-24 21:11:53 +00:00
|
|
|
"Overlay used to highlight working text during compose sequence insert.
|
|
|
|
When text is in th echo area, this just stores the length of the working text.")
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2009-01-25 19:50:16 +00:00
|
|
|
(defvar ns-working-text) ; nsterm.m
|
|
|
|
|
|
|
|
;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
|
|
|
|
;; This will fail if called from a NONASCII_KEYSTROKE event on the global map.
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-in-echo-area ()
|
|
|
|
"Whether, for purposes of inserting working composition text, the minibuffer
|
|
|
|
is currently being used."
|
|
|
|
(or isearch-mode
|
|
|
|
(and cursor-in-echo-area (current-message))
|
|
|
|
;; Overlay strings are not shown in some cases.
|
|
|
|
(get-char-property (point) 'invisible)
|
|
|
|
(and (not (bobp))
|
|
|
|
(or (and (get-char-property (point) 'display)
|
|
|
|
(eq (get-char-property (1- (point)) 'display)
|
|
|
|
(get-char-property (point) 'display)))
|
|
|
|
(and (get-char-property (point) 'composition)
|
|
|
|
(eq (get-char-property (1- (point)) 'composition)
|
|
|
|
(get-char-property (point) 'composition)))))))
|
|
|
|
|
2009-01-23 13:00:21 +00:00
|
|
|
;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
|
|
|
|
;; always returns nil for some reason. If this WASN'T the case, we could
|
|
|
|
;; map this to [ns-insert-working-text] and eliminate Fevals in nsterm.m.
|
2009-01-25 19:50:16 +00:00
|
|
|
;; These functions test whether in echo area and delegate accordingly.
|
2009-01-23 13:00:21 +00:00
|
|
|
(defun ns-put-working-text ()
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
2009-01-23 13:00:21 +00:00
|
|
|
(if (ns-in-echo-area) (ns-echo-working-text) (ns-insert-working-text)))
|
2009-01-25 19:50:16 +00:00
|
|
|
(defun ns-unput-working-text ()
|
|
|
|
(interactive)
|
2009-02-24 21:11:53 +00:00
|
|
|
(ns-delete-working-text))
|
2008-07-16 02:29:39 +00:00
|
|
|
|
2009-01-23 13:00:21 +00:00
|
|
|
(defun ns-insert-working-text ()
|
2009-05-03 23:19:35 +00:00
|
|
|
"Insert contents of `ns-working-text' as UTF-8 string and mark with
|
2009-02-24 21:11:53 +00:00
|
|
|
`ns-working-overlay'. Any previously existing working text is cleared first.
|
|
|
|
The overlay is assigned the face `ns-working-text-face'."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
2009-02-24 21:11:53 +00:00
|
|
|
(ns-delete-working-text)
|
2008-07-15 18:15:18 +00:00
|
|
|
(let ((start (point)))
|
2019-12-19 00:32:54 +09:00
|
|
|
(overlay-put (setq ns-working-overlay (make-overlay start (point)))
|
|
|
|
'after-string
|
|
|
|
(propertize ns-working-text 'face 'ns-working-text-face))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defun ns-echo-working-text ()
|
2009-05-03 23:19:35 +00:00
|
|
|
"Echo contents of `ns-working-text' in message display area.
|
2009-02-24 21:11:53 +00:00
|
|
|
See `ns-insert-working-text'."
|
|
|
|
(ns-delete-working-text)
|
2008-07-15 18:15:18 +00:00
|
|
|
(let* ((msg (current-message))
|
|
|
|
(msglen (length msg))
|
|
|
|
message-log-max)
|
2009-02-24 21:11:53 +00:00
|
|
|
(setq ns-working-overlay (length ns-working-text))
|
2008-07-15 18:15:18 +00:00
|
|
|
(setq msg (concat msg ns-working-text))
|
2009-02-24 21:11:53 +00:00
|
|
|
(put-text-property msglen (+ msglen ns-working-overlay)
|
2009-01-24 10:27:03 +00:00
|
|
|
'face 'ns-working-text-face msg)
|
2009-02-24 21:11:53 +00:00
|
|
|
(message "%s" msg)))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defun ns-delete-working-text()
|
2009-02-24 21:11:53 +00:00
|
|
|
"Delete working text and clear `ns-working-overlay'."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
2009-02-24 21:11:53 +00:00
|
|
|
(cond
|
|
|
|
((and (overlayp ns-working-overlay)
|
|
|
|
;; Still alive?
|
|
|
|
(overlay-buffer ns-working-overlay))
|
|
|
|
(with-current-buffer (overlay-buffer ns-working-overlay)
|
2019-12-19 00:32:54 +09:00
|
|
|
(overlay-put ns-working-overlay 'after-string nil)
|
2009-02-24 21:11:53 +00:00
|
|
|
(delete-overlay ns-working-overlay)))
|
|
|
|
((integerp ns-working-overlay)
|
|
|
|
(let ((msg (current-message))
|
|
|
|
message-log-max)
|
|
|
|
(setq msg (substring msg 0 (- (length msg) ns-working-overlay)))
|
|
|
|
(message "%s" msg))))
|
|
|
|
(setq ns-working-overlay nil))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
|
2016-11-06 00:33:43 -07:00
|
|
|
;; macOS file system Unicode UTF-8 NFD (decomposed form) support.
|
2015-12-24 09:50:26 +01:00
|
|
|
(when (eq system-type 'darwin)
|
2015-12-25 10:55:38 +01:00
|
|
|
;; Used prior to Emacs 25.
|
|
|
|
(define-coding-system-alias 'utf-8-nfd 'utf-8-hfs)
|
|
|
|
|
2017-12-16 17:02:15 +00:00
|
|
|
(set-file-name-coding-system 'utf-8-hfs-unix))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;;;; Inter-app communications support.
|
|
|
|
|
|
|
|
(defun ns-insert-file ()
|
2009-05-03 23:19:35 +00:00
|
|
|
"Insert contents of file `ns-input-file' like insert-file but with less
|
|
|
|
prompting. If file is a directory perform a `find-file' on it."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
2010-10-27 00:39:34 -07:00
|
|
|
(let ((f (pop ns-input-file)))
|
2008-07-15 18:15:18 +00:00
|
|
|
(if (file-directory-p f)
|
|
|
|
(find-file f)
|
2010-10-26 23:48:04 -07:00
|
|
|
(push-mark (+ (point) (cadr (insert-file-contents f)))))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defvar ns-select-overlay nil
|
2008-07-21 16:23:55 +00:00
|
|
|
"Overlay used to highlight areas in files requested by Nextstep apps.")
|
2008-07-15 18:15:18 +00:00
|
|
|
(make-variable-buffer-local 'ns-select-overlay)
|
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
(defvar ns-input-line) ; nsterm.m
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-open-file-select-line ()
|
2008-07-18 17:09:23 +00:00
|
|
|
"Open a buffer containing the file `ns-input-file'.
|
|
|
|
Lines are highlighted according to `ns-input-line'."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
|
|
|
(ns-find-file)
|
|
|
|
(cond
|
|
|
|
((and ns-input-line (buffer-modified-p))
|
|
|
|
(if ns-select-overlay
|
|
|
|
(setq ns-select-overlay (delete-overlay ns-select-overlay)))
|
|
|
|
(deactivate-mark)
|
2009-09-01 03:18:44 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (1- (if (consp ns-input-line)
|
|
|
|
(min (car ns-input-line) (cdr ns-input-line))
|
|
|
|
ns-input-line))))
|
2008-07-15 18:15:18 +00:00
|
|
|
(ns-input-line
|
|
|
|
(if (not ns-select-overlay)
|
2009-08-21 07:31:10 +00:00
|
|
|
(overlay-put (setq ns-select-overlay (make-overlay (point-min)
|
|
|
|
(point-min)))
|
2008-07-15 18:15:18 +00:00
|
|
|
'face 'highlight))
|
|
|
|
(let ((beg (save-excursion
|
2009-08-21 07:31:10 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(line-beginning-position
|
|
|
|
(if (consp ns-input-line)
|
|
|
|
(min (car ns-input-line) (cdr ns-input-line))
|
|
|
|
ns-input-line))))
|
2008-07-15 18:15:18 +00:00
|
|
|
(end (save-excursion
|
2009-08-21 07:31:10 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(line-beginning-position
|
|
|
|
(1+ (if (consp ns-input-line)
|
|
|
|
(max (car ns-input-line) (cdr ns-input-line))
|
|
|
|
ns-input-line))))))
|
2008-07-15 18:15:18 +00:00
|
|
|
(move-overlay ns-select-overlay beg end)
|
|
|
|
(deactivate-mark)
|
|
|
|
(goto-char beg)))
|
|
|
|
(t
|
|
|
|
(if ns-select-overlay
|
|
|
|
(setq ns-select-overlay (delete-overlay ns-select-overlay))))))
|
|
|
|
|
|
|
|
(defun ns-unselect-line ()
|
2008-07-21 16:23:55 +00:00
|
|
|
"Removes any Nextstep highlight a buffer may contain."
|
2008-07-15 18:15:18 +00:00
|
|
|
(if ns-select-overlay
|
|
|
|
(setq ns-select-overlay (delete-overlay ns-select-overlay))))
|
|
|
|
|
|
|
|
(add-hook 'first-change-hook 'ns-unselect-line)
|
|
|
|
|
|
|
|
;;;; Preferences handling.
|
2008-07-16 02:29:39 +00:00
|
|
|
(declare-function ns-get-resource "nsfns.m" (owner name))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defun get-lisp-resource (arg1 arg2)
|
|
|
|
(let ((res (ns-get-resource arg1 arg2)))
|
|
|
|
(cond
|
|
|
|
((not res) 'unbound)
|
|
|
|
((string-equal (upcase res) "YES") t)
|
|
|
|
((string-equal (upcase res) "NO") nil)
|
|
|
|
(t (read res)))))
|
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
;; nsterm.m
|
Unify shutdown handling under NS, via ns-power-off key event (where appropriate) and save-buffers-kill-emacs.
remove NS-specific preferences window that used to show NS-specific preferences.
Integrate preferences in Lisp accessible customization system where possible.
Remove ns-expand-space, because it can be set only during fontloading (i.e. not at runtime),
and because of redundancy with line-spacing frame parameter.
Remove loading of most and saving of all NS resources (from org.gnu.Emacs.plist).
nsterm.m (ns_shutdown_properly, -terminate): remove global state variable as it was never reset
(ns_term_init): remove initialization of Lisp-settable defaults and ns_expand_space
(-setPanelFromDefaultValues): remove ns_expand_space.
(-showPreferencesWindow): send new KEY_NS_SHOW_PREFS key.
nsfont.m (nsfont_open): remove ns_expand_space, assume -0.5 i.e. no additional spacing, similar to Carbon port.
nsterm.h: define KEY_NS_SHOW_PREFS key.
nsfns.m (ns-popup-prefs-panel): remove.
term/ns-win.el (ns-expand-space): remove.
(ns-show-prefs event): run `customize'.
(ns-power-off): run `save-buffers-kill-emacs', but ask user whether to save files (as is standard)
(clipboard-yank, clipboard-kill-ring-save, clipboard-kill-region)
(menu-bar-enable-clipboard): do not undefine these.
(ns-save-preferences,ns-save-options,ns-show-preferences-help): remove.
2009-03-14 21:19:56 +00:00
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
(declare-function ns-read-file-name "nsfns.m"
|
2012-10-07 19:47:41 +02:00
|
|
|
(prompt &optional dir mustmatch init dir_only_p))
|
2008-07-16 02:29:39 +00:00
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;;;; File handling.
|
|
|
|
|
2012-09-30 15:43:47 +02:00
|
|
|
(defun x-file-dialog (prompt dir default_filename mustmatch only_dir_p)
|
Normalize and fix some mistakes in NS-related commentary
* lisp/term/ns-win.el (ns-insert-working-text): Normalize
commentary.
(x-file-dialog): Fix indentation.
* src/nsfns.m (ns_get_window, interpret_services_menu)
(x_set_background_color, x_set_icon_name, x_set_tool_bar_lines)
(x_set_icon_type, x_set_mouse_color, Fx_create_frame)
(ns_window_is_ancestor, Fns_popup_font_panel)
(Fx_display_visual_class, Fns_font_name, Fns_do_applescript)
(ns_screen_name, compute_tip_xy, Fns_mouse_absolute_pixel_position)
(handlePanelKeys): Normalize commentary (also in top-level
declarations) and remove two outdated comments (one in
Fx_create_frame, the other in compute_tip_xy).
* src/nsterm.h (NSApplication, NSWindow, ns_bitmap_record):
* src/nsselect.m:
* src/nsmenu.m (ns_update_menubar, addItemWithWidgetValue:)
(runMenuAt:forFrame:keymaps:, ns_menu_show, free_frame_tool_bar)
(update_frame_tool_bar, init)
(initWithContentRect:styleMask:backing:defer:)
(initFromContents:isQuestion:, timeout_handler:)
(Fmenu_or_popup_active_p):
* src/nsimage.m (initFromXBM, initFromXBMWithDepth):
* src/nsgui.h:
* src/nsfont.m (ns_spec_to_descriptor, ns_descriptor_to_entity)
(ns_charset_covers, ns_get_req_script, ns_findfonts)
(nsfont_list_family, nsfont_open, nsfont_encode_char)
(nsfont_draw, ns_uni_to_glyphs, ns_glyph_metrics)
(syms_of_nsfont): Normalize commentary (also in top-level
declarations).
* src/nsterm.m (ns_init_locale, ns_retain_object)
(ns_screen_margins_ignoring_hidden_dock, ns_unfocus, NSImageView)
(x_make_frame_visible, x_iconify_frame, x_destroy_window)
(x_set_undecorated, x_set_no_focus_on_map, x_set_z_group)
(ns_index_color, ns_get_color, ns_lisp_to_color)
(note_mouse_movement, scrollbar, ns_scroll_run)
(ns_draw_fringe_bitmap, ns_draw_window_cursor)
(ns_draw_text_decoration, ns_draw_relief)
(ns_dumpglyphs_box_or_relief, ns_dumpglyphs_image)
(ns_dumpglyphs_stretch, ns_draw_glyph_string, ns_send_appdefined)
(ns_check_menu_open, ns_read_socket, ns_select, ns_run_loop_break)
(ns_set_vertical_scroll_bar, ns_set_horizontal_scroll_bar)
(ns_string_to_lispmod, ns_default, ns_initialize_display_info)
(ns_delete_display, ns_term_init, sendEvent:)
(applicationDidFinishLaunching:, applicationDidBecomeActive:)
(fd_handler:, setWindowClosing:, keyDown:, insertText:)
(mouseDown:, mouseMoved:, updateFrameSize:)
(windowWillResize:toSize:, windowDidResize:, windowDidResignKey:)
(initFrameFromEmacs:, toggleFullScreen:, toolbarClicked:)
(writeSelectionToPasteboard:types:, setMiniwindowImage:)
(scrollerWidth, initFrame:window:, setFrame:, repeatScroll:)
(ns_xlfd_to_fontname, syms_of_nsterm): Normalize commentary (also in
top-level declarations), and in ns_get_color, replace a Gmane link
with one from lists.gnu.org, which does not require JS to view the
message.
2018-03-19 20:16:19 +01:00
|
|
|
"SKIP: real doc in xfns.c."
|
2012-09-30 15:43:47 +02:00
|
|
|
(ns-read-file-name prompt dir mustmatch default_filename only_dir_p))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-open-file-using-panel ()
|
|
|
|
"Pop up open-file panel, and load the result in a buffer."
|
|
|
|
(interactive)
|
2008-07-16 20:06:14 +00:00
|
|
|
;; Prompt dir defaultName isLoad initial.
|
2008-07-15 18:15:18 +00:00
|
|
|
(setq ns-input-file (ns-read-file-name "Select File to Load" nil t nil))
|
|
|
|
(if ns-input-file
|
|
|
|
(and (setq ns-input-file (list ns-input-file)) (ns-find-file))))
|
|
|
|
|
|
|
|
(defun ns-write-file-using-panel ()
|
|
|
|
"Pop up save-file panel, and save buffer in resulting name."
|
|
|
|
(interactive)
|
|
|
|
(let (ns-output-file)
|
2008-07-16 20:06:14 +00:00
|
|
|
;; Prompt dir defaultName isLoad initial.
|
2008-07-15 18:15:18 +00:00
|
|
|
(setq ns-output-file (ns-read-file-name "Save As" nil nil nil))
|
|
|
|
(message ns-output-file)
|
|
|
|
(if ns-output-file (write-file ns-output-file))))
|
|
|
|
|
2009-04-07 03:19:44 +00:00
|
|
|
(defcustom ns-pop-up-frames 'fresh
|
|
|
|
"Non-nil means open files upon request from the Workspace in a new frame.
|
2008-07-16 02:29:39 +00:00
|
|
|
If t, always do so. Any other non-nil value means open a new frame
|
2009-04-07 03:19:44 +00:00
|
|
|
unless the current buffer is a scratch buffer."
|
|
|
|
:type '(choice (const :tag "Never" nil)
|
|
|
|
(const :tag "Always" t)
|
|
|
|
(other :tag "Except for scratch buffer" fresh))
|
|
|
|
:version "23.1"
|
|
|
|
:group 'ns)
|
2008-07-16 02:29:39 +00:00
|
|
|
|
|
|
|
(declare-function ns-hide-emacs "nsfns.m" (on))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-find-file ()
|
2009-05-03 23:19:35 +00:00
|
|
|
"Do a `find-file' with the `ns-input-file' as argument."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
2011-01-31 18:54:50 -05:00
|
|
|
(let* ((f (file-truename
|
|
|
|
(expand-file-name (pop ns-input-file)
|
|
|
|
command-line-default-directory)))
|
2010-10-27 00:39:34 -07:00
|
|
|
(file (find-file-noselect f))
|
|
|
|
(bufwin1 (get-buffer-window file 'visible))
|
2011-11-22 23:03:56 -08:00
|
|
|
(bufwin2 (get-buffer-window "*scratch*" 'visible)))
|
2008-07-15 18:15:18 +00:00
|
|
|
(cond
|
|
|
|
(bufwin1
|
|
|
|
(select-frame (window-frame bufwin1))
|
|
|
|
(raise-frame (window-frame bufwin1))
|
|
|
|
(select-window bufwin1))
|
|
|
|
((and (eq ns-pop-up-frames 'fresh) bufwin2)
|
|
|
|
(ns-hide-emacs 'activate)
|
|
|
|
(select-frame (window-frame bufwin2))
|
|
|
|
(raise-frame (window-frame bufwin2))
|
|
|
|
(select-window bufwin2)
|
|
|
|
(find-file f))
|
|
|
|
(ns-pop-up-frames
|
|
|
|
(ns-hide-emacs 'activate)
|
|
|
|
(let ((pop-up-frames t)) (pop-to-buffer file nil)))
|
|
|
|
(t
|
|
|
|
(ns-hide-emacs 'activate)
|
|
|
|
(find-file f)))))
|
|
|
|
|
2013-12-19 11:25:48 +01:00
|
|
|
|
2019-01-05 16:11:37 +00:00
|
|
|
(defun ns-drag-n-drop (event)
|
2013-12-19 11:25:48 +01:00
|
|
|
"Edit the files listed in the drag-n-drop EVENT.
|
2019-01-05 16:11:37 +00:00
|
|
|
Switch to a buffer editing the last file dropped, or insert the
|
|
|
|
string dropped into the current buffer."
|
2013-12-19 11:25:48 +01:00
|
|
|
(interactive "e")
|
|
|
|
(let* ((window (posn-window (event-start event)))
|
|
|
|
(arg (car (cdr (cdr event))))
|
|
|
|
(type (car arg))
|
2019-01-05 16:11:37 +00:00
|
|
|
(operations (car (cdr arg)))
|
|
|
|
(objects (cdr (cdr arg)))
|
|
|
|
(string (mapconcat 'identity objects "\n")))
|
2013-12-19 11:25:48 +01:00
|
|
|
(set-frame-selected-window nil window)
|
|
|
|
(raise-frame)
|
|
|
|
(setq window (selected-window))
|
2020-09-27 10:55:32 +01:00
|
|
|
(cond ((or (memq 'ns-drag-operation-generic operations)
|
|
|
|
(memq 'ns-drag-operation-copy operations))
|
|
|
|
;; Perform the default/copy action.
|
2019-01-05 16:11:37 +00:00
|
|
|
(dolist (data objects)
|
|
|
|
(dnd-handle-one-url window 'private (if (eq type 'file)
|
|
|
|
(concat "file:" data)
|
|
|
|
data))))
|
|
|
|
(t
|
|
|
|
;; Insert the text as is.
|
|
|
|
(dnd-insert-text window 'private string)))))
|
2013-12-19 11:25:48 +01:00
|
|
|
|
|
|
|
(global-set-key [drag-n-drop] 'ns-drag-n-drop)
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;;;; Frame-related functions.
|
|
|
|
|
2010-10-26 20:48:28 -07:00
|
|
|
;; nsterm.m
|
|
|
|
(defvar ns-alternate-modifier)
|
|
|
|
(defvar ns-right-alternate-modifier)
|
2010-11-21 14:09:34 +01:00
|
|
|
(defvar ns-right-command-modifier)
|
|
|
|
(defvar ns-right-control-modifier)
|
2010-10-26 20:48:28 -07:00
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;; You say tomAYto, I say tomAHto..
|
2018-04-20 18:34:39 -04:00
|
|
|
(with-no-warnings
|
|
|
|
(defvaralias 'ns-option-modifier 'ns-alternate-modifier)
|
|
|
|
(defvaralias 'ns-right-option-modifier 'ns-right-alternate-modifier))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(defun ns-do-hide-emacs ()
|
|
|
|
(interactive)
|
|
|
|
(ns-hide-emacs t))
|
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
(declare-function ns-hide-others "nsfns.m" ())
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-do-hide-others ()
|
|
|
|
(interactive)
|
|
|
|
(ns-hide-others))
|
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
(declare-function ns-emacs-info-panel "nsfns.m" ())
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-do-emacs-info-panel ()
|
|
|
|
(interactive)
|
|
|
|
(ns-emacs-info-panel))
|
|
|
|
|
2017-12-24 15:40:03 +00:00
|
|
|
(declare-function ns-show-character-palette "nsfns.m" ())
|
|
|
|
|
|
|
|
(defun ns-do-show-character-palette ()
|
|
|
|
(interactive)
|
|
|
|
(ns-show-character-palette))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-next-frame ()
|
|
|
|
"Switch to next visible frame."
|
|
|
|
(interactive)
|
|
|
|
(other-frame 1))
|
2009-05-03 23:19:35 +00:00
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-prev-frame ()
|
|
|
|
"Switch to previous visible frame."
|
|
|
|
(interactive)
|
|
|
|
(other-frame -1))
|
|
|
|
|
2013-09-12 16:21:41 -04:00
|
|
|
;; Frame will be focused anyway, so select it
|
2012-06-02 18:56:09 +08:00
|
|
|
;; (if this is not done, mode line is dimmed until first interaction)
|
2013-09-12 16:21:41 -04:00
|
|
|
;; FIXME: Sounds like we're working around a bug in the underlying code.
|
2008-07-15 18:15:18 +00:00
|
|
|
(add-hook 'after-make-frame-functions 'select-frame)
|
|
|
|
|
2008-08-11 01:23:07 +00:00
|
|
|
(defvar tool-bar-mode)
|
|
|
|
(declare-function tool-bar-mode "tool-bar" (&optional arg))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;; Based on a function by David Reitter <dreitter@inf.ed.ac.uk> ;
|
2017-11-25 22:45:41 -08:00
|
|
|
;; see https://lists.gnu.org/r/emacs-devel/2005-09/msg00681.html .
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-toggle-toolbar (&optional frame)
|
|
|
|
"Switches the tool bar on and off in frame FRAME.
|
|
|
|
If FRAME is nil, the change applies to the selected frame."
|
|
|
|
(interactive)
|
2008-07-16 20:06:14 +00:00
|
|
|
(modify-frame-parameters
|
|
|
|
frame (list (cons 'tool-bar-lines
|
2008-07-15 18:15:18 +00:00
|
|
|
(if (> (or (frame-parameter frame 'tool-bar-lines) 0) 0)
|
|
|
|
0 1)) ))
|
|
|
|
(if (not tool-bar-mode) (tool-bar-mode t)))
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Dialog-related functions.
|
|
|
|
|
|
|
|
;; Ask user for confirm before printing. Due to Kevin Rodgers.
|
|
|
|
(defun ns-print-buffer ()
|
|
|
|
"Interactive front-end to `print-buffer': asks for user confirmation first."
|
|
|
|
(interactive)
|
2009-10-02 03:48:36 +00:00
|
|
|
(if (and (called-interactively-p 'interactive)
|
2008-07-16 20:06:14 +00:00
|
|
|
(or (listp last-nonmenu-event)
|
|
|
|
(and (char-or-string-p (event-basic-type last-command-event))
|
|
|
|
(memq 'super (event-modifiers last-command-event)))))
|
|
|
|
(let ((last-nonmenu-event (if (listp last-nonmenu-event)
|
|
|
|
last-nonmenu-event
|
|
|
|
;; Fake it:
|
2018-11-05 01:22:15 +01:00
|
|
|
'(mouse-1 POSITION 1))))
|
2008-07-16 20:06:14 +00:00
|
|
|
(if (y-or-n-p (format "Print buffer %s? " (buffer-name)))
|
|
|
|
(print-buffer)
|
2014-01-05 22:25:30 -08:00
|
|
|
(error "Canceled")))
|
2008-07-15 18:15:18 +00:00
|
|
|
(print-buffer)))
|
|
|
|
|
|
|
|
;;;; Font support.
|
|
|
|
|
|
|
|
;; Needed for font listing functions under both backend and normal
|
|
|
|
(setq scalable-fonts-allowed t)
|
|
|
|
|
|
|
|
;; Set to use font panel instead
|
2008-11-15 22:29:59 +00:00
|
|
|
(declare-function ns-popup-font-panel "nsfns.m" (&optional frame))
|
2009-07-13 10:18:03 +00:00
|
|
|
(defalias 'x-select-font 'ns-popup-font-panel "Pop up the font panel.
|
2009-05-03 23:19:35 +00:00
|
|
|
This function has been overloaded in Nextstep.")
|
2009-03-29 00:00:30 +00:00
|
|
|
(defalias 'mouse-set-font 'ns-popup-font-panel "Pop up the font panel.
|
2009-05-03 23:19:35 +00:00
|
|
|
This function has been overloaded in Nextstep.")
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
;; nsterm.m
|
|
|
|
(defvar ns-input-font)
|
|
|
|
(defvar ns-input-fontsize)
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-respond-to-change-font ()
|
2020-09-22 13:38:16 +01:00
|
|
|
"Set the font chosen in the font-picker panel.
|
|
|
|
Respond to changeFont: event, expecting ns-input-font and
|
|
|
|
ns-input-fontsize of new font."
|
2008-07-15 18:15:18 +00:00
|
|
|
(interactive)
|
2020-09-22 13:38:16 +01:00
|
|
|
(let ((face 'default))
|
|
|
|
(set-face-attribute face t
|
|
|
|
:family ns-input-font
|
|
|
|
:height (* 10 ns-input-fontsize))
|
|
|
|
(set-face-attribute face (selected-frame)
|
|
|
|
:family ns-input-font
|
|
|
|
:height (* 10 ns-input-fontsize))
|
|
|
|
(let ((spec (list (list t (face-attr-construct 'default)))))
|
|
|
|
(put face 'customized-face spec)
|
|
|
|
(custom-push-theme 'theme-face face 'user 'set spec)
|
|
|
|
(put face 'face-modified nil))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2016-11-06 00:33:43 -07:00
|
|
|
;; Default fontset for macOS. This is mainly here to show how a fontset
|
2008-07-15 18:15:18 +00:00
|
|
|
;; can be set up manually. Ordinarily, fontsets are auto-created whenever
|
2009-05-03 23:19:35 +00:00
|
|
|
;; a font is chosen by
|
2008-07-15 18:15:18 +00:00
|
|
|
(defvar ns-standard-fontset-spec
|
2008-07-16 20:06:14 +00:00
|
|
|
;; Only some code supports this so far, so use uglier XLFD version
|
|
|
|
;; "-ns-*-*-*-*-*-10-*-*-*-*-*-fontset-standard,latin:Courier,han:Kai"
|
|
|
|
(mapconcat 'identity
|
|
|
|
'("-ns-*-*-*-*-*-10-*-*-*-*-*-fontset-standard"
|
|
|
|
"latin:-*-Courier-*-*-*-*-10-*-*-*-*-*-iso10646-1"
|
|
|
|
"han:-*-Kai-*-*-*-*-10-*-*-*-*-*-iso10646-1"
|
|
|
|
"cyrillic:-*-Trebuchet$MS-*-*-*-*-10-*-*-*-*-*-iso10646-1")
|
|
|
|
",")
|
|
|
|
"String of fontset spec of the standard fontset.
|
2008-07-15 18:15:18 +00:00
|
|
|
This defines a fontset consisting of the Courier and other fonts that
|
2016-11-06 00:33:43 -07:00
|
|
|
come with macOS.
|
2009-05-03 23:19:35 +00:00
|
|
|
See the documentation of `create-fontset-from-fontset-spec' for the format.")
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2009-09-24 03:22:40 +00:00
|
|
|
(defvar ns-reg-to-script) ; nsfont.m
|
|
|
|
|
2009-09-23 02:35:33 +00:00
|
|
|
;; This maps font registries (not exposed by NS APIs for font selection) to
|
2011-11-20 20:35:27 +01:00
|
|
|
;; Unicode scripts (which can be mapped to Unicode character ranges which are).
|
2009-09-23 02:35:33 +00:00
|
|
|
;; See ../international/fontset.el
|
|
|
|
(setq ns-reg-to-script
|
|
|
|
'(("iso8859-1" . latin)
|
|
|
|
("iso8859-2" . latin)
|
|
|
|
("iso8859-3" . latin)
|
|
|
|
("iso8859-4" . latin)
|
|
|
|
("iso8859-5" . cyrillic)
|
|
|
|
("microsoft-cp1251" . cyrillic)
|
|
|
|
("koi8-r" . cyrillic)
|
|
|
|
("iso8859-6" . arabic)
|
|
|
|
("iso8859-7" . greek)
|
|
|
|
("iso8859-8" . hebrew)
|
|
|
|
("iso8859-9" . latin)
|
|
|
|
("iso8859-10" . latin)
|
|
|
|
("iso8859-11" . thai)
|
|
|
|
("tis620" . thai)
|
|
|
|
("iso8859-13" . latin)
|
|
|
|
("iso8859-14" . latin)
|
|
|
|
("iso8859-15" . latin)
|
|
|
|
("iso8859-16" . latin)
|
|
|
|
("viscii1.1-1" . latin)
|
|
|
|
("jisx0201" . kana)
|
|
|
|
("jisx0208" . han)
|
|
|
|
("jisx0212" . han)
|
|
|
|
("jisx0213" . han)
|
|
|
|
("gb2312.1980" . han)
|
|
|
|
("gb18030" . han)
|
|
|
|
("gbk-0" . han)
|
|
|
|
("big5" . han)
|
|
|
|
("cns11643" . han)
|
|
|
|
("sisheng_cwnn" . bopomofo)
|
|
|
|
("ksc5601.1987" . hangul)
|
|
|
|
("ethiopic-unicode" . ethiopic)
|
|
|
|
("is13194-devanagari" . indian-is13194)
|
|
|
|
("iso10646.indian-1" . devanagari)))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;;;; Pasteboard support.
|
|
|
|
|
2011-12-18 14:49:38 +01:00
|
|
|
(define-obsolete-function-alias 'ns-store-cut-buffer-internal
|
2014-10-24 18:23:43 -04:00
|
|
|
'gui-set-selection "24.1")
|
2011-12-18 14:49:38 +01:00
|
|
|
|
2008-07-16 02:29:39 +00:00
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-copy-including-secondary ()
|
|
|
|
(interactive)
|
|
|
|
(call-interactively 'kill-ring-save)
|
2014-10-24 18:23:43 -04:00
|
|
|
(gui-set-selection 'SECONDARY (buffer-substring (point) (mark t))))
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(defun ns-paste-secondary ()
|
|
|
|
(interactive)
|
2015-05-07 19:48:19 +02:00
|
|
|
(insert (gui-get-selection 'SECONDARY)))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;;; Scrollbar handling.
|
|
|
|
|
2016-05-01 13:04:07 +02:00
|
|
|
(global-set-key [vertical-scroll-bar down-mouse-1] 'scroll-bar-toolkit-scroll)
|
|
|
|
(global-set-key [horizontal-scroll-bar down-mouse-1] 'scroll-bar-toolkit-horizontal-scroll)
|
2008-07-15 18:15:18 +00:00
|
|
|
(global-unset-key [vertical-scroll-bar mouse-1])
|
|
|
|
(global-unset-key [vertical-scroll-bar drag-mouse-1])
|
2016-05-01 13:04:07 +02:00
|
|
|
(global-unset-key [horizontal-scroll-bar mouse-1])
|
|
|
|
(global-unset-key [horizontal-scroll-bar drag-mouse-1])
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
|
2017-09-08 19:26:47 +01:00
|
|
|
;;;; macOS-like defaults for trackpad and mouse wheel scrolling on
|
|
|
|
;;;; macOS 10.7+.
|
|
|
|
|
2018-02-26 15:40:02 -05:00
|
|
|
(defvar ns-version-string)
|
2018-02-26 16:59:42 -05:00
|
|
|
(defvar mouse-wheel-scroll-amount)
|
|
|
|
(defvar mouse-wheel-progressive-speed)
|
2018-02-26 15:40:02 -05:00
|
|
|
|
2017-09-08 19:26:47 +01:00
|
|
|
;; FIXME: This doesn't look right. Is there a better way to do this
|
|
|
|
;; that keeps customize happy?
|
2017-08-15 09:58:33 +01:00
|
|
|
(when (featurep 'cocoa)
|
|
|
|
(let ((appkit-version
|
|
|
|
(progn (string-match "^appkit-\\([^\s-]*\\)" ns-version-string)
|
|
|
|
(string-to-number (match-string 1 ns-version-string)))))
|
|
|
|
;; Appkit 1138 ~= macOS 10.7.
|
|
|
|
(when (>= appkit-version 1138)
|
|
|
|
(setq mouse-wheel-progressive-speed nil)
|
|
|
|
(put 'mouse-wheel-progressive-speed 'customized-value
|
|
|
|
(list (custom-quote
|
|
|
|
(symbol-value 'mouse-wheel-progressive-speed)))))))
|
2017-09-08 19:26:47 +01:00
|
|
|
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
;;;; Color support.
|
|
|
|
|
|
|
|
;; Functions for color panel + drag
|
|
|
|
(defun ns-face-at-pos (pos)
|
|
|
|
(let* ((frame (car pos))
|
|
|
|
(frame-pos (cons (cadr pos) (cddr pos)))
|
|
|
|
(window (window-at (car frame-pos) (cdr frame-pos) frame))
|
|
|
|
(window-pos (coordinates-in-window-p frame-pos window))
|
|
|
|
(buffer (window-buffer window))
|
|
|
|
(edges (window-edges window)))
|
|
|
|
(cond
|
|
|
|
((not window-pos)
|
|
|
|
nil)
|
|
|
|
((eq window-pos 'mode-line)
|
2012-06-02 18:56:09 +08:00
|
|
|
'mode-line)
|
2008-07-15 18:15:18 +00:00
|
|
|
((eq window-pos 'vertical-line)
|
|
|
|
'default)
|
|
|
|
((consp window-pos)
|
* url-util.el (url-insert-entities-in-string):
* url-nfs.el (url-nfs-unescape):
* url-ldap.el (url-ldap):
* url-imap.el (url-imap):
* url-cid.el (url-cid-gnus, url-cid): Use with-current-buffer.
* erc.el (erc-display-line-1, erc-process-away):
* erc-truncate.el (erc-truncate-buffer-to-size):
Use with-current-buffer.
* term/ns-win.el (ns-scroll-bar-move, ns-face-at-pos):
* play/mpuz.el (mpuz-create-buffer):
* play/landmark.el (lm-prompt-for-move, lm-print-wts, lm-print-smell)
(lm-print-y,s,noise, lm-print-w0, lm-init):
* play/gomoku.el (gomoku-prompt-for-move):
* play/fortune.el (fortune-in-buffer):
* play/dissociate.el (dissociated-press):
* play/decipher.el (decipher-adjacency-list, decipher-display-regexp)
(decipher-analyze-buffer, decipher-stats-buffer,decipher-stats-buffer):
* mail/supercite.el (sc-eref-show):
* mail/smtpmail.el (smtpmail-send-it):
* mail/rmailsum.el (rmail-summary-next-labeled-message)
(rmail-summary-previous-labeled-message, rmail-summary-wipe)
(rmail-summary-undelete-many, rmail-summary-rmail-update)
(rmail-summary-goto-msg, rmail-summary-expunge)
(rmail-summary-get-new-mail, rmail-summary-search-backward)
(rmail-summary-add-label, rmail-summary-output-menu)
(rmail-summary-output-body):
* mail/rfc822.el (rfc822-addresses):
* mail/reporter.el (reporter-dump-variable, reporter-dump-state):
* mail/mailpost.el (post-mail-send-it):
* mail/hashcash.el (hashcash-generate-payment):
* mail/feedmail.el (feedmail-run-the-queue)
(feedmail-queue-send-edit-prompt-help-first)
(feedmail-send-it-immediately, feedmail-give-it-to-buffer-eater)
(feedmail-deduce-address-list):
* eshell/esh-ext.el (eshell-remote-command):
* eshell/em-unix.el (eshell-occur-mode-mouse-goto):
* emulation/viper-util.el (viper-glob-unix-files, viper-save-setting)
(viper-wildcard-to-regexp, viper-glob-mswindows-files)
(viper-save-string-in-file, viper-valid-marker):
* emulation/viper-keym.el (viper-toggle-key):
* emulation/viper-ex.el (ex-expand-filsyms, viper-get-ex-file)
(ex-edit, ex-global, ex-mark, ex-next-related-buffer, ex-quit)
(ex-get-inline-cmd-args, ex-tag, ex-command, ex-compile):
* emulation/viper-cmd.el (viper-exec-form-in-vi)
(viper-exec-form-in-emacs, viper-brac-function):
* emulation/viper.el (viper-delocalize-var):
* emulation/vip.el (vip-mode, vip-get-ex-token, vip-ex, vip-get-ex-pat)
(vip-get-ex-command, vip-get-ex-opt-gc, vip-get-ex-buffer)
(vip-get-ex-count, vip-get-ex-file, ex-edit, ex-global, ex-mark)
(ex-map, ex-unmap, ex-quit, ex-read, ex-tag, ex-command):
* emulation/vi.el (vi-switch-mode, vi-ex-cmd):
* emulation/edt.el (edt-electric-helpify):
* emulation/cua-rect.el (cua--rectangle-aux-replace):
* emulation/cua-gmrk.el (cua--insert-at-global-mark)
(cua--delete-at-global-mark, cua--copy-rectangle-to-global-mark)
(cua-indent-to-global-mark-column):
* calendar/diary-lib.el (calendar-mark-1):
* calendar/cal-hebrew.el (calendar-hebrew-mark-date-pattern):
Use with-current-buffer.
* emulation/viper.el (viper-delocalize-var): Use dolist.
2009-11-03 02:04:29 +00:00
|
|
|
(with-current-buffer buffer
|
2008-07-15 18:15:18 +00:00
|
|
|
(let ((p (car (compute-motion (window-start window)
|
|
|
|
(cons (nth 0 edges) (nth 1 edges))
|
|
|
|
(window-end window)
|
|
|
|
frame-pos
|
|
|
|
(- (window-width window) 1)
|
|
|
|
nil
|
|
|
|
window))))
|
|
|
|
(cond
|
|
|
|
((eq p (window-point window))
|
|
|
|
'cursor)
|
|
|
|
((and mark-active (< (region-beginning) p) (< p (region-end)))
|
|
|
|
'region)
|
|
|
|
(t
|
|
|
|
(let ((faces (get-char-property p 'face window)))
|
|
|
|
(if (consp faces) (car faces) faces)))))))
|
|
|
|
(t
|
|
|
|
nil))))
|
|
|
|
|
2014-02-02 15:10:50 +01:00
|
|
|
(defun ns-suspend-error ()
|
|
|
|
;; Don't allow suspending if any of the frames are NS frames.
|
|
|
|
(if (memq 'ns (mapcar 'window-system (frame-list)))
|
2017-08-05 12:00:31 +03:00
|
|
|
(error "Cannot suspend Emacs while an NS GUI frame exists")))
|
2014-02-02 15:10:50 +01:00
|
|
|
|
|
|
|
|
2008-07-21 16:23:55 +00:00
|
|
|
;; Set some options to be as Nextstep-like as possible.
|
2018-02-11 11:34:49 +00:00
|
|
|
(setq frame-title-format "%b"
|
|
|
|
icon-title-format "%b")
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defvar ns-initialized nil
|
2008-07-21 16:23:55 +00:00
|
|
|
"Non-nil if Nextstep windowing has been initialized.")
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2013-09-17 21:36:34 -07:00
|
|
|
(declare-function x-handle-args "common-win" (args))
|
2008-07-16 02:29:39 +00:00
|
|
|
(declare-function ns-list-services "nsfns.m" ())
|
2009-01-22 12:31:36 +00:00
|
|
|
(declare-function x-open-connection "nsfns.m"
|
2008-08-11 01:23:07 +00:00
|
|
|
(display &optional xrm-string must-succeed))
|
2011-06-29 19:54:16 -07:00
|
|
|
(declare-function ns-set-resource "nsfns.m" (owner name value))
|
2008-07-16 02:29:39 +00:00
|
|
|
|
2008-07-21 16:23:55 +00:00
|
|
|
;; Do the actual Nextstep Windows setup here; the above code just
|
|
|
|
;; defines functions and variables that we use now.
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
(cl-defmethod window-system-initialization (&context (window-system ns)
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
&optional _display)
|
2008-07-21 16:23:55 +00:00
|
|
|
"Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
|
2012-09-17 03:55:05 -08:00
|
|
|
(cl-assert (not ns-initialized))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2008-07-16 20:06:14 +00:00
|
|
|
;; PENDING: not needed?
|
2010-10-25 20:58:19 -07:00
|
|
|
(setq command-line-args (x-handle-args command-line-args))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2012-11-24 18:55:48 +01:00
|
|
|
;; Setup the default fontset.
|
|
|
|
(create-default-fontset)
|
|
|
|
;; Create the standard fontset.
|
|
|
|
(condition-case err
|
|
|
|
(create-fontset-from-fontset-spec ns-standard-fontset-spec t)
|
|
|
|
(error (display-warning
|
|
|
|
'initialization
|
|
|
|
(format "Creation of the standard fontset failed: %s" err)
|
|
|
|
:error)))
|
|
|
|
|
2018-02-06 12:20:37 -05:00
|
|
|
(x-open-connection (or (system-name) "") x-command-line-resources t)
|
2008-07-15 18:15:18 +00:00
|
|
|
|
2014-01-20 14:44:56 -05:00
|
|
|
;; Add GNUstep menu items Services, Hide and Quit. Rename Help to Info
|
2013-10-20 11:26:15 +02:00
|
|
|
;; and put it first (i.e. omit from menu-bar-final-items.
|
2013-10-20 10:50:34 +02:00
|
|
|
(if (featurep 'gnustep)
|
|
|
|
(progn
|
|
|
|
(setq menu-bar-final-items '(buffer services hide-app quit))
|
2013-10-20 11:26:15 +02:00
|
|
|
|
|
|
|
;; If running under GNUstep, "Help" is moved and renamed "Info".
|
|
|
|
(bindings--define-key global-map [menu-bar help-menu]
|
|
|
|
(cons "Info" menu-bar-help-menu))
|
2013-10-20 10:50:34 +02:00
|
|
|
(bindings--define-key global-map [menu-bar quit]
|
|
|
|
'(menu-item "Quit" save-buffers-kill-emacs
|
|
|
|
:help "Save unsaved buffers, then exit"))
|
|
|
|
(bindings--define-key global-map [menu-bar hide-app]
|
|
|
|
'(menu-item "Hide" ns-do-hide-emacs
|
|
|
|
:help "Hide Emacs"))
|
|
|
|
(bindings--define-key global-map [menu-bar services]
|
|
|
|
(cons "Services" (make-sparse-keymap "Services")))))
|
|
|
|
|
|
|
|
|
2008-07-16 20:06:14 +00:00
|
|
|
(dolist (service (ns-list-services))
|
|
|
|
(if (eq (car service) 'undefined)
|
|
|
|
(ns-define-service (cdr service))
|
|
|
|
(define-key global-map (vector (car service))
|
|
|
|
(ns-define-service (cdr service)))))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
(if (and (eq (get-lisp-resource nil "NXAutoLaunch") t)
|
|
|
|
(eq (get-lisp-resource nil "HideOnAutoLaunch") t))
|
|
|
|
(add-hook 'after-init-hook 'ns-do-hide-emacs))
|
|
|
|
|
2008-07-16 20:06:14 +00:00
|
|
|
;; FIXME: This will surely lead to "MODIFIED OUTSIDE CUSTOM" warnings.
|
2008-07-15 18:15:18 +00:00
|
|
|
(menu-bar-mode (if (get-lisp-resource nil "Menus") 1 -1))
|
|
|
|
|
2013-10-01 20:22:48 +02:00
|
|
|
;; For Darwin nothing except UTF-8 makes sense.
|
|
|
|
(when (eq system-type 'darwin)
|
|
|
|
(add-hook 'before-init-hook
|
|
|
|
#'(lambda ()
|
|
|
|
(setq locale-coding-system 'utf-8-unix)
|
|
|
|
(setq default-process-coding-system
|
|
|
|
'(utf-8-unix . utf-8-unix)))))
|
2013-09-29 19:09:39 +02:00
|
|
|
|
2016-11-06 00:33:43 -07:00
|
|
|
;; Mac OS X Lion introduces PressAndHold, which is unsupported by this port.
|
2011-06-21 11:45:36 -07:00
|
|
|
;; See this thread for more details:
|
2017-11-25 22:45:41 -08:00
|
|
|
;; https://lists.gnu.org/r/emacs-devel/2011-06/msg00505.html
|
2011-06-21 11:45:36 -07:00
|
|
|
(ns-set-resource nil "ApplePressAndHoldEnabled" "NO")
|
|
|
|
|
2012-04-27 13:40:46 +08:00
|
|
|
(x-apply-session-resources)
|
2014-02-02 15:10:50 +01:00
|
|
|
|
|
|
|
;; Don't let Emacs suspend under NS.
|
|
|
|
(add-hook 'suspend-hook 'ns-suspend-error)
|
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(setq ns-initialized t))
|
|
|
|
|
2013-07-02 20:16:09 +02:00
|
|
|
;; Any display name is OK.
|
|
|
|
(add-to-list 'display-format-alist '(".*" . ns))
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
(cl-defmethod handle-args-function (args &context (window-system ns))
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(x-handle-args args))
|
|
|
|
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
(cl-defmethod frame-creation-function (params &context (window-system ns))
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(x-create-frame-with-faces params))
|
2014-10-01 18:13:11 -04:00
|
|
|
|
2015-04-30 20:09:02 -04:00
|
|
|
(declare-function ns-own-selection-internal "nsselect.m" (selection value))
|
|
|
|
(declare-function ns-disown-selection-internal "nsselect.m" (selection))
|
2015-06-16 20:33:48 -04:00
|
|
|
(declare-function ns-selection-owner-p "nsselect.m" (&optional selection))
|
|
|
|
(declare-function ns-selection-exists-p "nsselect.m" (&optional selection))
|
|
|
|
(declare-function ns-get-selection "nsselect.m" (selection-symbol target-type))
|
2015-04-30 20:09:02 -04:00
|
|
|
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(cl-defmethod gui-backend-set-selection (selection value
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
&context (window-system ns))
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(if value (ns-own-selection-internal selection value)
|
|
|
|
(ns-disown-selection-internal selection)))
|
|
|
|
|
|
|
|
(cl-defmethod gui-backend-selection-owner-p (selection
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
&context (window-system ns))
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(ns-selection-owner-p selection))
|
|
|
|
|
|
|
|
(cl-defmethod gui-backend-selection-exists-p (selection
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
&context (window-system ns))
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(ns-selection-exists-p selection))
|
|
|
|
|
|
|
|
(cl-defmethod gui-backend-get-selection (selection-symbol target-type
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
&context (window-system ns))
|
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'.
2015-05-23 11:32:29 -04:00
|
|
|
(ns-get-selection selection-symbol target-type))
|
Consolidate management/ownership of selections.
* lisp/select.el (gui-get-selection-alist): New method.
(gui-get-selection): Use it. Rename from x-get-selection.
(x-get-selection): Define as obsolete alias.
(x-get-clipboard): Mark obsolete.
(gui-get-primary-selection): New function.
(x-get-selection-value): Mark obsolete.
(gui-own-selection-alist, gui-disown-selection-alist)
(gui-selection-owner-p-alist): New methods.
(gui-set-selection): Use them. Rename from x-set-selection.
(x-set-selection): Define as obsolete alias.
(gui--valid-simple-selection-p): Rename from
x-valid-simple-selection-p.
* lisp/w32-common-fns.el (gui-own-selection, gui-disown-selection)
(gui-selection-owner-p, gui-get-selection): Define for w32.
(w32-get-selection-value): Rename from x-get-selection-value.
Use the new gui-last-selected-text.
* lisp/term/x-win.el (x-get-selection-value): Remove.
(x-clipboard-yank): Declare obsolete.
(gui-own-selection, gui-disown-selection, gui-get-selection)
(gui-selection-owner-p): Define for x.
* lisp/term/w32-win.el (w32-win-suspend-error): Rename from
x-win-suspend-error.
* lisp/term/pc-win.el (w16-get-selection-value): Rename from
x-get-selection-value.
(w16-selection-owner-p): Rename from x-selection-owner-p.
(gui-own-selection, gui-disown-selection, gui-get-selection)
(gui-selection-owner-p): Define for pc.
(w16--select-text): New function.
* lisp/term/ns-win.el (gui-own-selection, gui-disown-selection)
(gui-get-selection, gui-selection-owner-p): Define for ns.
* lisp/term.el (term-mouse-paste):
* lisp/mouse.el (mouse-yank-primary): Use gui-get-primary-selection.
* src/nsselect.m (ns-own-selection-internal, ns-disown-selection-internal):
Rename from the "x-" prefix.
2014-10-01 23:19:32 -04:00
|
|
|
|
2008-07-15 18:15:18 +00:00
|
|
|
(provide 'ns-win)
|
Provide 'term/name in lisp/term files.
* lisp/term/AT386.el, lisp/term/bobcat.el, lisp/term/cygwin.el:
* lisp/term/internal.el, lisp/term/iris-ansi.el, lisp/term/linux.el:
* lisp/term/lk201.el, lisp/term/news.el, lisp/term/ns-win.el:
* lisp/term/pc-win.el, lisp/term/rxvt.el, lisp/term/screen.el:
* lisp/term/sun.el, lisp/term/tty-colors.el, lisp/term/tvi970.el:
* lisp/term/vt100.el, lisp/term/vt200.el, lisp/term/w32-win.el:
* lisp/term/w32console.el, lisp/term/wyse50.el, lisp/term/x-win.el:
For consistency, provide 'term/name in all files that don't already.
2016-02-15 21:59:40 -08:00
|
|
|
(provide 'term/ns-win)
|
2008-07-15 18:15:18 +00:00
|
|
|
|
|
|
|
;;; ns-win.el ends here
|