aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/unicode-tokens.el
diff options
context:
space:
mode:
authorGravatar David Aspinall <da@inf.ed.ac.uk>2009-09-01 23:13:38 +0000
committerGravatar David Aspinall <da@inf.ed.ac.uk>2009-09-01 23:13:38 +0000
commit45d528eb1d3a7a8ba6f8371be8b3166bd8d763b1 (patch)
tree01f2a5eb0a81b876b273d8c0297b0f589935e8a6 /lib/unicode-tokens.el
parentb3a76a8ea645f90123fbde1db42b305edd4baa9d (diff)
Attempt to make compatible with Mac OS X port of Emacs 23.
Diffstat (limited to 'lib/unicode-tokens.el')
-rw-r--r--lib/unicode-tokens.el85
1 files changed, 56 insertions, 29 deletions
diff --git a/lib/unicode-tokens.el b/lib/unicode-tokens.el
index da41f872..3d9b9d72 100644
--- a/lib/unicode-tokens.el
+++ b/lib/unicode-tokens.el
@@ -35,6 +35,7 @@
;; -- insert tokens via numeric code (extra format string), cf HTML
;; -- simplify: unify region and control settings?
;; -- simplify/optimise property handling
+;; -- support multiple modes with mode-local configs at once
;;
;;; Code:
@@ -212,23 +213,6 @@ This is used for an approximate reverse mapping, see `unicode-tokens-paste'.")
"Regular expression matching converted tokens.
This is used for an approximate reverse mapping, see `unicode-tokens-paste'.")
-
-;;
-;; Make all of those buffer local
-;;
-;; TODO: use per *mode* defaults for them, cf proof-unicode-tokens
-;;
-
-;; (mapcar 'make-variable-buffer-local
-;; unicode-tokens-configuration-variables)
-
-;; (mapcar 'make-variable-buffer-local
-;; '(unicode-tokens-token-list
-;; unicode-tokens-hash-table
-;; unicode-tokens-token-match-regexp
-;; unicode-tokens-uchar-hash-table
-;; unicode-tokens-uchar-regexp))
-
;;
;; Faces
;;
@@ -1011,19 +995,63 @@ Commands available are:
;; Font selection
;;
-;; parameterised version of function from menu-bar.el (Emacs 23.1)
+(when (fboundp 'ns-respond-to-change-font)
+
+ ;; A nasty hack to ns-win.el for Mac OS X support
+
+ ;; Tricky because we get a callback on font changes, but not when
+ ;; the window is closed. How do we know when user is finished?
+
+ (when (not (fboundp 'old-ns-respond-to-change-font))
+ (fset 'old-ns-respond-to-change-font
+ (symbol-function 'ns-respond-to-change-font)))
+
+ (when (not (fboundp 'old-ns-popup-font-panel))
+ (fset 'old-ns-popup-font-panel
+ (symbol-function 'ns-popup-font-panel)))
+
+ (defvar unicode-tokens-respond-to-change-font nil)
+
+ (defun ns-respond-to-change-font (&rest args)
+ (interactive)
+ (cond
+ (unicode-tokens-respond-to-change-font
+ (unicode-tokens-set-font-var-aux
+ unicode-tokens-respond-to-change-font
+ ns-input-font))
+ (t
+ (apply 'old-ns-respond-to-change-font args))))
+
+ (defun ns-popup-font-panel ()
+ (setq unicode-tokens-respond-to-change-font nil)
+ (old-ns-popup-font-panel))
+
+ (defun unicode-tokens-popup-font-panel (fontvar)
+ (setq unicode-tokens-respond-to-change-font fontvar)
+ (old-ns-popup-font-panel))
+)
+
+;; parameterised version of function from menu-bar.el (Emacs 23.1)
+;; this now copes with Emacs 23.1, Emacs 22, Mac OS X Emacs 23.1.
(defun unicode-tokens-set-font-var (fontvar)
"Interactively select a font for FONTVAR."
(interactive)
- (let ((font (cond
- ((fboundp 'x-select-font)
- (x-select-font))
- ((fboundp 'mouse-select-font)
- (mouse-select-font))
- (t
- (unicode-tokens-mouse-set-font))))
- spec)
+ (let (font spec)
+ (if (fboundp 'ns-popup-font-panel)
+ (unicode-tokens-popup-font-panel fontvar)
+ (cond
+ ((fboundp 'x-select-font)
+ (setq font (x-select-font)))
+ ((fboundp 'mouse-select-font)
+ (setq font (mouse-select-font)))
+ (t
+ (setq font (unicode-tokens-mouse-set-font))))
+ (unicode-tokens-set-font-var-aux fontvar font))))
+
+(defun unicode-tokens-set-font-var-aux (fontvar font)
+ "A subroutine of `unicode-tokens-set-font-var'."
+ (let (spec)
(when font
;; Be careful here: when set-face-attribute is called for the
;; :font attribute, Emacs tries to guess the best matching font
@@ -1035,10 +1063,9 @@ Commands available are:
(set-face-attribute fontvar (selected-frame)
:width 'normal
;; da: don't try to reset these for token fonts.
- ;;:weight 'normal
- ;;:slant 'normal
+ ;; :weight 'normal
+ ;; :slant 'normal
;; da: sometimes :font doesn't work but :family does!
- ;; e.g. "
:font font)
(let ((font-object (face-attribute fontvar :font)))
(dolist (f (frame-list))