Generalize logic to rename symbols.
Rename 'my-modelist-to-hooklist' to 'my-mode2hook'.
--- a/.emacs-my Sun Mar 20 23:26:45 2011 +0200
+++ b/.emacs-my Mon Mar 21 00:18:46 2011 +0200
@@ -36,12 +36,37 @@
;;; ----------------------------------------------------------------
(message "mode groups")
-(defun my-modelist-to-hooklist (modes)
- "Convert list of MODES to list of hooks for these modes."
- (mapcar
- (lambda (mode) (intern (concat (symbol-name mode) "-hook")))
- modes
- ) )
+(defmacro my-travel-symb-tree (name func tree)
+ `(cond
+ ((symbolp ,tree)
+ (,func ,tree)
+ )
+ ((listp ,tree)
+ (mapcar ,name ,tree)
+ )
+ (t (error "Only tree of symbols allowed."))
+ ) )
+
+(defun my-feature2mode (tree)
+ "Convert TREE of features to TREE of modes for these features. Single symbol allowed."
+ (my-travel-symb-tree
+ 'my-feature2mode
+ (lambda (symb) (intern (concat (symbol-name symb) "-mode")))
+ tree))
+
+(defun my-mode2hook (tree)
+ "Convert TREE of modes to TREE of hooks for these modes. Single symbol allowed."
+ (my-travel-symb-tree
+ 'my-feature2mode
+ (lambda (symb) (intern (concat (symbol-name tree) "-hook")))
+ tree))
+
+(defun my-mode2modemap (tree)
+ "Convert TREE of modes to TREE of keymaps for these modes. Single symbol allowed."
+ (my-travel-symb-tree
+ 'my-feature2mode
+ (lambda (symb) (intern (concat (symbol-name tree) "-map")))
+ tree))
(defvar my-devel-mode-list
'(
@@ -57,7 +82,7 @@
"List of development modes.")
(defvar my-devel-mode-hook-list
- (my-modelist-to-hooklist my-devel-mode-list)
+ (my-mode2hook my-devel-mode-list)
"List of development mode hooks.")
(defvar my-scroll-margin-mode-list
@@ -73,7 +98,7 @@
"List of modes for enabling scroll margin.")
(defvar my-scroll-margin-mode-hook-list
- (my-modelist-to-hooklist my-scroll-margin-mode-list)
+ (my-mode2hook my-scroll-margin-mode-list)
"List of mode hooks for enabling scroll margin.")
(defvar my-text-mode-list
@@ -81,7 +106,7 @@
"List of text modes.")
(defvar my-text-mode-hook-list
- (my-modelist-to-hooklist my-text-mode-list)
+ (my-mode2hook my-text-mode-list)
"List of text mode hooks.")
;;; ----------------------------------------------------------------