My typical usage of the JDE is to have a custom-set-variables block in
my .emacs that sets a bunch of defaults for the JDE, and then only
override a couple of the jde variables in each of my projects
(typically jde-global-classpath and a few others).  I always wondered
why it was necessary to save *every* jde variable in the project file.
For example, I can't see a use case for wanting to vary the
keybindings from project to project.

The patch for jde.el below allows one to save only those variables
that have been customized at the project level in the project file.  I
know in the past others have been clamoring for some sort of override
feature.  This solution does not solve the situation where one would
like to nest several project files, with each deeper project file
overriding any found above it in the directory hierarchy.  But at
least it enables users to customize the JDE on two levels - default
and project - and make customizations at the default level without
having to go update every project file if the change is orthogonal to
customizations made in the project.

I haven't been testing this code very long, but I wanted to get it out
to others and see if it is viable.  To update your project files, it
should be sufficient to simply load and re-save them after you've
applied the patch to jde.el.  Comments?

/Nick

*** jde.el      2001/03/29 06:19:15     1.154
--- jde.el      2001/03/29 19:05:27
***************
*** 997,1003 ****
    (interactive)
    (let ((prj-file (jde-find-project-file default-directory)))
      (if prj-file
!       (load-file prj-file)
        (jde-set-variables-init-value))))
  
  
--- 997,1005 ----
    (interactive)
    (let ((prj-file (jde-find-project-file default-directory)))
      (if prj-file
!       (progn
!         (jde-set-variables-init-value t) ; don't display reset message
!         (load-file prj-file))
        (jde-set-variables-init-value))))
  
  
***************
*** 1061,1067 ****
  
  
  (defun jde-save-variables (buffer)
!   "Save all JDE variables in project file."
    (jde-save-delete 'jde-set-variables buffer)
    (let ((standard-output buffer))
      (unless (bolp)
--- 1063,1069 ----
  
  
  (defun jde-save-variables (buffer)
!   "Save all *customized* JDE variables in project file."
    (jde-save-delete 'jde-set-variables buffer)
    (let ((standard-output buffer))
      (unless (bolp)
***************
*** 1072,1091 ****
       (lambda (symbol)
         (when 
           (and (string-match "jde-" (symbol-name symbol))
!               (get symbol 'custom-type))
         (let ((value (symbol-value symbol)))      
             (princ "\n '(")
             (princ symbol)
             (princ " ")
             (prin1 (custom-quote value))
!            ;; Check whether the user has changed the value of this
!            ;; variable in a customization buffer. If so, save flag
!            ;; so that custom knows that this value differs from
!              ;; standard value.
!            (if (get symbol 'customized-value)
!                (princ " t)")
!              (princ ")"))              
!            )))
        (jde-symbol-list))
        (princ ")")
        (save-excursion
--- 1074,1087 ----
       (lambda (symbol)
         (when 
           (and (string-match "jde-" (symbol-name symbol))
!               (get symbol 'custom-type)
!               (get symbol 'customized-value))
         (let ((value (symbol-value symbol)))      
             (princ "\n '(")
             (princ symbol)
             (princ " ")
             (prin1 (custom-quote value))
!            (princ " t)"))))
        (jde-symbol-list))
        (princ ")")
        (save-excursion
***************
*** 1120,1129 ****
                   (funcall set symbol (eval value)))
            (setq args (cdr args)))))))
  
! (defun jde-set-variables-init-value ()
    "Set each JDE variable to the value it has at Emacs startup."
    (interactive)
!   (message "Setting JDE variables to startup values...")
    (mapcar 
     (lambda (symbol) 
       (when 
--- 1116,1126 ----
                   (funcall set symbol (eval value)))
            (setq args (cdr args)))))))
  
! (defun jde-set-variables-init-value (&optional no-msg)
    "Set each JDE variable to the value it has at Emacs startup."
    (interactive)
!   (if (null no-msg)
!       (message "Setting JDE variables to startup values..."))
    (mapcar 
     (lambda (symbol) 
       (when 


Reply via email to