Mercurial > emacs
comparison lisp/files.el @ 94248:63d5fa94ea09
(read-buffer-to-switch): New function.
(switch-to-buffer-other-window, switch-to-buffer-other-frame):
Change interactive spec to call read-buffer-to-switch instead of
using the letter "B".
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 22 Apr 2008 19:48:02 +0000 |
parents | 959a3833d833 |
children | 1a8916b995cf |
comparison
equal
deleted
inserted
replaced
94247:57c8f6a6456a | 94248:63d5fa94ea09 |
---|---|
1037 (default-file-name-coding-system nil) | 1037 (default-file-name-coding-system nil) |
1038 (locale-coding-system nil)) | 1038 (locale-coding-system nil)) |
1039 (rename-file encoded new-encoded ok-if-already-exists) | 1039 (rename-file encoded new-encoded ok-if-already-exists) |
1040 newname)) | 1040 newname)) |
1041 | 1041 |
1042 (defun read-buffer-to-switch (prompt) | |
1043 "Read the name of a buffer to switch to and return as a string. | |
1044 It is intended for `switch-to-buffer' family of commands since they | |
1045 need to omit the name of current buffer from the list of complations | |
1046 and default values." | |
1047 (minibuffer-with-setup-hook | |
1048 (lambda () | |
1049 (set (make-local-variable 'minibuffer-completion-table) | |
1050 (internal-complete-buffer-except (other-buffer (current-buffer) t)))) | |
1051 (read-buffer prompt (other-buffer (current-buffer))))) | |
1052 | |
1042 (defun switch-to-buffer-other-window (buffer &optional norecord) | 1053 (defun switch-to-buffer-other-window (buffer &optional norecord) |
1043 "Select buffer BUFFER in another window. | 1054 "Select buffer BUFFER in another window. |
1044 If BUFFER does not identify an existing buffer, then this function | 1055 If BUFFER does not identify an existing buffer, then this function |
1045 creates a buffer with that name. | 1056 creates a buffer with that name. |
1046 | 1057 |
1051 do not put this buffer at the front of the list of recently selected ones. | 1062 do not put this buffer at the front of the list of recently selected ones. |
1052 This function returns the buffer it switched to. | 1063 This function returns the buffer it switched to. |
1053 | 1064 |
1054 This uses the function `display-buffer' as a subroutine; see its | 1065 This uses the function `display-buffer' as a subroutine; see its |
1055 documentation for additional customization information." | 1066 documentation for additional customization information." |
1056 (interactive "BSwitch to buffer in other window: ") | 1067 (interactive |
1068 (list (read-buffer-to-switch "Switch to buffer in other window: "))) | |
1057 (let ((pop-up-windows t) | 1069 (let ((pop-up-windows t) |
1058 ;; Don't let these interfere. | 1070 ;; Don't let these interfere. |
1059 same-window-buffer-names same-window-regexps) | 1071 same-window-buffer-names same-window-regexps) |
1060 (pop-to-buffer buffer t norecord))) | 1072 (pop-to-buffer buffer t norecord))) |
1061 | 1073 |
1065 do not put this buffer at the front of the list of recently selected ones. | 1077 do not put this buffer at the front of the list of recently selected ones. |
1066 This function returns the buffer it switched to. | 1078 This function returns the buffer it switched to. |
1067 | 1079 |
1068 This uses the function `display-buffer' as a subroutine; see its | 1080 This uses the function `display-buffer' as a subroutine; see its |
1069 documentation for additional customization information." | 1081 documentation for additional customization information." |
1070 (interactive "BSwitch to buffer in other frame: ") | 1082 (interactive |
1083 (list (read-buffer-to-switch "Switch to buffer in other frame: "))) | |
1071 (let ((pop-up-frames t) | 1084 (let ((pop-up-frames t) |
1072 same-window-buffer-names same-window-regexps) | 1085 same-window-buffer-names same-window-regexps) |
1073 (prog1 | 1086 (prog1 |
1074 (pop-to-buffer buffer t norecord) | 1087 (pop-to-buffer buffer t norecord) |
1075 (raise-frame (window-frame (selected-window)))))) | 1088 (raise-frame (window-frame (selected-window)))))) |