comparison lisp/font-lock.el @ 4607:517f6887fbc0

Remove duplicate functions, chiefly #'delete-duplicates reimplementations. lisp/ChangeLog addition: 2009-02-08 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete-duplicates): Add a new compiler macro, inlining this function if it's called with a literal #'eq or #'equal test arguments and no other keywords. * font-lock.el (font-lock-unique): Remove this function. * font-lock.el (font-lock-prepend-text-property): (font-lock-append-text-property): Use #'delete-duplicates instead of #'font-lock-unique. * font.el (font-unique): Remove this function. * font.el (font-combine-fonts-internal): (x-font-families-for-device): (xft-font-families-for-device): (ns-font-families-for-device): Use #'delete-duplicates instead of #'font-unique. * fontconfig.el (fc-delete-duplicates): * fontconfig.el (fc-filter): Remove these functions. * fontconfig.el (fc-find-available-font-families): Replace #'fc-delete-duplicates with #'delete-duplicates, #'fc-filter with #'delete-if-not. * format.el (format-make-relatively-unique): Document that this is equivalent to #'nset-exclusive-or with a test of #'equal.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 08 Feb 2009 18:45:22 +0000
parents f6c39b2d8b62
children c1784fd59d7d
comparison
equal deleted inserted replaced
4606:88ba7d18dc23 4607:517f6887fbc0
1634 (setq next (next-single-property-change start markprop object end)) 1634 (setq next (next-single-property-change start markprop object end))
1635 (put-nonduplicable-text-property start next setprop value object) 1635 (put-nonduplicable-text-property start next setprop value object)
1636 (put-nonduplicable-text-property start next markprop value object) 1636 (put-nonduplicable-text-property start next markprop value object)
1637 (setq start (text-property-any next end markprop nil object))))) 1637 (setq start (text-property-any next end markprop nil object)))))
1638 1638
1639 ;; This function (from simon's unique.el) is rewritten and inlined for speed.
1640 ;(defun unique (list function)
1641 ; "Uniquify LIST, deleting elements using FUNCTION.
1642 ;Return the list with subsequent duplicate items removed by side effects.
1643 ;FUNCTION is called with an element of LIST and a list of elements from LIST,
1644 ;and should return the list of elements with occurrences of the element removed,
1645 ;i.e., a function such as `delete' or `delq'.
1646 ;This function will work even if LIST is unsorted. See also `uniq'."
1647 ; (let ((list list))
1648 ; (while list
1649 ; (setq list (setcdr list (funcall function (car list) (cdr list))))))
1650 ; list)
1651
1652 (defsubst font-lock-unique (list)
1653 "Uniquify LIST, deleting elements using `delq'.
1654 Return the list with subsequent duplicate items removed by side effects."
1655 (let ((list list))
1656 (while list
1657 (setq list (setcdr list (delq (car list) (cdr list))))))
1658 list)
1659
1660 ;; A generalisation of `facemenu-add-face' for any property, but without the 1639 ;; A generalisation of `facemenu-add-face' for any property, but without the
1661 ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special 1640 ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special
1662 ;; treatment of `default'. Uses `unique' to remove duplicate property values. 1641 ;; treatment of `default'. Uses `unique' to remove duplicate property values.
1663 (defsubst font-lock-prepend-text-property (start end prop value &optional object) 1642 (defsubst font-lock-prepend-text-property (start end prop value &optional object)
1664 "Prepend to one property of the text from START to END. 1643 "Prepend to one property of the text from START to END.
1669 (while (/= start end) 1648 (while (/= start end)
1670 (setq next (next-single-property-change start prop object end) 1649 (setq next (next-single-property-change start prop object end)
1671 prev (get-text-property start prop object)) 1650 prev (get-text-property start prop object))
1672 (put-text-property 1651 (put-text-property
1673 start next prop 1652 start next prop
1674 (font-lock-unique (append val (if (listp prev) prev (list prev)))) 1653 (delete-duplicates (append val (if (listp prev) prev (list prev)))
1654 :test #'eq)
1675 object) 1655 object)
1676 (setq start next)))) 1656 (setq start next))))
1677 1657
1678 (defsubst font-lock-append-text-property (start end prop value &optional object) 1658 (defsubst font-lock-append-text-property (start end prop value &optional object)
1679 "Append to one property of the text from START to END. 1659 "Append to one property of the text from START to END.
1684 (while (/= start end) 1664 (while (/= start end)
1685 (setq next (next-single-property-change start prop object end) 1665 (setq next (next-single-property-change start prop object end)
1686 prev (get-text-property start prop object)) 1666 prev (get-text-property start prop object))
1687 (put-text-property 1667 (put-text-property
1688 start next prop 1668 start next prop
1689 (font-lock-unique (append (if (listp prev) prev (list prev)) val)) 1669 (delete-duplicates (append (if (listp prev) prev (list prev)) val)
1670 :test #'eq)
1690 object) 1671 object)
1691 (setq start next)))) 1672 (setq start next))))
1692 1673
1693 ;;; Syntactic regexp fontification functions (taken from FSF Emacs 20.7.1) 1674 ;;; Syntactic regexp fontification functions (taken from FSF Emacs 20.7.1)
1694 1675