[comp.emacs] elisp problem...

john@wpi.WPI.EDU (John F Stoffel) (11/10/90)

I'm trying to hack the following elisp code to delete the buffer it
has just left when it goes to the new buffer.  This code is for
enhancements to dired to go up and down directories easier.


(defun dired-up-directory ()
  "Find .., switching to its buffer if it exists"
  (interactive)
  (let* ((target-dir (parent dired-directory))
	 (target-dir-entry (assoc target-dir dired-dirs-alist))
	 (target-dir-buffer (car (cdr target-dir-entry))))
    (cond (target-dir-entry
	   (cond ((memq target-dir-buffer (buffer-list))
		  (switch-to-buffer target-dir-buffer))
		 (t (setq dired-dirs-alist (alist-delete target-dir-entry
							 dired-dirs-alist))
		    (find-file target-dir))))
		  (t (find-file target-dir))))
)


I'm trying to use (kill-buffer (previous-window)) which worked in
another function to kill the buffer, but nothing happens now.  I've
tried placing it right after the (interactive), just before and after
(switch-to-buffer ...), and at the very end after (t (find-file
target-dir)))) but nothing happens.  It all loads fine, but it go...
blah!

No while I'd like a fix for this problem, I'd also like an explanation
of WHY it didn't work.  Thanks for your time and effort...
--
I dreamt about a reefer five feet long,  | John Stoffel
a might immense, but not too stong,      | john@wpi.wpi.edu
you'll be high, but not for long.        |--------------------------------- 
when you're, a viper...          <-- The Viper Drag    Ain't Misbehaiving

manderso@spain.mpr.ca (Mark Anderson) (11/10/90)

In article <JOHN.90Nov9173651@wpi.WPI.EDU>
john@wpi.WPI.EDU (John F Stoffel) writes:
>I'm trying to hack the following elisp code to delete the buffer it
>has just left when it goes to the new buffer.
[...]
>I'm trying to use (kill-buffer (previous-window))

Just glancing at this, don't you mean:

	(kill-buffer (window-buffer (previous-window)))

Or, after switching to a new buffer I think you can kill the previous
one with:

	(switch-to-buffer ...)
	(kill-buffer (car (cdr (buffer-list))))

Or you could always kill the current buffer before switching:

	(kill-buffer (current-buffer))
	(switch-to-buffer ...)

Or maybe I don't really understand the problem. :-)
-- 
Mark Anderson
manderso@mprgate.mpr.ca