emacs-devel
[Top][All Lists]
Advanced

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

Re: Finding faces to customize


From: Juri Linkov
Subject: Re: Finding faces to customize
Date: Tue, 28 Jun 2005 03:00:33 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

>>>I dislike the new italic style for arguments in the help.
>>>So I decided I wanted to customize it.  But how do I find it?
>>>(Without reading the code of course ;-)
>>
>>On an argument name you can type `C-u C-x = TAB RET TAB RET'
>>or `M-x customize-face RET RET'
>>  
> Thanks, that helped I could find the face without problem.

BTW, the default prompt for `customize-face' has several problems.

1. The `face' property on a character under the point takes precedence
   over the face name extracted from the buffer.  So if the point is
   located on the face name in the `defface' specification, then the
   default will be `font-lock-variable-name-face' instead of the face
   from `defface', because the face name is fontified in that font-lock
   face.

   The patch below joins all faces (from `face' property and face names
   under the point) into one list.  The patch is backward-compatible
   for the argument `multiple' since it places faces from the `face'
   property in front of the face name extracted from the buffer, so
   the first element will be the same as now if `multiple' is nil.

2. When the `face' property has a list of faces, these faces are
   displayed in the default prompt as words separated by comma.
   It would be natural to expect that M-n in the minibuffer will allow
   their editing, but this doesn't work.

   The patch adds the default argument for completing-read, and splits
   the result afterwards.  One drawback of such approach is that it
   doesn't allow completion for multiple face names (there is the file
   emacs-lisp/crm.el distribued with Emacs that could be used here but
   it is not up-to-date).  Also it can accept invalid face name (to
   allow a comma-separated input string to be accepted), but this is
   not a big problem.  `complete-in-turn' still works on a single face.

Index: lisp/faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.325
diff -c -r1.325 faces.el
*** lisp/faces.el       25 Jun 2005 23:48:27 -0000      1.325
--- lisp/faces.el       28 Jun 2005 01:43:35 -0000
***************
*** 869,875 ****
          (aliasfaces nil)
          (nonaliasfaces nil)
        faces)
!     ;; Make a list of the named faces that the `face' property uses.
      (if (and (listp faceprop)
             ;; Don't treat an attribute spec as a list of faces.
             (not (keywordp (car faceprop)))
--- 869,878 ----
          (aliasfaces nil)
          (nonaliasfaces nil)
        faces)
!     ;; Try to get a face name from the buffer.
!     (if (memq (intern-soft (thing-at-point 'symbol)) (face-list))
!       (setq faces (list (intern-soft (thing-at-point 'symbol)))))
!     ;; Add the named faces that the `face' property uses.
      (if (and (listp faceprop)
             ;; Don't treat an attribute spec as a list of faces.
             (not (keywordp (car faceprop)))
***************
*** 879,888 ****
              (push f faces)))
        (if (symbolp faceprop)
          (push faceprop faces)))
-     ;; If there are none, try to get a face name from the buffer.
-     (if (and (null faces)
-            (memq (intern-soft (thing-at-point 'symbol)) (face-list)))
-       (setq faces (list (intern-soft (thing-at-point 'symbol)))))
  
      ;; Build up the completion tables.
      (mapatoms (lambda (s)
--- 882,887 ----
***************
*** 904,916 ****
                         (if faces (mapconcat 'symbol-name faces ", ")
                           string-describing-default))
               (format "%s: " prompt))
!            (complete-in-turn nonaliasfaces aliasfaces) nil t))
           ;; Canonicalize the output.
           (output
            (if (equal input "")
                faces
              (if (stringp input)
!                 (list (intern input))
                input))))
        ;; Return either a list of faces or just one face.
        (if multiple
--- 903,917 ----
                         (if faces (mapconcat 'symbol-name faces ", ")
                           string-describing-default))
               (format "%s: " prompt))
!            (complete-in-turn nonaliasfaces aliasfaces)
!            nil nil nil nil
!            (if faces (mapconcat 'symbol-name faces ", "))))
           ;; Canonicalize the output.
           (output
            (if (equal input "")
                faces
              (if (stringp input)
!                 (mapcar 'intern (split-string input ", *" t))
                input))))
        ;; Return either a list of faces or just one face.
        (if multiple

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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