all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Anything.el for Windows
@ 2008-02-04 12:03 Sébastien Vauban
  2008-02-04 20:36 ` Tassilo Horn
       [not found] ` <mailman.6969.1202157424.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-04 12:03 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I've read, not so long ago, about the fantastic `anything.el'
package, which opens pretty anything in a few keystrokes.

What's really great about it, is its integration with Locate and
Tracker (under Ubuntu). Unmissable, once tried...

How could I replicate such behaviors under Windows (that I have
to use for work -- can't avoid it yet) where neither one neither
the other exists by default?

Other question: can we impose an order for the presentation of
the different sources?  It seems the order specified by my
`anything-sources' variable is not taken into account.

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-04 12:03 Anything.el for Windows Sébastien Vauban
@ 2008-02-04 20:36 ` Tassilo Horn
       [not found] ` <mailman.6969.1202157424.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-04 20:36 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> How could I replicate such behaviors under Windows (that I have to use
> for work -- can't avoid it yet) where neither one neither the other
> exists by default?

I'm not sure, but maybe you can install both with Cygwin [1].

> Other question: can we impose an order for the presentation of the
> different sources?  It seems the order specified by my
> `anything-sources' variable is not taken into account.

I think it should use the order in anything-sources with the exception
of asynchronous sources.  Of course both locate and tracker are
asynchronous sources, so currently you cannot control the order there.
But there's a TODO in anything.el:

,----[ ~/elisp/anything.el ]
| ;;   - results from async sources should appear in the order they are
| ;;     specified in anything-sources
`----

Bye,
Tassilo
__________
[1] http://www.cygwin.com/





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found] ` <mailman.6969.1202157424.18990.help-gnu-emacs@gnu.org>
@ 2008-02-05 16:07   ` Sébastien Vauban
  2008-02-05 17:00     ` Tassilo Horn
       [not found]     ` <mailman.7003.1202230839.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-05 16:07 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>> How could I replicate such behaviors under Windows (that I
>> have to use for work -- can't avoid it yet) where neither
>> `locate' neither `tracker-search' exists by default?
>
> I'm not sure, but maybe you can install both with Cygwin.

Excellent direction, at least to begin with!

`locate' is installed by default via `diffutils' (in the base
distribution), but it did not return any result...

So, I've updated the database, and set up a cron job:

--8<---------------cut here---------------start------------->8---
5 5 * * * nice updatedb --localpaths='/cygdrive/c /cygdrive/z' --prunepaths='/cygdrive/c/cygwin /cygdrive/c/RECYCLER'
--8<---------------cut here---------------end--------------->8---

Now, `locate' return the correct results, but...

it's still not visible in my `anything' buffer on Windows (while
it is described in the sources):

--8<---------------cut here---------------start------------->8---
        ;; source of candidates for anything
        (setq anything-sources
              (list anything-c-source-locate
                    anything-c-source-tracker-search
                    anything-c-source-buffers
                    anything-c-source-bookmarks
                    anything-c-source-file-name-history
                    anything-c-source-man-pages
                    anything-c-source-info-pages
                    ))
--8<---------------cut here---------------end--------------->8---

It is like if the processes was not called or ...?  Though, I've
no error messages returned... What could I do to check where the
problem comes from?

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-05 16:07   ` Sébastien Vauban
@ 2008-02-05 17:00     ` Tassilo Horn
       [not found]     ` <mailman.7003.1202230839.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-05 17:00 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

> It is like if the processes was not called or ...?  Though, I've no
> error messages returned... What could I do to check where the problem
> comes from?

The first thing I'd do is to ensure locate really gets called.  Does
cygwin have top?  If yes you can use that to see if M-x anything fires
up a locate process.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]     ` <mailman.7003.1202230839.18990.help-gnu-emacs@gnu.org>
@ 2008-02-06 11:27       ` Sébastien Vauban
  2008-02-06 13:49         ` Tassilo Horn
       [not found]         ` <mailman.7036.1202305782.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-06 11:27 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>> It is like if the [locate] process was not called or ... ?
>> Though, I've no error messages returned...
>> What could I do to check where the problem comes from?
>
> The first thing I'd do is to ensure locate really gets called.
> Does cygwin have top?

Yes, it is available from `System/procps'. Got it installed.
Works from the shell.


> If yes you can use that to see if M-x anything fires up a
> locate process.

Changed the process to launch with the following:

--8<---------------cut here---------------start------------->8---
(setq anything-c-locate-options '("top"))
--8<---------------cut here---------------end--------------->8---

... but nothing happens. Like if it was not called at all -
while still part of my anything sources.

Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-06 11:27       ` Sébastien Vauban
@ 2008-02-06 13:49         ` Tassilo Horn
       [not found]         ` <mailman.7036.1202305782.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-06 13:49 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

>> If yes you can use that to see if M-x anything fires up a
>> locate process.
>
> Changed the process to launch with the following:
>
> (setq anything-c-locate-options '("top"))
>
> ... but nothing happens. Like if it was not called at all - while
> still part of my anything sources.

No, don't touch anything-c-locate-options.  You should invoke `top' in a
terminal and then fire up anything and watch in top's output if a locate
process is started then.

And please check if locate accepts the options given in
anything-c-locate-options.  (locate --help in a terminal)

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]         ` <mailman.7036.1202305782.18990.help-gnu-emacs@gnu.org>
@ 2008-02-11 15:24           ` Sébastien Vauban
  2008-02-11 17:10             ` Tassilo Horn
       [not found]             ` <mailman.7291.1202749829.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-11 15:24 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>>> You can use that to see if M-x anything fires up a locate
>>> process.
>>
>> Changed the process to launch with the following:
>>
>> (setq anything-c-locate-options '("top"))
>>
>> ... but nothing happens. Like if it was not called at all - while
>> still part of my anything sources.
>
> No, don't touch anything-c-locate-options. You should invoke
> `top' in a terminal and then fire up anything and watch in
> top's output if a locate process is started then.

Stupid from me!  Sorry.

To answer your question, no, `M-x anything' does not fire up a
`locate' process (checked with `top -d 0.1' - *correctly*
working under cygwin). I don't understand why.

On the other hand, `M-x locate' does well launch a `locate'
process, with the following result (as example, for the pattern
`diary') outputted in a buffer:

--8<---------------cut here---------------start------------->8---
  /:
 Matches for diary:

    /cygdrive/c/Media/Download/emacs/site-lisp/.TEMP/diary-outlook.el
    /cygdrive/c/Media/Download/emacs/site-lisp/emacs-w3m-cvs/shimbun/sb-tdiary-ml.el
    /cygdrive/c/Media/Download/emacs/site-lisp/emacs-w3m-cvs/shimbun/sb-tdiary.el
    /cygdrive/c/Media/Download/emacs/site-lisp/gnus-cvs/lisp/gnus-diary.el
    /cygdrive/c/Media/Download/emacs/site-lisp/gnus-cvs/lisp/nndiary.el
    /cygdrive/c/Program Files/Emacs/emacs/lisp/calendar/diary-lib.el
    /cygdrive/c/Program Files/Emacs/emacs/lisp/calendar/diary-lib.elc
    /cygdrive/c/Program Files/Emacs/emacs/lisp/gnus/gnus-diary.el
    /cygdrive/c/Program Files/Emacs/emacs/lisp/gnus/gnus-diary.elc
    /cygdrive/c/Program Files/Emacs/emacs/lisp/gnus/nndiary.el
    /cygdrive/c/Program Files/Emacs/emacs/lisp/gnus/nndiary.elc
    /cygdrive/z/.emacs_backups/!drive_z!home!diary-birthdays.~1~
    /cygdrive/z/.emacs_backups/!drive_z!home!diary.~1~
    /cygdrive/z/.svn/prop-base/diary-birthdays.svn-base
    /cygdrive/z/.svn/prop-base/diary.svn-base
    /cygdrive/z/.svn/text-base/diary-birthdays.svn-base
    /cygdrive/z/.svn/text-base/diary.svn-base
    /cygdrive/z/diary
    /cygdrive/z/diary-birthdays
    /cygdrive/z/Media/Download/emacs/site-lisp/.TEMP/diary-outlook.el
    /cygdrive/z/Media/Download/emacs/site-lisp/emacs-w3m-cvs/shimbun/sb-tdiary-ml.el
    /cygdrive/z/Media/Download/emacs/site-lisp/emacs-w3m-cvs/shimbun/sb-tdiary.el
    /cygdrive/z/Media/Download/emacs/site-lisp/gnus-cvs/lisp/gnus-diary.el
    /cygdrive/z/Media/Download/emacs/site-lisp/gnus-cvs/lisp/nndiary.el
--8<---------------cut here---------------end--------------->8---


> And please check if locate accepts the options given in
> anything-c-locate-options.

Yes, it does support `-i' and `-r', as you can see (extracted
from my bash terminal window):

--8<---------------cut here---------------start------------->8---
[Administrator@CLARK-VBW] ~>locate -i -r pattern
/cygdrive/c/cygwin/lib/perl5/5.8/unicore/lib/gc_sc/PatternS.pl
/cygdrive/c/cygwin/lib/perl5/5.8/unicore/lib/gc_sc/PatternW.pl
/cygdrive/c/Program Files/Microsoft Visual Studio 8/Xml/1033/Snippets/xsd/Attributes/pattern.snippet
/cygdrive/c/Program Files/Microsoft Visual Studio 8/Xml/1033/Snippets/xsd/SimpleTypes/pattern.snippet
/cygdrive/z/.gimp-2.2/patterns
--8<---------------cut here---------------end--------------->8---


> (locate --help in a terminal)

--8<---------------cut here---------------start------------->8---
[Administrator@CLARK-VBW] ~>locate --help
Usage: locate [-d path | --database=path] [-e | -E | --[non-]existing]
      [-i | --ignore-case] [-w | --wholename] [-b | --basename]
      [--limit=N | -l N] [-S | --statistics] [-0 | --null] [-c | --count]
      [-P | -H | --nofollow] [-L | --follow] [-m | --mmap ] [ -s | --stdio ]
      [-A | --all] [-p | --print] [-r | --regex ] [--regextype=TYPE]
      [--max-database-age D] [--version] [--help]
      pattern...
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-11 15:24           ` Sébastien Vauban
@ 2008-02-11 17:10             ` Tassilo Horn
       [not found]             ` <mailman.7291.1202749829.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-11 17:10 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> To answer your question, no, `M-x anything' does not fire up a
> `locate' process (checked with `top -d 0.1' - *correctly* working
> under cygwin). I don't understand why.

Strange.  Could you please eval the following expression and report back
what happens?

(let ((buf "*locate*"))
  (apply 'start-process "locate-process" buf
         (append anything-c-locate-options
                 (list "pattern")))
  (pop-to-buffer buf)) ;; <-- Press `C-x C-e' behind the last closing
                       ;;     parenthesis.

Bye,
Tassilo
-- 
No person,  no idea, and no  religion deserves to be  illegal to insult,
not even the Church of Emacs. (Richard M. Stallman)





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]             ` <mailman.7291.1202749829.18990.help-gnu-emacs@gnu.org>
@ 2008-02-12 11:17               ` Sébastien Vauban
  2008-02-12 15:47                 ` Tassilo Horn
       [not found]                 ` <mailman.7338.1202831286.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-12 11:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>> To answer your question, no, `M-x anything' does not fire up
>> a `locate' process (checked with `top -d 0.1' - *correctly*
>> working under cygwin). I don't understand why.
>
> Strange. Could you please eval the following expression and
> report back what happens?
>
> (let ((buf "*locate*"))
>   (apply 'start-process "locate-process" buf
>          (append anything-c-locate-options
>                  (list "pattern")))
>   (pop-to-buffer buf)) ;; <-- Press `C-x C-e' behind the last closing
>                        ;;     parenthesis.

Yes, it does create a new buffer, in which the following is to
be found:

    ,----[ *locate* ]
    | /cygdrive/c/cygwin/lib/perl5/5.8/unicore/lib/gc_sc/PatternS.pl
    | /cygdrive/c/cygwin/lib/perl5/5.8/unicore/lib/gc_sc/PatternW.pl
    | /cygdrive/c/Program Files/Microsoft Visual Studio 8/Xml/1033/Snippets/xsd/Attributes/pattern.snippet
    | /cygdrive/c/Program Files/Microsoft Visual Studio 8/Xml/1033/Snippets/xsd/SimpleTypes/pattern.snippet
    | /cygdrive/z/.gimp-2.2/patterns
    |
    | Process locate-process finished
    `----

