unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Custom/define-minor-mode problem
@ 2005-08-09 17:17 Michael Mauger
  2005-08-10 17:45 ` Michael Mauger
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Mauger @ 2005-08-09 17:17 UTC (permalink / raw)


I noticed that my `recentf' menu of recently used files was suddenly
empty.  (It actually has been an issue for a while, I just got around to
addressing it today.)

Looking at an old copy of my .emacs, I noticed that the mode entry in
`custom-set-variables' has changed.

Was  '(recentf-mode t nil (recentf))
Now  '(recentf-mode t)

Reading the custom code, it makes sense that things are now broken.  I
define the `recentf-save-file' in custom and it's entry appears after the
`recentf-mode' entry.  Entries with a require list (the fourth member of
the custom entry) are deferred so that all the customizations for the
mode are complete.  There's no longer a require list, so the mode is
being enabled before its told where the old save file is.

The lack of a require list in the custom entry is problem with all minor
modes defined via `define-minor-mode'.  It is only noticable if the user
also customizes a variable whose name sorts after the mode variable's
name and the variable is used when the mode starts.

I spent some time looking at the new `define-minor-mode' code but my head
exploded.  Could someone with more experience with that code take a look
and see what needs to be done to get the :require property on the
defcustom for the mode?  

Thanks.

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

* Re: Custom/define-minor-mode problem
  2005-08-09 17:17 Custom/define-minor-mode problem Michael Mauger
@ 2005-08-10 17:45 ` Michael Mauger
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Mauger @ 2005-08-10 17:45 UTC (permalink / raw)


I wrote:
> 
> I noticed that my `recentf' menu of recently used files was suddenly
> empty.  (It actually has been an issue for a while, I just got around to
> addressing it today.)
> 
> Looking at an old copy of my .emacs, I noticed that the mode entry in
> `custom-set-variables' has changed.
> 
> Was  '(recentf-mode t nil (recentf))
> Now  '(recentf-mode t)
> 
> Reading the custom code, it makes sense that things are now broken.  I
> define the `recentf-save-file' in custom and it's entry appears after the
> `recentf-mode' entry.  Entries with a require list (the fourth member of
> the custom entry) are deferred so that all the customizations for the
> mode are complete.  There's no longer a require list, so the mode is
> being enabled before its told where the old save file is.
> 
> The lack of a require list in the custom entry is problem with all minor
> modes defined via `define-minor-mode'.  It is only noticable if the user
> also customizes a variable whose name sorts after the mode variable's
> name and the variable is used when the mode starts.
> 
> I spent some time looking at the new `define-minor-mode' code but my head
> exploded.  Could someone with more experience with that code take a look
> and see what needs to be done to get the :require property on the
> defcustom for the mode?  
> 
> Thanks.
> 

After reassembling my empty head, I took another look at the `define-minor-
mode' code.  Here's an initial attempt at correcting the problem I described 
above.  This patch works for me, but deserves some more knowledgable review.

Index: emacs/lisp/emacs-lisp/easy-mmode.el
===================================================================
RCS file: /c/cvsroot/emacs/emacs/lisp/emacs-lisp/easy-mmode.el,v
retrieving revision 1.70
diff -c -r1.70 easy-mmode.el
*** emacs/lisp/emacs-lisp/easy-mmode.el 22 Jul 2005 01:26:03 -0000      1.70
--- emacs/lisp/emacs-lisp/easy-mmode.el 10 Aug 2005 16:46:11 -0000
***************
*** 214,220 ****
               ,@type
               ,@(cond
                  ((not (and curfile require)) nil)
!                 ((not (eq require t)) `(:require ,require)))
               ,@(nreverse extra-keywords))))
  
         ;; The actual function.
--- 214,221 ----
               ,@type
               ,@(cond
                  ((not (and curfile require)) nil)
!                 ((not (eq require t)) `(:require ',require))
!                 (curfile `(:require ',(intern (file-name-sans-extension (file-
name-nondirectory curfile))))))
               ,@(nreverse extra-keywords))))
  
         ;; The actual function.

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

