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, 31 Jul 2007 15:36:45 -0000
User-agent: G2/1.0

On Jul 31, 6:41 am, Tassilo Horn <address@hidden> wrote:
> address@hidden writes:
>
> Hi Bill,
>
>
>
> > (setq anything-transform-files-excludes (list "/Applications/cache/"
> >                                          "/.backups"
> >                                          "/.svn"
> >                                          "/CVS"
> >                                          "/.DS_Store"
> >                                          "/.cvsignore"))
>
> > (defun anything-transform-files (files)
> >   "Transform file candidates."
>
> >   (if anything-transform-files-excludes
> >       (setq files (let ((filtered-files nil))
> >                (loop for file in files
> >                      do (if (loop for regexp in 
> > anything-transform-files-excludes
> >                                   do (if (string-match regexp file) (return 
> > nil))
> >                                   finally (return file))
> >                             (setq filtered-files (append (list file) 
> > filtered-files)))
> >                      finally (return filtered-files)))))
>
> >   (let ((boring-file-regexp
> >          (concat "\\(?:" (regexp-opt completion-ignored-extensions) "\
> > \)\\'")))
> >     (mapcar (lambda (file)
> >               ;; Add shadow face property to boring files.
> >               (let ((face (if (facep 'file-name-shadow)
> >                               'file-name-shadow
> >                             ;; fall back to default on XEmacs
> >                             'default)))
> >                 (if (string-match boring-file-regexp file)
> >                     (setq file (propertize file 'face face))))
>
> >               ;; replace path of HOME directory in paths with the
> > string
> >               ;; <home>
> >               (let ((home (replace-regexp-in-string "\\\\" "/" ;
> > stupid Windows...
> >                                                     (getenv "HOME"))))
> >                 (if (string-match home file)
> >                     (cons (replace-match "<home>" nil nil file) file)
> >                   file)))
> >             files)))
>
> Hey, that's nice. I'll integrate it in anything-config.el, but I'll
> modify it a bit to have the same interface as the action transformers.

That would be nice - it would keep the action and candidate transform
definitions consistent.

If you plan to add my code as an example transform, you probably
should add "delete-dups" to it too:

(setq anything-transform-files-excludes (list "/Applications/cache/"
                                              "/\.backups"
                                              "/\.svn"
                                              "/CVS"
                                              "/\.DS_Store"
                                              "/\.cvsignore"
                                              ".*~$"))

(defun anything-transform-files (files)
  "Transform file candidates."

  (if anything-transform-files-excludes
      (setq files (delete-dups (let ((filtered-files nil))
                                 (loop for file in files
                                       do (if (loop for regexp in 
anything-transform-files-
excludes
                                                    do (if (string-match regexp 
file) (return nil))
                                                    finally (return file))
                                              (setq filtered-files (append 
(list file) filtered-files)))
                                       finally (return filtered-files)))))))

I know that this has been brought up in the past and (setq history-
delete-duplicates t) is supposed to fix the problem; however, I still
get duplicates in the file history list. So, having the delete-dups in
the candidate transformer ensures that there's only 1 instance of a
file name displayed.

- Bill




reply via email to

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