stumpwm-devel
[Top][All Lists]
Advanced

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

[STUMP] [PATCH] Use PPCRE for rules matching instead of the "..." syntax


From: Lionel Flandrin
Subject: [STUMP] [PATCH] Use PPCRE for rules matching instead of the "..." syntax.
Date: Thu, 6 Nov 2008 16:45:01 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

---
 window-placement.lisp |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/window-placement.lisp b/window-placement.lisp
index cbb1186..696bab2 100644
--- a/window-placement.lisp
+++ b/window-placement.lisp
@@ -18,19 +18,23 @@
    :plist (make-hash-table)
    :unmap-ignores 0))
 
+(defvar *rule-scanners-cache* (make-hash-table :test 'equal)
+  "A cache for the ppcre scanners")
+
+(defun get-or-create-rule-scanner (regex)
+  (or (gethash regex *rule-scanners-cache*)
+      (setf (gethash regex *rule-scanners-cache*)
+           (ppcre:create-scanner regex))))
+
 (defun string-match (string pat)
-  (let ((l (length pat)))
-    (when (> l 0)
-      (if (and (> l 3) (equal (subseq pat 0 3) "..."))
-          (search (subseq pat 3 l) string)
-          (equal string pat)))))
+  (ppcre:scan (get-or-create-rule-scanner pat) string))
 
 (defun window-matches-properties-p (window &key class instance type role title)
   "Returns T if window matches all the given properties"
   (and
-   (if class (equal (window-class window) class) t)
-   (if instance (equal (window-res window) instance) t)
-   (if type (equal (window-type window) type) t)
+   (if class (string-match (window-class window) class) t)
+   (if instance (string-match (window-res window) instance) t)
+   (if type (string-match (window-type window) type) t)
    (if role (string-match (window-role window) role) t)
    (if title (string-match (window-title window) title) t) t))
 
-- 
1.6.0.3




reply via email to

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