[uim-commit] r446 - in trunk: doc scm
yamaken at freedesktop.org
yamaken at freedesktop.org
Mon Jan 31 19:06:01 PST 2005
Author: yamaken
Date: 2005-01-31 19:05:58 -0800 (Mon, 31 Jan 2005)
New Revision: 446
Modified:
trunk/doc/CUSTOM
trunk/scm/action.scm
trunk/scm/load-action.scm
Log:
* doc/CUSTOM
- Add a section "Invoke an arbitrary procedure when a custom
variable has been set" to indicate usage of custom-set-hooks
* scm/action.scm
- (context-list-replace-widgets!): Add a comment
* scm/load-action.scm
- (context-list-replace-widgets!): New stub procedure
Modified: trunk/doc/CUSTOM
===================================================================
--- trunk/doc/CUSTOM 2005-02-01 02:20:50 UTC (rev 445)
+++ trunk/doc/CUSTOM 2005-02-01 03:05:58 UTC (rev 446)
@@ -23,6 +23,54 @@
required. But we recommend the naming convention to manage the files
easily.
+
+* Invoke an arbitrary procedure when a custom variable has been set
+
+ The feature is usable via the hook named 'custom-set-hooks'. See
+ following example.
+
+ (custom-add-hook 'anthy-input-mode-actions
+ 'custom-set-hooks
+ (lambda ()
+ (puts "anthy-input-mode-actions has been set\n")
+ (anthy-configure-widgets)))
+
+ Any procedure that takes no argument can be placed into the third
+ argument to custom-add-hook. The procedure will be invoked when the
+ custom variable anthy-input-mode-actions has been set. Interprocess
+ custom variable update via uim-helper-server also triggers this
+ hook. So some variables edited on uim-pref will be propagated to any
+ processes and invokes the hook on the fly.
+
+ For example, dynamic file switching can be triggered by uim-pref
+ using following hook.
+
+ (custom-add-hook 'skk-dic-file-name
+ 'custom-set-hooks
+ skk-reload-dic)
+
+ There are some limitations for the set-hook feature.
+
+ - Runtime version of the custom facility (custom-rt.scm) only
+ accepts at most one hook per custom variable (full-featured
+ version can handle multiple hooks)
+
+ - Custom API enabled only in full-featured version (custom.scm)
+ cannot be invoked in the hook procedure.
+
+ Enclose such code into conditional block as follows. This ensures
+ that custom-rt.scm ignores the hook.
+
+ (if custom-full-featured?
+ (custom-add-hook 'anthy-kana-input-method-actions
+ 'custom-set-hooks
+ (lambda ()
+ (custom-choice-range-reflect-olist-val
+ 'default-widget_anthy_kana_input_method
+ 'anthy-kana-input-method-actions
+ anthy-kana-input-method-indication-alist))))
+
+
* Control activity of a custom variable
Any custom variables has a state named 'activity'. This state
Modified: trunk/scm/action.scm
===================================================================
--- trunk/scm/action.scm 2005-02-01 02:20:50 UTC (rev 445)
+++ trunk/scm/action.scm 2005-02-01 03:05:58 UTC (rev 446)
@@ -315,6 +315,7 @@
(context-propagate-widget-configuration context))))
;; TODO: write test
+;; API for uim developers
(define context-list-replace-widgets!
(lambda (target-im-name widget-id-list)
(for-each (lambda (context)
Modified: trunk/scm/load-action.scm
===================================================================
--- trunk/scm/load-action.scm 2005-02-01 02:20:50 UTC (rev 445)
+++ trunk/scm/load-action.scm 2005-02-01 03:05:58 UTC (rev 446)
@@ -84,6 +84,7 @@
(define activity-indicator-new do-nothing)
(define actions-new do-nothing)
(define context-init-widgets do-nothing)
+ (define context-list-replace-widgets! do-nothing)
(define context-update-widgets do-nothing)
(define context-prop-activate-handler do-nothing)
(define context-mode-handler do-nothing)))
More information about the Uim-commit
mailing list