unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* More bugs in Custom themes
@ 2005-06-30  1:52 Luc Teirlinck
  2005-06-30 21:30 ` Richard M. Stallman
  0 siblings, 1 reply; 16+ messages in thread
From: Luc Teirlinck @ 2005-06-30  1:52 UTC (permalink / raw)


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.
============================================================

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-07-25 13:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-30  1:52 More bugs in Custom themes Luc Teirlinck
2005-06-30 21:30 ` Richard M. Stallman
2005-07-01  1:04   ` Luc Teirlinck
2005-07-02 12:33     ` Richard M. Stallman
2005-07-02 13:46       ` David Kastrup
2005-07-03  1:55       ` Luc Teirlinck
2005-07-04  6:16         ` Richard M. Stallman
2005-07-03  2:15       ` Luc Teirlinck
2005-07-05  4:35         ` Richard M. Stallman
2005-07-06  2:39           ` Luc Teirlinck
2005-07-06  3:32           ` Luc Teirlinck
2005-07-11  5:34             ` Richard M. Stallman
2005-07-11  5:35             ` Richard M. Stallman
2005-07-25  1:04               ` Luc Teirlinck
2005-07-25 11:53                 ` Per Abrahamsen
2005-07-25 13:10                 ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).