summaryrefslogtreecommitdiff
path: root/lisp/term
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/term')
-rw-r--r--lisp/term/common-win.el32
-rw-r--r--lisp/term/internal.el3
-rw-r--r--lisp/term/ns-win.el44
-rw-r--r--lisp/term/pc-win.el140
-rw-r--r--lisp/term/sun.el19
-rw-r--r--lisp/term/tty-colors.el20
-rw-r--r--lisp/term/tvi970.el3
-rw-r--r--lisp/term/vt100.el5
-rw-r--r--lisp/term/w32-win.el15
-rw-r--r--lisp/term/x-win.el8
-rw-r--r--lisp/term/xterm.el123
11 files changed, 201 insertions, 211 deletions
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index 4399eaed186..b7a778fc004 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -59,20 +59,20 @@
(setq system-key-alist
(list
;; These are special "keys" used to pass events from C to lisp.
- (cons (logior (lsh 0 16) 1) 'ns-power-off)
- (cons (logior (lsh 0 16) 2) 'ns-open-file)
- (cons (logior (lsh 0 16) 3) 'ns-open-temp-file)
- (cons (logior (lsh 0 16) 4) 'ns-drag-file)
- (cons (logior (lsh 0 16) 5) 'ns-drag-color)
- (cons (logior (lsh 0 16) 6) 'ns-drag-text)
- (cons (logior (lsh 0 16) 7) 'ns-change-font)
- (cons (logior (lsh 0 16) 8) 'ns-open-file-line)
-;;; (cons (logior (lsh 0 16) 9) 'ns-insert-working-text)
-;;; (cons (logior (lsh 0 16) 10) 'ns-delete-working-text)
- (cons (logior (lsh 0 16) 11) 'ns-spi-service-call)
- (cons (logior (lsh 0 16) 12) 'ns-new-frame)
- (cons (logior (lsh 0 16) 13) 'ns-toggle-toolbar)
- (cons (logior (lsh 0 16) 14) 'ns-show-prefs)
+ (cons 1 'ns-power-off)
+ (cons 2 'ns-open-file)
+ (cons 3 'ns-open-temp-file)
+ (cons 4 'ns-drag-file)
+ (cons 5 'ns-drag-color)
+ (cons 6 'ns-drag-text)
+ (cons 7 'ns-change-font)
+ (cons 8 'ns-open-file-line)
+;;; (cons 9 'ns-insert-working-text)
+;;; (cons 10 'ns-delete-working-text)
+ (cons 11 'ns-spi-service-call)
+ (cons 12 'ns-new-frame)
+ (cons 13 'ns-toggle-toolbar)
+ (cons 14 'ns-show-prefs)
))))
(set-terminal-parameter frame 'x-setup-function-keys t)))
@@ -112,7 +112,7 @@
;; Handle the -xrm option.
(defun x-handle-xrm-switch (switch)
(unless (consp x-invocation-args)
- (error "%s: missing argument to `%s' option" (invocation-name) switch))
+ (error "%s: missing argument to `%s' option" invocation-name switch))
(setq x-command-line-resources
(if (null x-command-line-resources)
(pop x-invocation-args)
@@ -152,7 +152,7 @@
;; the initial frame, too.
(defun x-handle-name-switch (switch)
(or (consp x-invocation-args)
- (error "%s: missing argument to `%s' option" (invocation-name) switch))
+ (error "%s: missing argument to `%s' option" invocation-name switch))
(setq x-resource-name (pop x-invocation-args)
initial-frame-alist (cons (cons 'name x-resource-name)
initial-frame-alist)))
diff --git a/lisp/term/internal.el b/lisp/term/internal.el
index 1e9cbf477df..396521d676d 100644
--- a/lisp/term/internal.el
+++ b/lisp/term/internal.el
@@ -595,8 +595,7 @@ list. You can (and should) also run it if and when the value of
(set-selection-coding-system coding-dos)
(IT-setup-unicode-display coding-unix)
(prefer-coding-system coding-dos)
- (and (default-value 'enable-multibyte-characters)
- (setq unibyte-display-via-language-environment t))
+ (setq unibyte-display-via-language-environment t)
;; Some codepages have sporadic support for Latin-1, Greek, and
;; symbol glyphs, which don't belong to their native character
;; set. It's a nuisance to have all those glyphs here, for all
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 40397fcfedd..c9f5bfef520 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -42,7 +42,7 @@
(eval-when-compile (require 'cl-lib))
(or (featurep 'ns)
(error "%s: Loading ns-win.el but not compiled for GNUstep/macOS"
- (invocation-name)))
+ invocation-name))
;; Documentation-purposes only: actually loaded in loadup.el.
(require 'frame)
@@ -125,7 +125,6 @@ The properties returned may include `top', `left', `height', and `width'."
(define-key global-map [?\s-h] 'ns-do-hide-emacs)
(define-key global-map [?\s-H] 'ns-do-hide-others)
(define-key global-map [?\M-\s-h] 'ns-do-hide-others)
-(define-key key-translation-map [?\M-\s-\u02D9] [?\M-\s-h])
(define-key global-map [?\s-j] 'exchange-point-and-mark)
(define-key global-map [?\s-k] 'kill-current-buffer)
(define-key global-map [?\s-l] 'goto-line)
@@ -142,8 +141,13 @@ The properties returned may include `top', `left', `height', and `width'."
(define-key global-map [?\s-x] 'kill-region)
(define-key global-map [?\s-y] 'ns-paste-secondary)
(define-key global-map [?\s-z] 'undo)
+(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)
(define-key global-map [?\s-|] 'shell-command-on-region)
(define-key global-map [s-kp-bar] 'shell-command-on-region)
+(define-key global-map [?\C-\s- ] 'ns-do-show-character-palette)
;; (as in Terminal.app)
(define-key global-map [s-right] 'ns-next-frame)
(define-key global-map [s-left] 'ns-prev-frame)
@@ -307,8 +311,8 @@ is currently being used."
"Insert contents of `ns-working-text' as UTF-8 string and mark with
`ns-working-overlay'. Any previously existing working text is cleared first.
The overlay is assigned the face `ns-working-text-face'."
- ;; FIXME: if buffer is read-only, don't try to insert anything
- ;; and if text is bound to a command, execute that instead (Bug#1453)
+ ;; FIXME: if buffer is read-only, don't try to insert anything, and
+ ;; if text is bound to a command, execute that instead (Bug#1453).
(interactive)
(ns-delete-working-text)
(let ((start (point)))
@@ -354,7 +358,7 @@ See `ns-insert-working-text'."
;; Used prior to Emacs 25.
(define-coding-system-alias 'utf-8-nfd 'utf-8-hfs)
- (set-file-name-coding-system 'utf-8-hfs))
+ (set-file-name-coding-system 'utf-8-hfs-unix))
;;;; Inter-app communications support.
@@ -437,14 +441,7 @@ Lines are highlighted according to `ns-input-line'."
;;;; File handling.
(defun x-file-dialog (prompt dir default_filename mustmatch only_dir_p)
-"Read file name, prompting with PROMPT in directory DIR.
-Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
-selection box, if specified. If MUSTMATCH is non-nil, the returned file
-or directory must exist.
-
-This function is only defined on NS, MS Windows, and X Windows with the
-Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
-Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories."
+ "SKIP: real doc in xfns.c."
(ns-read-file-name prompt dir mustmatch default_filename only_dir_p))
(defun ns-open-file-using-panel ()
@@ -556,8 +553,9 @@ the last file dropped is selected."
(defvar ns-right-control-modifier)
;; You say tomAYto, I say tomAHto..
-(defvaralias 'ns-option-modifier 'ns-alternate-modifier)
-(defvaralias 'ns-right-option-modifier 'ns-right-alternate-modifier)
+(with-no-warnings
+ (defvaralias 'ns-option-modifier 'ns-alternate-modifier)
+ (defvaralias 'ns-right-option-modifier 'ns-right-alternate-modifier))
(defun ns-do-hide-emacs ()
(interactive)
@@ -575,6 +573,12 @@ the last file dropped is selected."
(interactive)
(ns-emacs-info-panel))
+(declare-function ns-show-character-palette "nsfns.m" ())
+
+(defun ns-do-show-character-palette ()
+ (interactive)
+ (ns-show-character-palette))
+
(defun ns-next-frame ()
"Switch to next visible frame."
(interactive)
@@ -619,7 +623,7 @@ the last file dropped is selected."
(let ((last-nonmenu-event (if (listp last-nonmenu-event)
last-nonmenu-event
;; Fake it:
- `(mouse-1 POSITION 1))))
+ '(mouse-1 POSITION 1))))
(if (y-or-n-p (format "Print buffer %s? " (buffer-name)))
(print-buffer)
(error "Canceled")))
@@ -739,6 +743,10 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;;;; macOS-like defaults for trackpad and mouse wheel scrolling on
;;;; macOS 10.7+.
+(defvar ns-version-string)
+(defvar mouse-wheel-scroll-amount)
+(defvar mouse-wheel-progressive-speed)
+
;; FIXME: This doesn't look right. Is there a better way to do this
;; that keeps customize happy?
(when (featurep 'cocoa)
@@ -801,8 +809,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; Set some options to be as Nextstep-like as possible.
-(setq frame-title-format t
- icon-title-format t)
+(setq frame-title-format "%b"
+ icon-title-format "%b")
(defvar ns-initialized nil
diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el
index 214c5a37f55..09275991cf5 100644
--- a/lisp/term/pc-win.el
+++ b/lisp/term/pc-win.el
@@ -38,7 +38,7 @@
(if (not (fboundp 'msdos-remember-default-colors))
(error "%s: Loading pc-win.el but not compiled for MS-DOS"
- (invocation-name)))
+ invocation-name))
(declare-function msdos-remember-default-colors "msdos.c")
(declare-function w16-set-clipboard-data "w16select.c")
@@ -158,159 +158,59 @@ created."
;; a useful function for returning 'nil regardless of argument.
;; Note: Any re-definition in this file of a function that is defined
-;; in C on other platforms, should either have no doc-string, or one
-;; that is identical to the C version, but with the arglist signature
-;; at the end. Otherwise help-split-fundoc gets confused on other
-;; platforms. (Bug#10783)
+;; in C on other platforms, should either have a doc-string that
+;; starts with "SKIP", or one that is identical to the C version,
+;; but with the arglist signature at the end. Otherwise
+;; help-split-fundoc gets confused on other platforms. (Bug#10783)
-;; From src/xfns.c
(defun x-list-fonts (_pattern &optional _face _frame _maximum width)
- "Return a list of the names of available fonts matching PATTERN.
-If optional arguments FACE and FRAME are specified, return only fonts
-the same size as FACE on FRAME.
-
-PATTERN should be a string containing a font name in the XLFD,
-Fontconfig, or GTK format. A font name given in the XLFD format may
-contain wildcard characters:
- the * character matches any substring, and
- the ? character matches any single character.
- PATTERN is case-insensitive.
-
-The return value is a list of strings, suitable as arguments to
-`set-face-font'.
-
-Fonts Emacs can't use may or may not be excluded
-even if they match PATTERN and FACE.
-The optional fourth argument MAXIMUM sets a limit on how many
-fonts to match. The first MAXIMUM fonts are reported.
-The optional fifth argument WIDTH, if specified, is a number of columns
-occupied by a character of a font. In that case, return only fonts
-the WIDTH times as wide as FACE on FRAME."
+ "SKIP: real doc in xfaces.c."
(if (or (null width) (and (numberp width) (= width 1)))
(list "ms-dos")
(list "no-such-font")))
(defun x-display-pixel-width (&optional frame)
- "Return the width in pixels of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display.
-
-On \"multi-monitor\" setups this refers to the pixel width for all
-physical monitors associated with DISPLAY. To get information for
-each physical monitor, use `display-monitor-attributes-list'."
+ "SKIP: real doc in xfns.c."
(frame-width frame))
(defun x-display-pixel-height (&optional frame)
- "Return the height in pixels of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display.
-
-On \"multi-monitor\" setups this refers to the pixel height for all
-physical monitors associated with DISPLAY. To get information for
-each physical monitor, use `display-monitor-attributes-list'."
+ "SKIP: real doc in xfns.c."
(frame-height frame))
(defun x-display-planes (&optional _frame)
- "Return the number of bitplanes of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
4) ;bg switched to 16 colors as well
(defun x-display-color-cells (&optional _frame)
- "Return the number of color cells of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
16)
(defun x-server-max-request-size (&optional _frame)
- "Return the maximum request size of the server of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
1000000) ; ???
(defun x-server-vendor (&optional _frame)
- "Return the \"vendor ID\" string of the GUI software on TERMINAL.
-
-\(Labeling every distributor as a \"vendor\" embodies the false assumption
-that operating systems cannot be developed and distributed noncommercially.)
-
-For GNU and Unix systems, this queries the X server software; for
-MS-Windows, this queries the OS.
-
-The optional argument TERMINAL specifies which display to ask about.
-TERMINAL should be a terminal object, a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
"GNU")
(defun x-server-version (&optional _frame)
- "Return the version numbers of the GUI software on TERMINAL.
-The value is a list of three integers specifying the version of the GUI
-software in use.
-
-For GNU and Unix system, the first 2 numbers are the version of the X
-Protocol used on TERMINAL and the 3rd number is the distributor-specific
-release number. For MS-Windows, the 3 numbers report the version and
-the build number of the OS.
-
-See also the function `x-server-vendor'.
-
-The optional argument TERMINAL specifies which display to ask about.
-TERMINAL should be a terminal object, a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
'(1 0 0))
(defun x-display-screens (&optional _frame)
- "Return the number of screens on the server of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
1)
(defun x-display-mm-height (&optional _frame)
- "Return the height in millimeters of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display.
-
-On \"multi-monitor\" setups this refers to the height in millimeters for
-all physical monitors associated with DISPLAY. To get information
-for each physical monitor, use `display-monitor-attributes-list'."
+ "SKIP: real doc in xfns.c."
245) ; Guess the size of my...
(defun x-display-mm-width (&optional _frame)
- "Return the width in millimeters of DISPLAY.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display.
-
-On \"multi-monitor\" setups this refers to the width in millimeters for
-all physical monitors associated with TERMINAL. To get information
-for each physical monitor, use `display-monitor-attributes-list'."
+ "SKIP: real doc in xfns.c."
322) ; ...monitor, EZ...
(defun x-display-backing-store (&optional _frame)
- "Return an indication of whether DISPLAY does backing store.
-The value may be `always', `when-mapped', or `not-useful'.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
'not-useful)
(defun x-display-visual-class (&optional _frame)
- "Return the visual class of DISPLAY.
-The value is one of the symbols `static-gray', `gray-scale',
-`static-color', `pseudo-color', `true-color', or `direct-color'.
-
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display."
+ "SKIP: real doc in xfns.c."
'static-color)
(fset 'x-display-save-under 'ignore)
(fset 'x-get-resource 'ignore)
-;; From lisp/term/x-win.el
(defvar x-display-name "pc"
- "The name of the window display on which Emacs was started.
-On X, the display name of individual X frames is recorded in the
-`display' frame parameter.")
+ "SKIP: real doc in common-win.el.")
(defvar x-colors (mapcar 'car msdos-color-values)
- "List of basic colors available on color displays.
-For X, the list comes from the `rgb.txt' file,v 10.41 94/02/20.
-For Nextstep, this is a list of non-PANTONE colors returned by
-the operating system.")
+ "SKIP: real doc in common-win.el.")
;; From lisp/term/w32-win.el
;
diff --git a/lisp/term/sun.el b/lisp/term/sun.el
index a1c018483d5..c9f531e3520 100644
--- a/lisp/term/sun.el
+++ b/lisp/term/sun.el
@@ -118,14 +118,6 @@
(define-key map "D" [left]) ; R10
map))
-;; Since .emacs gets loaded before this file, a hook is supplied
-;; for you to put your own bindings in.
-
-(defvar sun-raw-prefix-hooks nil
- "List of forms to evaluate after setting `sun-raw-prefix'.")
-;; Obsolete since 21.1, but tty-setup-hook only exists since 24.4.
-(make-obsolete-variable 'sun-raw-prefix-hooks 'tty-setup-hook "21.1")
-
(defun terminal-init-sun ()
@@ -147,16 +139,7 @@
(global-set-key [f3] 'scroll-down-in-place)
(global-set-key [f4] 'scroll-up-in-place)
(global-set-key [f6] 'shrink-window)
- (global-set-key [f7] 'enlarge-window)
-
- (when sun-raw-prefix-hooks
- (message "sun-raw-prefix-hooks is obsolete! Use %s instead!"
- (or (car-safe (get 'sun-raw-prefix-hooks 'byte-obsolete-variable))
- "emacs-startup-hook"))
- (let ((hooks sun-raw-prefix-hooks))
- (while hooks
- (eval (car hooks))
- (setq hooks (cdr hooks))))))
+ (global-set-key [f7] 'enlarge-window))
(provide 'term/sun)
diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el
index 04b433e178c..307586f2213 100644
--- a/lisp/term/tty-colors.el
+++ b/lisp/term/tty-colors.el
@@ -830,10 +830,10 @@ DISPLAY can be a display name or a frame, and defaults to the
selected frame's display.
If DISPLAY is not on a 24-but TTY terminal, return nil."
(when (and rgb (= (display-color-cells display) 16777216))
- (let ((r (lsh (car rgb) -8))
- (g (lsh (cadr rgb) -8))
- (b (lsh (nth 2 rgb) -8)))
- (logior (lsh r 16) (lsh g 8) b))))
+ (let ((r (ash (car rgb) -8))
+ (g (ash (cadr rgb) -8))
+ (b (ash (nth 2 rgb) -8)))
+ (logior (ash r 16) (ash g 8) b))))
(defun tty-color-define (name index &optional rgb frame)
"Specify a tty color by its NAME, terminal INDEX and RGB values.
@@ -895,9 +895,9 @@ FRAME defaults to the selected frame."
;; never consider it for approximating another color.
(if try-rgb
(progn
- (setq try-r (lsh (car try-rgb) -8)
- try-g (lsh (cadr try-rgb) -8)
- try-b (lsh (nth 2 try-rgb) -8))
+ (setq try-r (ash (car try-rgb) -8)
+ try-g (ash (cadr try-rgb) -8)
+ try-b (ash (nth 2 try-rgb) -8))
(setq dif-r (- r try-r)
dif-g (- g try-g)
dif-b (- b try-b))
@@ -938,13 +938,13 @@ should be the same regardless of what display is being used."
(i2 (+ i1 ndig))
(i3 (+ i2 ndig)))
(list
- (lsh
+ (ash
(string-to-number (substring color i1 i2) 16)
(* 4 (- 4 ndig)))
- (lsh
+ (ash
(string-to-number (substring color i2 i3) 16)
(* 4 (- 4 ndig)))
- (lsh
+ (ash
(string-to-number (substring color i3) 16)
(* 4 (- 4 ndig))))))
((and (>= len 9) ;; X-style RGB:xx/yy/zz color spec
diff --git a/lisp/term/tvi970.el b/lisp/term/tvi970.el
index 20c5a53fc2d..3b748483eef 100644
--- a/lisp/term/tvi970.el
+++ b/lisp/term/tvi970.el
@@ -101,9 +101,6 @@
;; Should keypad numbers send ordinary digits or distinct escape sequences?
(define-minor-mode tvi970-set-keypad-mode
"Toggle alternate keypad mode on TVI 970 keypad.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise. If called from Lisp, enable the mode
-if ARG is omitted or nil.
In alternate keypad mode, the keys send distinct escape
sequences, meaning that they can have their own bindings,
diff --git a/lisp/term/vt100.el b/lisp/term/vt100.el
index a296f7e5293..81843ceb975 100644
--- a/lisp/term/vt100.el
+++ b/lisp/term/vt100.el
@@ -39,10 +39,7 @@
;;; Controlling the screen width.
(define-minor-mode vt100-wide-mode
- "Toggle 132/80 column mode for vt100s.
-With a prefix argument ARG, switch to 132-column mode if ARG is
-positive, and 80-column mode otherwise. If called from Lisp,
-switch to 132-column mode if ARG is omitted or nil."
+ "Toggle 132/80 column mode for vt100s."
:global t :init-value (= (frame-width) 132)
:group 'terminals
(send-string-to-terminal (if vt100-wide-mode "\e[?3h" "\e[?3l"))
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index 39f393fcf98..beb7425ce55 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -66,7 +66,7 @@
;; ../startup.el.
;; (if (not (eq window-system 'w32))
-;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
+;; (error "%s: Loading w32-win.el but not compiled for w32" invocation-name))
(eval-when-compile (require 'cl-lib))
(require 'frame)
@@ -276,7 +276,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
'(gnutls "libgnutls-28.dll" "libgnutls-26.dll"))
'(libxml2 "libxml2-2.dll" "libxml2.dll")
'(zlib "zlib1.dll" "libz-1.dll")
- '(lcms2 "liblcms2-2.dll")))
+ '(lcms2 "liblcms2-2.dll")
+ '(json "libjansson-4.dll")))
;;; multi-tty support
(defvar w32-initialized nil
@@ -309,7 +310,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(setq x-resource-name
;; Change any . or * characters in x-resource-name to hyphens,
;; so as not to choke when we use it in X resource queries.
- (replace-regexp-in-string "[.*]" "-" (invocation-name))))
+ (replace-regexp-in-string "[.*]" "-" invocation-name)))
(x-open-connection "w32" x-command-line-resources
;; Exit with a fatal error if this fails and we
@@ -391,8 +392,12 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(declare-function w32-set-clipboard-data "w32select.c"
(string &optional ignored))
-(declare-function w32-get-clipboard-data "w32select.c")
-(declare-function w32-selection-exists-p "w32select.c")
+(declare-function w32-get-clipboard-data "w32select.c"
+ (&optional ignored))
+(declare-function w32-selection-exists-p "w32select.c"
+ (&optional selection terminal))
+(declare-function w32-selection-targets "w32select.c"
+ (&optional selection terminal))
;;; Fix interface to (X-specific) mouse.el
(defun w32--set-selection (type value)
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index f159a71d988..56061371fe1 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -69,7 +69,7 @@
(eval-when-compile (require 'cl-lib))
(if (not (fboundp 'x-create-frame))
- (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
+ (error "%s: Loading x-win.el but not compiled for X" invocation-name))
(require 'term/common-win)
(require 'frame)
@@ -93,7 +93,7 @@
;; Handle the --parent-id option.
(defun x-handle-parent-id (switch)
(or (consp x-invocation-args)
- (error "%s: missing argument to `%s' option" (invocation-name) switch))
+ (error "%s: missing argument to `%s' option" invocation-name switch))
(setq initial-frame-alist (cons
(cons 'parent-id
(string-to-number (car x-invocation-args)))
@@ -104,7 +104,7 @@
;; to give us back our session id we had on the previous run.
(defun x-handle-smid (switch)
(or (consp x-invocation-args)
- (error "%s: missing argument to `%s' option" (invocation-name) switch))
+ (error "%s: missing argument to `%s' option" invocation-name switch))
(setq x-session-previous-id (car x-invocation-args)
x-invocation-args (cdr x-invocation-args)))
@@ -1205,7 +1205,7 @@ This returns an error if any Emacs frames are X frames."
;; Make sure we have a valid resource name.
(or (stringp x-resource-name)
(let (i)
- (setq x-resource-name (invocation-name))
+ (setq x-resource-name (copy-sequence invocation-name))
;; Change any . or * characters in x-resource-name to hyphens,
;; so as not to choke when we use it in X resource queries.
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 8cbf5dace0f..0973329fa3a 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -68,8 +68,13 @@ string bytes that can be copied is 3/4 of this value."
:version "25.1"
:type 'integer)
+(defcustom xterm-set-window-title nil
+ "Whether Emacs should set window titles to an Emacs frame in an XTerm."
+ :version "27.1"
+ :type 'boolean)
+
(defconst xterm-paste-ending-sequence "\e[201~"
- "Characters send by the terminal to end a bracketed paste.")
+ "Characters sent by the terminal to end a bracketed paste.")
(defun xterm--pasted-text ()
"Handle the rest of a terminal paste operation.
@@ -90,15 +95,49 @@ Return the pasted text as a string."
(decode-coding-region (point-min) (point) (keyboard-coding-system)
t)))))
-(defun xterm-paste ()
+(defun xterm-paste (event)
"Handle the start of a terminal paste operation."
- (interactive)
- (let* ((pasted-text (xterm--pasted-text))
+ (interactive "e")
+ (unless (eq (car-safe event) 'xterm-paste)
+ (error "xterm-paste must be found to xterm-paste event"))
+ (let* ((pasted-text (nth 1 event))
(interprogram-paste-function (lambda () pasted-text)))
(yank)))
+;; Put xterm-paste itself in global-map because, after translation,
+;; it's just a normal input event.
(define-key global-map [xterm-paste] #'xterm-paste)
+;; By returning an empty key sequence, these two functions perform the
+;; moral equivalent of the kind of transparent event processing done
+;; by read-event's handling of special-event-map, but inside
+;; read-key-sequence (which can recognize multi-character terminal
+;; notifications) instead of read-event (which can't).
+
+(defun xterm-translate-focus-in (_prompt)
+ (setf (terminal-parameter nil 'tty-focus-state) 'focused)
+ (funcall after-focus-change-function)
+ [])
+
+(defun xterm-translate-focus-out (_prompt)
+ (setf (terminal-parameter nil 'tty-focus-state) 'defocused)
+ (funcall after-focus-change-function)
+ [])
+
+(defun xterm--suspend-tty-function (_tty)
+ ;; We can't know what happens to the tty after we're suspended
+ (setf (terminal-parameter nil 'tty-focus-state) nil)
+ (funcall after-focus-change-function))
+
+;; Similarly, we want to transparently slurp the entirety of a
+;; bracketed paste and encapsulate it into a single event. We used to
+;; just slurp up the bracketed paste content in the event handler, but
+;; this strategy can produce unexpected results in a caller manually
+;; looping on read-key and buffering input for later processing.
+
+(defun xterm-translate-bracketed-paste (_prompt)
+ (vector (list 'xterm-paste (xterm--pasted-text))))
+
(defvar xterm-rxvt-function-map
(let ((map (make-sparse-keymap)))
(define-key map "\e[2~" [insert])
@@ -127,9 +166,15 @@ Return the pasted text as a string."
(define-key map "\e[13~" [f3])
(define-key map "\e[14~" [f4])
- ;; Recognize the start of a bracketed paste sequence. The handler
- ;; internally recognizes the end.
- (define-key map "\e[200~" [xterm-paste])
+ ;; Recognize the start of a bracketed paste sequence.
+ ;; The translation function internally recognizes the end.
+ (define-key map "\e[200~" #'xterm-translate-bracketed-paste)
+
+ ;; These translation functions actually call the focus handlers
+ ;; internally and return an empty sequence, causing us to go on to
+ ;; read the next event.
+ (define-key map "\e[I" #'xterm-translate-focus-in)
+ (define-key map "\e[O" #'xterm-translate-focus-out)
map)
"Keymap of escape sequences, shared between xterm and rxvt support.")
@@ -634,7 +679,7 @@ Return the pasted text as a string."
(let ((str "")
chr)
;; The reply should be: \e ] 11 ; rgb: NUMBER1 / NUMBER2 / NUMBER3 \e \\
- (while (and (setq chr (read-event nil nil 2)) (not (equal chr ?\\)))
+ (while (and (setq chr (xterm--read-event-for-query)) (not (equal chr ?\\)))
(setq str (concat str (string chr))))
(when (string-match
"rgb:\\([a-f0-9]+\\)/\\([a-f0-9]+\\)/\\([a-f0-9]+\\)" str)
@@ -662,7 +707,7 @@ Return the pasted text as a string."
;; respond to this escape sequence. RMS' opinion was to remove
;; it completely. That might be right, but let's first try to
;; see if by using a longer timeout we get rid of most issues.
- (while (and (setq chr (read-event nil nil 2)) (not (equal chr ?c)))
+ (while (and (setq chr (xterm--read-event-for-query)) (not (equal chr ?c)))
(setq str (concat str (string chr))))
;; Since xterm-280, the terminal type (NUMBER1) is now 41 instead of 0.
(when (string-match "\\([0-9]+\\);\\([0-9]+\\);0" str)
@@ -712,6 +757,24 @@ Return the pasted text as a string."
"Seconds to wait for an answer from the terminal.
Can be nil to mean \"no timeout\".")
+(defvar xterm-query-redisplay-timeout 0.2
+ "Seconds to wait before allowing redisplay during terminal
+ query." )
+
+(defun xterm--read-event-for-query ()
+ "Like read-event, but inhibit redisplay.
+
+By not redisplaying right away for xterm queries, we can avoid
+unsightly flashing during initialization. Give up and redisplay
+anyway if we've been waiting a little while."
+ (let ((start-time (float-time)))
+ (or (let ((inhibit-redisplay t))
+ (read-event nil nil xterm-query-redisplay-timeout))
+ (read-event nil nil
+ (and xterm-query-timeout
+ (max 0 (+ start-time xterm-query-timeout
+ (- (float-time)))))))))
+
(defun xterm--query (query handlers &optional no-async)
"Send QUERY string to the terminal and watch for a response.
HANDLERS is an alist with elements of the form (STRING . FUNCTION).
@@ -744,7 +807,7 @@ We run the first FUNCTION whose STRING matches the input events."
(let ((handler (pop handlers))
(i 0))
(while (and (< i (length (car handler)))
- (let ((evt (read-event nil nil xterm-query-timeout)))
+ (let ((evt (xterm--read-event-for-query)))
(if (and (null evt) (= i 0) (not no-async))
;; Timeout on the first event: fallback on async.
(progn
@@ -807,9 +870,13 @@ We run the first FUNCTION whose STRING matches the input events."
(when (memq 'setSelection xterm-extra-capabilities)
(xterm--init-activate-set-selection)))
+ (when xterm-set-window-title
+ (xterm--init-frame-title))
;; Unconditionally enable bracketed paste mode: terminals that don't
;; support it just ignore the sequence.
(xterm--init-bracketed-paste-mode)
+ ;; We likewise unconditionally enable support for focus tracking.
+ (xterm--init-focus-tracking)
(run-hooks 'terminal-init-xterm-hook))
@@ -825,6 +892,12 @@ We run the first FUNCTION whose STRING matches the input events."
(push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings))
(push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings)))
+(defun xterm--init-focus-tracking ()
+ "Terminal initialization for focus tracking mode."
+ (send-string-to-terminal "\e[?1004h")
+ (push "\e[?1004l" (terminal-parameter nil 'tty-mode-reset-strings))
+ (push "\e[?1004h" (terminal-parameter nil 'tty-mode-set-strings)))
+
(defun xterm--init-activate-get-selection ()
"Terminal initialization for `gui-get-selection'."
(set-terminal-parameter nil 'xterm--get-selection t))
@@ -833,6 +906,34 @@ We run the first FUNCTION whose STRING matches the input events."
"Terminal initialization for `gui-set-selection'."
(set-terminal-parameter nil 'xterm--set-selection t))
+(defun xterm--init-frame-title ()
+ "Terminal initialization for XTerm frame titles."
+ (xterm-set-window-title)
+ (add-hook 'after-make-frame-functions 'xterm-set-window-title-flag)
+ (add-hook 'window-configuration-change-hook 'xterm-unset-window-title-flag)
+ (add-hook 'post-command-hook 'xterm-set-window-title)
+ (add-hook 'minibuffer-exit-hook 'xterm-set-window-title))
+
+(defvar xterm-window-title-flag nil
+ "Whether a new frame has been created, calling for a title update.")
+
+(defun xterm-set-window-title-flag (_frame)
+ "Set `xterm-window-title-flag'.
+See `xterm--init-frame-title'"
+ (setq xterm-window-title-flag t))
+
+(defun xterm-unset-window-title-flag ()
+ (when xterm-window-title-flag
+ (setq xterm-window-title-flag nil)
+ (xterm-set-window-title)))
+
+(defun xterm-set-window-title (&optional terminal)
+ "Set the window title of the Xterm TERMINAL.
+The title is constructed from `frame-title-format'."
+ (send-string-to-terminal
+ (format "\e]2;%s\a" (format-mode-line frame-title-format))
+ terminal))
+
(defun xterm--selection-char (type)
(pcase type
('PRIMARY "p")
@@ -908,7 +1009,7 @@ hitting screen's max DCS length."
(defun xterm-rgb-convert-to-16bit (prim)
"Convert an 8-bit primary color value PRIM to a corresponding 16-bit value."
- (logior prim (lsh prim 8)))
+ (logior prim (ash prim 8)))
(defun xterm-register-default-colors (colors)
"Register the default set of colors for xterm or compatible emulator.