Major mode for EIEIO custom buffers

Leo P White <[email protected]> 06 Jun 2012 15:29:38 +0100
Newsgroups gmane.emacs.eieio
Message-ID <[email protected]>
Hi,

I think it would be an improvement if eieio-custom.el had its own major 
mode for the buffers it creates.

I need this because I have a minor mode that defines new key bindings for 
RET and TAB, which shadow the ones in widget-keymap. This is easily 
remedied, but it requires a hook for the buffers that eieio-custom creates. 
Rather than just adding a hook, it seems more sensible to create a simple 
major mode, as this would also improve documentation.

I've included a simple patch below.

Regards,

Leo

-----------------------------------------------------------------

diff -ruN old/eieio-custom.el new/eieio-custom.el
--- old/eieio-custom.el	2012-06-06 14:55:00.258634000 +0100
+++ new/eieio-custom.el	2012-06-06 15:05:15.311976000 +0100
@@ -332,6 +332,16 @@
 Optional argument GROUP is the sub-group of slots to display."
   (eieio-customize-object obj group))
 
+(defvar eieio-custom-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map widget-keymap)
+    map)
+  "Keymap for EIEIO Custom mode")
+
+(define-derived-mode eieio-custom-mode fundamental-mode "EIEIO Custom"
+  "Major mode for customizing EIEIO objects.
+\\{eieio-custom-mode-map}")
+
 (defmethod eieio-customize-object ((obj eieio-default-superclass)
 				   &optional group)
   "Customize OBJ in a specialized custom buffer.
@@ -347,6 +357,7 @@
 			       (symbol-name g) "*")))
     (setq buffer-read-only nil)
     (kill-all-local-variables)
+    (eieio-custom-mode)
     (erase-buffer)
     (let ((all (overlay-lists)))
       ;; Delete all the overlays.
@@ -363,7 +374,6 @@
     (widget-insert "\n")
     (eieio-custom-object-apply-reset obj)
     ;; Now initialize the buffer
-    (use-local-map widget-keymap)
     (widget-setup)
     ;;(widget-minor-mode)
     (goto-char (point-min))



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/