From 2efef60d1f263289f5c5c6397a5c0eb0e1a165a8 Mon Sep 17 00:00:00 2001 From: deb0ch Date: Sat, 15 Apr 2017 15:50:39 +0200 Subject: [PATCH] use a named predicate instead of a lambda for ignored windows Using a named function makes the code more readable than using a lambda. --- winum.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/winum.el b/winum.el index 06fd7e1..617a3e5 100644 --- a/winum.el +++ b/winum.el @@ -438,12 +438,7 @@ Returns the assigned number, or nil on error." (defun winum--window-list () "Return a list of interesting windows." (cl-remove-if - (lambda (w) - (let ((f (window-frame w))) - (or (not (and (frame-live-p f) - (frame-visible-p f))) - (string= "initial_terminal" (terminal-name f)) - (member (buffer-name (window-buffer w)) winum-ignored-buffers)))) + #'winum--ignore-window-p (cl-case winum-scope (global (cl-mapcan 'winum--list-windows-in-frame @@ -460,14 +455,21 @@ Returns the assigned number, or nil on error." (t (error "Invalid `winum-scope': %S" winum-scope))))) +(defun winum--ignore-window-p (window) + "Non-nil if WINDOW should be ignored for numbering." + (let ((f (window-frame window))) + (or (not (and (frame-live-p f) + (frame-visible-p f))) + (string= "initial_terminal" (terminal-name f)) + (member (buffer-name (window-buffer window)) winum-ignored-buffers)))) + (defun winum--list-windows-in-frame (&optional f) "List windows in frame F using natural Emacs ordering." (window-list f 0 (frame-first-window f))) (defun winum--get-window-vector () "Return the window vector used to get a window given a number. -This vector is not stored the same way depending on the value of -`winum-scope'." +This vector is not stored the same way depending on the value of `winum-scope'." (if (eq winum-scope 'frame-local) (car (gethash (selected-frame) winum--frames-table)) winum--window-vector))