unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [billl@neurosim.downstate.edu: finding clone]
@ 2006-04-29 19:09 Richard Stallman
  2006-05-01 21:28 ` Stuart D. Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Stallman @ 2006-04-29 19:09 UTC (permalink / raw)


What code does "the buffer clone package" refer to?

------- Start of forwarded message -------
Date: Fri, 28 Apr 2006 09:59:53 -0400
From: Bill Lytton <billl@neurosim.downstate.edu>
To: bug-gnu-emacs@gnu.org
Subject: finding clone
Reply-To: billl@neurosim.downstate.edu
X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed 
	version=3.0.4


I imagine that you guys are already working on augmenting the buffer clone
package

I would suggest having a routine such as the following that will allow you to find
an existing clone once it's been lost in a pile of buffers

(defun find-clone ()
  "Find another buffer looking at same file (made from clone-indirect-buffer)"
  (interactive)
  (let ((blist (cdr (buffer-list))) ;; leave off current buffer
	(f (buffer-file-name)) f2 done bl)
    (while (and blist (not done))
      (setq bl (car blist) f2 (buffer-file-name bl) blist (cdr blist))
      (and (string= f f2)(setq done t)))
    (if done (pop-to-buffer bl)
      (message "No clone found"))))


_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [billl@neurosim.downstate.edu: finding clone]
  2006-04-29 19:09 [billl@neurosim.downstate.edu: finding clone] Richard Stallman
@ 2006-05-01 21:28 ` Stuart D. Herring
  0 siblings, 0 replies; 2+ messages in thread
From: Stuart D. Herring @ 2006-05-01 21:28 UTC (permalink / raw)
  Cc: emacs-devel

> What code does "the buffer clone package" refer to?

The builtin function `make-indirect-buffer' and the functions
`clone-indirect-buffer' and `clone-indirect-buffer-other-window' in
simple.el.

> I would suggest having a routine such as the following that will allow you
> to find
> an existing clone once it's been lost in a pile of buffers

His routine is not entirely without merit, but would be better implemented
with `buffer-base-buffer' as follows:

defun switch-to-clone (&optional buffer)
  "Select another buffer with the same base buffer as BUFFER.
BUFFER defaults to the current buffer.
Non-indirect buffers are considered to be their own bases.
If BUFFER is indirect, the buffer selected may be its base buffer or another
indirect buffer with the same base buffer.  If BUFFER is not indirect, the
buffer selected will be an indirect buffer with it as base."
  (interactive)
  (setq buffer (get-buffer (or buffer (current-buffer))))
  (let ((l (buffer-list)) (b (or (buffer-base-buffer buffer) buffer)) found)
    (while (and l (not found))
      (and (not (eq (car l) buffer))
           (eq (or (buffer-base-buffer (car l)) (car l)) b)
           (setq found (car l)))
      (setq l (cdr l)))
    (if found (switch-to-buffer found)
      (error "No indirect buffers for that buffer"))))

I'm not really sure it's useful enough to warrant inclusion; a very
similar effect can be achieved by naming indirect buffers
CLONE_originalname or originalname_CLONE or so and using completion.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-01 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-29 19:09 [billl@neurosim.downstate.edu: finding clone] Richard Stallman
2006-05-01 21:28 ` Stuart D. Herring

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).