[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looking for a buffer-cycling library
From: |
Tim Johnson |
Subject: |
Re: Looking for a buffer-cycling library |
Date: |
Fri, 14 Nov 2014 18:32:02 -0900 |
User-agent: |
Mutt/1.4.2.3i |
* Alexis <flexibeast@gmail.com> [141114 16:48]:
>
> Tim Johnson writes:
>
> > I'm looking for a buffer cycling mechanism that will ignore any
> > buffer not loaded from or written to a file.
> >
> > Example - any buffer whose name begins with '*' would be "jumped
> > over"
> >
> > Ideally it would work just like 'buffer-next or 'previous-buffer,
> > but I would still be able to access _all_ buffers from 'buffer-menu.
> >
> > It would have to work in terminal mode and my best imagined use
> > would be from a netbook without split windows.
> >
> > Recommendations are welcome.
>
> Might something like this be what you're after?
>
> --- BEGIN ---
> (defun get-buffers-with-files ()
> (let ((wanted '()))
> (dolist (b (buffer-list))
> (if (buffer-file-name b)
> (setq wanted (append wanted (list b)))))
> wanted))
>
> (add-hook 'buffer-list-update-hook #'(lambda ()
> (setq buffers-with-files
> (get-buffers-with-files))))
>
> (defun next-buffer-with-file ()
> (interactive)
> (setq buffers-with-files (append (cdr buffers-with-files) (list (car
> buffers-with-files))))
> (switch-to-buffer (car buffers-with-files)))
>
> (defun previous-buffer-with-file ()
> (interactive)
> (setq buffers-with-files (append (last buffers-with-files) (butlast
> buffers-with-files)))
> (switch-to-buffer (car buffers-with-files)))
> --- END ---
Looks good Alex, I will have to grok it further tomorrow.
As far as a quick hack, I've seen some good stuff at
http://stackoverflow.com/questions/14323516/make-emacs-next-buffer-skip-messages-buffer
but I thought that a full-blown library might introduce me to some
other goodies I haven't thought off.
thanks a lot
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com