help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to convert a char to a property


From: Cecil Westerhof
Subject: Re: How to convert a char to a property
Date: Wed, 08 Dec 2010 15:21:15 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Op dinsdag 27 jul 2010 10:29 CEST schreef Cecil Westerhof:

> I have the following property list:
> (defvar dcbl-bbdb-user-defined-fields (list :L "mail-alias"
> :M "mailer"
> :P "playlist"
> :s "subjects"
> :t "type"
> :w "website")
> "User defined fields in the bbdb with parameter to insert into buffer")
>
> With (getf dcbl-bbdb-user-defined-fields :M) I get "mailer".
>
> But I want to work parameter driven. So for example I have:
> (setq parameters "MLst")
> (setq current-char (string-to-char parameters))
>
> The variable current-char now contains 77. How could I use
> current-char to retrieve "mailer"?

At the moment I use another solution.

I now have:
    (defvar dcbl-bbdb-user-defined-fields '(("L" "mail-alias")
                                            ("M" "mailer")
                                            ("P" "playlist")
                                            ("s" "subjects")
                                            ("t" "type")
                                            ("w" "website"))
      "User defined fields in the bbdb with parameter to insert into buffer")

and use the following code:
    (setq field-name     nil
          parameters     dcbl-bbdb-user-defined-fields
          this-value     nil)
    (while parameters
      (setq this-parameter (car parameters)
            parameters     (cdr parameters))
      (when (string= current-char (car this-parameter))
        (setq field-name (car (cdr this-parameter))
              parameters nil)))

The variable current-char is the parameter (as a string) that I am
searching for.

This does work, but I do not know if it is very efficient. Is this a
good solution, or should I code it differently?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


reply via email to

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