Update emacsrc for previous/next buffers cycling
authorHugo Villeneuve <hugo@hugovil.com>
Thu, 8 Jan 2015 22:12:04 +0000 (17:12 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Thu, 8 Jan 2015 22:12:31 +0000 (17:12 -0500)
stage5/misc/emacs/emacsrc

index d9259f5..5777294 100644 (file)
@@ -7,6 +7,9 @@
 ;; Do not display a splash screen on startup
 (setq inhibit-splash-screen t)
 
+;; Do not open a scratch buffer
+(kill-buffer "*scratch*")
+
 ;; Emacs Load Path
 (setq load-path (cons "/usr/local/share/emacs/site-lisp" load-path))
 
   (interactive)
   (compile (concat "checkpatch.pl --no-tree --emacs --strict --file " (buffer-file-name))))
 
+(setq my-skippable-buffers '("*Messages*" "*scratch*" "*Help*" "*Completions*"))
+
+(defun my-change-buffer (change-buffer)
+  "Call CHANGE-BUFFER until current buffer is not in `my-skippable-buffers'."
+  (let ((initial (current-buffer)))
+    (funcall change-buffer)
+    (let ((first-change (current-buffer)))
+      (catch 'loop
+        (while (member (buffer-name) my-skippable-buffers)
+          (funcall change-buffer)
+          (when (eq (current-buffer) first-change)
+            (switch-to-buffer initial)
+            (throw 'loop t)))))))
+
+(defun my-next-buffer ()
+  "`next-buffer' that skips `my-skippable-buffers'."
+  (interactive)
+  (my-change-buffer 'next-buffer))
+
+(defun my-previous-buffer ()
+  "`previous-buffer' that skips `my-skippable-buffers'."
+  (interactive)
+  (my-change-buffer 'previous-buffer))
+
 ;; F1: Switch to previous buffers
-(global-set-key [f1] 'previous-buffer)
+(global-set-key [f1] 'my-previous-buffer)
 ;; F2: Switch to next buffers
-(global-set-key [f2] 'next-buffer)
+(global-set-key [f2] 'my-next-buffer)
 
 ;; F4: make clean
 (global-set-key [f4] 'compile-make-clean)