emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/swsw b5ebc9e08a 106/146: Use lambdas for ':set' functions


From: ELPA Syncer
Subject: [nongnu] elpa/swsw b5ebc9e08a 106/146: Use lambdas for ':set' functions
Date: Wed, 25 May 2022 02:59:52 -0400 (EDT)

branch: elpa/swsw
commit b5ebc9e08a9fbc070bfe89894374b1e45e6f567e
Author: Daniel Semyonov <daniel@dsemy.com>
Commit: Daniel Semyonov <daniel@dsemy.com>

    Use lambdas for ':set' functions
    
    * swsw.el (swsw--set-id-chars, swsw-id-chars, swsw--set-scope)
    (swsw-scope, swsw--set-display-function, swsw-display-function):
    Remove ':set' functions in favor of using (identical) lambdas in the
    respective custom variables.
---
 swsw.el | 50 ++++++++++++++++++--------------------------------
 1 file changed, 18 insertions(+), 32 deletions(-)

diff --git a/swsw.el b/swsw.el
index 098025d604..f66a08b981 100644
--- a/swsw.el
+++ b/swsw.el
@@ -78,30 +78,19 @@
   :group 'convenience
   :prefix "swsw-")
 
-(defun swsw--set-id-chars (sym chars)
-  "Set the variable `swsw-id-chars'.
-Check that the new list has at least two elements, set SYM's value to
-CHARS, and call `swsw-update'."
-  (unless (nth 1 chars)
-    (user-error "`swsw-id-chars' should contain at least two characters"))
-  (set-default sym chars)
-  (when (fboundp 'swsw-update)
-    (swsw-update)))
-
 (defcustom swsw-id-chars '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
   "Base set of characters from which window IDs are constructed.
 This list should contain at least two characters."
   :type '(repeat character)
-  :set #'swsw--set-id-chars
+  :set (lambda (sym chars)
+         (unless (nth 1 chars)
+           (user-error
+            "`swsw-id-chars' should contain at least two characters"))
+         (set-default sym chars)
+         (when (fboundp 'swsw-update)
+           (swsw-update)))
   :package-version '(swsw . 1.0))
 
-(defun swsw--set-scope (sym scope)
-  "Set the variable `swsw-scope'.
-Set SYM's value to SCOPE and call `swsw-update'."
-  (set-default sym scope)
-  (when (fboundp 'swsw-update)
-    (swsw-update)))
-
 (defcustom swsw-scope t
   "Scope of all window operations.
 t means consider all windows on all existing frames.
@@ -116,21 +105,12 @@ t means consider all windows on all existing frames.
                 (const
                  :tag "All windows on the currently selected frame"
                  current))
-  :set #'swsw--set-scope
+  :set (lambda (sym scope)
+         (set-default sym scope)
+         (when (fboundp 'swsw-update)
+           (swsw-update)))
   :package-version '(swsw . 1.1))
 
-(defun swsw--set-display-function (sym fun)
-  "Set the variable `swsw-display-function'.
-Call the previous display function with nil as the sole argument
-\(turning it off), set SYM's value to FUN, and call FUN with t as the
-sole argument (turning it on)."
-  (unless (or (not (boundp 'swsw-display-function))
-              (eq swsw-display-function 'lighter))
-    (funcall swsw-display-function nil))
-  (set-default sym fun)
-  (unless (eq fun 'lighter)
-    (funcall fun t)))
-
 (defcustom swsw-display-function 'lighter
   "Function used to display the ID of each window.
 This function is called with t as the sole argument when enabling
@@ -138,7 +118,13 @@ This function is called with t as the sole argument when 
enabling
 If set to `lighter', use the mode line lighter of `swsw-mode'."
   :type '(radio (const :tag "Mode line lighter" lighter)
                 (function :tag "Display function"))
-  :set #'swsw--set-display-function
+  :set (lambda (sym fun)
+         (unless (or (not (boundp 'swsw-display-function))
+                     (eq swsw-display-function 'lighter))
+           (funcall swsw-display-function nil))
+         (set-default sym fun)
+         (unless (eq fun 'lighter)
+           (funcall fun t)))
   :package-version '(swsw . 1.0))
 
 (defcustom swsw-id-format " <%s>"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]