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

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

Re: buffers


From: Kester Clegg
Subject: Re: buffers
Date: 27 Jan 2003 11:59:36 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

"chris.danx" <address@hidden> writes:

> Is there any way to prevent certain buffers from being selected when
> you cycle through buffers?  Are their "hidden buffers" in emacs?

I have the following in mine, stolen from somewhere I can't remember:

;;-- trick for switching buffers nice and fast (use Ctrl-right or left arrow)
;;-- see also key binding for control tab above ----------------------------

(defun crs-delete-these (delete-these from-this-list)
  "Delete DELETE-THESE FROM-THIS-LIST."

  (cond
   ((car delete-these)
    (if (member (car delete-these) from-this-list)
        (crs-delete-these (cdr delete-these) (delete (car delete-these)
                                                 from-this-list))
      (crs-delete-these (cdr delete-these) from-this-list)))
   (t from-this-list)))

; this is the list of buffers we never want to see
(defvar crs-hated-buffers
  '("KILL" "*Compile-Log*" "*scratch*"))

(setq iswitchb-buffer-ignore (append '("^ " "*Buffer") crs-hated-buffers))

(defun crs-hated-buffers ()
  "List of buffers I never want to see, converted from names to buffers."
  (delete nil
          (append
           (mapcar 'get-buffer crs-hated-buffers)
           (mapcar (lambda (this-buffer)
                     (if (string-match "^ " (buffer-name this-buffer))
                         this-buffer))
                   (buffer-list)))))

(defun crs-bury-buffer (&optional n)
  (interactive)
  (unless n
    (setq n 1))
  (let ((my-buffer-list (crs-delete-these (crs-hated-buffers)
                                          (buffer-list (selected-frame)))))
    (switch-to-buffer
     (if (< n 0)
         (nth (+ (length my-buffer-list) n)
              my-buffer-list)
       (bury-buffer)
       (nth n my-buffer-list)))))

(global-set-key [(control right)] 'crs-bury-buffer)
(global-set-key [(control left)] (lambda ()
                                       (interactive)
                                       (crs-bury-buffer -1)))
;;----------------------------------------------------------

It's not perfect, but it's OK for what I need.

-- 
************************************************************************
Kester Clegg                            Dept. of Computer Science,
Research Assistant (UTC)                University of York, 
Tel (01904) 43 27 49                    email: kester at cs.york.ac.uk
************************************************************************


reply via email to

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