emacs-devel
[Top][All Lists]
Advanced

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

Re: Rename `eww' to `web'


From: Juanma Barranquero
Subject: Re: Rename `eww' to `web'
Date: Fri, 5 Jul 2013 03:14:55 +0200

On Fri, Jul 5, 2013 at 1:40 AM, Glenn Morris <address@hidden> wrote:

> If someone would like to actually DO this, that would be useful.

(defgroup dispatcher nil
  "Generic dispatcher")

(defmacro def-dispatcher (command)
  (let* ((commandn (symbol-name command))
         (varaltn (concat commandn "-alternatives"))
         (varalts (intern varaltn))
         (varimps (intern (concat commandn "-implementation"))))
    `(progn

       (defcustom ,varalts nil
         ,(format "Alist of alternative implementations for the `%s' command.

Each entry must be a pair (ALTNAME . ALTFUN), where:
ALTNAME - The name shown at user to describe the alternative implementation.
ALTFUN  - The function called to implement this alternative."
                  commandn)
         :type '(alist :key-type string :value-type function))

       (defcustom ,varimps nil "Internal use only.")

       (defun ,command (&optional arg)
         ,(format "Run the generic command `%s'.
If used for the first time, or with interactive ARG, ask the user
which implementation to use for `%s'.  The variable `%s'
contains the list of implementations currently supported for this command."
                  commandn commandn varaltn)
         (interactive "P")
         (when (or arg (null ,varimps))
           (let ((val (completing-read
                       ,(format "Select implementation for command
`%s': " commandn)
                       ,varalts nil t)))
             (unless (string-equal val "")
               (customize-save-variable ',varimps (cdr (assoc-string
val ,varalts))))))
         (if ,varimps
             (funcall ,varimps)
           (message ,(format "No implementation selected for commmand
`%s'" commandn)))))))



reply via email to

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