[Top][All Lists]

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

Re: ;;; anything.el --- open anything

From: Tassilo Horn
Subject: Re: ;;; anything.el --- open anything
Date: Fri, 27 Jul 2007 09:48:56 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

address@hidden writes:

Hi Bill,

>>> (defmacro anything-add-to-actions (var action)
>>>   `(setq ,var (cons (car ,var)
>>>                 (append
>>>                  (cdr ,var)
>>>                  (list ',action)))))
>> Yep, that looks nice. I made some little changes, so that multiple
>> evaluations don't add an action several times and added
>> documentation.
> Thanks for adding it to anything-config.el - that's one less thing I
> need to have in my .emacs file! ;-)

Yesterday I enhanced it so that it can add an action to both a source or
a type actions variable. See its docstring for examples.

> An alternative would be to provide (in anything-config.el) a
> "standard" transformer function for a "type" and some example
> transforms that others can model their transforms after. For example,
> for the file transforms:
> (defvar anything-transform-actions-file nil "Transforms for files.")
> (defun anything-transform-file-actions (actions candidate)
>   "Append useful actions to the list of actions."
>   (when (and (listp actions)
>            anything-transform-actions-file)
>     (loop for func in anything-transform-actions-file
>         do (setq actions (or (funcall func actions candidate) actions))
>         finally (return actions))))
> (setq anything-transform-actions-file
>       (append anything-transform-actions-file
>             '((lambda (actions candidate)
>                 (if (or (string= (file-name-extension candidate) "el")
>                         (string= (file-name-extension candidate) "elc"))
>                     (append actions '(("Load Emacs Lisp File" . 
> load-file))))))))
> (setq anything-transform-actions-file
>       (append anything-transform-actions-file
>             '((lambda (actions candidate)
>                 (if (string= "darwin" (symbol-name system-type))
>                     (append actions
>                             '(("Open File with default Tool" .
>                                (lambda (filename)
>                                  (call-process "/usr/bin/open" nil 0 nil 
> filename))))))))))
> Then, it's just a matter of appending additonal transformers to the
> list.
> What do you think?

I've though about it already, and it's clear to me that some mechanism
like that has to be implemented. I'll give it a try today.

Little  Miss Muffet  sat on  her tuffet,  until Chuck  Norris roundhouse
kicked her into a glacier.

reply via email to

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