* Re: Custom/define-minor-mode problem
@ 2005-08-22 18:20 Michael Mauger
  2005-08-24  0:10 ` Richard M. Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Mauger @ 2005-08-22 18:20 UTC (permalink / raw)


--- Michael Mauger <mmaug@yahoo.com> wrote:

> I noticed that my `recentf' menu of recently used files was suddenly
> empty.  (It actually has been an issue for a while, I just got around
> to addressing it today.)
> 
> Looking at an old copy of my .emacs, I noticed that the mode entry in
> `custom-set-variables' has changed.
> 
> Was  '(recentf-mode t nil (recentf))
> Now  '(recentf-mode t)
> 

There was no feedback on this.  The problem could arise with any minor
mode that has customized variables.  If no one objects, could it be
comitted? 

Thanks.

Here's the ChangeLog and final patch:

2005-08-22  Michael R. Mauger  <mmaug@yahoo.com>

	* emacs-lisp/easy-mmode.el (define-minor-mode): Add :require
	property to mode variable if loaded from a file.


Index: emacs/lisp/emacs-lisp/easy-mmode.el
===================================================================
RCS file: /c/cvsroot/emacs/emacs/lisp/emacs-lisp/easy-mmode.el,v
retrieving revision 1.70
diff -c -r1.70 easy-mmode.el
*** emacs/lisp/emacs-lisp/easy-mmode.el	22 Jul 2005 01:26:03 -0000	1.70
--- emacs/lisp/emacs-lisp/easy-mmode.el	22 Aug 2005 18:15:29 -0000
***************
*** 214,220 ****
  	       ,@type
  	       ,@(cond
  		  ((not (and curfile require)) nil)
! 		  ((not (eq require t)) `(:require ,require)))
  	       ,@(nreverse extra-keywords))))
  
         ;; The actual function.
--- 214,222 ----
  	       ,@type
  	       ,@(cond
  		  ((not (and curfile require)) nil)
! 		  ((not (eq require t)) `(:require ,require))
! 		  (curfile `(:require ',(intern (file-name-sans-extension
! 						 (file-name-nondirectory curfile))))))
  	       ,@(nreverse extra-keywords))))
  
         ;; The actual function.

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

* Re: Custom/define-minor-mode problem
  2005-08-22 18:20 Michael Mauger
@ 2005-08-24  0:10 ` Richard M. Stallman
  2005-08-24 11:33   ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Richard M. Stallman @ 2005-08-24  0:10 UTC (permalink / raw)
  Cc: emacs-devel

    There was no feedback on this.  The problem could arise with any minor
    mode that has customized variables.  If no one objects, could it be
    comitted? 

I can't access the repository now, but it looks like you want to revert
the following change:

2005-06-26  Stefan Monnier  <monnier@iro.umontreal.ca>

	* emacs-lisp/easy-mmode.el (define-minor-mode): Don't automatically add
	a :require to the defcustom.

I don't remember the precise details of the bug that that change fixed,
but it certainly fixed one.  So your change is definitely not correct.
Please do not install it.

If there is a new bug to be corrected now, we can't address it properly
without considering the old problem at the same time.

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

* Re: Custom/define-minor-mode problem
  2005-08-24  0:10 ` Richard M. Stallman
@ 2005-08-24 11:33   ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2005-08-24 11:33 UTC (permalink / raw)
  Cc: Michael Mauger, emacs-devel

> 	* emacs-lisp/easy-mmode.el (define-minor-mode): Don't automatically add
> 	a :require to the defcustom.

> I don't remember the precise details of the bug that that change fixed,
> but it certainly fixed one.  So your change is definitely not correct.
> Please do not install it.

The bug it fixed is the one where customizing font-lock-mode would add in
your .emacs a custom setting that requires font-core which of course breaks
when the same .emacs is read with some older Emacs.

AFAIK Michael's problem should be fixed by Luc Van Eycken
<Luc.VanEycken@esat.kuleuven.be>'s patch.  I thought it had been installed
already, but it seems like that's not the case.  I'll do that now.


        Stefan

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

end of thread, other threads:[~2005-08-24 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-09 17:17 Custom/define-minor-mode problem Michael Mauger
2005-08-10 17:45 ` Michael Mauger
  -- strict thread matches above, loose matches on Subject: below --
2005-08-22 18:20 Michael Mauger
2005-08-24  0:10 ` Richard M. Stallman
2005-08-24 11:33   ` Stefan Monnier

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