If I redo it, or change "pattern" into something else, it reacts
correctly (to my understanding of it), appending the new results
at the end of that same buffer.

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-12 11:17               ` Sébastien Vauban
@ 2008-02-12 15:47                 ` Tassilo Horn
       [not found]                 ` <mailman.7338.1202831286.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-12 15:47 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

>> Strange. Could you please eval the following expression and report
>> back what happens?
>>
>> (let ((buf "*locate*"))
>>   (apply 'start-process "locate-process" buf
>>          (append anything-c-locate-options
>>                  (list "pattern")))
>>   (pop-to-buffer buf)) ;; <-- Press `C-x C-e' behind the last closing
>>                        ;;     parenthesis.
>
> Yes, it does create a new buffer, in which the following is to be
> found:

[...]

Really strange.  The code above is a copy of the command
anything-c-source-locate uses to get the candidates list.  Did you
redefine it or use an home-brewn locate source in anything-sources?

Anyway, please paste your anything-sources, so that I can check if I can
reproduce the bug here.

Bye,
Tassilo
-- 
Thousands  of years  ago Chuck  Norris  came across  a bear.  It was  so
terrified that it  fled north into the arctic. It  was also so terrified
that all of its decendents now have white hair.





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                 ` <mailman.7338.1202831286.18990.help-gnu-emacs@gnu.org>
@ 2008-02-12 16:08                   ` Sébastien Vauban
  2008-02-13  7:55                     ` Tassilo Horn
       [not found]                     ` <mailman.7363.1202889358.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-12 16:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>>> Strange. Could you please eval the following expression and
>>> report back what happens?
>>>
>>> (let ((buf "*locate*"))
>>>   (apply 'start-process "locate-process" buf
>>>          (append anything-c-locate-options
>>>                  (list "pattern")))
>>>   (pop-to-buffer buf)) ;; <-- Press `C-x C-e' behind the last closing
>>>                        ;;     parenthesis.
>>
>> Yes, it does create a new buffer, in which the following is
>> to be found:
>
> [...]
>
> Really strange. The code above is a copy of the command
> anything-c-source-locate uses to get the candidates list. Did
> you redefine it or use an home-brewn locate source in
> anything-sources?

Nope. See the relevant extract from my `.emacs' file:

