unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Hansen <larsh@math.ku.dk>
Subject: desktop and tilde-expand-file-name
Date: Sun, 29 Dec 2002 10:14:38 +0100	[thread overview]
Message-ID: <3E0EBCFE.8090106@math.ku.dk> (raw)

Hi

I have written some enhancements for the desktop module, and I would 
like to propose them for the Emacs distribution. A description of the 
enhancements is included below. But I have two questions:

1. How do I do? I have not participated in Emacs development before, and 
I don't have CVS.
2. For use in the desktop module, I need a function 
`tilde-expand-file-name' that should work like `expand-file-name' except 
that path is specified from "~" rather than from root when that is 
possible. Such a function allows desktop modules to be portable. But the 
implementation, listed below, is not good. Can anyone sugest something 
better? In particular the implementation should not refer to Tramp.

;;;###autoload
(defun tilde-expand-file-name (file-name &optional default-dir)
;; Don't use parameter name `default-directory' here! Then 
`expand-file-name' will
;; see the parameter instead of the buffer-local variable of the same name.
"Works like `expand-file-name' except that path is specified from \"~\"
rather than form root when possible.
\(It can be impossible on MSDOS and Windows when the FILE-NAME and \"~\"
are on different drives.)
"
   (if
      (and
         (fboundp 'tramp-tramp-file-p)
         (or
            (tramp-tramp-file-p file-name)
            (and default-dir (tramp-tramp-file-p default-dir))
            (and (not default-dir) (tramp-tramp-file-p default-directory))
         )
      )
      (expand-file-name file-name default-dir)
      (let (
         (relative-name (file-relative-name (expand-file-name file-name 
default-dir) "~"))
      )
         (cond
            ((file-name-absolute-p relative-name) relative-name)
            ((string= "./" relative-name) "~/")
            ((string= "." relative-name) "~")
            (t (concat "~/" relative-name))
         )
      )
   )
)

Enhancements for the desktop module:

;;  1. Customizable variable `desktop-save' introduced.
;;     When the user changes desktop or quits emacs, should the desktop 
be saved?
;;        t          -- Allways save.
;;        ask        -- Ask.
;;        ask-if-new -- Ask if no desktop file exists, otherwise just save.
;;        nil        -- Never.
;;     The desktop is never saved when `desktop-enable' is nil"
;;  2. Customizable variable `desktop-path' introduced.
;;     List of directories in which to lookup the desktop file.
;;  3. Customizable hook `desktop-after-read-hook' introduced.
;;     It is run after a desktop is read. It can be used to e.g. show a 
buffer list.
;;  4. Customizable hook `desktop-no-desktop-file-hook' introduced.
;;     It is run when no desktop file is found. By default a dired 
buffer is shown.
;;  5. Customizable variable `desktop-globals-to-save' introduced.
;;  6. Customizable variable `desktop-globals-to-clear' introduced.
;;  7. Command line option --no-desktop introduced.
;;     When this is specified, no desktop file is loaded.
;;  8. Functions `desktop-create-buffer' and 
`desktop-buffer-dired-misc-data' write file
;;     names in portable form using `tilde-expand-file-name'.
;;  9. Previously the desktop module wrote buffers in the desktop file 
in the reverse order
;;     of the buffer list. Morover restoring buffers in the same order 
depended on handlers
;;     to not change the order of the buffer list and to put newly 
created buffers at the
;;     top of the list. The new module writes buffers in the desktop 
file in the same order
;;     as the buffer list, and the dependence of handlers just described 
is removed. The
;;     change is backwards compatible in the sense that old desktop 
files are handled in the
;;     same way as the were with the old module.
;; 10. New function `desktop-change-dir'.
;;     Saves and clears the desktop, changes to directory DIR and loads 
the desktop there
;;     indepentently of the value of `desktop-path'.
;;     If `desktop-enable' was nil at call, the desktop is not saved, 
but `desktop-enable' is
;;     subsequently set to t.
;; 11. New function `desktop-save-in-load-dir'.
;;     Save desktop in directory from witch it was loaded.
;; 12. New function `desktop-revert'. Revert to the last loaded desktop.

Lars Hansen

             reply	other threads:[~2002-12-29  9:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-29  9:14 Lars Hansen [this message]
2002-12-29 11:45 ` desktop and tilde-expand-file-name Kai Großjohann
  -- strict thread matches above, loose matches on Subject: below --
2003-02-18 22:04 Lars Hansen
2003-02-19  0:01 ` Kim F. Storm
2003-02-19  9:22   ` Lars Hansen
     [not found]     ` <84heb0wnc9.fsf@lucy.is.informatik.uni-duisburg.de>
2003-02-19 11:09       ` Lars Hansen
2003-02-19 15:43     ` Reiner Steib
2003-02-19 17:18       ` Lars Hansen
2003-02-19 18:57       ` Kim F. Storm
2003-02-19 20:54         ` Lars Hansen
2003-02-19 10:51 ` Richard Stallman
2003-02-19 10:56   ` Lars Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E0EBCFE.8090106@math.ku.dk \
    --to=larsh@math.ku.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).