Commits

Anonymous committed b1f2bf6

fixed autoloads in buffer-colors.el

Comments (0)

Files changed (2)

+2012-11-19  Steve Mitchell   <smitchel@bnin.net> 
+	    Byrel Mitchell   <byrel.mitchell@gmail.com>
+         
+	* buffer-colors.el : re-added autoloads with 
+                             checks for behavior support.
+                             uses variables if behavior
+                             support not available.
+
 2012-01-13  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 2.46 released.
 (define-specifier-tag 'bc-read-only)
 
 (defvar bc-fgbg-menu nil "Menu for Buffer Colors")
-
+(defvar bc-buffer-colors-enabled-p nil
+  "Is buffer-colors currently loaded.
+This variable is used on systems without behavior functionality to keep track of whether buffer-colors is currently loaded.")
 
 ;; the behaviour lets us 
 ;;      disable Buffer Colors, 
 ;;      remove the Buffer Colors menu item,
 ;;      and delete all previously set buffer colors,
 ;;         restoring them to the colors in the default face.  
-(define-behavior 'buffer-colors
-  "A system for quickly changing the fg and bg colors of buffers.
+(when (functionp 'define-behavior)
+  (define-behavior 'buffer-colors
+    "A system for quickly changing the fg and bg colors of buffers.
 It includes a rule-based system for coloring new buffers."
-  :enable 'bc-enable-behavior
-  :disable 'bc-disable-behavior)
+    :enable 'bc-enable-behavior
+    :disable 'bc-disable-behavior))
 
 ;;---- functions for rules ----------------------------------------
 (defun bc-read-only-p ()
       (disable-behavior 'buffer-colors)
     (enable-behavior 'buffer-colors)))
 
+;;;###autoload
+(defun bc-toggle-no-behavior ()
+  (interactive)
+  (if bc-buffer-colors-enabled-p
+      (bc-disable-behavior)
+    (bc-enable-behavior))
+  (setq bc-buffer-colors-enabled-p (not bc-buffer-colors-enabled-p)))
+	
+
 (defun bc-write-current-fgbg ()
   "Writes buffer colors menu to file"
   (custom-save-all))
 						    :value bc-read-only))))))
 
 ;;;;--- start up code ----------------------------------------------
+;;;###autoload
+(unless (featurep 'buffer-colors)
+  (when (boundp 'current-menubar) 
+    (add-menu-button '("Options" "Display")
+		     "---"))) ;add a separator only first time loaded
 
-(unless (featurep 'buffer-colors)
-  (add-menu-button '("Options" "Display")
-		   "---")) ;add a separator only first time loaded
+;;;###autoload
+(when (boundp 'current-menubar) 
+  (if (functionp 'define-behavior)
+      (add-menu-button '("Options" "Display")
+		       [ "Buffer Colors" bc-toggle-behavior
+			 :style toggle
+			 :selected (behavior-enabled-p 'buffer-colors)])
+    (add-menu-button '("Options" "Display")
+		     [ "Buffer Colors" bc-toggle-no-behavior
+		       :style toggle
+		       :selected bc-buffer-colors-enabled-p])))
 
-(add-menu-button '("Options" "Display")
-		 [ "Buffer Colors" bc-toggle-behavior
-		   :style toggle
-		   :selected (behavior-enabled-p 'buffer-colors)])
 
 (provide 'buffer-colors)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.