emacs-devel
[Top][All Lists]
Advanced

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

Proposal: Change for propertize


From: Kim F. Storm
Subject: Proposal: Change for propertize
Date: Wed, 28 Feb 2007 17:16:43 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux)

While fixing the places where we have

(propertize message 'face 'minibuffer-prompt)

to do

(apply 'propertize message minibuffer-prompt-properties)

it occurred to me that the following format would be nice:

(propertize message minibuffer-prompt-properties)

i.e. if propertize is called with just two arguments,
the second arg is a list of properties to use.

Here's a patch:

*** editfns.c   16 Feb 2007 16:30:28 +0100      1.434
--- editfns.c   28 Feb 2007 17:11:51 +0100      
***************
*** 3338,3344 ****
         doc: /* Return a copy of STRING with text properties added.
  First argument is the string to copy.
  Remaining arguments form a sequence of PROPERTY VALUE pairs for text
! properties to add to the result.
  usage: (propertize STRING &rest PROPERTIES)  */)
       (nargs, args)
       int nargs;
--- 3338,3345 ----
         doc: /* Return a copy of STRING with text properties added.
  First argument is the string to copy.
  Remaining arguments form a sequence of PROPERTY VALUE pairs for text
! properties to add to the result, or a single argument PROPERTY-LIST
! which is a list of such text property pairs.
  usage: (propertize STRING &rest PROPERTIES)  */)
       (nargs, args)
       int nargs;
***************
*** 3350,3356 ****
  
    /* Number of args must be odd.  */
    if ((nargs & 1) == 0 || nargs < 1)
!     error ("Wrong number of arguments");
  
    properties = string = Qnil;
    GCPRO2 (properties, string);
--- 3351,3358 ----
  
    /* Number of args must be odd.  */
    if ((nargs & 1) == 0 || nargs < 1)
!     if (nargs != 2 || !CONSP (args[1]))
!       error ("Wrong number of arguments");
  
    properties = string = Qnil;
    GCPRO2 (properties, string);
***************
*** 3359,3366 ****
    CHECK_STRING (args[0]);
    string = Fcopy_sequence (args[0]);
  
!   for (i = 1; i < nargs; i += 2)
!     properties = Fcons (args[i], Fcons (args[i + 1], properties));
  
    Fadd_text_properties (make_number (0),
                        make_number (SCHARS (string)),
--- 3361,3371 ----
    CHECK_STRING (args[0]);
    string = Fcopy_sequence (args[0]);
  
!   if (nargs == 2)
!     properties = args[1];
!   else
!     for (i = 1; i < nargs; i += 2)
!       properties = Fcons (args[i], Fcons (args[i + 1], properties));
  
    Fadd_text_properties (make_number (0),
                        make_number (SCHARS (string)),

-- 
Kim F. Storm  http://www.cua.dk





reply via email to

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