[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Cycling through favored buffers
From: |
Rami A |
Subject: |
Cycling through favored buffers |
Date: |
Wed, 24 Apr 2013 15:59:12 -0700 (PDT) |
User-agent: |
G2/1.0 |
Hi,
I have some code in my dotemacs file that would allow me to switch between
opened files and ignoring specific buffers, like "TAGS" "Messages" and some
folder names "headers" "source". I am binding this behavior to both C-Tab and
C-M-Tab.
I have two questions"
1. How do I ignore "all directory type buffers" and limit the switching to be
between files only.
2. How do I create another list of buffers that only includes directories
"headers" and "source" and when press a combination of keys lets say C-M-S-Tab
to cycle through only these?
This is the snippet of code that I have:
;; Control TABbuffer Cycling
; necessary support function for buffer burial
(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 I never want to see
(defvar crs-hated-buffers
'("KILL" "*Compile-Log*" "*Buffer List*" "*Messages*"
"*compilation*" "TAGS" "*scratch*" "source" "headers"))
; might as well use this for both
(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)))))
; I'm sick of switching buffers only to find KILL right in front of me
(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)))))
; Key Bindings
(global-set-key [(control tab)] 'crs-bury-buffer)
(global-set-key [(control meta tab)] (lambda ()
(interactive)
(crs-bury-buffer -1)))
- Cycling through favored buffers,
Rami A <=