annotate lisp/prim/buffer.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 0293115a14e9
children b9518feda344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; buffer.el --- buffer routines taken from C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1995 Sun Microsystems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 4
diff changeset
19 ;; along with XEmacs; see the file COPYING. If not, write to the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
20 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 4
diff changeset
21 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Synched up with: FSF 19.30 buffer.c.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (defun switch-to-buffer (bufname &optional norecord)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 "Select buffer BUFNAME in the current window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 BUFNAME may be a buffer or a buffer name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 Optional second arg NORECORD non-nil means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 do not put this buffer at the front of the list of recently selected ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 WARNING: This is NOT the way to work on another buffer temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 within a Lisp program! Use `set-buffer' instead. That avoids messing with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 the window-buffer correspondences."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (interactive "BSwitch to buffer: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; #### Doc string should indicate that the buffer name will get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; translated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if (eq (minibuffer-window) (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (error "Cannot switch buffers in minibuffer window"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (if (window-dedicated-p (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (error "Cannot switch buffers in a dedicated window"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (let (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if (null bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (setq buf (other-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq buf (get-buffer bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (if (null buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq buf (get-buffer-create bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (set-buffer-major-mode buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (push-window-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (or norecord (record-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (set-window-buffer (if (eq (selected-window) (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (next-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defun pop-to-buffer (bufname &optional not-this-window-p on-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "Select buffer BUFNAME in some window, preferably a different one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 If BUFNAME is nil, then some other buffer is chosen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 If `pop-up-windows' is non-nil, windows can be split to do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 If optional second arg NOT-THIS-WINDOW-P is non-nil, insist on finding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 another window even if BUFNAME is already visible in the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 If optional third arg is non-nil, it is the frame to pop to this
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
69 buffer on."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; #### Doc string should indicate that the buffer name will get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; translated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
74 (let (buf window frame)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (if (null bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (setq buf (other-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (setq buf (get-buffer bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (null buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (setq buf (get-buffer-create bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (set-buffer-major-mode buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (push-window-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (setq window (display-buffer buf not-this-window-p on-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq frame (window-frame window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; if the display-buffer hook decided to show this buffer in another
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
87 ;; frame, then select that frame.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
88 (if (not (eq frame (selected-frame)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (select-frame frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (record-buffer buf)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
91 (select-window window)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 buf))