[ A few weeks ago, during a conversation with Daniel, I said ... ]

> I'd like `j' to do what it does in Ibuffer, i.e. jump to a line with
> ido-like completion if ido is enabled.  That's also what it does in
> XMMS/BMP.

So I finally prototyped this.  The command itself is very useful, but
building the completion list is somewhat slow: 1.317678 seconds in my
usual playlist, which has approximately 1300 tracks.

Is there a more efficient alternative to my code below?

Also, note that this function adds both headers and tracks to the
completions, on purpose: this allows the user to jump to a header line
or a track line with the same interface.

(defun ore-bongo-jump ()
  "Prompt for a track and go to the corresponding line in the
playlist buffer."
  (interactive)
  (let (tracks)
    (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))
               tracks))))
    (goto-char
     (cadr (assoc (ido-completing-read "Jump to track: " tracks nil t)
                  tracks)))))

(define-key bongo-mode-map (kbd "j") 'ore-bongo-jump)

-- 
Romain Francoise <[EMAIL PROTECTED]> | The sea! the sea! the open
it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
                                        | ever free! --Bryan W. Procter


_______________________________________________
bongo-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/bongo-devel

Reply via email to