all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Changing "open file" buffer handling
@ 2003-03-05 11:15 Niclas Blomqvist
  2003-03-05 15:48 ` Jeffery B. Rancier
  2003-03-05 16:34 ` Changing open file " Ehud Karni
  0 siblings, 2 replies; 7+ messages in thread
From: Niclas Blomqvist @ 2003-03-05 11:15 UTC (permalink / raw)


When I use C-x C-f to open a directory buffer and then use Enter key to
navigate through directories until I finally find the desired file, Emacs
leaves me with a buffer list containing every directory buffer I have
visited on the way. Is there a setting that can be changed so that walking
through directories updates the current buffer until I reach my file
instead of creating a new buffer for every new directory?

Thx
//Niclas Blomquist

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Changing "open file" buffer handling
  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
  1 sibling, 0 replies; 7+ messages in thread
From: Jeffery B. Rancier @ 2003-03-05 15:48 UTC (permalink / raw)


Niclas Blomqvist <niclas-b@dsv.su.se> writes:

> When I use C-x C-f to open a directory buffer and then use Enter key to
> navigate through directories until I finally find the desired file, Emacs
> leaves me with a buffer list containing every directory buffer I have
> visited on the way. Is there a setting that can be changed so that walking
> through directories updates the current buffer until I reach my file
> instead of creating a new buffer for every new directory?
>
> Thx
> //Niclas Blomquist

-- 

I recently asked the same thing, the answer was to use the following:

,----[ C-h f dired-maybe-insert-subdir RET ]
| dired-maybe-insert-subdir is an interactive autoloaded Lisp function in `dired-aux'.
| [Arg list not available until function definition is loaded.]
| 
| Insert this subdirectory into the same dired buffer.
| If it is already present, just move to it (type M-x dired-do-redisplay to refresh),
|   else inserts it at its natural place (as `ls -lR' would have done).
| With a prefix arg, you may edit the ls switches used for this listing.
|   You can add `R' to the switches to expand the whole tree starting at
|   this subdirectory.
| This function takes some pains to conform to `ls -lR' output.
`----

Jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Changing "open file" buffer handling
@ 2003-03-05 16:31 Ed Rubinsky
  0 siblings, 0 replies; 7+ messages in thread
From: Ed Rubinsky @ 2003-03-05 16:31 UTC (permalink / raw)


Typing 'i' on a line with a sub-directory in a dired buffer will insert the 
contents of that sub-directory into the same buffer immediately after the 
top level directory of the dired buffer and move there. C-u C-<space> will 
move back to the sub-directory line.

Best, Ed

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Changing open file buffer handling
  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 ` Ehud Karni
  2003-03-05 18:28   ` Jeffery B. Rancier
       [not found]   ` <mailman.2808.1046888898.21513.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 7+ messages in thread
From: Ehud Karni @ 2003-03-05 16:34 UTC (permalink / raw)
  Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 5 Mar 2003 12:15:28 +0100 (MET), Niclas Blomqvist <niclas-b@dsv.su.se> wrote:
> 
> When I use C-x C-f to open a directory buffer and then use Enter key to
> navigate through directories until I finally find the desired file, Emacs
> leaves me with a buffer list containing every directory buffer I have
> visited on the way. Is there a setting that can be changed so that walking
> through directories updates the current buffer until I reach my file
> instead of creating a new buffer for every new directory?

You can press `i' to add the subdirectory in the current buffer as was
suggested by Jeffery B. Rancier <jeff.rancier@softechnics.com>, or you
can write few elisp lines and have a "real" subdirectory replacement.

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)))

(eval-after-load "dired"
  '(define-key dired-mode-map  "a"   'dired-find-alternate-file))


Now, when you press `a' you'll edit the file or brows the subdirectory
instead of the parent directory.

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)

iD8DBQE+ZickLFvTvpjqOY0RAhgCAJ4/2vSbzCdQGt0w0oEEEZoR4QE2ogCfdAcV
Wty33ABAte7FgMQZtU4oa3c=
=QPO5
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Changing open file buffer handling
  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
       [not found]   ` <mailman.2808.1046888898.21513.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Jeffery B. Rancier @ 2003-03-05 18:28 UTC (permalink / raw)


"Ehud Karni" <ehud@unix.mvs.co.il> writes:

[snip]
>
> 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)))

?
-- 

Thanks,
Jeff
,----
| Jeffery B. Rancier
| 
| Softechnics
| a METTLER TOLEDO company
`----

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Changing open file buffer handling
       [not found]   ` <mailman.2808.1046888898.21513.help-gnu-emacs@gnu.org>
@ 2003-03-05 19:43     ` Kevin Rodgers
  0 siblings, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2003-03-05 19:43 UTC (permalink / raw)


Jeffery B. Rancier wrote:

> 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)))

Your point being that there's no function argument to map a prefix argument to.

But you still have to provide an (empty) argument list:

(defun dired-find-alternate-file ()
  "In dired, visit this file or directory instead of dired buffer."
  (interactive)
  (find-alternate-file (dired-get-filename)))


-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Changing open file buffer handling
  2003-03-05 18:28   ` Jeffery B. Rancier
@ 2003-03-05 20:16     ` Ehud Karni
  0 siblings, 0 replies; 7+ messages in thread
From: Ehud Karni @ 2003-03-05 20:16 UTC (permalink / raw)
  Cc: help-gnu-emacs

-----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-----

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-03-05 20:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.