From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Newsgroups: gmane.emacs.bugs Subject: bug#35058: [PATCH] Use display-graphic-p in more cases Date: Fri, 05 Apr 2019 10:35:33 -0600 Message-ID: <87k1g8csve.fsf@gmail.com> References: <8736n4ndav.fsf@gmail.com> <83tvfjgilm.fsf@gnu.org> <875zry9x94.fsf@gmail.com> <83a7hagv11.fsf@gnu.org> <87d0m4pcca.fsf@gmail.com> <83ef6kfhjf.fsf@gnu.org> <878swsp9wh.fsf@gmail.com> <838swsfdzb.fsf@gnu.org> <87r2ajbrhd.fsf@gmail.com> <83pnq3ejxe.fsf@gnu.org> <87h8be7s3t.fsf@gmail.com> <838swodi54.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="174229"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 35058@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 05 18:37:30 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCRqK-000j8n-8m for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Apr 2019 18:37:29 +0200 Original-Received: from localhost ([127.0.0.1]:44508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCRqJ-000788-6K for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Apr 2019 12:37:27 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCRq7-00074u-9v for bug-gnu-emacs@gnu.org; Fri, 05 Apr 2019 12:37:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCRq2-0007QH-LB for bug-gnu-emacs@gnu.org; Fri, 05 Apr 2019 12:37:14 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hCRow-0006GN-Mp for bug-gnu-emacs@gnu.org; Fri, 05 Apr 2019 12:37:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hCRow-0003yO-En for bug-gnu-emacs@gnu.org; Fri, 05 Apr 2019 12:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Apr 2019 16:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35058 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35058-submit@debbugs.gnu.org id=B35058.155448214815248 (code B ref 35058); Fri, 05 Apr 2019 16:36:02 +0000 Original-Received: (at 35058) by debbugs.gnu.org; 5 Apr 2019 16:35:48 +0000 Original-Received: from localhost ([127.0.0.1]:46231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCRoh-0003xp-Mc for submit@debbugs.gnu.org; Fri, 05 Apr 2019 12:35:48 -0400 Original-Received: from mail-pl1-f169.google.com ([209.85.214.169]:42970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCRof-0003xc-Hg for 35058@debbugs.gnu.org; Fri, 05 Apr 2019 12:35:46 -0400 Original-Received: by mail-pl1-f169.google.com with SMTP id cv12so3300505plb.9 for <35058@debbugs.gnu.org>; Fri, 05 Apr 2019 09:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=shq9Oi2moqm9+O4KgjnWMnEESw3kziJDnuG/7ZOibLw=; b=AWDw7k6aMGod17Vox3Hg4SinHpYOZqzJ1sY01T8/vrYTY1D7ervEB567ndEeFbYa8v x3RryFHfsNxqydeihKZW4CWIBi0/yl0w41ssthlgBMTkK24mVfEqg9VIkfIjuS2AW5Vs IZHOfO7BX2rwbNnp8lqfie2QURByLDqaUPVDS+6BtpH5vbukuqmzqMJxW9/xRthugCbJ RrNEZRjE4BqotyqGlNFK3I2EQwSJVFiXP6puCBw697U/7Mlz2rxx/3fbbPlI7vjWzQYd Z8Irc6UELPiLTOcET0oSrvqJV0jD1vl/82B/LUQLb4ZpQ/0+pZYuVoPatgSKAxiQPDES accg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=shq9Oi2moqm9+O4KgjnWMnEESw3kziJDnuG/7ZOibLw=; b=GqD5ng8no3WcWm8O/6KybbecMpz7Huot0ZChTx3ncijlsueGGhaiQE9+imvKWyWJAz VOK+V5hwAL17s3ILEk9mITDdym4Zmjw+wuSbnBYZKqeC67S+88qCOptcwI8hzcbSAz5P 2gUsyTeAL/0Iaxg8iwPBp58AS7VcKu44DhUlwoaea3JmjMLzz0qs98NFYD51xRnMdYW+ BjrbFCpqnCuKQyj1XivmIrrxxtzaWQGP9eOI6mil/4ulDp44C41izqdM/gzYToKUueFH yiUjE22KDj6gRbHBWkHNyJ7tG4qG9wyi7j/xqNxkT1wm7qbMTxcULownBWjkDp8R0ORl G+kQ== X-Gm-Message-State: APjAAAVRPRzM7EypXlR2ch+tSUs+Z16Z00PRDy1TJa2Pk5qhJxSVBKQA +okxwTduML4NDnl8JQmOODWtp5rC X-Google-Smtp-Source: APXvYqxdIHKP6anmJi2JoUhywTRHRVoRwMyVAacXIm09rpEjKJ0Ck+MmHTKj04jJKYtZf1/Xz/7/cg== X-Received: by 2002:a17:902:2947:: with SMTP id g65mr13640987plb.258.1554482138901; Fri, 05 Apr 2019 09:35:38 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id u62sm45800003pfa.124.2019.04.05.09.35.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Apr 2019 09:35:37 -0700 (PDT) In-Reply-To: <838swodi54.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 05 Apr 2019 10:29:43 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157228 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> --- a/lisp/faces.el >> +++ b/lisp/faces.el >> @@ -55,6 +55,7 @@ term-file-aliases >> :group 'terminals >> :version "25.1") >> >> +(declare-function display-graphic-p "frame" (&optional display)) > > Did you try to bootstrap with this? frame.el is loaded after > faces.el. (There are more similar declarations in the patches with > the same issues.) Yes, I successfully bootstrapped, and the loading issue is why I added the declare-function calls. It seems to work fine. My usage of display-graphic-p appears to be different compared to the one in face-spec-reset-face, which apparently is run during bootstrap. >> --- a/lisp/emulation/cua-base.el >> +++ b/lisp/emulation/cua-base.el >> @@ -427,7 +427,7 @@ cua-rectangle-mark-key >> >> (defcustom cua-rectangle-modifier-key 'meta >> "Modifier key used for rectangle commands bindings. >> -On non-window systems, always use the meta modifier. >> +On non-window systems, use `cua-rectangle-terminal-modifier-key'. >> Must be set prior to enabling CUA." >> :type '(choice (const :tag "Meta key" meta) >> (const :tag "Alt key" alt) >> @@ -435,6 +435,16 @@ cua-rectangle-modifier-key >> (const :tag "Super key" super)) >> :group 'cua) >> >> +(defcustom cua-rectangle-terminal-modifier-key 'meta >> + "Modifier key used for rectangle commands bindings in terminals. >> +Must be set prior to enabling CUA." >> + :type '(choice (const :tag "Meta key" meta) >> + (const :tag "Alt key" alt) >> + (const :tag "Hyper key" hyper) >> + (const :tag "Super key" super)) >> + :group 'cua >> + :version "27.1") > > This change should be called out in NEWS. > > The new display-* predicates should probably also be mentioned in > NEWS. Okay, here's a new set of patches (excluding the same logb patch). --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-display-graphic-p-and-display-multi-frame-p-in-m.patch >From 3f476d5e827fc1e94a18101604838923a2a686c7 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Wed, 3 Apr 2019 13:57:16 -0600 Subject: [PATCH 1/4] 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. --- lisp/disp-table.el | 14 +++++++------- lisp/faces.el | 20 +++++++++----------- lisp/frame.el | 19 +++++++++---------- lisp/info.el | 2 +- lisp/window.el | 4 +++- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/lisp/disp-table.el b/lisp/disp-table.el index 476c0cb986..4a59750677 100644 --- a/lisp/disp-table.el +++ b/lisp/disp-table.el @@ -175,8 +175,8 @@ standard-display-ascii (defun standard-display-g1 (c sc) "Display character C as character SC in the g1 character set. This function assumes that your terminal uses the SO/SI characters; -it is meaningless for an X frame." - (if (memq window-system '(x w32 ns)) +it is meaningless for a graphical frame." + (if (display-graphic-p) (error "Cannot use string glyphs in a windowing system")) (or standard-display-table (setq standard-display-table (make-display-table))) @@ -186,9 +186,9 @@ standard-display-g1 ;;;###autoload (defun standard-display-graphic (c gc) "Display character C as character GC in graphics character set. -This function assumes VT100-compatible escapes; it is meaningless for an -X frame." - (if (memq window-system '(x w32 ns)) +This function assumes VT100-compatible escapes; it is meaningless +for a graphical frame." + (if (display-graphic-p) (error "Cannot use string glyphs in a windowing system")) (or standard-display-table (setq standard-display-table (make-display-table))) @@ -276,7 +276,7 @@ standard-display-european (progn (standard-display-default (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) (set-terminal-coding-system nil)))) @@ -289,7 +289,7 @@ standard-display-european ;; unless some other has been specified. (if (equal current-language-environment "English") (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. ;; If we are using single-byte characters, ;; it doesn't matter which coding system we use. diff --git a/lisp/faces.el b/lisp/faces.el index ab6c384c80..fa526c3506 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -55,6 +55,7 @@ term-file-aliases :group 'terminals :version "25.1") +(declare-function display-graphic-p "frame" (&optional display)) (declare-function xw-defined-colors "term/common-win" (&optional frame)) (defvar help-xref-stack-item) @@ -1239,7 +1240,7 @@ read-face-attribute ;; explicitly in VALID, using color approximation code ;; in tty-colors.el. (when (and (memq attribute '(:foreground :background)) - (not (memq (window-system frame) '(x w32 ns))) + (not (display-graphic-p frame)) (not (member new-value '("unspecified" "unspecified-fg" "unspecified-bg")))) @@ -1833,7 +1834,7 @@ defined-colors The value may be different for frames on different display types. If FRAME doesn't support colors, the value is nil. 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) (mapcar 'car (tty-color-alist frame)))) (defalias 'x-defined-colors 'defined-colors) @@ -1877,7 +1878,7 @@ color-defined-p If FRAME is omitted or nil, use the selected frame." (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) (numberp (tty-color-translate color frame))))) (defalias 'x-color-defined-p 'color-defined-p) @@ -1903,7 +1904,7 @@ color-values (cond ((member color '(unspecified "unspecified-fg" "unspecified-bg")) nil) - ((memq (framep (or frame (selected-frame))) '(x w32 ns)) + ((display-graphic-p frame) (xw-color-values color frame)) (t (tty-color-values color frame)))) @@ -1917,7 +1918,7 @@ display-color-p 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." - (if (memq (framep-on-display display) '(x w32 ns)) + (if (display-graphic-p display) (xw-display-color-p display) (tty-display-color-p display))) (defalias 'x-display-color-p 'display-color-p) @@ -1928,12 +1929,9 @@ display-grayscale-p "Return non-nil if frames on DISPLAY can display shades of gray. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display." - (let ((frame-type (framep-on-display display))) - (cond - ((memq frame-type '(x w32 ns)) - (x-display-grayscale-p display)) - (t - (> (tty-color-gray-shades display) 2))))) + (if (display-graphic-p display) + (x-display-grayscale-p display) + (> (tty-color-gray-shades display) 2))) (defun read-color (&optional prompt convert-to-RGB allow-empty-name msg) "Read a color name or RGB triplet. diff --git a/lisp/frame.el b/lisp/frame.el index 6cb1247372..acf6a46716 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -974,7 +974,7 @@ select-frame-set-input-focus (select-frame frame norecord) (raise-frame frame) ;; 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)) ;; Move mouse cursor if necessary. (cond @@ -1027,16 +1027,15 @@ suspend-frame "Do whatever is right to suspend the current frame. Calls `suspend-emacs' if invoked from the controlling tty device, `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) - (let ((type (framep (selected-frame)))) - (cond - ((memq type '(x ns w32)) (iconify-or-deiconify-frame)) - ((eq type t) - (if (controlling-tty-p) - (suspend-emacs) - (suspend-tty))) - (t (suspend-emacs))))) + (cond + ((display-multi-frame-p) (iconify-or-deiconify-frame)) + ((eq (framep (selected-frame)) t) + (if (controlling-tty-p) + (suspend-emacs) + (suspend-tty))) + (t (suspend-emacs)))) (defun make-frame-names-alist () ;; Only consider the frames on the same display. diff --git a/lisp/info.el b/lisp/info.el index f2a064abb6..f3b413a2f9 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4768,7 +4768,7 @@ Info-fontify-node ;; This is a serious problem for trying to handle multiple ;; frame types at once. We want this text to be invisible ;; 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) '(invisible t front-sticky nil rear-nonsticky t)))))) diff --git a/lisp/window.el b/lisp/window.el index b769be0633..b4f5ac5cc4 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -9314,6 +9314,8 @@ mouse-autoselect-window-select ;; autoselection. (mouse-autoselect-window-start mouse-position window))))) +(declare-function display-multi-frame-p "frame" (&optional display)) + (defun handle-select-window (event) "Handle select-window events." (interactive "^e") @@ -9351,7 +9353,7 @@ handle-select-window ;; we might get two windows with an active cursor. (select-window window) (cond - ((or (not (memq (window-system frame) '(x w32 ns))) + ((or (not (display-multi-frame-p)) (not focus-follows-mouse) ;; Focus FRAME if it's either a child frame or an ancestor ;; of the frame switched from. -- 2.21.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Define-and-use-new-alias-display-blink-cursor-p.patch >From 372299922bbff28d8fe19fffc6c784b390e13402 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Wed, 3 Apr 2019 14:03:42 -0600 Subject: [PATCH 2/4] Define and use new alias display-blink-cursor-p display-graphic-p is not used in this case because it may be possible in the future for terminals to allow control over cursor blinking. For details, see bug#35058. * lisp/frame.el (blink-cursor-mode): Use display-blink-cursor-p. --- lisp/frame.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/frame.el b/lisp/frame.el index acf6a46716..cc8ca49b3b 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1905,6 +1905,7 @@ display-images-p (fboundp 'image-mask-p) (fboundp 'image-size))) +(defalias 'display-blink-cursor-p 'display-graphic-p) (defalias 'display-multi-frame-p 'display-graphic-p) (defalias 'display-multi-font-p 'display-graphic-p) @@ -2545,7 +2546,7 @@ blink-cursor-mode :init-value (not (or noninteractive no-blinking-cursor (eq system-type 'ms-dos) - (not (memq window-system '(x w32 ns))))) + (not (display-blink-cursor-p)))) :initialize 'custom-initialize-delay :group 'cursor :global t -- 2.21.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-Define-and-use-new-procedure-display-symbol-keys-p.patch >From 6d171ce90f42f16f148fae87f083038cc95acf05 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Wed, 3 Apr 2019 14:03:28 -0600 Subject: [PATCH 3/4] Define and use new procedure display-symbol-keys-p * lisp/frame.el (display-symbol-keys-p): Define. * lisp/simple.el (normal-erase-is-backspace-setup-frame): Use eq instead of memq. (normal-erase-is-backspace-mode): Use display-symbol-keys-p. --- etc/NEWS | 5 +++++ lisp/frame.el | 10 ++++++++++ lisp/simple.el | 7 ++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7f6aeab73f..1e64c0f15f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1226,6 +1226,11 @@ the 128...255 range, as expected. This allows to create and parent immediately a minibuffer-only child frame when making a frame. +*** New predicates 'display-blink-cursor-p' and 'display-symbol-keys-p'. +These predicates are to be preferred over 'display-graphic-p' when +testing for blinking cursor capability and the capability to have +symbols (e.g., [return], [tab], [backspace]) as keys respectively. + ** Tabulated List mode +++ diff --git a/lisp/frame.el b/lisp/frame.el index cc8ca49b3b..aa14e87d7b 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1927,6 +1927,16 @@ display-selections-p (t nil)))) +(defun display-symbol-keys-p (&optional display) + "Return non-nil if DISPLAY supports symbol names as keys. +This means that, for example, DISPLAY can differentiate between +the keybinding RET and [return]." + (let ((frame-type (framep-on-display display))) + (or (memq frame-type '(x w32 ns pc)) + ;; MS-DOS and MS-Windows terminals have built-in support for + ;; function (symbol) keys + (memq system-type '(ms-dos windows-nt))))) + (declare-function x-display-screens "xfns.c" (&optional terminal)) (defun display-screens (&optional display) diff --git a/lisp/simple.el b/lisp/simple.el index 306df96766..857e0fc001 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8690,7 +8690,7 @@ normal-erase-is-backspace-setup-frame (and (not noninteractive) (or (memq system-type '(ms-dos windows-nt)) (memq window-system '(w32 ns)) - (and (memq window-system '(x)) + (and (eq window-system 'x) (fboundp 'x-backspace-delete-keys-p) (x-backspace-delete-keys-p)) ;; If the terminal Emacs is running on has erase char @@ -8701,6 +8701,8 @@ normal-erase-is-backspace-setup-frame normal-erase-is-backspace) 1 0))))) +(declare-function display-symbol-keys-p "frame" (&optional display)) + (define-minor-mode normal-erase-is-backspace-mode "Toggle the Erase and Delete mode of the Backspace and Delete keys. @@ -8736,8 +8738,7 @@ normal-erase-is-backspace-mode (let ((enabled (eq 1 (terminal-parameter nil 'normal-erase-is-backspace)))) - (cond ((or (memq window-system '(x w32 ns pc)) - (memq system-type '(ms-dos windows-nt))) + (cond ((display-symbol-keys-p) (let ((bindings '(([M-delete] [M-backspace]) ([C-M-delete] [C-M-backspace]) -- 2.21.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0004-Introduce-new-defcustom-for-terminal-CUA-rectangle-c.patch >From 04766b452e895526f2ca196dad7cf05bab1e61ba Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Wed, 3 Apr 2019 14:06:45 -0600 Subject: [PATCH 4/4] Introduce new defcustom for terminal CUA rectangle commands This allows a user to set a non-meta modifier for their terminal should his/her terminal support it. See bug#35058 for background on this change. * lisp/emulation/cua-base.el (cua-rectangle-terminal-modifier-key): New defcustom. * lisp/emulation/cua-base.el (cua--shift-control-x-prefix): Use new defcustom. --- etc/NEWS | 6 ++++++ lisp/emulation/cua-base.el | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1e64c0f15f..5c62daf2b9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1247,6 +1247,12 @@ near the current column in Tabulated Lists (see variables +++ *** 'text-mode-variant' is now obsolete, use 'derived-mode-p' instead. +** CUA mode + +*** New defcustom 'cua-rectangle-terminal-modifier-key' +This defcustom is used instead of forcing the modifier key to +'meta in a terminal frame. + * New Modes and Packages in Emacs 27.1 diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 302ef12386..105e1ab43d 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el @@ -427,7 +427,7 @@ cua-rectangle-mark-key (defcustom cua-rectangle-modifier-key 'meta "Modifier key used for rectangle commands bindings. -On non-window systems, always use the meta modifier. +On non-window systems, use `cua-rectangle-terminal-modifier-key'. Must be set prior to enabling CUA." :type '(choice (const :tag "Meta key" meta) (const :tag "Alt key" alt) @@ -435,6 +435,16 @@ cua-rectangle-modifier-key (const :tag "Super key" super)) :group 'cua) +(defcustom cua-rectangle-terminal-modifier-key 'meta + "Modifier key used for rectangle commands bindings in terminals. +Must be set prior to enabling CUA." + :type '(choice (const :tag "Meta key" meta) + (const :tag "Alt key" alt) + (const :tag "Hyper key" hyper) + (const :tag "Super key" super)) + :group 'cua + :version "27.1") + (defcustom cua-enable-rectangle-auto-help t "If non-nil, automatically show help for region, rectangle and global mark." :type 'boolean @@ -1237,10 +1247,9 @@ cua--shift-control-x-prefix (defun cua--init-keymaps () ;; Cache actual rectangle modifier key. (setq cua--rectangle-modifier-key - (if (and cua-rectangle-modifier-key - (memq window-system '(x))) - cua-rectangle-modifier-key - 'meta)) + (if (eq (framep (selected-frame)) t) + cua-rectangle-terminal-modifier-key + cua-rectangle-modifier-key)) ;; C-return always toggles rectangle mark (define-key cua-global-keymap cua-rectangle-mark-key 'cua-set-rectangle-mark) (unless (eq cua--rectangle-modifier-key 'meta) -- 2.21.0 --=-=-=--