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

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

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


From: billclem
Subject: Re: ;;; anything.el --- open anything
Date: Tue, 24 Jul 2007 21:05:45 -0000
User-agent: G2/1.0

address@hidden writes:

> Hmm, that requires 2 more keystrokes than my command, so I think I'll
> just keep it in my .emacs file as I use that action quite a
> lot. Incidentally, I wrote a little helper macro that adds new actions
> to the existing ones (I find the "standard" actions quite useful, so I
> don't want to do a reassignment that just replicates what's already in
> anything-config.el and I also I didn't want to have to clone the
> variable assignment every time a new version of anything-config.el
> came out with additional actions). You might want to add it to
> anything-config.el if you think others might also find it useful:
>
> (defmacro anything-add-to-actions (var field action)
>   `(setq ,var (cons ',field
>                   (append
>                    (cdr ,var)
>                    (list ',action)))))
>
> To add the two actions I sent in earlier, one would do the following:
>
> (anything-add-to-actions anything-actions-file
>                        file
>                        ("Open File with default Tool" .
>                          (lambda (filename)
>                            (call-process "/usr/bin/open" nil 0 nil 
> filename))))
>
> (anything-add-to-actions anything-actions-function
>                        function
>                        ("Find Function" .
>                         (lambda (command-name)
>                           (find-function (intern command-name)))))
>

Actually, the macro should be:

(defmacro anything-add-to-actions (var action)
  `(setq ,var (cons (car ,var)
                    (append
                     (cdr ,var)
                     (list ',action)))))

And to add an action:

(anything-add-to-actions anything-actions-file
                         ("Open File with default Tool" .
                           (lambda (filename)
                             (call-process "/usr/bin/open" nil 0 nil 
filename))))

--
Bill Clementson



reply via email to

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