emacs-devel
[Top][All Lists]
Advanced

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

Re: Moving handlers out of desktop.el


From: Juri Linkov
Subject: Re: Moving handlers out of desktop.el
Date: Tue, 13 Apr 2004 18:12:36 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Lars Hansen <address@hidden> writes:
> My question is: Why should `desktop-buffer-foo' be placed _outside_
> desktop.el but the handlers for dired, rmail, mh and info _inside_
> desktop.el?

I believe the question whether to place these functions into a service
module or a client module is mostly a matter of taste.  The desktop
package at least currently consistently uses the former approach,
placing all mode handling functions in desktop.el.

But there are Emacs packages which are inconsistent in this question.
For example, why the speedbar package has the code for Info support
in info.el, but speedbar support for dired in speedbar.el?

>>Making general functions (with an autoload cookie) from them would be
>>good.  Such functions could have general arguments and be useful
>>for other purposes as well.
>>  
> I don't think I understand what kind of functions you mean.

For example, as you already noted, `desktop-buffer-dired' restores
subdirectories by inserting them in the dired buffer.  Instead
of the following code in desktop.el:

      (let* ((dired-dir (car desktop-buffer-misc))
             (dir (if (consp dired-dir) (car dired-dir) dired-dir)))
        (if (file-directory-p (file-name-directory dir))
            (progn
              (dired dired-dir)
              (mapcar 'dired-maybe-insert-subdir (cdr desktop-buffer-misc))
              (current-buffer))
          (message "Directory %s no longer exists." dir)
          (sit-for 1)
          'ignored))

it would be better to add a new argument SUBDIRECTORIES
to the `dired' function:

(dired DIRNAME &optional SWITCHES SUBDIRECTORIES)

and call from desktop.el only one dired function:

      (let* ((dired-dir (car desktop-buffer-misc))
             (dir (if (consp dired-dir) (car dired-dir) dired-dir)))
        (dired dir nil (cdr desktop-buffer-misc)))

And the `(message "Directory %s no longer exists." dir)' is not needed
in desktop.el, because the function `dired' already raises an error.
Only desktop.el should have the code to catch this error and continue
to restore the rest of the desktop file.

So, I think the code for getting saved parameters from the desktop file
(like parsing the `desktop-buffer-misc' data) should belong to desktop.el.
And some code of desktop.el should be generalized and placed into
respective packages.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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