Skip to content

Commit 3849c0b

Browse files
committed
Add php-mode-test--buffer-face-list
1 parent 0d7f970 commit 3849c0b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

php-mode-test.el

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ be processed."
7878
answers))))
7979
answers)))
8080

81+
(defun php-mode-test--buffer-face-list (buffer)
82+
"Return list of (STRING . FACE) from `BUFFER'."
83+
(with-current-buffer buffer
84+
(save-excursion
85+
(goto-char (point-min))
86+
(let (retval begin-pos last-face current-face str)
87+
(setq last-face (get-text-property (point) 'face))
88+
(setq begin-pos (point))
89+
(forward-char 1)
90+
91+
(while (< (point) (point-max))
92+
(setq current-face (get-text-property (point) 'face))
93+
(unless (equal current-face last-face)
94+
(setq str (buffer-substring-no-properties begin-pos (point)))
95+
(setq retval (nconc retval (list (cons str last-face))))
96+
(setq begin-pos (point))
97+
(setq last-face current-face))
98+
(forward-char 1))
99+
(setq str (buffer-substring-no-properties begin-pos (point)))
100+
(nconc retval (list (cons str last-face)))))))
101+
81102
(cl-defmacro with-php-mode-test ((file &key style indent magic custom) &rest body)
82103
"Set up environment for testing `php-mode'.
83104
Execute BODY in a temporary buffer containing the contents of

0 commit comments

Comments
 (0)