help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

set-window-buffer bugs


From: jenia.ivlev
Subject: set-window-buffer bugs
Date: Sat, 05 Dec 2015 15:52:12 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hello.

Using dired, I want find-buffer-other-window to open in the exact
same window. 

So I made this little program:


    (define-key dired-mode-map "o" 'dired-find-file-other-opened-window)

    (defun dired-find-file-other-opened-window ()
        (interactive)
        (set-window-buffer (frame-first-window) (dired-get-filename 'no-dir))
        (dired-find-file-other-window))
        

It turns out that you needed to have visited that file already for
this to work.


Here is the backtrace for when it doesnt work:

    Debugger entered--entering a function:
    * #<subr set-window-buffer>(#<window 3 on *Backtrace*> "String.h" nil)
    * apply(#<subr set-window-buffer> (#<window 3 on *Backtrace*> "String.h"))
    * set-window-buffer(#<window 3 on *Backtrace*> "String.h")
    dired-find-file-other-opened-window()
    dired-fnd-fl-otr-opn-wnd-keep-cursor()
    call-interactively(dired-fnd-fl-otr-opn-wnd-keep-cursor nil nil)
    command-execute(dired-fnd-fl-otr-opn-wnd-keep-cursor)

After pressing `d` again, I get:

    * command-error-default-function((wrong-type-argument bufferp nil) "" apply)

And here is a backtrace where it does work (the file has been previous visited):

    Debugger entered--entering a function:
    * window-buffer(#<window 3 on *Backtrace*>)
    * linum-after-scroll(#<window 3 on *Backtrace*> 1)
    * #<subr set-window-buffer>(#<window 3 on *Backtrace*> "String.c" nil)
    * apply(#<subr set-window-buffer> (#<window 3 on *Backtrace*> "String.c"))
    * set-window-buffer(#<window 3 on *Backtrace*> "String.c")
    dired-find-file-other-opened-window()
    dired-fnd-fl-otr-opn-wnd-keep-cursor()
    call-interactively(dired-fnd-fl-otr-opn-wnd-keep-cursor nil nil)
    command-execute(dired-fnd-fl-otr-opn-wnd-keep-cursor)



I mean, I don't get it. Why do I need to have visited the file before?
And in any case, how do I fix this? I just want it to open in the
(frame-first-window) that's all.


Thanks




reply via email to

[Prev in Thread] Current Thread [Next in Thread]