From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lars Hansen Newsgroups: gmane.emacs.devel Subject: desktop and tilde-expand-file-name Date: Sun, 29 Dec 2002 10:14:38 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <3E0EBCFE.8090106@math.ku.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1041153322 9202 80.91.224.249 (29 Dec 2002 09:15:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 29 Dec 2002 09:15:22 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18SZXT-0002O3-00 for ; Sun, 29 Dec 2002 10:15:19 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18SZYU-0006F3-00 for ; Sun, 29 Dec 2002 10:16:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18SZXE-0007eh-06 for emacs-devel@quimby.gnus.org; Sun, 29 Dec 2002 04:15:04 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18SZWv-0007eE-00 for emacs-devel@gnu.org; Sun, 29 Dec 2002 04:14:45 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18SZWt-0007cX-00 for emacs-devel@gnu.org; Sun, 29 Dec 2002 04:14:44 -0500 Original-Received: from richardson.uni2.net ([130.227.52.104]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18SZWs-0007av-00 for emacs-devel@gnu.org; Sun, 29 Dec 2002 04:14:42 -0500 Original-Received: from math.ku.dk (p442-056.ppp.get2net.dk [195.47.149.56]) by richardson.uni2.net (8.11.6/8.11.6) with ESMTP id gBT9EdM08423 for ; Sun, 29 Dec 2002 10:14:39 +0100 User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10364 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10364 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