Juanma Barranquero wrote: >I'm having a few problems with highlight-changes-mode, which is a >not-very-standard minor mode. > > Yes, the desktop module expects minor modes to follow the conventions. The only mechanism to deal with non-conventional minor modes is `desktop-minor-mode-table' that allows the minor mode variable and minor mode function to have different names. To restore highlight changes mode, the function `highlight-changes-mode' needs to be called with the value of `highlight-changes-mode' to get the correct "sub-mode". So what is needed is something like `desktop-buffer-mode-handlers', but for minor modes. I suggest the patch below. It allows modules defining minor modes to define their own restore function without having to change the desktop module. >The other question is: why does `desktop-save' save `nil' for active >minor-modes which do appear in `desktop-minor-mode-table' as >non-restorable? > > I don't think there is any good reason. The patch below includes your suggested change (the second one). Now I have a question: To allow modules defining major or minor modes to add a special handler to `desktop-buffer-mode-handlers' or `desktop-minor-mode-handlers', the module in question must be loaded before the major or minor mode function is called. To do that, the patch below defines the following function: (defun desktop-load-file (function) "Load the file where auto loaded FUNCTION is defined." (let ((fcell (symbol-function function))) (when (and (listp fcell) (eq 'autoload (car fcell))) (load (cadr fcell))))) This function assumes that the mode function is autoloaded. Is this requirement ok? Is there a better solution?