Commit 8f6e4798 authored by Alexander Gramiak's avatar Alexander Gramiak

Use display-graphic-p and display-multi-frame-p in more cases

* lisp/disp-table.el:
* lisp/faces.el:
* lisp/frame.el:
* lisp/info.el (Info-fontify-node):
* lisp/window.el (handle-select-window): Use display-graphic-p and
  display-multi-frame-p instead of explicit memq calls.
parent 08235af3
...@@ -175,8 +175,8 @@ in the default way after this call." ...@@ -175,8 +175,8 @@ in the default way after this call."
(defun standard-display-g1 (c sc) (defun standard-display-g1 (c sc)
"Display character C as character SC in the g1 character set. "Display character C as character SC in the g1 character set.
This function assumes that your terminal uses the SO/SI characters; This function assumes that your terminal uses the SO/SI characters;
it is meaningless for an X frame." it is meaningless for a graphical frame."
(if (memq window-system '(x w32 ns)) (if (display-graphic-p)
(error "Cannot use string glyphs in a windowing system")) (error "Cannot use string glyphs in a windowing system"))
(or standard-display-table (or standard-display-table
(setq standard-display-table (make-display-table))) (setq standard-display-table (make-display-table)))
...@@ -186,9 +186,9 @@ it is meaningless for an X frame." ...@@ -186,9 +186,9 @@ it is meaningless for an X frame."
;;;###autoload ;;;###autoload
(defun standard-display-graphic (c gc) (defun standard-display-graphic (c gc)
"Display character C as character GC in graphics character set. "Display character C as character GC in graphics character set.
This function assumes VT100-compatible escapes; it is meaningless for an This function assumes VT100-compatible escapes; it is meaningless
X frame." for a graphical frame."
(if (memq window-system '(x w32 ns)) (if (display-graphic-p)
(error "Cannot use string glyphs in a windowing system")) (error "Cannot use string glyphs in a windowing system"))
(or standard-display-table (or standard-display-table
(setq standard-display-table (make-display-table))) (setq standard-display-table (make-display-table)))
...@@ -276,7 +276,7 @@ in `.emacs'." ...@@ -276,7 +276,7 @@ in `.emacs'."
(progn (progn
(standard-display-default (standard-display-default
(unibyte-char-to-multibyte 160) (unibyte-char-to-multibyte 255)) (unibyte-char-to-multibyte 160) (unibyte-char-to-multibyte 255))
(unless (or (memq window-system '(x w32 ns))) (unless (display-graphic-p)
(and (terminal-coding-system) (and (terminal-coding-system)
(set-terminal-coding-system nil)))) (set-terminal-coding-system nil))))
...@@ -289,7 +289,7 @@ in `.emacs'." ...@@ -289,7 +289,7 @@ in `.emacs'."
;; unless some other has been specified. ;; unless some other has been specified.
(if (equal current-language-environment "English") (if (equal current-language-environment "English")
(set-language-environment "latin-1")) (set-language-environment "latin-1"))
(unless (or noninteractive (memq window-system '(x w32 ns))) (unless (or noninteractive (display-graphic-p))
;; Send those codes literally to a character-based terminal. ;; Send those codes literally to a character-based terminal.
;; If we are using single-byte characters, ;; If we are using single-byte characters,
;; it doesn't matter which coding system we use. ;; it doesn't matter which coding system we use.
......
...@@ -55,6 +55,7 @@ This means to treat a terminal of type TYPE as if it were of type ALIAS." ...@@ -55,6 +55,7 @@ This means to treat a terminal of type TYPE as if it were of type ALIAS."
:group 'terminals :group 'terminals
:version "25.1") :version "25.1")
(declare-function display-graphic-p "frame" (&optional display))
(declare-function xw-defined-colors "term/common-win" (&optional frame)) (declare-function xw-defined-colors "term/common-win" (&optional frame))
(defvar help-xref-stack-item) (defvar help-xref-stack-item)
...@@ -1239,7 +1240,7 @@ of a global face. Value is the new attribute value." ...@@ -1239,7 +1240,7 @@ of a global face. Value is the new attribute value."
;; explicitly in VALID, using color approximation code ;; explicitly in VALID, using color approximation code
;; in tty-colors.el. ;; in tty-colors.el.
(when (and (memq attribute '(:foreground :background)) (when (and (memq attribute '(:foreground :background))
(not (memq (window-system frame) '(x w32 ns))) (not (display-graphic-p frame))
(not (member new-value (not (member new-value
'("unspecified" '("unspecified"
"unspecified-fg" "unspecified-bg")))) "unspecified-fg" "unspecified-bg"))))
...@@ -1833,7 +1834,7 @@ The argument FRAME specifies which frame to try. ...@@ -1833,7 +1834,7 @@ The argument FRAME specifies which frame to try.
The value may be different for frames on different display types. The value may be different for frames on different display types.
If FRAME doesn't support colors, the value is nil. If FRAME doesn't support colors, the value is nil.
If FRAME is nil, that stands for the selected frame." If FRAME is nil, that stands for the selected frame."
(if (memq (framep (or frame (selected-frame))) '(x w32 ns)) (if (display-graphic-p frame)
(xw-defined-colors frame) (xw-defined-colors frame)
(mapcar 'car (tty-color-alist frame)))) (mapcar 'car (tty-color-alist frame))))
(defalias 'x-defined-colors 'defined-colors) (defalias 'x-defined-colors 'defined-colors)
...@@ -1877,7 +1878,7 @@ or one of the strings \"unspecified-fg\" or \"unspecified-bg\". ...@@ -1877,7 +1878,7 @@ or one of the strings \"unspecified-fg\" or \"unspecified-bg\".
If FRAME is omitted or nil, use the selected frame." If FRAME is omitted or nil, use the selected frame."
(unless (member color '(unspecified "unspecified-bg" "unspecified-fg")) (unless (member color '(unspecified "unspecified-bg" "unspecified-fg"))
(if (member (framep (or frame (selected-frame))) '(x w32 ns)) (if (display-graphic-p frame)
(xw-color-defined-p color frame) (xw-color-defined-p color frame)
(numberp (tty-color-translate color frame))))) (numberp (tty-color-translate color frame)))))
(defalias 'x-color-defined-p 'color-defined-p) (defalias 'x-color-defined-p 'color-defined-p)
...@@ -1903,7 +1904,7 @@ return value is nil." ...@@ -1903,7 +1904,7 @@ return value is nil."
(cond (cond
((member color '(unspecified "unspecified-fg" "unspecified-bg")) ((member color '(unspecified "unspecified-fg" "unspecified-bg"))
nil) nil)
((memq (framep (or frame (selected-frame))) '(x w32 ns)) ((display-graphic-p frame)
(xw-color-values color frame)) (xw-color-values color frame))
(t (t
(tty-color-values color frame)))) (tty-color-values color frame))))
...@@ -1917,7 +1918,7 @@ return value is nil." ...@@ -1917,7 +1918,7 @@ return value is nil."
The optional argument DISPLAY specifies which display to ask about. The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string). DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display." If omitted or nil, that stands for the selected frame's display."
(if (memq (framep-on-display display) '(x w32 ns)) (if (display-graphic-p display)
(xw-display-color-p display) (xw-display-color-p display)
(tty-display-color-p display))) (tty-display-color-p display)))
(defalias 'x-display-color-p 'display-color-p) (defalias 'x-display-color-p 'display-color-p)
...@@ -1928,12 +1929,9 @@ If omitted or nil, that stands for the selected frame's display." ...@@ -1928,12 +1929,9 @@ If omitted or nil, that stands for the selected frame's display."
"Return non-nil if frames on DISPLAY can display shades of gray. "Return non-nil if frames on DISPLAY can display shades of gray.
DISPLAY should be either a frame or a display name (a string). DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display." If omitted or nil, that stands for the selected frame's display."
(let ((frame-type (framep-on-display display))) (if (display-graphic-p display)
(cond (x-display-grayscale-p display)
((memq frame-type '(x w32 ns)) (> (tty-color-gray-shades display) 2)))
(x-display-grayscale-p display))
(t
(> (tty-color-gray-shades display) 2)))))
(defun read-color (&optional prompt convert-to-RGB allow-empty-name msg) (defun read-color (&optional prompt convert-to-RGB allow-empty-name msg)
"Read a color name or RGB triplet. "Read a color name or RGB triplet.
......
...@@ -974,7 +974,7 @@ recently selected windows nor the buffer list." ...@@ -974,7 +974,7 @@ recently selected windows nor the buffer list."
(select-frame frame norecord) (select-frame frame norecord)
(raise-frame frame) (raise-frame frame)
;; Ensure, if possible, that FRAME gets input focus. ;; Ensure, if possible, that FRAME gets input focus.
(when (memq (window-system frame) '(x w32 ns)) (when (display-multi-frame-p frame)
(x-focus-frame frame)) (x-focus-frame frame))
;; Move mouse cursor if necessary. ;; Move mouse cursor if necessary.
(cond (cond
...@@ -1027,16 +1027,15 @@ that variable should be nil." ...@@ -1027,16 +1027,15 @@ that variable should be nil."
"Do whatever is right to suspend the current frame. "Do whatever is right to suspend the current frame.
Calls `suspend-emacs' if invoked from the controlling tty device, Calls `suspend-emacs' if invoked from the controlling tty device,
`suspend-tty' from a secondary tty device, and `suspend-tty' from a secondary tty device, and
`iconify-or-deiconify-frame' from an X frame." `iconify-or-deiconify-frame' from a graphical frame."
(interactive) (interactive)
(let ((type (framep (selected-frame)))) (cond
(cond ((display-multi-frame-p) (iconify-or-deiconify-frame))
((memq type '(x ns w32)) (iconify-or-deiconify-frame)) ((eq (framep (selected-frame)) t)
((eq type t) (if (controlling-tty-p)
(if (controlling-tty-p) (suspend-emacs)
(suspend-emacs) (suspend-tty)))
(suspend-tty))) (t (suspend-emacs))))
(t (suspend-emacs)))))
(defun make-frame-names-alist () (defun make-frame-names-alist ()
;; Only consider the frames on the same display. ;; Only consider the frames on the same display.
......
...@@ -4768,7 +4768,7 @@ first line or header line, and for breadcrumb links.") ...@@ -4768,7 +4768,7 @@ first line or header line, and for breadcrumb links.")
;; This is a serious problem for trying to handle multiple ;; This is a serious problem for trying to handle multiple
;; frame types at once. We want this text to be invisible ;; frame types at once. We want this text to be invisible
;; on frames that can display the font above. ;; on frames that can display the font above.
(when (memq (framep (selected-frame)) '(x pc w32 ns)) (when (display-multi-font-p)
(add-text-properties (1- (match-beginning 2)) (match-end 2) (add-text-properties (1- (match-beginning 2)) (match-end 2)
'(invisible t front-sticky nil rear-nonsticky t)))))) '(invisible t front-sticky nil rear-nonsticky t))))))
......
...@@ -9314,6 +9314,8 @@ is active. This function is run by `mouse-autoselect-window-timer'." ...@@ -9314,6 +9314,8 @@ is active. This function is run by `mouse-autoselect-window-timer'."
;; autoselection. ;; autoselection.
(mouse-autoselect-window-start mouse-position window))))) (mouse-autoselect-window-start mouse-position window)))))
(declare-function display-multi-frame-p "frame" (&optional display))
(defun handle-select-window (event) (defun handle-select-window (event)
"Handle select-window events." "Handle select-window events."
(interactive "^e") (interactive "^e")
...@@ -9351,7 +9353,7 @@ is active. This function is run by `mouse-autoselect-window-timer'." ...@@ -9351,7 +9353,7 @@ is active. This function is run by `mouse-autoselect-window-timer'."
;; we might get two windows with an active cursor. ;; we might get two windows with an active cursor.
(select-window window) (select-window window)
(cond (cond
((or (not (memq (window-system frame) '(x w32 ns))) ((or (not (display-multi-frame-p))
(not focus-follows-mouse) (not focus-follows-mouse)
;; Focus FRAME if it's either a child frame or an ancestor ;; Focus FRAME if it's either a child frame or an ancestor
;; of the frame switched from. ;; of the frame switched from.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment