Skip to content

Instantly share code, notes, and snippets.

@takaxp
Last active August 20, 2022 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaxp/ed9ae4a736628156a28fddb20a2fe0d7 to your computer and use it in GitHub Desktop.
Save takaxp/ed9ae4a736628156a28fddb20a2fe0d7 to your computer and use it in GitHub Desktop.
A custom patch for EMP build
*** emacs-28.1_origin/lisp/term/mac-win.el 2022-08-20 23:56:38.000000000 +0900
--- emacs-28.1/lisp/term/mac-win.el 2022-08-21 00:24:21.000000000 +0900
***************
*** 1362,1369 ****
--- 1362,1380 ----
(2 . mac-ts-selected-converted-text)) ; NSUnderlineStyleThick
"Alist of NSUnderlineStyle vs Emacs face in marked text.")
+ (defvar mac-win-debug-log nil)
+ (defvar mac-win-ime-cursor-type nil)
+ (defvar mac-win-default-background-echo-area nil)
+ (defun mac-min--minibuffer-setup ()
+ (let ((bg (face-background 'default)))
+ (setq-local face-remapping-alist
+ `((mac-ts-converted-text :background ,bg)
+ (mac-ts-selected-converted-text :background ,bg)))))
+
(defun mac-text-input-set-marked-text (event)
(interactive "e")
+ (when mac-win-debug-log
+ (message "mac-text-input-set-marked-text: %s" event))
(let* ((ae (mac-event-ae event))
(text (cdr (mac-ae-parameter ae)))
(selected-range (cdr (mac-ae-parameter ae "selectedRange")))
***************
*** 1373,1378 ****
--- 1384,1393 ----
(or (cdr (assq (car script-language)
mac-script-code-coding-systems))
'mac-roman))))
+ (when mac-win-ime-cursor-type
+ (if (and (= (car selected-range) 0) (> (cdr selected-range) 0))
+ (setq cursor-type '(bar . 0))
+ (setq cursor-type mac-win-ime-cursor-type)))
(let ((use-echo-area
(or isearch-mode
(and cursor-in-echo-area (current-message))
***************
*** 1415,1420 ****
--- 1430,1441 ----
(if use-echo-area
(let ((msg (current-message))
message-log-max)
+ (when mac-win-default-background-echo-area
+ (put-text-property
+ 0 (length active-input-string)
+ 'face
+ `(background-color . ,(face-background 'default))
+ active-input-string))
(if (and msg
;; Don't get confused by previously displayed
;; `active-input-string'.
***************
*** 1447,1452 ****
--- 1468,1475 ----
(defun mac-text-input-insert-text (event)
(interactive "e")
+ (when mac-win-debug-log
+ (message "mac-text-input-insert-text: %s" event))
(let* ((ae (mac-event-ae event))
(text (cdr (mac-ae-parameter ae)))
(replacement-range (cdr (mac-ae-parameter ae "replacementRange")))
***************
*** 1479,1485 ****
(+ (point-min) (car replacement-range)
(cdr replacement-range)))
(error nil)))
! (mac-unread-string (mac-utxt-to-string text coding))))
(defcustom mac-selected-keyboard-input-source-change-hook nil
"Hook run for a change to the selected keyboard input source.
--- 1502,1510 ----
(+ (point-min) (car replacement-range)
(cdr replacement-range)))
(error nil)))
! (mac-unread-string (mac-utxt-to-string text coding)))
! (when mac-win-ime-cursor-type
! (setq cursor-type mac-win-ime-cursor-type)))
(defcustom mac-selected-keyboard-input-source-change-hook nil
"Hook run for a change to the selected keyboard input source.
***************
*** 1496,1501 ****
--- 1521,1532 ----
:type 'hook
:group 'mac)
+ (defcustom mac-auto-ascii-setup-input-source-before-hook nil
+ "Hook that is run before automatic change to ascii."
+ :package-version '(Mac\ port . "6.0")
+ :type 'hook
+ :group 'mac)
+
(defun mac-text-input-handle-notification (event)
(interactive "e")
(let ((ae (mac-event-ae event)))
***************
*** 1524,1529 ****
--- 1555,1561 ----
"Set up the most-recently-used ASCII-capable keyboard input source.
Expects to be bound to global keymap's prefix keys in
`input-decode-map'."
+ (run-hooks 'mac-auto-ascii-setup-input-source-before-hook)
(mac-auto-ascii-select-input-source)
(vector last-input-event))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment