diff options
| author | Gerd Moellmann | 2000-04-17 15:24:58 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-04-17 15:24:58 +0000 |
| commit | fa65f20bcbcf7a3065ce995a22ddf36d70dab2b1 (patch) | |
| tree | 3c2a972465b1e21e50e116ee4759382000315b38 | |
| parent | e1603a09df3e184ec7511f6d3b66dc844c7ddc34 (diff) | |
| download | emacs-fa65f20bcbcf7a3065ce995a22ddf36d70dab2b1.tar.gz emacs-fa65f20bcbcf7a3065ce995a22ddf36d70dab2b1.zip | |
(clone-indirect-buffer): New function.
| -rw-r--r-- | lisp/simple.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 2ae66339661..69ce6e19e87 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -399,6 +399,7 @@ that uses or sets the mark." | |||
| 399 | (push-mark (point)) | 399 | (push-mark (point)) |
| 400 | (push-mark (point-max) nil t) | 400 | (push-mark (point-max) nil t) |
| 401 | (goto-char (point-min))) | 401 | (goto-char (point-min))) |
| 402 | |||
| 402 | 403 | ||
| 403 | ;; Counting lines, one way or another. | 404 | ;; Counting lines, one way or another. |
| 404 | 405 | ||
| @@ -4156,6 +4157,31 @@ after it has been set up properly in other respects." | |||
| 4156 | (if display-flag (pop-to-buffer new)) | 4157 | (if display-flag (pop-to-buffer new)) |
| 4157 | new)) | 4158 | new)) |
| 4158 | 4159 | ||
| 4160 | |||
| 4161 | (defun clone-indirect-buffer (newname display-flag) | ||
| 4162 | "Create an indirect buffer that is a twin copy of the current buffer. | ||
| 4163 | |||
| 4164 | Give the indirect buffer name NEWNAME. Interactively, read NEW-NAME | ||
| 4165 | from the minibuffer when invoked with a prefix arg. If NEWNAME is nil | ||
| 4166 | or if not called with a prefix arg, NEWNAME defaults to the current | ||
| 4167 | buffer's name. The name is modified by adding a `<N>' suffix to it | ||
| 4168 | or by incrementing the N in an existing suffix. | ||
| 4169 | |||
| 4170 | DISPLAY-FLAG non-nil means show the new buffer with `pop-to-buffer'. | ||
| 4171 | This is always done when called interactively." | ||
| 4172 | (interactive (list (if current-prefix-arg | ||
| 4173 | (read-string "BName of indirect buffer: ")) | ||
| 4174 | t)) | ||
| 4175 | (setq newname (or newname (buffer-name))) | ||
| 4176 | (if (string-match "<[0-9]+>\\'" newname) | ||
| 4177 | (setq newname (substring newname 0 (match-beginning 0)))) | ||
| 4178 | (let* ((name (generate-new-buffer-name newname)) | ||
| 4179 | (buffer (make-indirect-buffer (current-buffer) name t))) | ||
| 4180 | (when display-flag | ||
| 4181 | (pop-to-buffer buffer)) | ||
| 4182 | buffer)) | ||
| 4183 | |||
| 4184 | |||
| 4159 | 4185 | ||
| 4160 | ;;; Syntax stuff. | 4186 | ;;; Syntax stuff. |
| 4161 | 4187 | ||