Commit 9397e56f authored by Martin Rudalics's avatar Martin Rudalics

Move/add window-buffer-related functions to window.el.

* buffer.c: New Lisp objects Qbuffer_list_update_hook and
Qclone_number.  Remove external declaration of Qdelete_window.
(Fbuffer_list): Rewrite doc-string.  Minor restructuring of
code.
(Fget_buffer_create, Fmake_indirect_buffer, Frename_buffer): Run
Qbuffer_list_update_hook if allowed.
(Fother_buffer): Rewrite doc-string.  Major rewrite for new
buffer list implementation.
(other_buffer_safely): New function.
(Fkill_buffer): Replace call to replace_buffer_in_all_windows by
calls to replace_buffer_in_windows and
replace_buffer_in_windows_safely.  Run Qbuffer_list_update_hook
if allowed.
(record_buffer): Inhibit quitting and rewrite using quittable
functions.  Run Qbuffer_list_update_hook if allowed.
(Frecord_buffer, Funrecord_buffer): New functions.
(switch_to_buffer_1, Fswitch_to_buffer): Remove.  Move
switch-to-buffer to window.el.
(bury-buffer): Move to window.el.
(Vbuffer_list_update_hook): New variable.

* lisp.h (other_buffer_safely): Add prototype in buffer.c
section.

* window.h (resize_frame_windows): Move up in code.
(Fwindow_frame): Remove EXFUN.
(replace_buffer_in_all_windows): Remove prototype.
(replace_buffer_in_windows_safely): Add prototype.

* window.c: Declare Qdelete_window static again.  Move down
declaration of select_count.
(Fnext_window, Fprevious_window): Rewrite doc-strings.
(Fother_window): Move to window.el.
(window_loop): Remove DELETE_BUFFER_WINDOWS and UNSHOW_BUFFER
cases.  Add REPLACE_BUFFER_IN_WINDOWS_SAFELY case.
(Fdelete_windows_on, Freplace_buffer_in_windows): Move to
window.el.
(replace_buffer_in_windows): Implement by calling
Qreplace_buffer_in_windows.
(replace_buffer_in_all_windows): Remove with some functionality
moved into replace_buffer_in_windows_safely.
(replace_buffer_in_windows_safely): New function.
(select_window_norecord, select_frame_norecord): Move in front
of run_window_configuration_change_hook.  Remove now obsolete
declarations.
(Fset_window_buffer): Rewrite doc-string.  Call
Qrecord_window_buffer.
(keys_of_window): Move binding for other-window to window.el.

* loadup.el (top-level): Load window before files for the sake
of replace-buffer-in-windows.

* files.el (read-buffer-to-switch)
(switch-to-buffer-other-window)
(switch-to-buffer-other-frame, display-buffer-other-frame): Move
to window.el.

* simple.el (get-next-valid-buffer, last-buffer, next-buffer)
(previous-buffer): Move to window.el.

* bindings.el (unbury-buffer): Move to window.el.