--8<---------------cut here---------------start------------->8---
;; open anything
(GNUEmacs
    (when (require 'anything-config)  ; loads `anything.el' too

        ;; source of candidates for anything
        (setq anything-sources
              (list anything-c-source-locate
                    anything-c-source-tracker-search
                    anything-c-source-bookmarks          ;; 1
                    anything-c-source-file-name-history  ;; 2
                    anything-c-source-buffers            ;; 3
                    anything-c-source-man-pages          ;; 4
                    anything-c-source-info-pages         ;; 5
                    ))

        ;; do not show more candidates than this limit from inidividual sources
        (setq anything-candidate-number-limit 10)

        ;; make anything minibuffer better input latency
        (defadvice anything-check-minibuffer-input (around sit-for activate)
          (if (sit-for anything-idle-delay t)
              ad-do-it))

        ;; select anything
        (global-set-key [(f3)] 'anything)))
--8<---------------cut here---------------end--------------->8---


> Anyway, please paste your anything-sources, so that I can
> check if I can reproduce the bug here.

Yes, sure. Here it is (`C-h v' in GNU Emacs/Windows):

--8<---------------cut here---------------start------------->8---
anything-sources is a variable defined in `anything.el'.
Its value is shown below.

Documentation:
The source of candidates for anything.

[...]

Value: 
(((name . "Locate")
  (candidates lambda nil
              (apply 'start-process "locate-process" nil
                     (append anything-c-locate-options
                             (list anything-pattern))))
  (type . file)
  (requires-pattern . 3)
  (delayed))
 ((name . "Tracker Search")
  (candidates lambda nil
              (start-process "tracker-search-process" nil "tracker-search" anything-pattern))
  (type . file)
  (requires-pattern . 3)
  (delayed))
 ((name . "Bookmarks")
  (init lambda nil
        (require 'bookmark))
  (candidates . bookmark-all-names)
  (action
   ("Jump to Bookmark" . bookmark-jump)))
 ((name . "File Name History")
  (candidates . file-name-history)
  (match anything-c-match-on-file-name anything-c-match-on-directory-name)
  (type . file))
 ((name . "Buffers")
  (candidates . anything-c-buffer-list)
  (volatile)
  (type . buffer))
 ((name . "Manual Pages")
  (candidates lambda nil
              (if anything-c-man-pages anything-c-man-pages
                (setq anything-c-man-pages
                      (condition-case nil
                          (progn
                            (require 'woman)
                            (woman-file-name "")
                            (sort
                             (mapcar 'car woman-topic-all-completions)
                             'string-lessp))
                        (error nil)))))
  (action
   ("Show with Woman" . woman))
  (requires-pattern . 2))
 ((name . "Info Pages")
  (candidates lambda nil
              (if anything-c-info-pages anything-c-info-pages
                (setq anything-c-info-pages
                      (save-window-excursion
                        (save-excursion
                          (require 'info)
                          (Info-find-node "dir" "top")
                          (goto-char
                           (point-min))
                          (let
                              ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
                               topics)
                            (while
                                (re-search-forward info-topic-regexp nil t)
                              (add-to-list 'topics
                                           (match-string-no-properties 1)))
                            (goto-char
                             (point-min))
                            (Info-exit)
                            topics))))))
  (action
   ("Show with Info" lambda
    (node-str)
    (info
     (replace-regexp-in-string "^[^:]+: " "" node-str))))
  (requires-pattern . 2)))
--8<---------------cut here---------------end--------------->8---

Thanks again for your help!!!

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-12 16:08                   ` Sébastien Vauban
@ 2008-02-13  7:55                     ` Tassilo Horn
       [not found]                     ` <mailman.7363.1202889358.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-13  7:55 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

>> Anyway, please paste your anything-sources, so that I can check if I
>> can reproduce the bug here.
>
> Yes, sure. Here it is (`C-h v' in GNU Emacs/Windows):

[...]

> Value: 
> (((name . "Locate")
>   (candidates lambda nil
>               (apply 'start-process "locate-process" nil
>                      (append anything-c-locate-options
>                              (list anything-pattern))))
>   (type . file)
>   (requires-pattern . 3)
>   (delayed))

[...]

>  ((name . "Info Pages")
>   (candidates lambda nil
>               (if anything-c-info-pages anything-c-info-pages
>                 (setq anything-c-info-pages
>                       (save-window-excursion
>                         (save-excursion
>                           (require 'info)
>                           (Info-find-node "dir" "top")
>                           (goto-char
>                            (point-min))
>                           (let
>                               ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>                                topics)
>                             (while
>                                 (re-search-forward info-topic-regexp nil t)
>                               (add-to-list 'topics
>                                            (match-string-no-properties 1)))
>                             (goto-char
>                              (point-min))
>                             (Info-exit)
>                             topics)))))) ;; <-- [1]
>   (action
>    ("Show with Info" lambda
>     (node-str)
>     (info
>      (replace-regexp-in-string "^[^:]+: " "" node-str))))
>   (requires-pattern . 2)))

Hah!  There's the bug!  The "Info Pages" source ends at [1], the
following action section and the requires-pattern stand alone.  Is it
possible that you use an outdated version of anything-config.el?  Please
get the current one from my git repository [1]or from emacswiki [2].

Bye,
Tassilo
__________
[1] git clone http://www.tsdh.de/repos/git/anything-config.git/
[2] http://www.emacswiki.org/cgi-bin/wiki/anything-config.el





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                     ` <mailman.7363.1202889358.18990.help-gnu-emacs@gnu.org>
@ 2008-02-14 13:08                       ` Sébastien Vauban
  2008-02-14 13:57                         ` Tassilo Horn
       [not found]                         ` <mailman.7403.1202997494.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-14 13:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>>> Anyway, please paste your anything-sources, so that I can
>>> check if I can reproduce the bug here.
>>
>> Value: 
>> (((name . "Locate")
>>   (candidates lambda nil
>>               (apply 'start-process "locate-process" nil
>>                      (append anything-c-locate-options
>>                              (list anything-pattern))))
>>   (type . file)
>>   (requires-pattern . 3)
>>   (delayed))
>
> [...]
>
>>  ((name . "Info Pages")
>>   (candidates lambda nil
>>               (if anything-c-info-pages anything-c-info-pages
>>                 (setq anything-c-info-pages
>>                       (save-window-excursion
>>                         (save-excursion
>>                           (require 'info)
>>                           (Info-find-node "dir" "top")
>>                           (goto-char
>>                            (point-min))
>>                           (let
>>                               ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>>                                topics)
>>                             (while
>>                                 (re-search-forward info-topic-regexp nil t)
>>                               (add-to-list 'topics
>>                                            (match-string-no-properties 1)))
>>                             (goto-char
>>                              (point-min))
>>                             (Info-exit)
>>                             topics)))))) ;; <-- [1]
>>   (action
>>    ("Show with Info" lambda
>>     (node-str)
>>     (info
>>      (replace-regexp-in-string "^[^:]+: " "" node-str))))
>>   (requires-pattern . 2)))
>
> Hah! There's the bug! The "Info Pages" source ends at [1], the
> following action section and the requires-pattern stand alone.
> Is it possible that you use an outdated version of
> anything-config.el?

Not really. Here are the differences between my original
anything-sources.el and the latest one on [2].

--8<---------------cut here---------------start------------->8---
341c341
<     (type . bookmark))
---
>     (action . (("Jump to Bookmark" . bookmark-jump))))
811c811
<   "Replaces /home/user with ~."
---
>   "Replaces /home/user with $HOME."
812a813
>             ;; replace path of HOME directory in paths with the string <home>
816c817
<                   (cons (replace-match "~" nil nil file) file)
---
>                   (cons (replace-match "$HOME" nil nil file) file)
1074,1076c1075
<                                        '(anything-c-transform-sexp-eval-command-sexp)))))
<         (bookmark (action ("Jump to bookmark" . bookmark-jump)
<                           ("Delete bookmark" . bookmark-delete)))))
---
>                                        '(anything-c-transform-sexp-eval-command-sexp)))))))
--8<---------------cut here---------------end--------------->8---

From what I understand, nothing that would explain my problem?


> Please get the current one from my git repository [1] or from
> emacswiki [2].
> __________
> [1] git clone http://www.tsdh.de/repos/git/anything-config.git/
> [2] http://www.emacswiki.org/cgi-bin/wiki/anything-config.el

I've git'ted your file as well (2nd try), but my problem still
stays!?

FYI, here's my `anything-sources' with the latest "sources"
file:

--8<---------------cut here---------------start------------->8---
Value: 
(((name . "Locate")
  (candidates lambda nil
              (apply 'start-process "locate-process" nil
                     (append anything-c-locate-options
                             (list anything-pattern))))
  (type . file)
  (requires-pattern . 3)
  (delayed))
 ((name . "Tracker Search")
  (candidates lambda nil
              (start-process "tracker-search-process" nil "tracker-search" anything-pattern))
  (type . file)
  (requires-pattern . 3)
  (delayed))
 ((name . "Bookmarks")
  (init lambda nil
        (require 'bookmark))
  (candidates . bookmark-all-names)
  (type . bookmark))
 ((name . "File Name History")
  (candidates . file-name-history)
  (match anything-c-match-on-file-name anything-c-match-on-directory-name)
  (type . file))
 ((name . "Buffers")
  (candidates . anything-c-buffer-list)
  (volatile)
  (type . buffer))
 ((name . "Manual Pages")
  (candidates lambda nil
              (if anything-c-man-pages anything-c-man-pages
                (setq anything-c-man-pages
                      (condition-case nil
                          (progn
                            (require 'woman)
                            (woman-file-name "")
                            (sort
                             (mapcar 'car woman-topic-all-completions)
                             'string-lessp))
                        (error nil)))))
  (action
   ("Show with Woman" . woman))
  (requires-pattern . 2))
 ((name . "Info Pages")
  (candidates lambda nil
              (if anything-c-info-pages anything-c-info-pages
                (setq anything-c-info-pages
                      (save-window-excursion
                        (save-excursion
                          (require 'info)
                          (Info-find-node "dir" "top")
                          (goto-char
                           (point-min))
                          (let
                              ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
                               topics)
                            (while
                                (re-search-forward info-topic-regexp nil t)
                              (add-to-list 'topics
                                           (match-string-no-properties 1)))
                            (goto-char
                             (point-min))
                            (Info-exit)
                            topics))))))
  (action
   ("Show with Info" lambda
    (node-str)
    (info
     (replace-regexp-in-string "^[^:]+: " "" node-str))))
  (requires-pattern . 2)))
--8<---------------cut here---------------end--------------->8---

The problem seems to stay, even with the updated versions of
both `anything.el' and `anything-sources.el'.

Can you help me?

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-14 13:08                       ` Sébastien Vauban
@ 2008-02-14 13:57                         ` Tassilo Horn
       [not found]                         ` <mailman.7403.1202997494.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-14 13:57 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

[...]

>> Is it possible that you use an outdated version of
>> anything-config.el?
>
> Not really. Here are the differences between my original
> anything-sources.el and the latest one on [2].

[...]

> From what I understand, nothing that would explain my problem?

Correct.

> I've git'ted your file as well (2nd try), but my problem still stays!?

Ok.

> FYI, here's my `anything-sources' with the latest "sources" file:
>
> Value: 
> (((name . "Locate")
>   (candidates lambda nil
>               (apply 'start-process "locate-process" nil
>                      (append anything-c-locate-options
>                              (list anything-pattern))))
>   (type . file)
>   (requires-pattern . 3)
>   (delayed))

[...]

>  ((name . "Info Pages")
>   (candidates lambda nil
>               (if anything-c-info-pages anything-c-info-pages
>                 (setq anything-c-info-pages
>                       (save-window-excursion
>                         (save-excursion
>                           (require 'info)
>                           (Info-find-node "dir" "top")
>                           (goto-char
>                            (point-min))
>                           (let
>                               ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>                                topics)
>                             (while
>                                 (re-search-forward info-topic-regexp nil t)
>                               (add-to-list 'topics
>                                            (match-string-no-properties 1)))
>                             (goto-char
>                              (point-min))
>                             (Info-exit)
>                             topics))))))
>   (action
>    ("Show with Info" lambda
>     (node-str)
>     (info
>      (replace-regexp-in-string "^[^:]+: " "" node-str))))
>   (requires-pattern . 2)))
>
> The problem seems to stay, even with the updated versions of both
> `anything.el' and `anything-sources.el'.

Indeed, it's the same error...

> Can you help me?

Are those the only settings that you have?

--8<---------------cut here---------------start------------->8---
;; open anything
(GNUEmacs
    (when (require 'anything-config)  ; loads `anything.el' too

        ;; source of candidates for anything
        (setq anything-sources
              (list anything-c-source-locate
                    anything-c-source-tracker-search
                    anything-c-source-bookmarks          ;; 1
                    anything-c-source-file-name-history  ;; 2
                    anything-c-source-buffers            ;; 3
                    anything-c-source-man-pages          ;; 4
                    anything-c-source-info-pages         ;; 5
                    ))

        ;; do not show more candidates than this limit from inidividual sources
        (setq anything-candidate-number-limit 10)

        ;; make anything minibuffer better input latency
        (defadvice anything-check-minibuffer-input (around sit-for activate)
          (if (sit-for anything-idle-delay t)
              ad-do-it))

        ;; select anything
        (global-set-key [(f3)] 'anything)))
--8<---------------cut here---------------end--------------->8---

What is `GNUEmacs'?

Anyway, to me it looks all right.  I suspect you have a broken
anything-c-source-info-pages lying around somewhere.  Because this is
defvar'ed the broken value won't be overwritten when requiring
anything-config.  What does `C-h v anything-c-source-info-pages' say?

Bye,
Tassilo
-- 
Windows: So easy to admin, even a worm can do it.





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                         ` <mailman.7403.1202997494.18990.help-gnu-emacs@gnu.org>
@ 2008-02-14 14:33                           ` Sébastien Vauban
  2008-02-14 14:54                             ` Tassilo Horn
       [not found]                             ` <mailman.7405.1203000915.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-14 14:33 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

Sorry to disturb you again...


>> I've git'ted your file as well, but my problem still stays!?
>
> Ok.
>
>> FYI, here's my `anything-sources' with the latest "sources" file:
>>
>> Value:

[...]

>>  ((name . "Info Pages")
>>   (candidates lambda nil
>>               (if anything-c-info-pages anything-c-info-pages
>>                 (setq anything-c-info-pages
>>                       (save-window-excursion
>>                         (save-excursion
>>                           (require 'info)
>>                           (Info-find-node "dir" "top")
>>                           (goto-char
>>                            (point-min))
>>                           (let
>>                               ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>>                                topics)
>>                             (while
>>                                 (re-search-forward info-topic-regexp nil t)
>>                               (add-to-list 'topics
>>                                            (match-string-no-properties 1)))
>>                             (goto-char
>>                              (point-min))
>>                             (Info-exit)
>>                             topics))))))
>>   (action
>>    ("Show with Info" lambda
>>     (node-str)
>>     (info
>>      (replace-regexp-in-string "^[^:]+: " "" node-str))))
>>   (requires-pattern . 2)))
>>
>> The problem seems to stay, even with the updated versions of
>> both `anything.el' and `anything-sources.el'.
>
> Indeed, it's the same error...

OK.


>> Can you help me?
>
> Are those the only settings that you have?

Yes, no trace of "anything" somewhere else in my `.emacs'.


> ;; open anything
> (GNUEmacs
>     (when (require 'anything-config)  ; loads `anything.el' too
>
>         ;; source of candidates for anything
>         (setq anything-sources
>               (list anything-c-source-locate
>                     anything-c-source-tracker-search
>                     anything-c-source-bookmarks          ;; 1
>                     anything-c-source-file-name-history  ;; 2
>                     anything-c-source-buffers            ;; 3
>                     anything-c-source-man-pages          ;; 4
>                     anything-c-source-info-pages         ;; 5
>                     ))
>
>         ;; do not show more candidates than this limit from inidividual sources
>         (setq anything-candidate-number-limit 10)
>
>         ;; make anything minibuffer better input latency
>         (defadvice anything-check-minibuffer-input (around sit-for activate)
>           (if (sit-for anything-idle-delay t)
>               ad-do-it))
>
>         ;; select anything
>         (global-set-key [(f3)] 'anything)))
>
> What is `GNUEmacs'?

It's a macro to handle snippets of code that only work with GNU
Emacs or with XEmacs:

--8<---------------cut here---------------start------------->8---
(defmacro GNUEmacs (&rest body)
  "Execute any number of forms if running under GNU Emacs."
  (list 'if (not running-xemacs) (cons 'progn body)))

(defmacro XEmacs (&rest body)
  "Execute any number of forms if running under XEmacs."
  (list 'if running-xemacs (cons 'progn body)))
--8<---------------cut here---------------end--------------->8---

I surrounded the "anything" code with GNUEmacs because my first
(very quick) trials showed me problems running `anything' under
XEmacs.


> Anyway, to me it looks all right.  I suspect you have a broken
> anything-c-source-info-pages lying around somewhere.  Because this is
> defvar'ed the broken value won't be overwritten when requiring
> anything-config.

Oops, I don't imagine I could have done that ;-)


> What does `C-h v anything-c-source-info-pages' say?

--8<---------------cut here---------------start------------->8---
anything-c-source-info-pages is a variable defined in `anything-config.el'.
Its value is shown below.

Documentation:
Not documented as a variable.

Value: 
((name . "Info Pages")
 (candidates lambda nil
             (if anything-c-info-pages anything-c-info-pages
               (setq anything-c-info-pages
                     (save-window-excursion
                       (save-excursion
                         (require 'info)
                         (Info-find-node "dir" "top")
                         (goto-char
                          (point-min))
                         (let
                             ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
                              topics)
                           (while
                               (re-search-forward info-topic-regexp nil t)
                             (add-to-list 'topics
                                          (match-string-no-properties 1)))
                           (goto-char
                            (point-min))
                           (Info-exit)
                           topics))))))
 (action
  ("Show with Info" lambda
   (node-str)
   (info
    (replace-regexp-in-string "^[^:]+: " "" node-str))))
 (requires-pattern . 2))
--8<---------------cut here---------------end--------------->8---

Hope it helps.

Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-14 14:33                           ` Sébastien Vauban
@ 2008-02-14 14:54                             ` Tassilo Horn
       [not found]                             ` <mailman.7405.1203000915.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-14 14:54 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

>> What does `C-h v anything-c-source-info-pages' say?
>
> anything-c-source-info-pages is a variable defined in
> `anything-config.el'.  Its value is shown below.
>
> Value: 
> ((name . "Info Pages")
>  (candidates lambda nil
>              (if anything-c-info-pages anything-c-info-pages
>                (setq anything-c-info-pages
>                      (save-window-excursion
>                        (save-excursion
>                          (require 'info)
>                          (Info-find-node "dir" "top")
>                          (goto-char
>                           (point-min))
>                          (let
>                              ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>                               topics)
>                            (while
>                                (re-search-forward info-topic-regexp nil t)
>                              (add-to-list 'topics
>                                           (match-string-no-properties 1)))
>                            (goto-char
>                             (point-min))
>                            (Info-exit)
>                            topics))))))
>  (action
>   ("Show with Info" lambda
>    (node-str)
>    (info
>     (replace-regexp-in-string "^[^:]+: " "" node-str))))
>  (requires-pattern . 2))
>
> Hope it helps.

Yep, it's broken!  But I'm absolutely sure that it's ok in the current
anything-config.el.  So it seems that you've got a outdated and broken
anything-config.el in a directory in your `load-path' which comes before
the directory of the new anything-config.el.  So the broken one get's
loaded and the new one won't be loaded because it's already provided.
(And even if you'd load it explicitly you wouldn't change the broken
defvar'ed values...)

Try to `locate' and delete it and restart emacs.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                             ` <mailman.7405.1203000915.18990.help-gnu-emacs@gnu.org>
@ 2008-02-15 11:38                               ` Sébastien Vauban
  2008-02-15 12:44                                 ` Tassilo Horn
       [not found]                                 ` <mailman.7443.1203079486.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-15 11:38 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>>> What does `C-h v anything-c-source-info-pages' say?

Value from the very latest test under Windows:

--8<---------------cut here---------------start------------->8---
anything-c-source-info-pages is a variable defined in `anything-config.el'.
Its value is shown below.

Documentation:
Not documented as a variable.

Value: 
((name . "Info Pages")
 (candidates lambda nil
             (if anything-c-info-pages anything-c-info-pages
               (setq anything-c-info-pages
                     (save-window-excursion
                       (save-excursion
                         (require 'info)
                         (Info-find-node "dir" "top")
                         (goto-char
                          (point-min))
                         (let
                             ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
                              topics)
                           (while
                               (re-search-forward info-topic-regexp nil t)
                             (add-to-list 'topics
                                          (match-string-no-properties 1)))
                           (goto-char
                            (point-min))
                           (Info-exit)
                           topics))))))
 (action
  ("Show with Info" lambda
   (node-str)
   (info
    (replace-regexp-in-string "^[^:]+: " "" node-str))))
 (requires-pattern . 2))
--8<---------------cut here---------------end--------------->8---


> Yep, it's broken! But I'm absolutely sure that it's ok in the
> current anything-config.el. So it seems that you've got a
> outdated and broken anything-config.el in a directory in your
> `load-path' which comes before the directory of the new
> anything-config.el. So the broken one get's loaded and the new
> one won't be loaded because it's already provided. (And even
> if you'd load it explicitly you wouldn't change the broken
> defvar'ed values...)
>
> Try to `locate' and delete it and restart emacs.

This seems a good explanation, but I've still the problem, while
having only one version of `anything-config.el'!

    o   Both locate from cygwin and locate-library from Emacs
        point to the unique copy I have of your file:

        ~/Media/Download/emacs/site-lisp/anything-config/anything-config.el

    o   No other hidden file in another path.

    o   I have no `.elc' file of it, neither.

Nothing that could explain my problem, but it still stays not
working.

FYI, I'm using the file I git'ted yesterday (or the day before -
don't remember) from your repository:

--8<---------------cut here---------------start------------->8---
;;; anything-config.el --- predefined configurations for anything

;; Copyright (C) 2007 Tassilo Horn

;; Maintainer: Tassilo Horn <tassilo@member.fsf.org>

;; Contributors:
;;     Tamas Patrovics
;;     Tassilo Horn <tassilo@member.fsf.org>
;;     Vagn Johansen <gonz808@hotmail.com>
;;     Mathias Dahl <mathias.dahl@gmail.com>
;;     Bill Clementson <billclem@gmail.com>
;;     Stefan Kamphausen <ska@skamphausen.de>
;;     Drew Adams <drew.adams@oracle.com>

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;;
;; This package provides predefined configurations for anything.el.  To enable
;; it, put this into your `user-init-file'.
;;
;;   (require 'anything-config) ; loads anything.el too
;;
;; To configure anything you should tweak the variables `anything-sources' and
;; `anything-type-attributes'.  See the default configuration at the bottom of
;; this file.  Copy and modify it to your needs.
;;
;;   (setq anything-sources ...)
;;   (setq anything-type-attributes ...)
;;

;;; Bugs and TODOs:

;;
;; - TODO: anything-c-adaptive stores infos for sources/types that don't have
;;   set it as `filtered-candidate-transformer'.
;;
;; - TODO: The Imenu source is broken for very recent emacsen.  It seems to
;;   work with 22.1, though.
;;

;;; Startup

(require 'anything)

;;; Version

(defvar anything-c-version "<2007-09-05 Wed 21:04>"
  "The version of anything-config.el, or better the date of the
last change.")

;;; Keymaps

(defvar anything-c-use-standard-keys t
  "If non-nil the keybindings of anything will be the standard
bindings used in most parts of emacs, e.g. M-p/M-n for minibuffer
history, C-s for isearch, etc.

If it's nil anything uses some bindings that don't conflict with
`iswitchb', e.g. C-p/C-n for the minibuffer history.  If you use
`iswitchb' you probably should say nil here.")

(when anything-c-use-standard-keys
  (setq anything-map
        (let ((map (copy-keymap minibuffer-local-map)))
          (define-key map (kbd "<down>")  'anything-next-line)
          (define-key map (kbd "<up>")    'anything-previous-line)
          (define-key map (kbd "C-n")     'anything-next-line)
          (define-key map (kbd "C-p")     'anything-previous-line)
          (define-key map (kbd "<prior>") 'anything-previous-page)
          (define-key map (kbd "<next>")  'anything-next-page)
          (define-key map (kbd "M-v")     'anything-previous-page)
          (define-key map (kbd "C-v")     'anything-next-page)
          (define-key map (kbd "<right>") 'anything-next-source)
          (define-key map (kbd "<left>")  'anything-previous-source)
          (define-key map (kbd "<RET>")   'anything-exit-minibuffer)
          (define-key map (kbd "C-1")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-2")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-3")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-4")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-5")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-6")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-7")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-8")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-9")     'anything-select-with-digit-shortcut)
          (define-key map (kbd "<tab>")   'anything-select-action)
          (defalias 'anything-next-history-element     'next-history-element)
          (defalias 'anything-previous-history-element 'previous-history-element)
          (define-key map (kbd "M-p")     'anything-previous-history-element)
          (define-key map (kbd "M-n")     'anything-next-history-element)
          (define-key map (kbd "C-s")     'anything-isearch)
          (define-key map (kbd "C-r")     'undefined)
          map))

  (setq anything-isearch-map
        (let ((map (copy-keymap (current-global-map))))
          (define-key map (kbd "<return>")    'anything-isearch-default-action)
          (define-key map (kbd "<tab>")       'anything-isearch-select-action)
          (define-key map (kbd "C-g")         'anything-isearch-cancel)
          (define-key map (kbd "C-s")         'anything-isearch-again)
          (define-key map (kbd "C-r")         'undefined)
          (define-key map (kbd "<backspace>") 'anything-isearch-delete)
          ;; add printing chars
          (let ((i ?\s))
            (while (< i 256)
              (define-key map (vector i) 'anything-isearch-printing-char)
              (setq i (1+ i))))
          map)))

;;; Sources

;;;; Match functions

(defun anything-c-match-on-file-name (candidate)
  "Return non-nil if `anything-pattern' matches the
filename (without directory part) of CANDIDATE."
  (string-match anything-pattern (file-name-nondirectory candidate)))

(defun anything-c-match-on-directory-name (candidate)
  "Return non-nil if `anything-pattern' matches the directory
part of CANDIDATE (a file)."
  (let ((dir (file-name-directory candidate)))
    (when dir
      (string-match anything-pattern dir))))

(defun anything-c-string-match (candidate)
  "Return non-nil if `anything-pattern' matches CANDIDATE.
The match is done with `string-match'."
  (string-match anything-pattern candidate))

;;;; Buffers

(defun anything-c-buffer-list ()
  "Return the list of names of buffers with the `anything-buffer'
and hidden buffers filtered out.  The first buffer in the list
will be the last recently used buffer that is not the current
buffer."
  (let ((buffers (remove-if (lambda (name)
                              (or (equal name anything-buffer)
                                  (eq ?\  (aref name 0))))
                            (mapcar 'buffer-name (buffer-list)))))
    (append (cdr buffers) (list (car buffers)))))

(defvar anything-c-source-buffers
  '((name . "Buffers")
    (candidates . anything-c-buffer-list)
    (volatile)
    (type . buffer)))

;;;; File name history

(defvar anything-c-source-file-name-history
  '((name . "File Name History")
    (candidates . file-name-history)
    (match . (anything-c-match-on-file-name
              anything-c-match-on-directory-name))
    (type . file)))

;;;; Recentf files

(defvar anything-c-source-recentf
  '((name . "Recentf")
    (candidates . recentf-list)
    (match . (anything-c-match-on-file-name
              anything-c-match-on-directory-name))
    (type . file))
  "See (info \"(emacs)File Conveniences\").")

;;;; Files in current dir

(defvar anything-c-source-files-in-current-dir
  '((name . "Files from Current Directory")
    (init . (lambda ()
              (setq anything-c-default-directory
                    default-directory)))
    (candidates . (lambda ()
                    (directory-files
                     anything-c-default-directory)))
    (volatile)
    (type . file)))

;;;; Man Pages

(defvar anything-c-man-pages nil
  "All man pages on system.
Will be calculated the first time you invoke anything with this
source.")

(defvar anything-c-source-man-pages
  `((name . "Manual Pages")
    (candidates . (lambda ()
                    (if anything-c-man-pages
                        anything-c-man-pages
                      ;; XEmacs doesn't have a woman :)
                      (setq anything-c-man-pages
                            (condition-case nil
                                (progn
                                  (require 'woman)
                                  (woman-file-name "")
                                  (sort (mapcar 'car
                                                woman-topic-all-completions)
                                        'string-lessp))
                              (error nil))))))
    (action . (("Show with Woman" . woman)))
    (requires-pattern . 2)))

;;;; Info pages

(defvar anything-c-info-pages nil
  "All info pages on system.
Will be calculated the first time you invoke anything with this
source.")

(defvar anything-c-source-info-pages
  `((name . "Info Pages")
    (candidates
     . (lambda ()
         (if anything-c-info-pages
             anything-c-info-pages
           (setq anything-c-info-pages
                 (save-window-excursion
                   (save-excursion
                     (require 'info)
                     (Info-find-node "dir" "top")
                     (goto-char (point-min))
                     (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
                           topics)
                       (while (re-search-forward info-topic-regexp nil t)
                         (add-to-list 'topics (match-string-no-properties 1)))
                       (goto-char (point-min))
                       (Info-exit)
                       topics)))))))
    (action . (("Show with Info" .(lambda (node-str)
                                    (info (replace-regexp-in-string "^[^:]+: "
                                                                    ""
                                                                    node-str))))))
    (requires-pattern . 2)))

;;;; Complex command history

(defvar anything-c-source-complex-command-history
  '((name . "Complex Command History")
    (candidates . (lambda ()
                    (mapcar 'prin1-to-string
                            command-history)))
    (volatile)
    (type . sexp)))

;;;; Emacs commands

(defvar anything-c-source-emacs-commands
  '((name . "Emacs Commands")
    (candidates . (lambda ()
                    (let (commands)
                      (mapatoms (lambda (a)
                                  (if (commandp a)
                                      (push (symbol-name a)
                                            commands))))
                      (sort commands 'string-lessp))))
    (volatile)
    (type . command)
    (requires-pattern . 2))
  "Source for completing and invoking Emacs commands.  A command
is a function with interactive spec that can be invoked with
`M-x'.

To get non-interactive functions listed, use
`anything-c-source-emacs-functions'.")

;;;; Emacs functions

;;;;; Normal

(defvar anything-c-source-emacs-functions
  '((name . "Emacs Functions")
    (candidates . (lambda ()
                    (let (commands)
                      (mapatoms (lambda (a)
                                  (if (functionp a)
                                      (push (symbol-name a)
                                            commands))))
                      (sort commands 'string-lessp))))
    (volatile)
    (type . function)
    (requires-pattern . 2))
  "Source for completing Emacs functions.")

;;;;; With abbrev expansion similar to my exec-abbrev-cmd.el

;; See http://www.tsdh.de/cgi-bin/wiki.pl/exec-abbrev-cmd.el

(defvar anything-c-function-abbrev-regexp nil
  "Regexp built from the current `anything-pattern' interpreting
it as abbreviation.  Only for internal use.")

(defun anything-c-match-function-by-abbrev (candidate)
  "Return non-nil if `anything-pattern' is an abbreviation of the
function CANDIDATE.

Abbreviations are made by taking the first character from each
word in the function's name, e.g. \"bb\" is an abbrev for
`bury-buffer', \"stb\" is an abbrev for `switch-to-buffer'."
  (string-match anything-c-function-abbrev-regexp candidate))

(defvar anything-c-source-emacs-functions-with-abbrevs
  (append anything-c-source-emacs-functions
          '((match . (anything-c-match-function-by-abbrev
                      anything-c-string-match)))
          '((init . (lambda ()
                      (defadvice anything-update
                        (before anything-c-update-function-abbrev-regexp activate)
                        (let ((char-list (append anything-pattern nil))
                              (str "^"))
                          (dolist (c char-list)
                            (setq str (concat str (list c) "[^-]*-")))
                          (setq str (concat (substring str 0 (1- (length str))) "$"))
                          (setq anything-c-function-abbrev-regexp str))))))))

;;;; Bookmarks

(defvar anything-c-source-bookmarks
  '((name . "Bookmarks")
    (init . (lambda ()
              (require 'bookmark)))
    (candidates . bookmark-all-names)
    (type . bookmark))
  "See (info \"(emacs)Bookmarks\").")

;;;; Picklist

(defvar anything-c-source-picklist
  '((name . "Picklist")
    (candidates . (lambda ()
                    (mapcar 'car picklist-list)))
    (volatile)
    (type . file)))

;;;; Imenu

(defvar anything-c-source-imenu
  '((name . "Imenu")
    (init . (lambda ()
              (setq anything-c-imenu-current-buffer
                    (current-buffer))))
    (candidates . (lambda ()
                    (condition-case nil
                        (with-current-buffer anything-c-imenu-current-buffer
                          (mapcar (lambda (x)
                                    (cons (car x) x))
                                  ;; leave only top level completions for
                                  ;; simplicity (could be more sophisticated)
                                  (remove-if-not (lambda (x)
                                                   (markerp (cdr x)))
                                                 (imenu--make-index-alist))))
                      (error nil))))
    (volatile)
    (action . imenu)))

;;;; File Cache

(defvar anything-c-source-file-cache-initialized nil)

(defvar anything-c-file-cache-files nil)

(defvar anything-c-source-file-cache
  '((name . "File Cache")
    (init . (lambda ()
              (unless anything-c-source-file-cache-initialized
                (setq anything-c-file-cache-files
                      (loop for item in file-cache-alist append
                            (destructuring-bind (base &rest dirs) item
                              (loop for dir in dirs collect
                                    (concat dir base)))))
                (defadvice file-cache-add-file (after file-cache-list activate)
                  (add-to-list 'anything-c-file-cache-files (expand-file-name file)))
                (setq anything-c-source-file-cache-initialized t))))
    (candidates . anything-c-file-cache-files)
    (match . (anything-c-match-on-file-name
              anything-c-match-on-directory-name))
    (type . file)))

;;;; Locate

(defvar anything-c-locate-options (if (eq system-type 'darwin)
                                      '("locate")
                                    '("locate" "-i" "-r"))
  "A list where the `car' is the name of the locat program
followed by options.  The search pattern will be appended, so the
\"-r\" option should be the last option.")

(defvar anything-c-source-locate
  '((name . "Locate")
    (candidates . (lambda ()
                    (apply 'start-process "locate-process" nil
                           (append anything-c-locate-options
                                   (list anything-pattern)))))
    (type . file)
    (requires-pattern . 3)
    (delayed))
  "Source for retrieving files matching the current input pattern
with locate.")

;;;; Tracker desktop search

(defvar anything-c-source-tracker-search
  '((name . "Tracker Search")
    (candidates . (lambda ()
                    (start-process "tracker-search-process" nil
                                   "tracker-search"
                                   anything-pattern)))
    (type . file)
    (requires-pattern . 3)
    (delayed))
  "Source for retrieving files matching the current input pattern
with the tracker desktop search.")

;;;; Spotlight (MacOS X desktop search)

(defvar anything-c-source-mac-spotlight
  '((name . "mdfind")
    (candidates . (lambda ()
                    (start-process "mdfind-process" nil
                                   "mdfind" anything-pattern)))
    (type . file)
    (requires-pattern . 3)
    (delayed))
  "Source for retrieving files via Spotlight's command line
utility mdfind.")

;;;; BBDB

(defun anything-c-bbdb-candidates ()
  "Return a list of all names in the bbdb database.  The format
is \"Firstname Lastname\"."
  (mapcar (lambda (bbdb-record)
            (concat (aref bbdb-record 0) " " (aref bbdb-record 1)))
          (bbdb-records)))

(defun anything-c-bbdb-create-contact (actions candidate)
  "Action transformer that returns only an entry to add the
current `anything-pattern' as new contact.  All other actions are
removed."
  (if (string= candidate "*Add to contacts*")
      '(("Add to contacts"
         . (lambda (actions)
             (bbdb-create-internal
              (read-from-minibuffer "Name: " anything-c-bbdb-name)
              (read-from-minibuffer "Company: ")
              (read-from-minibuffer "Email: ")
              nil
              nil
              (read-from-minibuffer "Note: ")))))
    actions))

(defvar anything-c-bbdb-name nil
  "Only for internal use.")

(defvar anything-c-source-bbdb
  '((name . "BBDB")
    (candidates . anything-c-bbdb-candidates)
    (volatile)
    (action ("View person's data" . (lambda (candidate)
                                      (bbdb candidate nil)
                                      (set-buffer "*BBDB*")
                                      (bbdb-redisplay-one-record (bbdb-current-record))))
            ("Send a mail" . (lambda (candidate)
                               (let ((rec (progn
                                            (bbdb candidate nil)
                                            (set-buffer "*BBDB*")
                                            (bbdb-current-record))))
                                 (bbdb-send-mail rec)))))
    (filtered-candidate-transformer . (lambda (candidates source)
                                        (setq anything-c-bbdb-name anything-pattern)
                                        (if (not candidates)
                                            (list "*Add to contacts*")
                                          candidates)))
    (action-transformer . (lambda (actions candidate)
                            (anything-c-bbdb-create-contact actions candidate)))))

;;;; Evaluation Result

(defvar anything-c-source-evaluation-result
  '((name . "Evaluation Result")
    (requires-pattern)
    (match (lambda (candidate) t))
    (candidates  "dummy")
    (filtered-candidate-transformer
     . (lambda (candidates source)
         (list
          (condition-case nil
              (prin1-to-string
               (eval (read anything-pattern)))
            (error "error")))))
    (volatile)
    (action ("Do Nothing" . ignore))))

;;;; Calculation Result

(defvar anything-c-source-calculation-result
  '((name . "Calculation Result")
    (requires-pattern)
    (match (lambda (candidate) t))
    (candidates  "dummy")
    (filtered-candidate-transformer
     . (lambda (candidates source)
         (list
          (condition-case nil
              (calc-eval anything-pattern)
            (error "error")))))
    (volatile)
    (action ("Do Nothing" . ignore))))

;;;; Google Suggestions

(defvar anything-c-source-google-suggest
  '((name . "Google Suggest")
    (candidates
     . (lambda ()
         (let ((suggestions (anything-c-google-suggest-fetch anything-input)))
           (if (some (lambda (suggestion)
                       (equal (cdr suggestion) anything-input))
                     suggestions)
               suggestions
             ;; if there is no suggestion exactly matching the input then
             ;; prepend a Search on Google item to the list
             (append (list (cons (concat "Search for "
                                         "'" anything-input "'"
                                         " on Google")
                                 anything-input))
                     suggestions)))))
    (action . (("Google Search" .
                (lambda (candidate)
                  (browse-url (concat anything-c-google-suggest-search-url
                                      (url-hexify-string candidate)))))))
    (volatile)
    (requires-pattern . 3)
    (delayed)))

(defvar anything-c-google-suggest-url
  "http://www.google.com/complete/search?hl=en&js=true&qu="
  "URL used for looking up suggestions.")

(defvar anything-c-google-suggest-search-url
  "http://www.google.com/search?ie=utf-8&oe=utf-8&q="
  "URL used for searching.")

(defun anything-c-google-suggest-fetch (input)
  "Fetch suggestions for INPUT."
  (let* ((result (with-current-buffer
                     (url-retrieve-synchronously
                      (concat anything-c-google-suggest-url
                              (url-hexify-string input)))
                   (buffer-substring (point-min) (point-max))))
         (split (split-string result "new Array("))
         (suggestions (anything-c-google-suggest-get-items (second split)))
         (numbers (anything-c-google-suggest-get-items (third split)))
         (longest (+ (apply 'max 0 (let (lengths)
                                     (dotimes (i (length suggestions))
                                       (push (+ (length (nth i suggestions))
                                                (length (nth i numbers)))
                                             lengths))
                                     lengths))
                     10))
         items)
    (dotimes (i (length suggestions))
      (let ((suggestion (nth i suggestions))
            (number (nth i numbers)))
        (push (cons (concat suggestion
                            (make-string (- longest
                                            (length suggestion)
                                            (length number))
                                         32)
                            number)
                    suggestion)
              items)))
    items))

(defun anything-c-google-suggest-get-items (str)
  "Extract items from STR returned by Google Suggest."
  (let ((start nil)
        items)
    (while (string-match "\"\\([^\"]+?\\)\"" str start)
      (push (match-string 1 str) items)
      (setq start (1+ (match-end 1))))
    items))

;;;; Jabber Contacts (jabber.el)

(defun anything-c-jabber-online-contacts ()
  "List online Jabber contacts."
  (let (jids)
    (dolist (item (jabber-concat-rosters) jids)
      (when (get item 'connected)
        (push (if (get item 'name)
                  (cons (get item 'name) item)
                (cons (symbol-name item) item)) jids)))))

(defvar anything-c-source-jabber-contacts
  '((name . "Jabber Contacts")
    (init . (lambda () (require 'jabber)))
    (candidates . (lambda ()
                    (mapcar
                     'car
                     (anything-c-jabber-online-contacts))))
    (action . (lambda (x)
                (jabber-chat-with
                 (jabber-read-account)
                 (symbol-name
                  (cdr (assoc x (anything-c-jabber-online-contacts)))))))))

;;; Type Action helpers

;;;; Files

(defvar anything-c-external-commands-list nil
  "A list of all external commands the user can execute.  If this
variable is not set by the user, it will be calculated
automatically.")

(defun anything-c-external-commands-list-1 ()
  "Returns a list of all external commands the user can execute.

If `anything-c-external-commands-list' is non-nil it will
return its contents.  Else it calculates all external commands
and sets `anything-c-external-commands-list'.

The code is ripped out of `eshell-complete-commands-list'."
  (if anything-c-external-commands-list
      anything-c-external-commands-list
    (setq anything-c-external-commands-list
          (let* ((paths (split-string (getenv "PATH") path-separator))
                 (cwd (file-name-as-directory
                       (expand-file-name default-directory)))
                 (path "") (comps-in-path ())
                 (file "") (filepath "") (completions ()))
            ;; Go thru each path in the search path, finding completions.
            (while paths
              (setq path (file-name-as-directory
                          (expand-file-name (or (car paths) ".")))
                    comps-in-path
                    (and (file-accessible-directory-p path)
                         (file-name-all-completions "" path)))
              ;; Go thru each completion found, to see whether it should be
              ;; used, e.g. see if it's executable.
              (while comps-in-path
                (setq file (car comps-in-path)
                      filepath (concat path file))
                (if (and (not (member file completions))
                         (or (string-equal path cwd)
                             (not (file-directory-p filepath)))
                         (file-executable-p filepath))
                    (setq completions (cons file completions)))
                (setq comps-in-path (cdr comps-in-path)))
              (setq paths (cdr paths)))
            completions))))

(defun anything-c-file-buffers (filename)
  "Returns a list of those buffer names which correspond to the
file given by FILENAME."
  (let (name ret)
    (dolist (buf (buffer-list) ret)
      (let ((bfn (buffer-file-name buf)))
        (when (and bfn
                   (string= filename bfn))
          (push (buffer-name buf) ret)))
      ret)))

(defun anything-c-delete-file (file)
  "Delete the given file after querying the user.  Ask to kill
buffers associated with that file, too."
  (if (y-or-n-p (format "Really delete file %s? " file))
      (progn
        (let ((buffers (anything-c-file-buffers file)))
          (delete-file file)
          (dolist (buf buffers)
            (when (y-or-n-p (format "Kill buffer %s, too? " buf))
              (kill-buffer buf)))))
    (message "Nothing deleted.")))

(defun anything-c-open-file-externally (file)
  "Open FILE with an external tool.  Query the user which tool to
use."
  (start-process "anything-c-open-file-externally"
                 nil
                 (completing-read "Program: "
                                  (anything-c-external-commands-list-1))
                 file))

(defun anything-c-open-with-default-tool (file)
  "Open FILE with the default tool on this platform."
  (start-process "anything-c-open-file-with-default-tool"
                 nil
                 (cond ((eq system-type 'gnu/linux)
                        "xdg-open")
                       ((or (eq system-type 'darwin)  ;; Mac OS X
                            (eq system-type 'macos))  ;; Mac OS 9
                        "open"))
                 file))

(defun anything-c-open-dired (file)
  "Opens a dired buffer in FILE's directory.  If FILE is a
directory, open this directory."
  (if (file-directory-p file)
      (dired file)
    (dired (file-name-directory file))
    (dired-goto-file file)))

;;; Action Transformers

;;;; Files

(defun anything-c-transform-file-load-el (actions candidate)
  "Add action to load the file CANDIDATE if it is an emacs lisp
file.  Else return ACTIONS unmodified."
  (if (or (string= (file-name-extension candidate) "el")
          (string= (file-name-extension candidate) "elc"))
      (append actions '(("Load Emacs Lisp File" . load-file)))
    actions))

(defun anything-c-transform-file-browse-url (actions candidate)
  "Add an action to browse the file CANDIDATE if it in a html
file.  Else return ACTIONS unmodified."
  (if (or (string= (file-name-extension candidate) "htm")
          (string= (file-name-extension candidate) "html"))
      (append actions '(("Browse with Browser" . browse-url)))
    actions))

;;;; Function

(defun anything-c-transform-function-call-interactively (actions candidate)
  "Add an action to call the function CANDIDATE interactively if
it is a command.  Else return ACTIONS unmodified."
  (if (commandp (intern candidate))
      (append actions '(("Call Interactively"
                         .
                         (lambda (c)
                           (call-interactively (intern c))))))
    actions))

;;;; S-Expressions

(defun anything-c-transform-sexp-eval-command-sexp (actions candidate)
  "If CANDIDATE's `car' is a command, then add an action to
evaluate it and put it onto the `command-history'."
  (if (commandp (car (read candidate)))
      ;; Make it first entry
      (cons '("Eval and put onto command-history" .
              (lambda (sexp)
                (let ((sym (read sexp)))
                  (eval sym)
                  (setq command-history
                        (cons sym command-history)))))
            actions)
    actions))

;;; Candidate Transformers

;;;; Files

(defvar anything-c-boring-file-regexp
  (rx (or
       ;; Boring directories
       (and "/" (or ".svn" "CVS" "_darcs" ".git") (or "/" eol))
       ;; Boring files
       (and (or ".class" ".la" ".o") eol)))
  "File candidates matching this regular expression will be
filtered from the list of candidates if the
`anything-c-skip-boring-files' candidate transformer is used, or
they will be displayed with face `file-name-shadow' if
`anything-c-shadow-boring-files' is used.")

(defun anything-c-shadow-boring-files (files)
  "Files matching `anything-c-boring-file-regexp' will be
displayed with the `file-name-shadow' face if available."
  (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 anything-c-boring-file-regexp file)
                  (setq file (propertize file 'face face))))
            file)
          files))

(defun anything-c-skip-boring-files (files)
  "Files matching `anything-c-boring-file-regexp' will be
skipped."
  (let (filtered-files)
    (loop for file in files
          do (when (not (string-match anything-c-boring-file-regexp file))
               (push file filtered-files))
          finally (return (nreverse filtered-files)))))

(defun anything-c-shorten-home-path (files)
  "Replaces /home/user with ~."
  (mapcar (lambda (file)
            (let ((home (replace-regexp-in-string "\\\\" "/" ; stupid Windows...
                                                  (getenv "HOME"))))
              (if (string-match home file)
                  (cons (replace-match "~" nil nil file) file)
                file)))
          files))

;;; Filtered Candidate Transformers

;;;; Adaptive Sorting of Candidates

;; User config

(defvar anything-c-adaptive-history-file "~/.emacs.d/anything-c-adaptive-history"
  "Path of file where history information is stored.")

(defvar anything-c-adaptive-history-length 50
  "Maximum number of candidates stored for a source.")

;;----------------------------------------------------------------------

(defvar anything-c-adaptive-done nil
  "nil if history information is not yet stored for the current
selection.")

(defvar anything-c-adaptive-history nil
  "Contains the stored history information.
Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)")

(defadvice anything-initialize (before anything-c-adaptive-initialize activate)
  "Advise `anything-initialize' to reset `anything-c-adaptive-done'
when anything is started."
  (setq anything-c-adaptive-done nil))

(defadvice anything-exit-minibuffer (before anything-c-adaptive-exit-minibuffer activate)
  "Advise `anything-exit-minibuffer' to store history information
when a candidate is selected with RET."
  (anything-c-adaptive-store-selection))

(defadvice anything-select-action (before anything-c-adaptive-select-action activate)
  "Advise `anything-select-action' to store history information
when the user goes to the action list with TAB."
  (anything-c-adaptive-store-selection))

(defun anything-c-adaptive-store-selection ()
  "Store history information for the selected candidate."
  (unless anything-c-adaptive-done
    (setq anything-c-adaptive-done t)
    (let* ((source (anything-get-current-source))
           (source-name (or (assoc-default 'type source)
                            (assoc-default 'name source)))
           (source-info (or (assoc source-name anything-c-adaptive-history)
                            (progn
                              (push (list source-name) anything-c-adaptive-history)
                              (car anything-c-adaptive-history))))
           (selection (anything-get-selection))
           (selection-info (progn
                             (setcdr source-info
                                     (cons
                                      (let ((found (assoc selection (cdr source-info))))
                                        (if (not found)
                                            ;; new entry
                                            (list selection)

                                          ;; move entry to the beginning of the
                                          ;; list, so that it doesn't get
                                          ;; trimmed when the history is
                                          ;; truncated
                                          (setcdr source-info
                                                  (delete found (cdr source-info)))
                                          found))
                                      (cdr source-info)))
                             (cadr source-info)))
           (pattern-info (progn
                           (setcdr selection-info
                                   (cons
                                    (let ((found (assoc anything-pattern (cdr selection-info))))
                                      (if (not found)
                                          ;; new entry
                                          (cons anything-pattern 0)

                                        ;; move entry to the beginning of the
                                        ;; list, so if two patterns used the
                                        ;; same number of times then the one
                                        ;; used last appears first in the list
                                        (setcdr selection-info
                                                (delete found (cdr selection-info)))
                                        found))
                                    (cdr selection-info)))
                           (cadr selection-info))))

      ;; increase usage count
      (setcdr pattern-info (1+ (cdr pattern-info)))

      ;; truncate history if needed
      (if (> (length (cdr selection-info)) anything-c-adaptive-history-length)
          (setcdr selection-info
                  (subseq (cdr selection-info) 0 anything-c-adaptive-history-length))))))

(if (file-readable-p anything-c-adaptive-history-file)
    (load-file anything-c-adaptive-history-file))
(add-hook 'kill-emacs-hook 'anything-c-adaptive-save-history)

(defun anything-c-adaptive-save-history ()
  "Save history information to file given by
`anything-c-adaptive-history-file'."
  (interactive)
  (with-temp-buffer
    (insert
     ";; -*- mode: emacs-lisp -*-\n"
     ";; History entries used for anything adaptive display.\n")
    (prin1 `(setq anything-c-adaptive-history ',anything-c-adaptive-history)
           (current-buffer))
    (insert ?\n)
    (write-region (point-min) (point-max) anything-c-adaptive-history-file nil
                  (unless (interactive-p) 'quiet))))

(defun anything-c-adaptive-sort (candidates source)
  "Sort the CANDIDATES for SOURCE by usage frequency.
This is a filtered candidate transformer you can use for the
attribute `filtered-candidate-transformer' of a source in
`anything-sources' or a type in `anything-type-attributes'."
  (let* ((source-name (or (assoc-default 'type source)
                          (assoc-default 'name source)))
         (source-info (assoc source-name anything-c-adaptive-history)))
    (if (not source-info)
        ;; if there is no information stored for this source then do nothing
        candidates
      ;; else...
      (let ((usage
             ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT)
             ;; pairs
             (mapcar (lambda (candidate-info)
                       (let ((count 0))
                         (dolist (pattern-info (cdr candidate-info))
                           (if (not (equal (car pattern-info)
                                           anything-pattern))
                               (incf count (cdr pattern-info))

                             ;; if current pattern is equal to the previously
                             ;; used one then this candidate has priority
                             ;; (that's why its count is boosted by 10000) and
                             ;; it only has to compete with other candidates
                             ;; which were also selected with the same pattern
                             (setq count (+ 10000 (cdr pattern-info)))
                             (return)))
                         (cons (car candidate-info) count)))
                     (cdr source-info)))
            sorted)

        ;; sort the list in descending order, so candidates with highest
        ;; priorty come first
        (setq usage (sort usage (lambda (first second)
                                  (> (cdr first) (cdr second)))))

        ;; put those candidates first which have the highest usage count
        (dolist (info usage)
          (when (member* (car info) candidates
                         :test 'anything-c-adaptive-compare)
            (push (car info) sorted)
            (setq candidates (remove* (car info) candidates
                                      :test 'anything-c-adaptive-compare))))

        ;; and append the rest
        (append (reverse sorted) candidates nil)))))

(defun anything-c-adaptive-compare (x y)
  "Compare candidates X and Y taking into account that the
candidate can be in (DISPLAY . REAL) format."
  (equal (if (listp x)
             (cdr x)
           x)
         (if (listp y)
             (cdr y)
           y)))

;;; Default Configuration

;;;; Helper Functions

(defun anything-c-compose (arg-lst func-lst)
  "Call each function in FUNC-LST with the arguments specified in
ARG-LST.  The result of each function will be the new `car' of
ARG-LST.

This function allows easy sequencing of transformer functions."
  (dolist (func func-lst)
    (setcar arg-lst (apply func arg-lst)))
  (car arg-lst))

;;;; Sources

(setq anything-sources
      (list anything-c-source-buffers
            anything-c-source-file-name-history
            anything-c-source-info-pages
            anything-c-source-man-pages
            anything-c-source-locate
            anything-c-source-emacs-commands))

;;;; Type Attributes

(setq anything-type-attributes
      `((buffer
         (action
          ,@(if pop-up-frames
                '(("Switch to buffer other window" . switch-to-buffer-other-window)
                  ("Switch to buffer" . switch-to-buffer))
              '(("Switch to buffer" . switch-to-buffer)
                ("Switch to buffer other window" . switch-to-buffer-other-window)
                ("Switch to buffer other frame" . switch-to-buffer-other-frame)))
          ("Display buffer"   . display-buffer)
          ("Kill buffer"      . kill-buffer)))
        (file
         (action
          ,@(if pop-up-frames
                '(("Find file other window" . find-file-other-window)
                  ("Find file" . find-file))
              '(("Find file" . find-file)
                ("Find file other window" . find-file-other-window)
                ("Find file other frame" . find-file-other-frame)))
          ("Open dired in file's directory" . anything-c-open-dired)
          ("Delete file" . anything-c-delete-file)
          ("Open file externally" . anything-c-open-file-externally)
          ("Open file with default tool" . anything-c-open-file-with-default-tool))
         (action-transformer . (lambda (actions candidate)
                                 (anything-c-compose
                                  (list actions candidate)
                                  '(anything-c-transform-file-load-el
                                    anything-c-transform-file-browse-url))))
         (candidate-transformer . (lambda (candidates)
                                    (anything-c-compose
                                     (list candidates)
                                     '(anything-c-shadow-boring-files
                                       anything-c-shorten-home-path)))))
        (command (action ("Call interactively" . (lambda (command-name)
                                                   (call-interactively (intern command-name))))
                         ("Describe command" . (lambda (command-name)
                                                 (describe-function (intern command-name))))
                         ("Add command to kill ring" . kill-new)
                         ("Go to command's definition" . (lambda (command-name)
                                                           (find-function
                                                            (intern command-name)))))
                 ;; Sort commands according to their usage count.
                 (filtered-candidate-transformer . anything-c-adaptive-sort))
        (function (action ("Describe function" . (lambda (function-name)
                                                   (describe-function (intern function-name))))
                          ("Add function to kill ring" . kill-new)
                          ("Go to function's definition" . (lambda (function-name)
                                                             (find-function
                                                              (intern function-name)))))
                  (action-transformer . (lambda (actions candidate)
                                          (anything-c-compose
                                           (list actions candidate)
                                           '(anything-c-transform-function-call-interactively)))))
        (sexp (action ("Eval s-expression" . (lambda (c)
                                               (eval (read c))))
                      ("Add s-expression to kill ring" . kill-new))
              (action-transformer . (lambda (actions candidate)
                                      (anything-c-compose
                                       (list actions candidate)
                                       '(anything-c-transform-sexp-eval-command-sexp)))))
        (bookmark (action ("Jump to bookmark" . bookmark-jump)
                          ("Delete bookmark" . bookmark-delete)))))

;;; Provide anything-config

(provide 'anything-config)

;; Local Variables:
;; mode: outline-minor
;; End:

;;; anything-config.el ends here
--8<---------------cut here---------------end--------------->8---

I'm loosing my (iso-)latin ;-(

Bye,
Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-15 11:38                               ` Sébastien Vauban
@ 2008-02-15 12:44                                 ` Tassilo Horn
       [not found]                                 ` <mailman.7443.1203079486.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-15 12:44 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> FYI, I'm using the file I git'ted yesterday (or the day before - don't
> remember) from your repository:
>
> ;;; anything-config.el --- predefined configurations for anything

[...]

> ;;;; Info pages

[...]

> (defvar anything-c-source-info-pages
>   `((name . "Info Pages")
>     (candidates
>      . (lambda ()
>          (if anything-c-info-pages
>              anything-c-info-pages
>            (setq anything-c-info-pages
>                  (save-window-excursion
>                    (save-excursion
>                      (require 'info)
>                      (Info-find-node "dir" "top")
>                      (goto-char (point-min))
>                      (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>                            topics)
>                        (while (re-search-forward info-topic-regexp nil t)
>                          (add-to-list 'topics (match-string-no-properties 1)))
>                        (goto-char (point-min))
>                        (Info-exit)
>                        topics)))))))
>     (action . (("Show with Info" .(lambda (node-str)
>                                     (info (replace-regexp-in-string "^[^:]+: "
>                                                                     ""
>                                                                     node-str))))))
>     (requires-pattern . 2)))

Damn!  It's broken in the file!  I cannot imagine why.  I clone my
repository myself using

  git clone http://www.tsdh.de/repos/git/anything-config.git foo

and got a checkout in the directory foo with a working version of the
info source.  (I suspected that I forgot to install the update-hook on
my web-server so that an old version is provided when pulling via http,
but that's not the case...)

Please try to clone again.

> I'm loosing my (iso-)latin ;-(

And so I am.

Bye,
Tassilo
-- 
Richard Stallman's left and right hands are named "(" and ")"





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                 ` <mailman.7443.1203079486.18990.help-gnu-emacs@gnu.org>
@ 2008-02-15 13:34                                   ` Sébastien Vauban
  2008-02-15 19:47                                     ` Tassilo Horn
       [not found]                                     ` <mailman.7458.1203104854.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-15 13:34 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2486 bytes --]

Hi Tassilo,

>> FYI, I'm using the file I git'ted yesterday (or the day before - don't
>> remember) from your repository:
>>
>> ;;; anything-config.el --- predefined configurations for anything
>
> [...]
>
>> ;;;; Info pages
>
> [...]
>
>> (defvar anything-c-source-info-pages
>>   `((name . "Info Pages")
>>     (candidates
>>      . (lambda ()
>>          (if anything-c-info-pages
>>              anything-c-info-pages
>>            (setq anything-c-info-pages
>>                  (save-window-excursion
>>                    (save-excursion
>>                      (require 'info)
>>                      (Info-find-node "dir" "top")
>>                      (goto-char (point-min))
>>                      (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
>>                            topics)
>>                        (while (re-search-forward info-topic-regexp nil t)
>>                          (add-to-list 'topics (match-string-no-properties 1)))
>>                        (goto-char (point-min))
>>                        (Info-exit)
>>                        topics)))))))
>>     (action . (("Show with Info" .(lambda (node-str)
>>                                     (info (replace-regexp-in-string "^[^:]+: "
>>                                                                     ""
>>                                                                     node-str))))))
>>     (requires-pattern . 2)))
>
> Damn!  It's broken in the file!  I cannot imagine why.  I clone my
> repository myself using
>
>   git clone http://www.tsdh.de/repos/git/anything-config.git foo
>
> and got a checkout in the directory foo with a working version of the
> info source.  (I suspected that I forgot to install the update-hook on
> my web-server so that an old version is provided when pulling via http,
> but that's not the case...)
>
> Please try to clone again.

Just did it (at 14:21 - if you look in your logs) with the exact
same command as yours (destination in the `foo' directory):

    git clone http://www.tsdh.de/repos/git/anything-config.git foo

Got the attached file. There is no diff (using ediff-buffers)
with my "other" `anything-config.el'!??? How is this possible?

Then, downloaded `anything-config.el' from EmacsWiki:

    http://www.emacswiki.org/cgi-bin/wiki/download/anything-config.el

Compared it with the cloned version. No diff neither.

I'm lost...

Seb

-- 
Sébastien Vauban

[-- Attachment #2: anything-config.el --]
[-- Type: application/emacs-lisp, Size: 44606 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-15 13:34                                   ` Sébastien Vauban
@ 2008-02-15 19:47                                     ` Tassilo Horn
       [not found]                                     ` <mailman.7458.1203104854.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-15 19:47 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Sébastien,

sorry, but I suspected an error where there's no error.  The file and
the version you have is fine and the same that I'm using here.  The
misplaced parenthesis I saw was an artifact of non-lispy paren-matching
in message-mode, e.g. the one closing paren in the regexp isn't escaped
like it is in emacs-lisp-mode.  So `show-paren-mode' played me a trick.

The problem you have is located somewhere else.  But I don't know
where.  Do you use the current anything version?

Bye,
Tassilo
-- 
Richard Stallman is the only man  alive who can pronounce GNU the way it
is meant to be pronounced.





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                     ` <mailman.7458.1203104854.18990.help-gnu-emacs@gnu.org>
@ 2008-02-18  9:38                                       ` Sébastien Vauban
  2008-02-18 13:26                                         ` Tassilo Horn
       [not found]                                         ` <mailman.7571.1203341195.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-18  9:38 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

Hi Tassilo,

> sorry, but I suspected an error where there's no error. The
> file and the version you have is fine and the same that I'm
> using here. The misplaced parenthesis I saw was an artifact of
> non-lispy paren-matching in message-mode, e.g. the one closing
> paren in the regexp isn't escaped like it is in
> emacs-lisp-mode. So `show-paren-mode' played me a trick.

Good. Now I understand why I did not understand ;-)


> The problem you have is located somewhere else. But I don't
> know where. Do you use the current anything version?

Yes, I downloaded a new version last Thursday from the EmacsWiki
site.

But, in order to be 100% sure we're talking of the same things,
I'm attaching it as well, as it's a pity there is no version
number (would be easy to compare).

Best regards,
  Seb

-- 
Sébastien Vauban

[-- Attachment #2: anything.el --]
[-- Type: application/emacs-lisp, Size: 62127 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-18  9:38                                       ` Sébastien Vauban
@ 2008-02-18 13:26                                         ` Tassilo Horn
       [not found]                                         ` <mailman.7571.1203341195.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-18 13:26 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> But, in order to be 100% sure we're talking of the same things, I'm
> attaching it as well, as it's a pity there is no version number (would
> be easy to compare).

We're using the same version.

One thing you could try is to insert a (message "foo") into
anything-c-source-locate's candidates lambda function, so that you can
see if it is called.  Be sure to restart emacs after the modification,
so that it can take effect.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                         ` <mailman.7571.1203341195.18990.help-gnu-emacs@gnu.org>
@ 2008-02-18 14:32                                           ` Sébastien Vauban
  2008-02-18 15:04                                             ` Tassilo Horn
       [not found]                                             ` <mailman.7574.1203347089.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-18 14:32 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>> But, in order to be 100% sure we're talking of the same
>> things, I'm attaching it as well, as it's a pity there is no
>> version number (would be easy to compare).
>
> We're using the same version.

OK.


> One thing you could try is to insert a (message "foo") into
> anything-c-source-locate's candidates lambda function, so that
> you can see if it is called.

I could now check that it's not called (after restart of Emacs).

Bye,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-18 14:32                                           ` Sébastien Vauban
@ 2008-02-18 15:04                                             ` Tassilo Horn
       [not found]                                             ` <mailman.7574.1203347089.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-18 15:04 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

>> One thing you could try is to insert a (message "foo") into
>> anything-c-source-locate's candidates lambda function, so that you
>> can see if it is called.
>
> I could now check that it's not called (after restart of Emacs).

Grr, that's the worst thing you could tell. :-)

Ok, I looked into anything.el and maybe I found the culprit.  What does

  (sit-for anything-idle-delay)

return on your system?  If it returns nil, then that's the problem.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                             ` <mailman.7574.1203347089.18990.help-gnu-emacs@gnu.org>
@ 2008-02-18 15:55                                               ` Sébastien Vauban
  2008-02-18 17:07                                                 ` Tassilo Horn
       [not found]                                                 ` <mailman.7582.1203354459.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-18 15:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Sébastien,

>>> One thing you could try is to insert a (message "foo") into
>>> anything-c-source-locate's candidates lambda function, so
>>> that you can see if it is called.
>>
>> I could now check that it's not called (after restart of
>> Emacs).
>
> Grr, that's the worst thing you could tell. :-)

No, maybe there's worse... ;-((


> Ok, I looked into anything.el and maybe I found the culprit.
> What does
>
>   (sit-for anything-idle-delay)
>
> return on your system? If it returns nil, then that's the
> problem.

... it does return `t'.

I realized I even used that fact to speed up things under
Windows, as done in my `.emacs' (comes from EmacsWiki):

--8<---------------cut here---------------start------------->8---
;; make anything minibuffer better input latency
(defadvice anything-check-minibuffer-input (around sit-for activate)
  (if (sit-for anything-idle-delay t)
      ad-do-it))
--8<---------------cut here---------------end--------------->8---

I commented that, and restarted Emacs to see if there was a
change for my problem. No. It did not change anything, except it
way slower now on Windows...

Thanks for your help,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-18 15:55                                               ` Sébastien Vauban
@ 2008-02-18 17:07                                                 ` Tassilo Horn
       [not found]                                                 ` <mailman.7582.1203354459.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-18 17:07 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

>> Ok, I looked into anything.el and maybe I found the culprit.
>> What does
>>
>>   (sit-for anything-idle-delay)
>>
>> return on your system? If it returns nil, then that's the
>> problem.
>
> ... it does return `t'.

Ok, then eval this:

--8<---------------cut here---------------start------------->8---
(defun anything-update ()
  "Update the list of matches in the anything buffer according to
the current pattern."
  (setq anything-digit-shortcut-count 0)
  (anything-kill-async-processes)
  (with-current-buffer anything-buffer
    (erase-buffer)

    (if anything-enable-digit-shortcuts
        (dolist (overlay anything-digit-overlays)
          (delete-overlay overlay)))

    (let (delayed-sources)
      (dolist (source (anything-get-sources))
        (if (or (not anything-source-filter)
                (member (assoc-default 'name source) anything-source-filter))
          (if (equal anything-pattern "")
              (unless (assoc 'requires-pattern source)
                (if (assoc 'delayed source)
                    (push source delayed-sources)
                  (anything-process-source source)))

            (let ((min-pattern-length (assoc-default 'requires-pattern source)))
              (unless (and min-pattern-length
                           (< (length anything-pattern) min-pattern-length))
                (if (assoc 'delayed source)
                    (push source delayed-sources)
                  (anything-process-source source)))))))

      (message "delayed-sources = %s" (mapcar (lambda (s)
                                                (assoc 'name s))
                                                delayed-sources))

      (goto-char (point-min))
      (run-hooks 'anything-update-hook)
      (anything-next-line)

      (anything-maybe-fit-frame)

      (run-with-idle-timer (if (featurep 'xemacs)
                               0.1
                             0)
                           nil
                           'anything-process-delayed-sources
                           delayed-sources))))
--8<---------------cut here---------------end--------------->8---

Now invoke anything and type some pattern.  Then go to *Messages* and
see if something like

delayed-sources = ((name . Google Suggest) (name . Locate))

is there.

Bye,
Tassilo
-- 
"Ubuntu" - an African word, meaning "Slackware is too hard for me".





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                                 ` <mailman.7582.1203354459.18990.help-gnu-emacs@gnu.org>
@ 2008-02-19  8:20                                                   ` Sébastien Vauban
  2008-02-19 14:08                                                     ` Tassilo Horn
       [not found]                                                     ` <mailman.7630.1203430115.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-19  8:20 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>>> Ok, I looked into anything.el and maybe I found the culprit.
>>> What does
>>>
>>>   (sit-for anything-idle-delay)
>>>
>>> return on your system? If it returns nil, then that's the
>>> problem.
>>
>> ... it does return `t'.
>
> Ok, then eval this:
>
> (defun anything-update ()
>   "Update the list of matches in the anything buffer according to
> the current pattern."
>   [...])
>
> Now invoke anything and type some pattern. Then go to
> *Messages* and see if something like
>
> delayed-sources = ((name . Google Suggest) (name . Locate))
>
> is there.

I've launched anything twice. And that's what appears in my
`*Messages*' buffer:

--8<---------------cut here---------------start------------->8---
delayed-sources = nil
delayed-sources = ((name . Tracker Search) (name . Locate))
delayed-sources = nil
delayed-sources = ((name . Tracker Search) (name . Locate))
--8<---------------cut here---------------end--------------->8---

But I never saw any "Locate" results...

Best regards,
  Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-19  8:20                                                   ` Sébastien Vauban
@ 2008-02-19 14:08                                                     ` Tassilo Horn
       [not found]                                                     ` <mailman.7630.1203430115.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-19 14:08 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> delayed-sources = ((name . Tracker Search) (name . Locate))
>
> But I never saw any "Locate" results...

Ok, but at least the locate source should be processed.

Please eval the following defun and invoke anything.  Then go to
*Messages* and see if there's an error message of the form

  Error processing source: ...

--8<---------------cut here---------------start------------->8---
(defun anything-process-source (source)
  "Display matches from SOURCE according to its settings."
  (let (matches)
    (if (equal anything-pattern "")
        (progn
          (setq matches (anything-get-cached-candidates source))
          (if (> (length matches) anything-candidate-number-limit)
              (setq matches 
                    (subseq matches 0 anything-candidate-number-limit))))

      (condition-case err-var
          (let ((item-count 0)
                (functions (assoc-default 'match source))
                exit)

            (unless functions
              (setq functions
                    (list (lambda (candidate)
                            (string-match anything-pattern candidate)))))

            (dolist (function functions)
              (let (newmatches)
                (dolist (candidate (anything-get-cached-candidates source))
                  (when (and (not (member candidate matches))
                             (funcall function (if (listp candidate)
                                                   (car candidate)
                                                 candidate)))
                    (push candidate newmatches)

                    (when anything-candidate-number-limit
                      (incf item-count)
                      (when (= item-count anything-candidate-number-limit)
                        (setq exit t)
                        (return)))))

                (setq matches (append matches (reverse newmatches)))

                (if exit
                    (return)))))

        (invalid-regexp (setq matches nil))
        (error (message "Error processing source %s: %s" source err-var))))

    (let* ((transformer (assoc-default 'filtered-candidate-transformer source)))
      (if transformer
          (setq matches (funcall transformer matches source))))

    (when matches
      (anything-insert-header (assoc-default 'name source))

      (dolist (match matches)
        (when (and anything-enable-digit-shortcuts
                   (not (eq anything-digit-shortcut-count 9)))
          (move-overlay (nth anything-digit-shortcut-count
                             anything-digit-overlays)
                        (line-beginning-position)
                        (line-beginning-position))
          (incf anything-digit-shortcut-count))

        (anything-insert-match match 'insert)))))
--8<---------------cut here---------------end--------------->8---

BTW: Do other sources that return files work for you, i.e. the file name
history source?  If not, then the problem might be that a candidate
transformer for files doesn't work on windows.

Bye,
Tassilo
-- 
Some people wear Superman pajamas. Superman wears Chuck Norris pajamas. 





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                                     ` <mailman.7630.1203430115.18990.help-gnu-emacs@gnu.org>
@ 2008-02-19 15:49                                                       ` Sébastien Vauban
  2008-02-19 17:00                                                         ` Tassilo Horn
       [not found]                                                         ` <mailman.7636.1203440454.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-19 15:49 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>> delayed-sources = ((name . Tracker Search) (name . Locate))
>>
>> But I never saw any "Locate" results...
>
> Ok, but at least the locate source should be processed.

I don't think so, as I only see this in my `*Messages*' buffer:

--8<---------------cut here---------------start------------->8---
anything-process-source
Checking for library `filladapt'... Found
Composing main Info directory...done
--8<---------------cut here---------------end--------------->8---

while I still have a debug message inserted (as you told me
yesterday) in my `anything-c-source-locate':

--8<---------------cut here---------------start------------->8---
(defvar anything-c-source-locate
  '((name . "Locate")
    (candidates . (lambda ()
                    (message "!!!anything-c-source-locate gets called!!!")
                    (apply 'start-process "locate-process" nil
                           (append anything-c-locate-options
                                   (list anything-pattern)))))
    (type . file)
    (requires-pattern . 3)
    (delayed))
  "Source for retrieving files matching the current input pattern
with locate.")
--8<---------------cut here---------------end--------------->8---

To be clear, I see the message "!!!anything-c-source-locate gets
called!!!" when invoking `anything' in my Ubuntu Emacs, but
never ever ('till now) when invoking it from my Windows Emacs.

    Note - There is no difference regarding the load libraries
    and the Emacs customizations between my Ubuntu and my
    Windows environments: Windows is running as a VM on top of
    Ubuntu (launching it only when really needed), and all my
    Emacs files (dot-emacs, loaded libraries, and so on) are
    taken from the same directories (via the "shared folders" of
    VirtualBox). I mean: I don't have 2 `.emacs' files or
    whatever. Everything is shared between my 2 OSes.


> Please eval the following defun and invoke anything. Then go
> to *Messages* and see if there's an error message of the form
>
>   Error processing source: ...
>
> (defun anything-process-source (source)
>   "Display matches from SOURCE according to its settings."
>   [...])

As you saw above, no, I don't have such a message under Windows.


> BTW: Do other sources that return files work for you, i.e. the
> file name history source? If not, then the problem might be
> that a candidate transformer for files doesn't work on
> windows.

Yes, I do have the "File Name History" source working in
Windows.

I'm really to sorry to annoy you with all this...

Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-19 15:49                                                       ` Sébastien Vauban
@ 2008-02-19 17:00                                                         ` Tassilo Horn
       [not found]                                                         ` <mailman.7636.1203440454.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-19 17:00 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> while I still have a debug message inserted (as you told me yesterday)
> in my `anything-c-source-locate':
>
> (defvar anything-c-source-locate
>   '((name . "Locate")
>     (candidates . (lambda ()
>                     (message "!!!anything-c-source-locate gets called!!!")
>                     (apply 'start-process "locate-process" nil
>                            (append anything-c-locate-options
>                                    (list anything-pattern)))))
>     (type . file)
>     (requires-pattern . 3)
>     (delayed))
>   "Source for retrieving files matching the current input pattern
> with locate.")
>
> To be clear, I see the message "!!!anything-c-source-locate gets
> called!!!" when invoking `anything' in my Ubuntu Emacs, but never ever
> ('till now) when invoking it from my Windows Emacs.

Ah, ok.  I've thought you get it with windows, too.

But do you get the delayed sources messages on windows?
(delayed-sources = ((name . Tracker Search) (name . Locate)))

If yes, try do edebug `anything-process-delayed-sources'.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
       [not found]                                                         ` <mailman.7636.1203440454.18990.help-gnu-emacs@gnu.org>
@ 2008-02-20 12:16                                                           ` Sébastien Vauban
  2008-02-20 13:33                                                             ` Tassilo Horn
  0 siblings, 1 reply; 32+ messages in thread
From: Sébastien Vauban @ 2008-02-20 12:16 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

>> while I still have a debug message inserted (as you told me yesterday)
>> in my `anything-c-source-locate':
>>
>> (defvar anything-c-source-locate
>>   '((name . "Locate")
>>     (candidates . (lambda ()
>>                     (message "!!!anything-c-source-locate gets called!!!")
>>                     (apply 'start-process "locate-process" nil
>>                            (append anything-c-locate-options
>>                                    (list anything-pattern)))))
>>     (type . file)
>>     (requires-pattern . 3)
>>     (delayed))
>>   "Source for retrieving files matching the current input pattern
>> with locate.")
>>
>> To be clear, I see the message "!!!anything-c-source-locate gets
>> called!!!" when invoking `anything' in my Ubuntu Emacs, but never ever
>> ('till now) when invoking it from my Windows Emacs.
>
> Ah, ok.  I've thought you get it with windows, too.
>
> But do you get the delayed sources messages on windows?
> (delayed-sources = ((name . Tracker Search) (name . Locate)))
>
> If yes, try do edebug `anything-process-delayed-sources'.

Wait... I don't understand exactly why it didn't show up
yesterday, but today I got your extra log message appearing:

--8<---------------cut here---------------start------------->8---
Error processing source ((name . Tracker Search) (candidates lambda nil (start-process tracker-search-process nil tracker-search anything-pattern)) (type . file) (requires-pattern . 3) (delayed) (action (Find file . find-file) (Find file other window . find-file-other-window) (Find file other frame . find-file-other-frame) (Open dired in file's directory . anything-c-open-dired) (Delete file . anything-c-delete-file) (Open file externally . anything-c-open-file-externally) (Open file with default tool . anything-c-open-file-with-default-tool)) (action-transformer lambda (actions candidate) (anything-c-compose (list actions candidate) (quote (anything-c-transform-file-load-el anything-c-transform-file-browse-url)))) (candidate-transformer lambda (candidates) (anything-c-compose (list candidates) (quote (anything-c-shadow-boring-files anything-c-shorten-home-path))))): (file-error Searching for program no such file or directory tracker-search)
!!!anything-c-source-locate gets called!!!
--8<---------------cut here---------------end--------------->8---

Does this help?

Thank you very much!

Seb

-- 
Sébastien Vauban


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Anything.el for Windows
  2008-02-20 12:16                                                           ` Sébastien Vauban
@ 2008-02-20 13:33                                                             ` Tassilo Horn
  0 siblings, 0 replies; 32+ messages in thread
From: Tassilo Horn @ 2008-02-20 13:33 UTC (permalink / raw)
  To: help-gnu-emacs

Sébastien Vauban <zthjwsqqafhv@spammotel.com> writes:

Hi Sébastien,

> Wait... I don't understand exactly why it didn't show up yesterday,
> but today I got your extra log message appearing:
>
> Error processing source ((name . Tracker Search) ...):
> (file-error Searching for program no such file or directory tracker-search)
> !!!anything-c-source-locate gets called!!!
>
> Does this help?

Not really.  It only says that the tracker source doesn't work on
windows because the tracker command "tracker-search" cannot be found.
For locate it seems that thereVs no such error signalled.

Bye,
Tassilo
-- 
Windows: So easy to admin, even a worm can do it.





^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2008-02-20 13:33 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-04 12:03 Anything.el for Windows Sébastien Vauban
2008-02-04 20:36 ` Tassilo Horn
     [not found] ` <mailman.6969.1202157424.18990.help-gnu-emacs@gnu.org>
2008-02-05 16:07   ` Sébastien Vauban
2008-02-05 17:00     ` Tassilo Horn
     [not found]     ` <mailman.7003.1202230839.18990.help-gnu-emacs@gnu.org>
2008-02-06 11:27       ` Sébastien Vauban
2008-02-06 13:49         ` Tassilo Horn
     [not found]         ` <mailman.7036.1202305782.18990.help-gnu-emacs@gnu.org>
2008-02-11 15:24           ` Sébastien Vauban
2008-02-11 17:10             ` Tassilo Horn
     [not found]             ` <mailman.7291.1202749829.18990.help-gnu-emacs@gnu.org>
2008-02-12 11:17               ` Sébastien Vauban
2008-02-12 15:47                 ` Tassilo Horn
     [not found]                 ` <mailman.7338.1202831286.18990.help-gnu-emacs@gnu.org>
2008-02-12 16:08                   ` Sébastien Vauban
2008-02-13  7:55                     ` Tassilo Horn
     [not found]                     ` <mailman.7363.1202889358.18990.help-gnu-emacs@gnu.org>
2008-02-14 13:08                       ` Sébastien Vauban
2008-02-14 13:57                         ` Tassilo Horn
     [not found]                         ` <mailman.7403.1202997494.18990.help-gnu-emacs@gnu.org>
2008-02-14 14:33                           ` Sébastien Vauban
2008-02-14 14:54                             ` Tassilo Horn
     [not found]                             ` <mailman.7405.1203000915.18990.help-gnu-emacs@gnu.org>
2008-02-15 11:38                               ` Sébastien Vauban
2008-02-15 12:44                                 ` Tassilo Horn
     [not found]                                 ` <mailman.7443.1203079486.18990.help-gnu-emacs@gnu.org>
2008-02-15 13:34                                   ` Sébastien Vauban
2008-02-15 19:47                                     ` Tassilo Horn
     [not found]                                     ` <mailman.7458.1203104854.18990.help-gnu-emacs@gnu.org>
2008-02-18  9:38                                       ` Sébastien Vauban
2008-02-18 13:26                                         ` Tassilo Horn
     [not found]                                         ` <mailman.7571.1203341195.18990.help-gnu-emacs@gnu.org>
2008-02-18 14:32                                           ` Sébastien Vauban
2008-02-18 15:04                                             ` Tassilo Horn
     [not found]                                             ` <mailman.7574.1203347089.18990.help-gnu-emacs@gnu.org>
2008-02-18 15:55                                               ` Sébastien Vauban
2008-02-18 17:07                                                 ` Tassilo Horn
     [not found]                                                 ` <mailman.7582.1203354459.18990.help-gnu-emacs@gnu.org>
2008-02-19  8:20                                                   ` Sébastien Vauban
2008-02-19 14:08                                                     ` Tassilo Horn
     [not found]                                                     ` <mailman.7630.1203430115.18990.help-gnu-emacs@gnu.org>
2008-02-19 15:49                                                       ` Sébastien Vauban
2008-02-19 17:00                                                         ` Tassilo Horn
     [not found]                                                         ` <mailman.7636.1203440454.18990.help-gnu-emacs@gnu.org>
2008-02-20 12:16                                                           ` Sébastien Vauban
2008-02-20 13:33                                                             ` Tassilo Horn

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.