comparison lisp/faces.el @ 63382:9cbfa983c1cf

(read-face-name): Use complete-in-turn complete non-aliases in preference to face aliases.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 13 Jun 2005 20:47:08 +0000
parents 212616057d0b
children c449f070995c e58cb448e07c a1b34dec1104
comparison
equal deleted inserted replaced
63381:23b1ef64a00e 63382:9cbfa983c1cf
1 ;;; faces.el --- Lisp faces 1 ;;; faces.el --- Lisp faces
2 2
3 ;; Copyright (C) 1992,1993,1994,1995,1996,1998,1999,2000,2001,2002,2004 3 ;; Copyright (C) 1992,1993,1994,1995,1996,1998,1999,2000,2001,2002,2004,2005
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 5
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Keywords: internal 7 ;; Keywords: internal
8 8
852 if this function returns nil. 852 if this function returns nil.
853 If MULTIPLE is non-nil, return a list of faces (possibly only one). 853 If MULTIPLE is non-nil, return a list of faces (possibly only one).
854 Otherwise, return a single face." 854 Otherwise, return a single face."
855 (let ((faceprop (or (get-char-property (point) 'read-face-name) 855 (let ((faceprop (or (get-char-property (point) 'read-face-name)
856 (get-char-property (point) 'face))) 856 (get-char-property (point) 'face)))
857 (aliasfaces nil)
858 (nonaliasfaces nil)
857 faces) 859 faces)
858 ;; Make a list of the named faces that the `face' property uses. 860 ;; Make a list of the named faces that the `face' property uses.
859 (if (and (listp faceprop) 861 (if (and (listp faceprop)
860 ;; Don't treat an attribute spec as a list of faces. 862 ;; Don't treat an attribute spec as a list of faces.
861 (not (keywordp (car faceprop))) 863 (not (keywordp (car faceprop)))
868 ;; If there are none, try to get a face name from the buffer. 870 ;; If there are none, try to get a face name from the buffer.
869 (if (and (null faces) 871 (if (and (null faces)
870 (memq (intern-soft (thing-at-point 'symbol)) (face-list))) 872 (memq (intern-soft (thing-at-point 'symbol)) (face-list)))
871 (setq faces (list (intern-soft (thing-at-point 'symbol))))) 873 (setq faces (list (intern-soft (thing-at-point 'symbol)))))
872 874
875 ;; Build up the completion tables.
876 (mapatoms (lambda (s)
877 (if (custom-facep s)
878 (if (get s 'face-alias)
879 (push (symbol-name s) aliasfaces)
880 (push (symbol-name s) nonaliasfaces)))))
881
873 ;; If we only want one, and the default is more than one, 882 ;; If we only want one, and the default is more than one,
874 ;; discard the unwanted ones now. 883 ;; discard the unwanted ones now.
875 (unless multiple 884 (unless multiple
876 (if faces 885 (if faces
877 (setq faces (list (car faces))))) 886 (setq faces (list (car faces)))))
881 (if (or faces string-describing-default) 890 (if (or faces string-describing-default)
882 (format "%s (default %s): " prompt 891 (format "%s (default %s): " prompt
883 (if faces (mapconcat 'symbol-name faces ", ") 892 (if faces (mapconcat 'symbol-name faces ", ")
884 string-describing-default)) 893 string-describing-default))
885 (format "%s: " prompt)) 894 (format "%s: " prompt))
886 obarray 'custom-facep t)) 895 (complete-in-turn nonaliasfaces aliasfaces) nil t))
887 ;; Canonicalize the output. 896 ;; Canonicalize the output.
888 (output 897 (output
889 (if (equal input "") 898 (if (equal input "")
890 faces 899 faces
891 (if (stringp input) 900 (if (stringp input)
2287 (internal-frob-font-slant font "i"))) 2296 (internal-frob-font-slant font "i")))
2288 (make-obsolete 'x-make-font-bold-italic 'make-face-bold-italic "21.1") 2297 (make-obsolete 'x-make-font-bold-italic 'make-face-bold-italic "21.1")
2289 2298
2290 (provide 'faces) 2299 (provide 'faces)
2291 2300
2292 ;;; arch-tag: 19a4759f-2963-445f-b004-425b9aadd7d6 2301 ;; arch-tag: 19a4759f-2963-445f-b004-425b9aadd7d6
2293 ;;; faces.el ends here 2302 ;;; faces.el ends here