Mercurial > hg > xemacs-beta
diff lisp/efs/default-dir.el @ 40:7e54bd776075 r19-15b103
Import from CVS: tag r19-15b103
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:54:25 +0200 |
parents | 4103f0995bd7 |
children | 8b8b7f3559a2 |
line wrap: on
line diff
--- a/lisp/efs/default-dir.el Mon Aug 13 08:54:02 2007 +0200 +++ b/lisp/efs/default-dir.el Mon Aug 13 08:54:25 2007 +0200 @@ -3,7 +3,7 @@ ;; ;; File: default-dir.el ;; RCS: -;; Version: $Revision: 1.2 $ +;; Version: $Revision: 1.5 $ ;; Description: Defines the function default-directory, for fancy handling ;; of the initial contents in the minibuffer when reading ;; file names. @@ -35,6 +35,10 @@ ((>= (string-to-int (substring emacs-version 0 2)) 19) 'fsf-19) (t 'fsf-18))) +(defconst default-dir-find-file-takes-coding-system + (and (eq default-dir-emacs-variant 'xemacs) + (>= (string-to-int (substring emacs-version 0 2)) 20))) + ;;;###autoload (defvar default-directory-function nil "A function to call to compute the default-directory for the current buffer. @@ -58,86 +62,157 @@ ;;; Overloads -(if (or (featurep 'mule) - (boundp 'MULE)) - (progn - - (defun default-dir-find-file (file &optional coding-system) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name "Find file: " (default-directory))) - (and current-prefix-arg - (read-coding-system "Coding-system: ")))) - (default-dir-real-find-file file coding-system)) +(cond + ((or (featurep 'mule) + (boundp 'MULE)) + + (defun default-dir-find-file (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file: " (default-directory))) + (and current-prefix-arg + (read-coding-system "Coding-system: ")))) + (default-dir-real-find-file file coding-system)) + + (defun default-dir-find-file-other-window (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file in other window: " (default-directory))) + (and current-prefix-arg + (read-coding-system "Coding-system: ")))) + (default-dir-real-find-file-other-window file coding-system)) - (defun default-dir-find-file-other-window (file &optional coding-system) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name "Find file in other window: " (default-directory))) - (and current-prefix-arg - (read-coding-system "Coding-system: ")))) - (default-dir-real-find-file-other-window file coding-system)) + (defun default-dir-find-file-read-only (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file read-only: " (default-directory) nil t)) + (and current-prefix-arg + (read-coding-system "Coding-system: ")))) + (default-dir-real-find-file-read-only file coding-system)) - (defun default-dir-find-file-read-only (file &optional coding-system) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name "Find file read-only: " (default-directory) nil t)) - (and current-prefix-arg - (read-coding-system "Coding-system: ")))) - (default-dir-real-find-file-read-only file coding-system)) + (if (fboundp 'find-file-read-only-other-window) + (progn + (defun default-dir-find-file-read-only-other-window + (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name + "Find file read-only in other window: " + (default-directory) nil t)) + (and current-prefix-arg + (read-coding-system "Coding-system: ")))) + (default-dir-real-find-file-read-only-other-window file + coding-system)))) - (if (fboundp 'find-file-read-only-other-window) - (progn - (defun default-dir-find-file-read-only-other-window - (file &optional coding-system) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name - "Find file read-only in other window: " - (default-directory) nil t)) - (and current-prefix-arg - (read-coding-system "Coding-system: ")))) - (default-dir-real-find-file-read-only-other-window file - coding-system)))) + (if (fboundp 'find-file-other-frame) + (progn + (defun default-dir-find-file-other-frame + (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file in other frame: " + (default-directory))) + (and current-prefix-arg + (read-coding-system "Coding-system: ")))) + (default-dir-real-find-file-other-frame file + coding-system)))) + + (if (fboundp 'find-file-read-only-other-frame) + (progn + (defun default-dir-find-file-read-only-other-frame + (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file read-only in other frame: " + (default-directory) nil t)) + (and current-prefix-arg + (read-coding-system "Coding-system: ")))) + (default-dir-real-find-file-read-only-other-frame file + coding-system))))) - (if (fboundp 'find-file-other-frame) - (progn - (defun default-dir-find-file-other-frame - (file &optional coding-system) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name "Find file in other frame: " - (default-directory))) - (and current-prefix-arg - (read-coding-system "Coding-system: ")))) - (default-dir-real-find-file-other-frame file - coding-system)))) + (default-dir-find-file-takes-coding-system + ;; This lossage is due to the fact that XEmacs 20.x without mule + ;; still accepts an optional argument for find-file related + ;; functions. Things like advice.el insist on passing nil for + ;; optional arguments, and the interaction screws things up. + ;; Therefore these functions accept an optional dummy coding-system + ;; argument. + + (defun default-dir-find-file (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file: " (default-directory))))) + (default-dir-real-find-file file)) + + (defun default-dir-find-file-other-window (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file in other window: " (default-directory))))) + (default-dir-real-find-file-other-window file)) + + (defun default-dir-find-file-read-only (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file read-only: " (default-directory) nil t)))) + (default-dir-real-find-file-read-only file)) - (if (fboundp 'find-file-read-only-other-frame) - (progn - (defun default-dir-find-file-read-only-other-frame - (file &optional coding-system) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name "Find file read-only in other frame: " - (default-directory) nil t)) - (and current-prefix-arg - (read-coding-system "Coding-system: ")))) - (default-dir-real-find-file-read-only-other-frame file - coding-system))))) + (if (fboundp 'find-file-read-only-other-window) + (progn + (defun default-dir-find-file-read-only-other-window + (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name + "Find file read-only in other window: " + (default-directory) nil t)))) + (default-dir-real-find-file-read-only-other-window file)))) + (if (fboundp 'find-file-other-frame) + (progn + (defun default-dir-find-file-other-frame + (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file in other frame: " + (default-directory))))) + (default-dir-real-find-file-other-frame file)))) + + (if (fboundp 'find-file-read-only-other-frame) + (progn + (defun default-dir-find-file-read-only-other-frame + (file &optional coding-system) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Find file read-only in other frame: " + (default-directory) nil t)))) + (default-dir-real-find-file-read-only-other-frame file))))) + + (t + (defun default-dir-find-file (file) "Documented as original" (interactive @@ -194,7 +269,9 @@ (expand-file-name (read-file-name "Find file read-only in other frame: " (default-directory) nil t)))) - (default-dir-real-find-file-read-only-other-frame file))))) + (default-dir-real-find-file-read-only-other-frame file)))))) + + (efs-overwrite-fn "default-dir" 'find-file 'default-dir-find-file) (efs-overwrite-fn "default-dir" 'find-file-other-window @@ -282,23 +359,15 @@ (efs-overwrite-fn "default-dir" 'shell-command 'default-dir-shell-command) -;; Is advice about? -(if (featurep 'advice) - (defadvice cd (before default-dir-cd activate compile) - (interactive - (list - (expand-file-name - (read-file-name "Change default directory: " (default-directory)))))) - - (defun default-dir-cd (dir) - "Documented as original" - (interactive - (list - (expand-file-name - (read-file-name "Change default directory: " (default-directory))))) - (default-dir-real-cd dir)) +(defun default-dir-cd (dir) + "Documented as original" + (interactive + (list + (expand-file-name + (read-file-name "Change default directory: " (default-directory))))) + (default-dir-real-cd dir)) - (efs-overwrite-fn "default-dir" 'cd 'default-dir-cd)) +(efs-overwrite-fn "default-dir" 'cd 'default-dir-cd) (defun default-dir-set-visited-file-name (filename) "Documented as original"