# HG changeset patch # User Gerd Moellmann # Date 955985098 0 # Node ID aef61acb21de9073d3d4148f45fde194d971520d # Parent 6d94533af241bfe704064650e7e363b346c6585c (clone-indirect-buffer): New function. diff -r 6d94533af241 -r aef61acb21de lisp/simple.el --- a/lisp/simple.el Mon Apr 17 15:24:06 2000 +0000 +++ b/lisp/simple.el Mon Apr 17 15:24:58 2000 +0000 @@ -399,6 +399,7 @@ (push-mark (point)) (push-mark (point-max) nil t) (goto-char (point-min))) + ;; Counting lines, one way or another. @@ -4156,6 +4157,31 @@ (if display-flag (pop-to-buffer new)) new)) + +(defun clone-indirect-buffer (newname display-flag) + "Create an indirect buffer that is a twin copy of the current buffer. + +Give the indirect buffer name NEWNAME. Interactively, read NEW-NAME +from the minibuffer when invoked with a prefix arg. If NEWNAME is nil +or if not called with a prefix arg, NEWNAME defaults to the current +buffer's name. The name is modified by adding a `' suffix to it +or by incrementing the N in an existing suffix. + +DISPLAY-FLAG non-nil means show the new buffer with `pop-to-buffer'. +This is always done when called interactively." + (interactive (list (if current-prefix-arg + (read-string "BName of indirect buffer: ")) + t)) + (setq newname (or newname (buffer-name))) + (if (string-match "<[0-9]+>\\'" newname) + (setq newname (substring newname 0 (match-beginning 0)))) + (let* ((name (generate-new-buffer-name newname)) + (buffer (make-indirect-buffer (current-buffer) name t))) + (when display-flag + (pop-to-buffer buffer)) + buffer)) + + ;;; Syntax stuff.