* window.el (delete-other-windows-vertically): Move after
definition of delete-other-windows.
(other-window, delete-windows-on, replace-buffer-in-windows):
Move here from window.c.
(record-window-buffer, unrecord-window-buffer)
(set-window-buffer-start-and-point, switch-to-prev-buffer)
(switch-to-next-buffer): New functions.
(get-next-valid-buffer, last-buffer, next-buffer): Move here
from simple.el.  Call switch-to-next-buffer.
(previous-buffer): Move here from simple.el.  Call
switch-to-prev-buffer.
(bury-buffer): Move here from buffer.c.  Switch to previous
buffer when window cannot be deleted.
(unbury-buffer): Move here from bindings.el.
(ctl-x-map): Move binding for other-window from window.c to
here.
(read-buffer-to-switch, switch-to-buffer-other-window)
(switch-to-buffer-other-frame): Move here from files.el.
(normalize-buffer-to-switch-to): New functions.
(switch-to-buffer): Move here from buffer.c.  Use
read-buffer-to-switch and normalize-buffer-to-switch-to.
parent b50691aa
2011-06-10 Martin Rudalics <rudalics@gmx.at>
* loadup.el (top-level): Load window before files for the sake
of replace-buffer-in-windows.
* files.el (read-buffer-to-switch)
(switch-to-buffer-other-window)
(switch-to-buffer-other-frame, display-buffer-other-frame): Move
to window.el.
* simple.el (get-next-valid-buffer, last-buffer, next-buffer)
(previous-buffer): Move to window.el.
* bindings.el (unbury-buffer): Move to window.el.
* window.el (delete-other-windows-vertically): Move after
definition of delete-other-windows.
(other-window, delete-windows-on, replace-buffer-in-windows):
Move here from window.c.
(record-window-buffer, unrecord-window-buffer)
(set-window-buffer-start-and-point, switch-to-prev-buffer)
(switch-to-next-buffer): New functions.
(get-next-valid-buffer, last-buffer, next-buffer): Move here
from simple.el. Call switch-to-next-buffer.
(previous-buffer): Move here from simple.el. Call
switch-to-prev-buffer.
(bury-buffer): Move here from buffer.c. Switch to previous
buffer when window cannot be deleted.
(unbury-buffer): Move here from bindings.el.
(ctl-x-map): Move binding for other-window from window.c to
here.
(read-buffer-to-switch, switch-to-buffer-other-window)
(switch-to-buffer-other-frame): Move here from files.el.
(normalize-buffer-to-switch-to): New functions.
(switch-to-buffer): Move here from buffer.c. Use
read-buffer-to-switch and normalize-buffer-to-switch-to.
2011-06-10 Martin Rudalics <rudalics@gmx.at>
* window.el (window-min-height, window-min-width): Move here
......
......@@ -454,11 +454,6 @@ Major modes that edit things other than ordinary files may change this
(put 'mode-line-buffer-identification 'risky-local-variable t)
(make-variable-buffer-local 'mode-line-buffer-identification)
(defun unbury-buffer () "\
Switch to the last buffer in the buffer list."
(interactive)
(switch-to-buffer (last-buffer)))
(defun mode-line-unbury-buffer (event) "\
Call `unbury-buffer' in this window."
(interactive "e")
......
......@@ -1288,100 +1288,6 @@ return value, which may be passed as the REQUIRE-MATCH arg to
'confirm)
(t nil)))
(defun read-buffer-to-switch (prompt)
"Read the name of a buffer to switch to and return as a string.
It is intended for `switch-to-buffer' family of commands since they
need to omit the name of current buffer from the list of completions
and default values."
(let ((rbts-completion-table (internal-complete-buffer-except)))
(minibuffer-with-setup-hook
(lambda ()
(setq minibuffer-completion-table rbts-completion-table)
;; Since rbts-completion-table is built dynamically, we
;; can't just add it to the default value of
;; icomplete-with-completion-tables, so we add it
;; here manually.
(if (and (boundp 'icomplete-with-completion-tables)
(listp icomplete-with-completion-tables))
(set (make-local-variable 'icomplete-with-completion-tables)
(cons rbts-completion-table
icomplete-with-completion-tables))))
(read-buffer prompt (other-buffer (current-buffer))
(confirm-nonexistent-file-or-buffer)))))
(defun switch-to-buffer-other-window (buffer-or-name &optional norecord)
"Select the buffer specified by BUFFER-OR-NAME in another window.
BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or
nil. Return the buffer switched to.
If called interactively, prompt for the buffer name using the
minibuffer. The variable `confirm-nonexistent-file-or-buffer'
determines whether to request confirmation before creating a new
buffer.
If BUFFER-OR-NAME is a string and does not identify an existing
buffer, create a new buffer with that name. If BUFFER-OR-NAME is
nil, switch to the buffer returned by `other-buffer'.
Optional second argument NORECORD non-nil means do not put this
buffer at the front of the list of recently selected ones.
This uses the function `display-buffer' as a subroutine; see its
documentation for additional customization information."
(interactive
(list (read-buffer-to-switch "Switch to buffer in other window: ")))
(let ((pop-up-windows t)
same-window-buffer-names same-window-regexps)
(pop-to-buffer buffer-or-name t norecord)))
(defun switch-to-buffer-other-frame (buffer-or-name &optional norecord)
"Switch to buffer BUFFER-OR-NAME in another frame.
BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or
nil. Return the buffer switched to.
If called interactively, prompt for the buffer name using the
minibuffer. The variable `confirm-nonexistent-file-or-buffer'
determines whether to request confirmation before creating a new
buffer.
If BUFFER-OR-NAME is a string and does not identify an existing
buffer, create a new buffer with that name. If BUFFER-OR-NAME is
nil, switch to the buffer returned by `other-buffer'.
Optional second arg NORECORD non-nil means do not put this
buffer at the front of the list of recently selected ones.
This uses the function `display-buffer' as a subroutine; see its
documentation for additional customization information."
(interactive
(list (read-buffer-to-switch "Switch to buffer in other frame: ")))
(let ((pop-up-frames t)
same-window-buffer-names same-window-regexps)
(pop-to-buffer buffer-or-name t norecord)))
(defun display-buffer-other-frame (buffer)
"Display buffer BUFFER in another frame.
This uses the function `display-buffer' as a subroutine; see
its documentation for additional customization information."
(interactive "BDisplay buffer in other frame: ")
(let ((pop-up-frames t)
same-window-buffer-names same-window-regexps
;;(old-window (selected-window))
new-window)
(setq new-window (display-buffer buffer t))
;; This may have been here in order to prevent the new frame from hiding
;; the old frame. But it does more harm than good.
;; Maybe we should call `raise-window' on the old-frame instead? --Stef
;;(lower-frame (window-frame new-window))
;; This may have been here in order to make sure the old-frame gets the
;; focus. But not only can it cause an annoying flicker, with some
;; window-managers it just makes the window invisible, with no easy
;; way to recover it. --Stef
;;(make-frame-invisible (window-frame old-window))
;;(make-frame-visible (window-frame old-window))
))
(defmacro minibuffer-with-setup-hook (fun &rest body)
"Temporarily add FUN to `minibuffer-setup-hook' while executing BODY.
BODY should use the minibuffer at most once.
......
......@@ -95,6 +95,7 @@
(load "env")
(load "format")
(load "bindings")
(load "window") ; Needed here for `replace-buffer-in-windows'.
(setq load-source-file-function 'load-with-code-conversion)
(load "files")
......@@ -156,7 +157,6 @@
(load "language/cham")
(load "indent")
(load "window")
(load "frame")
(load "term/tty-colors")
(load "font-core")
......
......@@ -52,60 +52,6 @@ wait this many seconds after Emacs becomes idle before doing an update."
(defgroup paren-matching nil
"Highlight (un)matching of parens and expressions."
:group 'matching)
(defun get-next-valid-buffer (list &optional buffer visible-ok frame)
"Search LIST for a valid buffer to display in FRAME.
Return nil when all buffers in LIST are undesirable for display,
otherwise return the first suitable buffer in LIST.
Buffers not visible in windows are preferred to visible buffers,
unless VISIBLE-OK is non-nil.
If the optional argument FRAME is nil, it defaults to the selected frame.
If BUFFER is non-nil, ignore occurrences of that buffer in LIST."
;; This logic is more or less copied from other-buffer.
(setq frame (or frame (selected-frame)))
(let ((pred (frame-parameter frame 'buffer-predicate))
found buf)
(while (and (not found) list)
(setq buf (car list))
(if (and (not (eq buffer buf))
(buffer-live-p buf)
(or (null pred) (funcall pred buf))
(not (eq (aref (buffer-name buf) 0) ?\s))
(or visible-ok (null (get-buffer-window buf 'visible))))
(setq found buf)
(setq list (cdr list))))
(car list)))
(defun last-buffer (&optional buffer visible-ok frame)
"Return the last buffer in FRAME's buffer list.
If BUFFER is the last buffer, return the preceding buffer instead.
Buffers not visible in windows are preferred to visible buffers,
unless optional argument VISIBLE-OK is non-nil.
Optional third argument FRAME nil or omitted means use the
selected frame's buffer list.
If no such buffer exists, return the buffer `*scratch*', creating
it if necessary."
(setq frame (or frame (selected-frame)))
(or (get-next-valid-buffer (nreverse (buffer-list frame))
buffer visible-ok frame)
(get-buffer "*scratch*")
(let ((scratch (get-buffer-create "*scratch*")))
(set-buffer-major-mode scratch)
scratch)))
(defun next-buffer ()
"Switch to the next buffer in cyclic order."
(interactive)
(let ((buffer (current-buffer)))
(switch-to-buffer (other-buffer buffer t))
(bury-buffer buffer)))
(defun previous-buffer ()
"Switch to the previous buffer in cyclic order."
(interactive)
(switch-to-buffer (last-buffer (current-buffer) t)))
;;; next-error support framework
......
This diff is collapsed.
2011-06-11 Martin Rudalics <rudalics@gmx.at>
* buffer.c: New Lisp objects Qbuffer_list_update_hook and
Qclone_number. Remove external declaration of Qdelete_window.
(Fbuffer_list): Rewrite doc-string. Minor restructuring of
code.
(Fget_buffer_create, Fmake_indirect_buffer, Frename_buffer): Run
Qbuffer_list_update_hook if allowed.
(Fother_buffer): Rewrite doc-string. Major rewrite for new
buffer list implementation.
(other_buffer_safely): New function.
(Fkill_buffer): Replace call to replace_buffer_in_all_windows by
calls to replace_buffer_in_windows and
replace_buffer_in_windows_safely. Run Qbuffer_list_update_hook
if allowed.
(record_buffer): Inhibit quitting and rewrite using quittable
functions. Run Qbuffer_list_update_hook if allowed.
(Frecord_buffer, Funrecord_buffer): New functions.
(switch_to_buffer_1, Fswitch_to_buffer): Remove. Move
switch-to-buffer to window.el.
(bury-buffer): Move to window.el.
(Vbuffer_list_update_hook): New variable.
* lisp.h (other_buffer_safely): Add prototype in buffer.c
section.
* window.h (resize_frame_windows): Move up in code.
(Fwindow_frame): Remove EXFUN.
(replace_buffer_in_all_windows): Remove prototype.
(replace_buffer_in_windows_safely): Add prototype.
* window.c: Declare Qdelete_window static again. Move down
declaration of select_count.
(Fnext_window, Fprevious_window): Rewrite doc-strings.
(Fother_window): Move to window.el.
(window_loop): Remove DELETE_BUFFER_WINDOWS and UNSHOW_BUFFER
cases. Add REPLACE_BUFFER_IN_WINDOWS_SAFELY case.
(Fdelete_windows_on, Freplace_buffer_in_windows): Move to
window.el.
(replace_buffer_in_windows): Implement by calling
Qreplace_buffer_in_windows.
(replace_buffer_in_all_windows): Remove with some functionality
moved into replace_buffer_in_windows_safely.
(replace_buffer_in_windows_safely): New function.
(select_window_norecord, select_frame_norecord): Move in front
of run_window_configuration_change_hook. Remove now obsolete
declarations.
(Fset_window_buffer): Rewrite doc-string. Call
Qrecord_window_buffer.
(keys_of_window): Move binding for other-window to window.el.
2011-06-11 Chong Yidong <cyd@stupidchicken.com>
* dispextern.h (struct image): Replace data member, whose int_val
......
This diff is collapsed.
......@@ -3011,6 +3011,7 @@ extern Lisp_Object set_buffer_if_live (Lisp_Object);
EXFUN (Fbarf_if_buffer_read_only, 0);
EXFUN (Fcurrent_buffer, 0);
EXFUN (Fother_buffer, 3);
extern Lisp_Object other_buffer_safely (Lisp_Object);
EXFUN (Foverlay_get, 2);
EXFUN (Fbuffer_modified_p, 1);
EXFUN (Fset_buffer_modified_p, 1);
......
This diff is collapsed.
......@@ -827,6 +827,7 @@ extern Lisp_Object make_window (void);
extern Lisp_Object window_from_coordinates (struct frame *, int, int,
enum window_part *, int);
EXFUN (Fwindow_dedicated_p, 1);
extern void resize_frame_windows (struct frame *, int, int);
extern void delete_all_subwindows (Lisp_Object);
extern void freeze_window_starts (struct frame *, int);
extern void grow_mini_window (struct window *, int);
......@@ -902,7 +903,6 @@ extern Lisp_Object Qwindowp, Qwindow_live_p;
extern Lisp_Object Vwindow_list;
EXFUN (Fwindow_buffer, 1);
EXFUN (Fwindow_frame, 1);
EXFUN (Fget_buffer_window, 2);
EXFUN (Fwindow_minibuffer_p, 1);
EXFUN (Fselected_window, 0);
......@@ -918,12 +918,10 @@ extern int window_internal_height (struct window *);
extern int window_body_cols (struct window *w);
EXFUN (Frecenter, 1);
extern void temp_output_buffer_show (Lisp_Object);
extern void replace_buffer_in_all_windows (Lisp_Object);
extern void replace_buffer_in_windows_safely (Lisp_Object);
extern void init_window_once (void);
extern void init_window (void);
extern void syms_of_window (void);
extern void keys_of_window (void);
extern void resize_frame_windows (struct frame *, int, int);
#endif /* not WINDOW_H_INCLUDED */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment