[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: File menu changes (suggestions)
From: |
public |
Subject: |
Re: File menu changes (suggestions) |
Date: |
Fri, 01 Jul 2005 02:45:19 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
> E.g. find-file might require confirmation before opening
> a non-existent file. I'll love such a new feature, seeing how often I do
> "C-x C-f emacs/src/rege TAB RET" only to find myself in "regexp." rather
> than in the "regexp.c" that I intended to open.
Here is what I use in Easymacs, which I have modified from
http://www-xray.ast.cam.ac.uk/~gmorris/dotemacs.html -- I just added the
make-directory bit.
(defadvice find-file (around confirm-new-file activate)
"If file does not exist, prompt."
(let ((file (ad-get-arg 0)))
(when (or (not (interactive-p))
(find-buffer-visiting file)
(string-match "\\`/\\[" file) ; old-style TRAMP
(string-match "\\`/address@hidden:" file) ; new-style TRAMP
(file-directory-p file)
;; file-exists-p does not handle wildcards.
(file-expand-wildcards file)
;; A nice trick, but not necessary.
;;; (string-match "0\n\\'" (shell-command-to-string
;;; (format "ls %s; echo $?" file)))
(yes-or-no-p
(format "`%s' does not exist, create new file? " file)))
;; Is this a good idea? If we open a new file by accident,
;; despite the confirmation, we probably don't want the directory.
(unless (file-directory-p (file-name-directory file))
(make-directory (file-name-directory file) t))
ad-do-it)))
(defadvice switch-to-buffer (around confirm-new-buffer activate)
"If buffer does not exist, prompt."
(let ((buff (ad-get-arg 0)))
(if (or (not (interactive-p))
(get-buffer buff)
(yes-or-no-p
(format "`%s' does not exist, create new file? " buff)))
ad-do-it)))
- Re: File menu changes (suggestions), (continued)
- Re: File menu changes (suggestions), Miles Bader, 2005/06/28
- Re: File menu changes (suggestions), Stefan Monnier, 2005/06/29
- Re: File menu changes (suggestions), Miles Bader, 2005/06/29
- Re: File menu changes (suggestions), Eli Zaretskii, 2005/06/29
- Re: File menu changes (suggestions), Miles Bader, 2005/06/29
- Re: File menu changes (suggestions), Richard M. Stallman, 2005/06/29
- Re: File menu changes (suggestions), David Kastrup, 2005/06/30
- Re: File menu changes (suggestions), Richard M. Stallman, 2005/06/29
- Re: File menu changes (suggestions), David Kastrup, 2005/06/30
- Re: File menu changes (suggestions), Miles Bader, 2005/06/30
- Re: File menu changes (suggestions),
public <=
Re: File menu changes (suggestions), David Reitter, 2005/06/26
Re: File menu changes (suggestions), LENNART BORGMAN, 2005/06/27
Re: File menu changes (suggestions), LENNART BORGMAN, 2005/06/30