emacs-devel
[Top][All Lists]
Advanced

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

Re: Should Emacs provide a uuid function?


From: Stefan Monnier
Subject: Re: Should Emacs provide a uuid function?
Date: Mon, 09 May 2011 14:03:44 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> I was particularly trying to avoid proliferating the ugliness of the
> kind we have in battery.el:

>   (defcustom battery-status-function
>     (cond ((and (eq system-type 'gnu/linux)
>               (file-readable-p "/proc/apm"))
>          'battery-linux-proc-apm)
>         ((and (eq system-type 'gnu/linux)
>               (file-directory-p "/proc/acpi/battery"))
>          'battery-linux-proc-acpi)
>         ((and (eq system-type 'gnu/linux)
>               (file-directory-p "/sys/class/power_supply/")
>               (directory-files "/sys/class/power_supply/" nil "BAT[0-9]$"))
>          'battery-linux-sysfs)
>         ((and (eq system-type 'darwin)
>               (condition-case nil
>                   (with-temp-buffer
>                     (and (eq (call-process "pmset" nil t nil "-g" "ps") 0)
>                          (> (buffer-size) 0)))
>                 (error nil)))
>          'battery-pmset)
>         ((eq system-type 'windows-nt)
>          'w32-battery-status))

I don't mind this kind of dispatch table, personally.

> I think it would be much cleaner to have 5 different implementations
> in sysdep.c of the same primitive, than have the above followed by 4
> different Lisp functions plus one primitive.

I don't find the dispatch table worse than the sysdep.c
code, personally.


        Stefan



reply via email to

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