comparison lisp/simple.el @ 91788:14206a515e37

(clone-indirect-buffer-hook): New hook. (clone-indirect-buffer): Run it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 12 Feb 2008 02:25:10 +0000
parents d4fe8debe315
children 07b62dd00afa
comparison
equal deleted inserted replaced
91787:457a4ba95667 91788:14206a515e37
5545 ;;;; 5545 ;;;;
5546 5546
5547 (defvar clone-buffer-hook nil 5547 (defvar clone-buffer-hook nil
5548 "Normal hook to run in the new buffer at the end of `clone-buffer'.") 5548 "Normal hook to run in the new buffer at the end of `clone-buffer'.")
5549 5549
5550 (defvar clone-indirect-buffer-hook nil
5551 "Normal hook to run in the new buffer at the end of `clone-indirect-buffer'.")
5552
5550 (defun clone-process (process &optional newname) 5553 (defun clone-process (process &optional newname)
5551 "Create a twin copy of PROCESS. 5554 "Create a twin copy of PROCESS.
5552 If NEWNAME is nil, it defaults to PROCESS' name; 5555 If NEWNAME is nil, it defaults to PROCESS' name;
5553 NEWNAME is modified by adding or incrementing <N> at the end as necessary. 5556 NEWNAME is modified by adding or incrementing <N> at the end as necessary.
5554 If PROCESS is associated with a buffer, the new process will be associated 5557 If PROCESS is associated with a buffer, the new process will be associated
5690 (setq newname (or newname (buffer-name))) 5693 (setq newname (or newname (buffer-name)))
5691 (if (string-match "<[0-9]+>\\'" newname) 5694 (if (string-match "<[0-9]+>\\'" newname)
5692 (setq newname (substring newname 0 (match-beginning 0)))) 5695 (setq newname (substring newname 0 (match-beginning 0))))
5693 (let* ((name (generate-new-buffer-name newname)) 5696 (let* ((name (generate-new-buffer-name newname))
5694 (buffer (make-indirect-buffer (current-buffer) name t))) 5697 (buffer (make-indirect-buffer (current-buffer) name t)))
5698 (with-current-buffer buffer
5699 (run-hooks 'clone-indirect-buffer-hook))
5695 (when display-flag 5700 (when display-flag
5696 (pop-to-buffer buffer norecord)) 5701 (pop-to-buffer buffer norecord))
5697 buffer)) 5702 buffer))
5698 5703
5699 5704