[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Jumping (was: [bongo-devel] Re: Bongo wishlist #5: visual seek)
From: |
Romain Francoise |
Subject: |
Jumping (was: [bongo-devel] Re: Bongo wishlist #5: visual seek) |
Date: |
Fri, 08 Dec 2006 19:46:54 +0100 |
Romain Francoise <address@hidden> writes:
> Is there a more efficient alternative to my code below?
If anyone is interested (doesn't look like it), since then I found out
that getting a hash of the current buffer is very fast. So my function
now recomputes the completion list only if the library buffer has
changed (or if a prefix argument is passed).
(defvar ore-bongo-jump-tracks nil)
(defvar ore-bongo-jump-sum nil)
(defun ore-bongo-jump ()
"Prompt for a track and go to the corresponding line in the
playlist buffer."
(interactive)
(when (or current-prefix-arg
(and ore-bongo-jump-sum
(not (string= ore-bongo-jump-sum
(md5 (buffer-string)))))
(null ore-bongo-jump-tracks))
(let (message-log-max garbage-collection-messages)
(message "Building completion list..."))
(setq ore-bongo-jump-sum (md5 (buffer-string)))
(save-excursion
;; Go through the buffer, collecting infosets and positions.
(with-bongo-library-buffer
(goto-char (point-max))
(while (bongo-previous-object-line t)
(push (list (bongo-format-infoset (bongo-line-infoset)) (point))
ore-bongo-jump-tracks)))))
(goto-char
(cadr (assoc (ido-completing-read "Jump to track: "
ore-bongo-jump-tracks nil t)
ore-bongo-jump-tracks))))
--
Romain Francoise <address@hidden> | The sea! the sea! the open
it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
| ever free! --Bryan W. Procter