emacs-devel
[Top][All Lists]
Advanced

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

Moving handlers out of desktop.el


From: Lars Hansen
Subject: Moving handlers out of desktop.el
Date: Tue, 06 Apr 2004 13:47:19 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040123 Debian/1.6-1.he-1

For a long time it has annoyed me that desktop.el has pieces of code that really ought not be there. I am talking about the functions
  `desktop-buffer-dired'
  `desktop-buffer-rmail'
  `desktop-buffer-mh'
  `desktop-buffer-info'
that holds code specific to dired, rmail, mh and info respectively, and therefore ought to be in those modules. Not only does it IMHO look messy, it also makes it more likely that one of these modules are changed but desktop.el forgotten.

The reason that the functions above are in desktop.el is, I guess, the following: When the desktop module restores a buffer, i calls the functions in `desktop-buffer-handlers' until one returns a buffer. By default desktop-buffer-handlers holds the four functions above together with a more general function `desktop-buffer-file'. If the functions above were moved to the respective modules, these would have to be loaded prior to desktop, and that's not good.

The functions in `desktop-buffer-misc-functions' also belong in their respective modules (dired and info), but I think they can be moved without problems since they are called at desktop save.

How about this change:
1. Move the functions above to their respective modules and give each an autoload cookie.
   Also move the two in `desktop-buffer-misc-functions'.
2. Add in desktop.el a new variable `desktop-buffer-mode-handlers' with a default value like
   (('dired-mode . 'desktop-buffer-dired)
    ('rmail-mode . 'desktop-buffer-rmail)
    ('mh-folder-mode 'desktop-buffer-mh)
    ('Info-mode . 'desktop-buffer-info))
3. Replace in `desktop-buffer-handlers' the four functions above with a function `desktop-buffer-special-mode' looking in the alist above for a handler.

What do you think about this?

Lars





reply via email to

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