From: Gerd Moellmann Date: Mon, 17 Apr 2000 15:24:58 +0000 (+0000) Subject: (clone-indirect-buffer): New function. X-Git-Tag: emacs-pretest-21.0.90~4220 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/fa65f20bcbcf7a3065ce995a22ddf36d70dab2b1?hp=e1603a09df3e184ec7511f6d3b66dc844c7ddc34 (clone-indirect-buffer): New function. --- diff --git a/lisp/simple.el b/lisp/simple.el index 2ae6633966..69ce6e19e8 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -399,6 +399,7 @@ that uses or sets the mark." (push-mark (point)) (push-mark (point-max) nil t) (goto-char (point-min))) + ;; Counting lines, one way or another. @@ -4156,6 +4157,31 @@ after it has been set up properly in other respects." (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.