]> git.eshelyaron.com Git - emacs.git/commitdiff
Disable on-screen keyboard outside fields in Custom buffers
authorPo Lu <luangruo@yahoo.com>
Wed, 1 May 2024 07:57:29 +0000 (15:57 +0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:30:34 +0000 (18:30 +0200)
* lisp/cus-edit.el (Custom-display-on-screen-keyboard-p): New
function.
(Custom-mode): Install it as the touch-screen-keyboard-function.

* lisp/touch-screen.el (touch-screen-keyboard-function): New
variable.
(touch-screen-handle-point-up): Don't special-case the splash
screen with respect to touch-screen-display-keyboard in keeping
with user feedback.

(cherry picked from commit 54dbd8b4fa2253682d044cc53bd658e361bff8a0)

lisp/cus-edit.el
lisp/touch-screen.el

index 4fff34e6130627bd05b18962d74ffc5931f77cc1..32cfef6bae48a1eba6fdf9a75a2aa96cb7131c93 100644 (file)
@@ -5388,6 +5388,12 @@ If several parents are listed, go to the first of them."
     (setq-local widget-link-suffix ""))
   (setq show-trailing-whitespace nil))
 
+(defvar touch-screen-keyboard-function) ; In touch-screen.el.
+
+(defun Custom-display-on-screen-keyboard-p ()
+  "Return whether it is okay to display the virtual keyboard at point."
+  (get-char-property (point) 'field))
+
 (define-derived-mode Custom-mode nil "Custom"
   "Major mode for editing customization buffers.
 
@@ -5426,6 +5432,8 @@ if that value is non-nil."
               custom--hidden-state 'hidden)
   (setq-local revert-buffer-function #'custom--revert-buffer)
   (setq-local text-conversion-style 'action)
+  (setq-local touch-screen-keyboard-function
+              #'Custom-display-on-screen-keyboard-p)
   (make-local-variable 'custom-options)
   (make-local-variable 'custom-local-buffer)
   (custom--initialize-widget-variables)
index e44b266a617cc81d405b3f2117bd370a2a03184a..ca02ca3caf61d90d9c1b11d9fe7018c0ba53413c 100644 (file)
@@ -154,6 +154,17 @@ selected.")
 Used in an attempt to keep this word selected during later
 dragging.")
 
+;; Should this variable be documented?
+(defvar-local touch-screen-keyboard-function nil
+  "Function that decides whether to display the on screen keyboard.
+If set, this function is called with point set to the position of the
+tap involved when a command listed in `touch-screen-set-point-commands'
+is about to be invoked in response to a tap, the current buffer, or the
+text beneath point (in the case of an `inhibit-read-only' text
+property), is not read only, and `touch-screen-display-keyboard' is nil,
+and should return non-nil if it is appropriate to display the on-screen
+keyboard afterwards.")
+
 \f
 
 ;;; Scroll gesture.
@@ -1374,18 +1385,22 @@ is not read-only."
                              ;; caller of `read-key-sequence' such as
                              ;; `describe-key'.
                              (throw 'input-event event)
-                           (if (and (or (not buffer-read-only)
-                                        ;; Display the on screen
-                                        ;; keyboard even if just the
-                                        ;; text under point is not
-                                        ;; read-only.
-                                        (get-text-property point
-                                                           'inhibit-read-only)
-                                        touch-screen-display-keyboard)
-                                    ;; Detect the splash screen and
-                                    ;; avoid displaying the on screen
-                                    ;; keyboard there.
-                                    (not (equal (buffer-name) "*GNU Emacs*")))
+                           (if (or touch-screen-display-keyboard
+                                   (and (or (not buffer-read-only)
+                                            inhibit-read-only
+                                            ;; Display the on screen
+                                            ;; keyboard even if just the
+                                            ;; text under point is not
+                                            ;; read-only.
+                                            (get-text-property
+                                             point 'inhibit-read-only))
+                                        ;; If the major mode has defined
+                                        ;; bespoke criteria for
+                                        ;; displaying the on screen
+                                        ;; keyboard, consult it here.
+                                        (or (not touch-screen-keyboard-function)
+                                            (funcall
+                                             touch-screen-keyboard-function))))
                                ;; Once the on-screen keyboard has been
                                ;; opened, add
                                ;; `touch-screen-window-selection-changed'