Optimization: buffer-local-value instead of with-current-buffer

This commit is contained in:
Henrik Lissner 2016-06-17 16:01:07 -04:00
parent b46a75bfe0
commit 85f3c14b2f
3 changed files with 8 additions and 8 deletions

View file

@ -38,7 +38,7 @@
(:custom (lambda (b &rest _) (:custom (lambda (b &rest _)
(when (and (featurep 'repl-toggle) (when (and (featurep 'repl-toggle)
(string-prefix-p "*" (buffer-name (get-buffer b)))) (string-prefix-p "*" (buffer-name (get-buffer b))))
(with-current-buffer b repl-toggle-mode)))) (buffer-local-value 'repl-toggle-mode b))))
:popup t :align below :size 16 :select t) :popup t :align below :size 16 :select t)
(map! :map repl-toggle-mode-map (map! :map repl-toggle-mode-map

View file

@ -86,7 +86,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
;;;###autoload ;;;###autoload
(defun doom/get-buffers-in-modes (modes &optional buffer-list) (defun doom/get-buffers-in-modes (modes &optional buffer-list)
"Get a list of buffers whose major-mode is one of MODES" "Get a list of buffers whose major-mode is one of MODES"
(--filter (with-current-buffer it (memq major-mode modes)) (--filter (memq (buffer-local-value 'major-mode it) modes)
(or buffer-list (doom/get-buffers)))) (or buffer-list (doom/get-buffers))))
;;;###autoload ;;;###autoload

View file

@ -27,12 +27,12 @@
;;;###autoload ;;;###autoload
(defun doom/popup-p (&optional window) (defun doom/popup-p (&optional window)
"Whether WINDOW is a shackle popup window or not. If WINDOW is nil, use "Whether WINDOW is a popup window or not. If WINDOW is nil, use current
current window." window. Returns nil or the popup window."
(let ((window (or window (selected-window)))) (setq window (or window (selected-window)))
(and (window-live-p window) (and (window-live-p window)
(with-selected-window window (bound-and-true-p doom-popup-mode)) (buffer-local-value 'doom-popup-mode (window-buffer window))
window))) window))
;;;###autoload ;;;###autoload
(defun doom/popups-p () (defun doom/popups-p ()