From: "Ehud Karni" <ehud@unix.mvs.co.il>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Changing open file buffer handling
Date: Wed, 5 Mar 2003 22:16:39 +0200 [thread overview]
Message-ID: <200303052016.h25KGd0P030506@beta.mvs.co.il> (raw)
In-Reply-To: <usmu1r7m6.fsf@softechnics.com> (jeff.rancier@softechnics.com)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, 05 Mar 2003 13:28:01 -0500, jeff.rancier@softechnics.com (Jeffery B. Rancier) wrote:
> >
> > Add this to your .emacs:
> >
> > (defun dired-find-alternate-file
> > "In dired, visit this file or directory instead of dired buffer."
> > (interactive "P")
> > (find-alternate-file (dired-get-filename)))
> >
>
> Should that be
>
> (defun dired-find-alternate-file
> "In dired, visit this file or directory instead of dired buffer."
> (interactive)
> (find-alternate-file (dired-get-filename)))
Sorry. It was "too quick" hack of my real function which is:
(defun dired-find-alternate-file (&optional as-directory)
"In dired, visit this file or directory instead of dired buffer."
(interactive "P")
(if as-directory
(ek-find-alternate-file nil as-directory)
(ek-find-alternate-file (dired-get-filename))))
;;------------- find-alternate-file (modified from files) ---------------
(defun ek-find-alternate-file (&optional filename as-directory)
"Find file FILENAME, select its buffer, kill previous buffer.
If the current buffer now contains an empty file that you just visited
\(presumably by mistake), use this command to visit the file you really want.
With non-nil prefix argument AS-DIRECTORY do `dired' on the file-name."
(interactive)
(setq as-directory current-prefix-arg)
(let ((file buffer-file-name)
(obuf (current-buffer))
(ofile buffer-file-name)
(onum buffer-file-number)
(otrue buffer-file-truename)
(oname (buffer-name))
file-name file-dir)
(or filename
(and file
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file))
nil)
(setq filename (read-file-name (concat "Find alternate "
(if as-directory "(dired): " "file: "))
file-dir nil nil file-name)))
(and (buffer-modified-p) (buffer-file-name)
;; (not buffer-read-only)
(not (yes-or-no-p (format "Buffer %s is modified, kill anyway? "
(buffer-name))))
(error "Aborted"))
(if (get-buffer " **lose**")
(kill-buffer " **lose**"))
(rename-buffer " **lose**")
(unwind-protect
(progn
(unlock-buffer)
(setq buffer-file-name nil)
(setq buffer-file-number nil)
(setq buffer-file-truename nil)
(if as-directory
(dired filename)
(find-file filename))
(cond (
(eq obuf (current-buffer))
(setq buffer-file-name ofile)
(setq buffer-file-number onum)
(setq buffer-file-truename otrue)
(lock-buffer)
(rename-buffer oname))))
(or (eq (current-buffer) obuf)
(kill-buffer obuf)))))
Ehud.
- --
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.mvs.co.il Better Safe Than Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)
iD4DBQE+ZlsnLFvTvpjqOY0RAr03AJ9YLLiL866oq4weVk8uA/LirQfHxwCVEQaV
vAzXxqidzRRm/tXNQOoLAg==
=u/9s
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2003-03-05 20:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-05 11:15 Changing "open file" buffer handling Niclas Blomqvist
2003-03-05 15:48 ` Jeffery B. Rancier
2003-03-05 16:34 ` Changing open file " Ehud Karni
2003-03-05 18:28 ` Jeffery B. Rancier
2003-03-05 20:16 ` Ehud Karni [this message]
[not found] ` <mailman.2808.1046888898.21513.help-gnu-emacs@gnu.org>
2003-03-05 19:43 ` Kevin Rodgers
-- strict thread matches above, loose matches on Subject: below --
2003-03-05 16:31 Changing "open file" " Ed Rubinsky
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=200303052016.h25KGd0P030506@beta.mvs.co.il \
--to=ehud@unix.mvs.co.il \
--cc=help-gnu-emacs@gnu.org \
/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.
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).