From 689e887354e8d1632d524448e97d045b22fa5875 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Wed, 21 Jun 2017 23:51:59 -0400 Subject: [PATCH] Blacklists additional modes from MRU buffer candidates --- emacs/wc-helper-functions.el | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/emacs/wc-helper-functions.el b/emacs/wc-helper-functions.el index 8c14d43b2..e393b1247 100644 --- a/emacs/wc-helper-functions.el +++ b/emacs/wc-helper-functions.el @@ -1,3 +1,5 @@ +(require 'cl) + (defun wc/edit-file-in-emacs (file) "Edits a file in a buffer in Emacs. On :wq, the buffer is deleted and the previous term session restored." (find-file file) @@ -172,21 +174,6 @@ (evil-window-down 1)) -(defun wc/file-buffer-p (buffer-candidate) - "Returns t if the buffer argument is backed by a file and is therefore presumably a code buffer." - (interactive) - (let ((buff-name (buffer-name buffer-candidate)) - (buff-mode (wc/buffer-major-mode buffer-candidate))) - (not (or (string-match-p "^\*.+\*$" buff-name) - (string-match-p "^dired-mode$" buff-mode))))) - - -(defun wc/buffer-major-mode (buffer-handle) - "Returns a symbol representing the buffer's active major-mode" - (interactive) - (symbol-name (with-current-buffer buffer-handle major-mode))) - - (defun wc/switch-to-mru-buffer () "Switches to the most recently used buffer, including visible buffers." (interactive) @@ -199,7 +186,7 @@ (setq buffer-candidate (car buffer-candidates)) (setq rest (cdr buffer-candidates)) (if (string-match-p current-buffer-name (buffer-name buffer-candidate)) - (wc/do-switch-to-mru-buffer rest) + (wc/do-switch-to--buffer rest) (if (eq 0 (list-length buffer-candidates)) (message "No more buffer candidates.") (if (wc/file-buffer-p buffer-candidate) @@ -207,6 +194,20 @@ (wc/do-switch-to-mru-buffer rest))))) +(defun wc/file-buffer-p (buffer-candidate) + "Returns t if the buffer argument is backed by a file and is therefore presumably a code buffer." + (interactive) + (let ((buff-name (buffer-name buffer-candidate)) + (buff-mode (wc/buffer-major-mode buffer-candidate))) + (not (or (string-match-p "*" buff-name) + (member buff-mode '(neotree-mode dired-mode)))))) + + +(defun wc/buffer-major-mode (buffer-handle) + "Returns a buffer's active major-mode." + (with-current-buffer buffer-handle major-mode)) + + (defun *-popwin-help-mode-off () "Turn `popwin-mode' off for *Help* buffers." (when (boundp 'popwin:special-display-config)