emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

More bugs in Custom themes


From: Luc Teirlinck
Subject: More bugs in Custom themes
Date: Wed, 29 Jun 2005 20:52:11 -0500 (CDT)

As I already said in another message, things are still a _lot_ worse
than I thought yesterday.  The Custom themes feature in its current
form is actually completely unusable and it seems impossible to make
it usable without a substantial effort in correcting porting errors
and finishing off the porting work (and then documenting it).  As I
already pointed out, I am not the right person for this.

First new bug.  After requiring a theme and then setting and saving
some option through Custom, all my customizations for all options for
which the theme specified a value were deleted.  I lost part of my
Custom file this way and had to recreate it.  This is a serious bug.
It probably can be fixed one way or the other, but the three unfixed
bugs I am currently aware of are guaranteed to be only three of very
many.  Every time I try out something new, I find new bugs.  The
current Custom themes stuff is completely dysfunctional.  The current
code in custom.el appears to be incoherent.

Second new bug: `custom-create-theme' can not handle variables with
a defcustom that needs a :require and there are a lot of those.

At present, people should not be using Custom themes, because you risk
loosing part of your customizations by doing that.  This stuff should
definitely not be documented in the Emacs manual at present.

I guess it still makes sense to apply my patches.  In case somebody
sooner or later manages to fix the mess in custom.el, they still fix a
few of the many bugs, thereby making that person's job at least
somewhat easier.

I definitely no longer want to make `require-theme' interactive,
because using it, at present, can lead to loss of part of your Custom
file.  Until things get fixed (if ever), I would make
`custom-theme-directory' into a defvar instead of a defcustom, because
we do not want to advertise a package with serious bugs.  I could
install my patch to custom.el with these changes.

My patch to cus-theme.el would document the bugs and tell people it is
currently only meant for developpers wanting to debug the Custom
themes machinery.  Anybody who manages to correct these and other bugs
enough to make Custom Themes safely usable can delete that warning.

New proposed cus-theme.el patch:

===File ~/cus-theme.el-new-diff=============================
*** cus-theme.el        17 Apr 2005 15:28:09 -0500      1.8
--- cus-theme.el        29 Jun 2005 20:32:47 -0500      
***************
*** 31,36 ****
--- 31,48 ----
  (eval-when-compile
    (require 'wid-edit))
  
+ (define-derived-mode custom-new-theme-mode nil "New-Theme"
+   "Major mode for the buffer created by `customize-create-theme'.
+ Do not call this mode function yourself.  It is only meant for internal
+ use by `customize-create-theme'."
+   (set-keymap-parent custom-new-theme-mode-map widget-keymap))
+ (put 'custom-new-theme-mode 'mode-class 'special)
+ 
+ (defvar custom-theme-name)
+ (defvar custom-theme-variables)
+ (defvar custom-theme-faces)
+ (defvar custom-theme-description)
+ 
  ;;;###autoload
  (defun customize-create-theme ()
    "Create a custom theme."
***************
*** 38,52 ****
    (if (get-buffer "*New Custom Theme*")
        (kill-buffer "*New Custom Theme*"))
    (switch-to-buffer "*New Custom Theme*")
!   (kill-all-local-variables)
    (make-local-variable 'custom-theme-name)
    (make-local-variable 'custom-theme-variables)
    (make-local-variable 'custom-theme-faces)
    (make-local-variable 'custom-theme-description)
-   (let ((inhibit-read-only t))
-     (erase-buffer))
    (widget-insert "This buffer helps you write a custom theme elisp file.
! This will help you share your customizations with other people.\n\n")
    (widget-insert "Theme name: ")
    (setq custom-theme-name
        (widget-create 'editable-field
--- 50,81 ----
    (if (get-buffer "*New Custom Theme*")
        (kill-buffer "*New Custom Theme*"))
    (switch-to-buffer "*New Custom Theme*")
!   (let ((inhibit-read-only t))
!     (erase-buffer))
!   (custom-new-theme-mode)
    (make-local-variable 'custom-theme-name)
    (make-local-variable 'custom-theme-variables)
    (make-local-variable 'custom-theme-faces)
    (make-local-variable 'custom-theme-description)
    (widget-insert "This buffer helps you write a custom theme elisp file.
! This will help you share your customizations with other people.
! 
! Just insert the names of all variables and faces you want the theme
! to include.  Then clicking mouse-2 or pressing RET on the [Done] button
! will write a theme file that sets all these variables and faces to their
! current global values.  It will write that file into the directory given
! by the variable `custom-theme-directory', usually \"~/.emacs.d/\".
! 
! To undo all your edits to the buffer, use the [Reset] button.
! 
! *Please Note*: This buffer and the theme files written by it, as well as
! the entire Custom themes feature, are experimental.  They are currently 
! only meant for use by developers who want to debug it.  The most serious
! known bug is that requiring a theme and then setting and saving some option
! through Custom may erase part of your Custom file.  (It erases the options
! for which the theme specifies a value.)  Another, less serious bug is that
! the file created by this buffer will not work for options defined with
! a defcustom that uses :require.\n\n")
    (widget-insert "Theme name: ")
    (setq custom-theme-name
        (widget-create 'editable-field
***************
*** 81,87 ****
                           (bury-buffer))
                 "Bury Buffer")
    (widget-insert "\n")
-   (use-local-map widget-keymap)
    (widget-setup))
  
  (defun custom-theme-write (&rest ignore)
--- 110,115 ----
***************
*** 90,95 ****
--- 118,127 ----
        (variables (widget-value custom-theme-variables))
        (faces (widget-value custom-theme-faces)))
      (switch-to-buffer (concat name "-theme.el"))
+     (emacs-lisp-mode)
+     (unless (file-exists-p custom-theme-directory)
+       (make-directory (file-name-as-directory custom-theme-directory) t))
+     (setq default-directory custom-theme-directory)
      (setq buffer-file-name (expand-file-name (concat name "-theme.el")))
      (let ((inhibit-read-only t))
        (erase-buffer))
***************
*** 100,106 ****
      (insert  ")\n")
      (custom-theme-write-variables name variables)
      (custom-theme-write-faces name faces)
!     (insert "\n(provide-theme '" name ")\n")))
  
  (defun custom-theme-write-variables (theme vars)
    "Write a `custom-theme-set-variables' command for THEME.
--- 132,139 ----
      (insert  ")\n")
      (custom-theme-write-variables name variables)
      (custom-theme-write-faces name faces)
!     (insert "\n(provide-theme '" name ")\n")
!     (save-buffer)))
  
  (defun custom-theme-write-variables (theme vars)
    "Write a `custom-theme-set-variables' command for THEME.
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]