monnier pushed a commit to branch master
in repository elpa.
commit e7c635cae2dae9c36285c2841c7d251da9ef9471
Author: Teemu Likonen <[email protected]>
Date: Mon Feb 22 17:17:47 2010 +0000
Lisätään matalan tason funktiot face-tietojen käsittelyyn
Näiden funktioiden tarkoitus on toimia varsinaisen työn tekijänä uudelle
ominaisuudelle, joka mahdollistaa ainoastaan tiettyjen alueiden
lukemisen puskurista. Kyseinen uusi ominaisuus lisätään käyttöön
myöhemmin.
---
wcheck-mode.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/wcheck-mode.el b/wcheck-mode.el
index f5ca399..80b33fb 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -871,6 +871,65 @@ visible in BUFFER within position range from BEG to END."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Face information functions
+
+
+(defun wcheck-collect-faces (beg end)
+ "Return a list of faces between positions BEG and END."
+ (let ((pos beg)
+ face faces)
+ (while (< pos end)
+ (setq face (get-text-property pos 'face)
+ faces (append (if (and face (listp face))
+ face
+ (list face))
+ faces)
+ pos (1+ pos)))
+ (delete-dups faces)))
+
+
+(defun wcheck-major-mode-op-mode (mode)
+ "Return the associated operation mode for major mode MODE.
+See the variable `wcheck-read-or-skip-faces' for more
+information."
+ (cadr (assq mode wcheck-read-or-skip-faces)))
+
+
+(defun wcheck-major-mode-faces (mode)
+ "Return the face list configuration for major mode MODE.
+See the variable `wcheck-read-or-skip-faces' for more
+information."
+ (cddr (assq mode wcheck-read-or-skip-faces)))
+
+
+(defun wcheck-generate-face-predicate (op-mode faces)
+ "Generate a predicate expression for reading words.
+This function creates a predicate expression which, by evaluating
+it, is used to check whether or not the current match should be
+read or skipped. OP-MODE is either symbol `read' or `skip' and
+FACES is a list of faces. This is only for `wcheck-mode's
+internal use."
+ (cond ((eq 'read op-mode)
+ `(wcheck-face-found-p
+ ',faces (wcheck-collect-faces (match-beginning 1)
+ (match-end 1))))
+ ((eq 'skip op-mode)
+ `(not (wcheck-face-found-p
+ ',faces (wcheck-collect-faces (match-beginning 1)
+ (match-end 1)))))
+ (t)))
+
+
+(defun wcheck-face-found-p (user-faces buffer-faces)
+ "Return t if a symbol in USER-FACES is found from BUFFER-FACES.
+Both arguments are lists."
+ (catch 'found
+ (dolist (face user-faces)
+ (when (member face buffer-faces)
+ (throw 'found t)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Miscellaneous low-level functions