help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for a buffer-cycling library


From: Alexis
Subject: Re: Looking for a buffer-cycling library
Date: Sat, 15 Nov 2014 12:34:05 +1100

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 ---


Alexis.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]