-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathanything.el
5158 lines (4610 loc) · 203 KB
/
anything.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;; anything.el --- open anything / QuickSilver-like candidate-selection framework
;; $Id: anything.el,v 1.201 2009/08/08 13:25:30 rubikitch Exp rubikitch $
;; Copyright (C) 2007 Tamas Patrovics
;; 2008, 2009 rubikitch <[email protected]>
;; Author: Tamas Patrovics
;; Maintainer: rubikitch <[email protected]>
;; Keywords: files, frames, help, matching, outlines, processes, tools, convenience, anything
;; URL: http://www.emacswiki.org/cgi-bin/wiki/download/anything.el
;; Site: http://www.emacswiki.org/cgi-bin/emacs/Anything
;; 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:
;;
;; Start with M-x anything, narrow the list by typing some pattern,
;; select with up/down/pgup/pgdown/C-p/C-n/C-v/M-v, choose with enter,
;; left/right moves between sources. With TAB actions can be selected
;; if the selected candidate has more than one possible action.
;;
;; Note that anything.el provides only the framework and some example
;; configurations for demonstration purposes. See anything-config.el
;; for practical, polished, easy to use configurations which can be
;; used to assemble a custom personalized configuration. And many
;; other configurations are in the EmacsWiki.
;;
;; http://www.emacswiki.org/cgi-bin/wiki/download/anything-config.el
;; http://www.emacswiki.org/cgi-bin/emacs/AnythingSources
;;
;; Maintainer's configuration is in the EmacsWiki. It would tell you
;; many tips to write smart sources!
;;
;; http://www.emacswiki.org/cgi-bin/emacs/RubikitchAnythingConfiguration
;;; Commands:
;;
;; Below are complete command list:
;;
;; `anything'
;; Select anything. In Lisp program, some optional arguments can be used.
;; `anything-resume'
;; Resurrect previously invoked `anything'.
;; `anything-at-point'
;; Same as `anything' except when C-u is pressed, the initial input is the symbol at point.
;; `anything-select-action'
;; Select an action for the currently selected candidate.
;; `anything-previous-line'
;; Move selection to the previous line.
;; `anything-next-line'
;; Move selection to the next line.
;; `anything-previous-page'
;; Move selection back with a pageful.
;; `anything-next-page'
;; Move selection forward with a pageful.
;; `anything-previous-source'
;; Move selection to the previous source.
;; `anything-next-source'
;; Move selection to the next source.
;; `anything-exit-minibuffer'
;; Select the current candidate by exiting the minibuffer.
;; `anything-delete-current-selection'
;; Delete the currently selected item.
;; `anything-delete-minibuffer-content'
;; Same as `delete-minibuffer-contents' but this is a command.
;; `anything-select-2nd-action'
;; Select the 2nd action for the currently selected candidate.
;; `anything-select-3rd-action'
;; Select the 3rd action for the currently selected candidate.
;; `anything-select-4th-action'
;; Select the 4th action for the currently selected candidate.
;; `anything-select-2nd-action-or-end-of-line'
;; Select the 2nd action for the currently selected candidate if the point is at the end of minibuffer.
;; `anything-execute-persistent-action'
;; If a candidate is selected then perform the associated action without quitting anything.
;; `anything-scroll-other-window'
;; Scroll other window (not *Anything* window) upward.
;; `anything-scroll-other-window-down'
;; Scroll other window (not *Anything* window) downward.
;; `anything-quit-and-find-file'
;; Drop into `find-file' from `anything' like `iswitchb-find-file'.
;; `anything-yank-selection'
;; Set minibuffer contents to current selection.
;; `anything-kill-selection-and-quit'
;; Store current selection to kill ring.
;; `anything-follow-mode'
;; If this mode is on, persistent action is executed everytime the cursor is moved.
;; `anything-isearch'
;; Start incremental search within results. (UNMAINTAINED)
;; `anything-isearch-printing-char'
;; Add printing char to the pattern.
;; `anything-isearch-again'
;; Search again for the current pattern
;; `anything-isearch-delete'
;; Undo last event.
;; `anything-isearch-default-action'
;; Execute the default action for the selected candidate.
;; `anything-isearch-select-action'
;; Choose an action for the selected candidate.
;; `anything-isearch-cancel'
;; Cancel Anything isearch.
;; `anything-iswitchb-setup'
;; Integrate anything completion into iswitchb (UNMAINTAINED).
;; `anything-iswitchb-cancel-anything'
;; Cancel anything completion and return to standard iswitchb.
;;
;;; Customizable Options:
;;
;; Below are customizable option list:
;;
;; You can extend `anything' by writing plug-ins. As soon as
;; `anything' is invoked, `anything-sources' is compiled into basic
;; attributes, then compiled one is used during invocation.
;;
;; The oldest built-in plug-in is `type' attribute: appends
;; appropriate element of `anything-type-attributes'. Second built-in
;; plug-in is `candidates-in-buffer': selecting a line from candidates
;; buffer.
;;
;; To write a plug-in:
;; 1. Define a compiler: anything-compile-source--*
;; 2. Add compier function to `anything-compile-source-functions'.
;; 3. (optional) Write helper functions.
;;
;; Anything plug-ins are found in the EmacsWiki.
;;
;; http://www.emacswiki.org/cgi-bin/emacs/AnythingPlugins
;; Tested on Emacs 22.
;;
;;
;; Thanks to Vagn Johansen for ideas.
;; Thanks to Stefan Kamphausen for fixes and XEmacs support.
;; Thanks to Tassilo Horn for fixes.
;; Thanks to Drew Adams for various fixes (frame, isearch, customization, etc.)
;; Thanks to IMAKADO for candidates-in-buffer idea.
;; Thanks to Tomohiro MATSUYAMA for multiline patch.
;;
;;; (@* "Index")
;; If you have library `linkd.el', load
;; `linkd.el' and turn on `linkd-mode' now. It lets you easily
;; navigate around the sections Linkd mode will
;; highlight this Index. You can get `linkd.el' here:
;; http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el
;;
;;; (@* "INCOMPATIBLE CHANGES")
;; v1.114
;;
;; `anything-attr' returns nil when the source attribute is defined
;; but the value of attribute is nil, eg. (volatile) cell. Use
;; `anything-attr-defined' when testing whether the attribute is
;; defined.
;;; (@* "Tips")
;;
;; Now symbols are acceptable as candidates. So you do not have to use
;; `symbol-name' function. The source is much simpler. For example,
;; `apropos-internal' returns a list of symbols.
;;
;; (anything
;; '(((name . "Commands")
;; (candidates . (lambda () (apropos-internal anything-pattern 'commandp)))
;; (volatile)
;; (action . describe-function))))
;;
;; To mark a candidate, press C-SPC as normal Emacs marking. To go to
;; marked candidate, press M-[ or M-].
;;
;; `anything-map' is now Emacs-standard key bindings by default. If
;; you are using `iswitchb', execute `anything-iswitchb-setup'. Then
;; some key bindings are adjusted to `iswitchb'. Note that
;; anything-iswitchb is not maintained.
;;
;; There are many `anything' applications, using `anything' for
;; selecting candidate. In this case, if there is one candidate or no
;; candidate, popping up *anything* buffer is irritating. If one
;; candidate, you want to select it at once. If no candidate, you want
;; to quit `anything'. Set `anything-execute-action-at-once-if-one'
;; and `anything-quit-if-no-candidate' to non-nil to remedy it. Note
;; that setting these variables GLOBALLY is bad idea because of
;; delayed sources. These are meant to be let-binded.
;; See anything-etags.el for example.
;;
;; [EVAL IT] (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/anything-etags.el")
;;
;; ex.
;; (let ((anything-execute-action-at-once-if-one t)
;; (anything-quit-if-no-candidate (lambda () (message "No candidate"))))
;; (anything temporary-sources input))
;;
;; `set-frame-configuration' arises flickering. If you hate
;; flickering, eval:
;; (setq anything-save-configuration-functions
;; '(set-window-configuration . current-window-configuration))
;; at the cost of restoring frame configuration (only window configuration).
;;
;; `anything-delete-current-selection' deletes the current line.
;; It is useful when deleting a candidate in persistent action.
;; eg. `kill-buffer'.
;;
;; [EVAL IT] (describe-function 'anything-delete-current-selection)
;;
;; `anything-attr' gets the attribute. `anything-attrset' sets the
;; attribute. `anything-attr-defined' tests whether the attribute is
;; defined. They handles source-local variables.
;;
;; [EVAL IT] (describe-function 'anything-attr)
;; [EVAL IT] (describe-function 'anything-attrset)
;; [EVAL IT] (describe-function 'anything-attr-defined)
;;
;; `anything-sources' accepts many attributes to make your life easier.
;; Now `anything-sources' accepts a list of symbols.
;;
;; [EVAL IT] (describe-variable 'anything-sources)
;;
;; `anything' has optional arguments. Now you do not have to let-bind
;; `anything-sources'.
;;
;; [EVAL IT] (describe-function 'anything)
;;
;; `anything-resume' resumes last `anything' session. Now you do not
;; have to retype pattern.
;;
;; [EVAL IT] (describe-function 'anything-resume)
;;
;; `anything-execute-persistent-action' executes action without
;; quitting `anything'. When popping up a buffer in other window by
;; persistent action, you can scroll with `anything-scroll-other-window' and
;; `anything-scroll-other-window-down'. See also `anything-sources' docstring.
;;
;; [EVAL IT] (describe-function 'anything-execute-persistent-action)
;; [EVAL IT] (describe-variable 'anything-sources)
;;
;; `anything-select-2nd-action', `anything-select-3rd-action' and
;; `anything-select-4th-action' select other than default action
;; without pressing Tab.
;;
;; Using `anything-candidate-buffer' and the candidates-in-buffer
;; attribute is much faster than traditional "candidates and match"
;; way. And `anything-current-buffer-is-modified' avoids to
;; recalculate candidates for unmodified buffer. See docstring of
;; them.
;;
;; [EVAL IT] (describe-function 'anything-candidate-buffer)
;; [EVAL IT] (describe-function 'anything-candidates-in-buffer)
;; [EVAL IT] (describe-function 'anything-current-buffer-is-modified)
;;
;; `anything-current-buffer' and `anything-buffer-file-name' stores
;; `(current-buffer)' and `buffer-file-name' in the buffer `anything'
;; is invoked. Use them freely.
;;
;; [EVAL IT] (describe-variable 'anything-current-buffer)
;; [EVAL IT] (describe-variable 'anything-buffer-file-name)
;;
;; `anything-completing-read' and `anything-read-file-name' are
;; experimental implementation. If you are curious, type M-x
;; anything-read-string-mode. It is a minor mode and toggles on/off.
;;
;; Use `anything-test-candidates' to test your handmade anything
;; sources. It simulates contents of *anything* buffer with pseudo
;; `anything-sources' and `anything-pattern', without side-effect. So
;; you can unit-test your anything sources! Let's TDD!
;;
;; [EVAL IT] (describe-function 'anything-test-candidates)
;;
;; There are many unit-testing framework in Emacs Lisp. See the EmacsWiki.
;; http://www.emacswiki.org/cgi-bin/emacs/UnitTesting
;;
;; There is an unit-test by Emacs Lisp Expectations at the tail of this file.
;; http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el
;; http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el
;; (@* "TODO")
;;
;; - process status indication
;;
;; - async sources doesn't honor digit-shortcut-count
;;
;; - anything-candidate-number-limit can't be nil everywhere
;; (@* "HISTORY")
;; $Log: anything.el,v $
;; Revision 1.201 2009/08/08 13:25:30 rubikitch
;; `anything-toggle-visible-mark': move next line after unmarking
;;
;; Revision 1.200 2009/08/08 13:23:46 rubikitch
;; `anything-toggle-visible-mark': Applied ThierryVolpiatto's patch. thx.
;;
;; Revision 1.199 2009/07/19 13:22:29 rubikitch
;; `anything-follow-execute-persistent-action-maybe': execute persistent action after `anything-input-idle-delay'
;;
;; Revision 1.198 2009/07/06 15:22:48 rubikitch
;; header modified (no code change)
;;
;; Revision 1.197 2009/06/29 15:10:13 rubikitch
;; OOPS! remove debug code
;;
;; Revision 1.196 2009/06/29 13:29:25 rubikitch
;; anything-follow-mode: automatical execution of persistent-action (C-c C-f)
;;
;; Revision 1.195 2009/06/19 14:42:57 rubikitch
;; silence byte compiler
;;
;; Revision 1.194 2009/06/14 15:12:34 rubikitch
;; typo
;;
;; Revision 1.193 2009/06/08 19:37:12 rubikitch
;; typo!
;;
;; Revision 1.192 2009/06/08 19:36:39 rubikitch
;; New keybind: C-e, C-j, C-k
;;
;; Revision 1.191 2009/06/08 19:30:27 rubikitch
;; New command: `anything-select-2nd-action-or-end-of-line'
;;
;; Revision 1.190 2009/06/07 17:09:50 rubikitch
;; add M-<next>, C-M-S-v, M-<prior> to `anything-map'.
;;
;; Revision 1.189 2009/06/01 21:36:31 rubikitch
;; New function: `anything-other-buffer'
;;
;; Revision 1.188 2009/05/29 18:33:07 rubikitch
;; avoid error when executing (anything-mark-current-line) in async process.
;;
;; Revision 1.187 2009/05/29 06:49:05 rubikitch
;; small refactoring
;;
;; Revision 1.186 2009/05/29 06:46:34 rubikitch
;; Prevent `anything-isearch-map' from overwriting `global-map'. With
;; `copy-keymap', the prefix command "M-s" in `global-map' ends up
;; getting clobbered by `anything-isearch-again', preventing `occur'
;; (among other things) from running. This change replaces overwriting a
;; copied map with writing to a sparse map whose parent is `global-map'.
;;
;; patched by DanielHackney. thanks!
;;
;; Revision 1.185 2009/05/25 19:07:42 rubikitch
;; `anything': set `case-fold-search' to t
;; Because users can assign commands to capital letter keys.
;;
;; Revision 1.184 2009/05/25 19:05:04 rubikitch
;; Added auto-document
;;
;; Revision 1.183 2009/05/15 01:50:46 rubikitch
;; typo
;;
;; Revision 1.182 2009/05/08 18:28:18 rubikitch
;; Bug fix: `anything-attr' is usable in `header-name' function.
;;
;; Revision 1.181 2009/05/04 19:05:03 rubikitch
;; * `anything-yank-selection' and `anything-kill-selection-and-quit' handles display string now.
;; * `anything-get-selection': Added optional arguments.
;;
;; Revision 1.180 2009/05/03 19:03:34 rubikitch
;; Add `anything-input' to `minibuffer-history' even if `anything' is quit.
;;
;; Revision 1.179 2009/04/20 16:35:44 rubikitch
;; New keybindings in anything-map:
;; C-c C-d: `anything-delete-current-selection'
;; C-c C-y: `anything-yank-selection'
;; C-c C-k: `anything-kill-selection-and-quit'
;;
;; Revision 1.178 2009/04/20 16:18:58 rubikitch
;; New variable: `anything-display-function'
;;
;; Revision 1.177 2009/04/20 02:17:16 rubikitch
;; New commands: `anything-yank-selection', `anything-kill-selection-and-quit'
;;
;; Revision 1.176 2009/04/08 14:48:15 rubikitch
;; bug fix in `anything-candidate-buffer'
;;
;; Revision 1.175 2009/03/22 19:10:37 rubikitch
;; New Variable: `anything-scroll-amount' (thx. ThierryVolpiatto)
;;
;; Revision 1.174 2009/03/12 19:12:24 rubikitch
;; New API: `define-anything-type-attribute'
;;
;; Revision 1.173 2009/03/11 08:10:32 rubikitch
;; Update doc
;;
;; Revision 1.172 2009/03/10 17:11:58 rubikitch
;; `candidate-transformer', `filtered-candidate-transformer',
;; `action-transformer' attributes: accept a list of functions
;;
;; Revision 1.171 2009/03/09 18:49:44 rubikitch
;; New command: `anything-quit-and-find-file'
;;
;; Revision 1.170 2009/03/09 18:46:11 rubikitch
;; New API: `anything-run-after-quit'
;;
;; Revision 1.169 2009/03/09 10:02:49 rubikitch
;; Set candidate-number-limit attribute for actions.
;;
;; Revision 1.168 2009/03/07 21:01:10 rubikitch
;; Bug workaround
;;
;; Revision 1.167 2009/03/06 04:13:42 rubikitch
;; Fix doc
;;
;; Revision 1.166 2009/03/03 10:35:57 rubikitch
;; Set default `anything-input-idle-delay' to 0.1
;;
;; Revision 1.165 2009/03/03 07:14:42 rubikitch
;; Make sure to run `anything-update-hook' after processing delayed sources.
;;
;; Revision 1.164 2009/03/02 01:51:40 rubikitch
;; better error handling.
;;
;; Revision 1.163 2009/03/01 05:15:00 rubikitch
;; anything-iswitchb and anything-isearch are marked as unmaintained.
;; (document change only)
;;
;; Revision 1.162 2009/02/28 01:24:13 rubikitch
;; Symbols are now acceptable as candidate.
;;
;; Revision 1.161 2009/02/27 07:18:46 rubikitch
;; Fix bug of `anything-scroll-other-window' and `anything-scroll-other-window-down'.
;;
;; Revision 1.160 2009/02/27 01:05:06 rubikitch
;; * Make sure to restore point after running `anything-update-hook'.
;; * Make `anything-compute-matches' easy to find error.
;;
;; Revision 1.159 2009/02/26 23:45:48 rubikitch
;; * Check whether candidate is a string, otherwise ignore.
;;
;; Revision 1.158 2009/02/24 06:39:20 rubikitch
;; suppress compile warnings.
;;
;; Revision 1.157 2009/02/23 22:51:43 rubikitch
;; New function: `anything-document-attribute'
;;
;; Revision 1.156 2009/02/23 21:36:09 rubikitch
;; New Variable: `anything-display-source-at-screen-top'
;;
;; Revision 1.155 2009/02/23 21:30:52 rubikitch
;; New command: `anything-at-point'
;;
;; Revision 1.154 2009/02/23 08:57:54 rubikitch
;; Visible Mark
;;
;; Revision 1.153 2009/02/23 08:38:57 rubikitch
;; update doc
;;
;; Revision 1.152 2009/02/23 08:32:17 rubikitch
;; More key bindings.
;;
;; Revision 1.151 2009/02/23 08:21:24 rubikitch
;; `anything-map' is now Emacs-standard key bindings by default.
;; After evaluating `anything-iswitchb-setup'. some key bindings are adjusted to iswitchb.
;;
;; Revision 1.150 2009/02/20 22:58:18 rubikitch
;; Cancel timer in `anything-cleanup'.
;;
;; Revision 1.149 2009/02/20 12:23:44 rubikitch
;; `anything-header' face now inherits header-line (not a copy).
;;
;; Revision 1.148 2009/02/16 23:40:22 rubikitch
;; `real-to-display' attribute bug fix.
;;
;; Revision 1.147 2009/02/02 20:51:41 rubikitch
;; New `anything-sources' attribute: real-to-display
;;
;; Revision 1.146 2009/02/01 20:01:00 rubikitch
;; Update Tips
;;
;; Revision 1.145 2009/02/01 19:45:53 rubikitch
;; New variable: `anything-quit-if-no-candidate'
;;
;; Revision 1.144 2009/02/01 19:31:47 rubikitch
;; fixed a typo
;;
;; Revision 1.143 2009/02/01 19:23:32 rubikitch
;; New variable: `anything-execute-action-at-once-if-one'
;;
;; Revision 1.142 2009/02/01 19:12:34 rubikitch
;; `anything-persistent-action-display-buffer': bug fix
;;
;; Revision 1.141 2009/02/01 18:25:25 rubikitch
;; * fix docstring
;; * New variable: `anything-selection-face'
;;
;; Revision 1.140 2009/01/16 16:36:25 rubikitch
;; New variable: `anything-persistent-action-use-special-display'.
;;
;; Revision 1.139 2009/01/05 20:15:53 rubikitch
;; Fixed a bug of anything action buffer.
;; The action source should not be cached.
;;
;; Revision 1.138 2008/12/21 16:56:05 rubikitch
;; Fixed an error when action attribute is a function symbol and press TAB,
;;
;; Revision 1.137 2008/12/20 19:38:47 rubikitch
;; `anything-check-minibuffer-input-1': proper quit handling
;; `anything-process-delayed-sources': ditto
;;
;; Revision 1.136 2008/10/27 17:41:27 rubikitch
;; `anything-process-delayed-sources', `anything-check-minibuffer-input-1': quittable
;;
;; Revision 1.135 2008/10/27 17:04:25 rubikitch
;; arranged source, added more linkd tags (no code change)
;;
;; Revision 1.134 2008/10/27 15:02:25 rubikitch
;; New variable: `anything-save-configuration-functions'
;; Delete variable: `anything-save-configuration-type'
;;
;; Revision 1.133 2008/10/27 11:16:13 rubikitch
;; New variable: `anything-save-configuration-type'
;;
;; Revision 1.132 2008/10/26 22:34:59 rubikitch
;; `anything-delete-current-selection' with multiline
;;
;; Revision 1.131 2008/10/26 21:44:43 rubikitch
;; New command: `anything-delete-current-selection'
;;
;; Revision 1.130 2008/10/22 10:41:09 rubikitch
;; `anything-insert-match': do not override 'anything-realvalue property
;;
;; Revision 1.129 2008/10/21 17:01:37 rubikitch
;; `anything-resume' per buffer.
;; `anything-last-sources': obsolete
;;
;; Revision 1.128 2008/10/20 06:27:54 rubikitch
;; `anything-quick-update': new user option
;;
;; Revision 1.127 2008/10/20 05:47:49 rubikitch
;; refactoring
;;
;; Revision 1.126 2008/10/20 03:47:58 rubikitch
;; `anything-update': reversed order of delayed sources
;;
;; Revision 1.125 2008/10/19 00:29:54 rubikitch
;; kill buffer-local candidate buffers when creating global candidate buffers.
;;
;; Revision 1.124 2008/10/18 13:04:20 rubikitch
;; Remove tick entry from `anything-tick-hash' when killing a buffer.
;;
;; Revision 1.123 2008/10/18 10:23:36 rubikitch
;; multiline patch by Tomohiro MATSUYAMA.
;;
;; Revision 1.122 2008/10/13 03:10:07 rubikitch
;; `anything': do `anything-mark-current-line' when resuming
;;
;; Revision 1.121 2008/10/13 03:08:08 rubikitch
;; always set `anything-current-position'
;;
;; Revision 1.120 2008/10/07 14:12:02 rubikitch
;; `anything-execute-persistent-action': optional arg
;;
;; Revision 1.119 2008/10/06 06:43:29 rubikitch
;; `anything-candidate-buffer': return nil when the buffer is dead
;;
;; Revision 1.118 2008/09/30 22:21:28 rubikitch
;; New `anything-sources' attribute: accept-empty
;; dummy: include accept-empty
;;
;; Revision 1.117 2008/09/30 21:59:10 rubikitch
;; New function: `anything-buffer-is-modified'
;;
;; Revision 1.116 2008/09/22 11:27:29 rubikitch
;; *** empty log message ***
;;
;; Revision 1.115 2008/09/20 20:21:11 rubikitch
;; added linkd index. (no code change)
;;
;; Revision 1.114 2008/09/20 20:09:57 rubikitch
;; INCOMPATIBLE CHANGES: `anything-attr'
;; New functions: `anything-attrset', `anything-attr-defined'
;;
;; Revision 1.113 2008/09/14 15:15:32 rubikitch
;; bugfix: volatile and match attribute / process and match attribute
;;
;; Revision 1.112 2008/09/12 01:57:17 rubikitch
;; When resuming anything, reinitialize overlays.
;;
;; Revision 1.111 2008/09/10 22:53:11 rubikitch
;; anything: bug fix of `anything-buffer'
;; New macro: `anything-test-update'
;;
;; Revision 1.110 2008/09/10 22:17:11 rubikitch
;; New `anything-sources' attribute: header-name
;;
;; Revision 1.109 2008/09/10 21:12:26 rubikitch
;; New hook: `anything-after-action-hook'
;;
;; Revision 1.108 2008/09/06 06:07:56 rubikitch
;; Extended `anything-set-sources' optional arguments.
;;
;; Revision 1.107 2008/09/05 03:14:35 rubikitch
;; reimplement `anything-current-buffer-is-modified' in the right way
;;
;; Revision 1.106 2008/09/05 00:11:05 rubikitch
;; Moved `anything-read-string-mode' and read functions to anything-complete.el.
;;
;; Revision 1.105 2008/09/04 12:45:06 rubikitch
;; New hook: `anything-after-persistent-action-hook'
;;
;; Revision 1.104 2008/09/04 12:27:05 rubikitch
;; `anything': prefixed optional arguments
;;
;; Revision 1.103 2008/09/04 09:16:28 rubikitch
;; fixed a bug of `anything-read-file-name'.
;;
;; Revision 1.102 2008/09/03 11:25:19 rubikitch
;; Extended `anything' optional arguments: buffer
;;
;; Revision 1.101 2008/09/03 11:15:13 rubikitch
;; `anything': return nil when keybord-quitted
;;
;; Revision 1.100 2008/09/01 23:11:02 rubikitch
;; bug fix of search-from-end
;;
;; Revision 1.99 2008/09/01 13:45:55 rubikitch
;; bug fix of search-from-end
;;
;; Revision 1.98 2008/09/01 11:23:38 rubikitch
;; New `anything-sources' attribute: search-from-end
;;
;; Revision 1.97 2008/09/01 00:44:34 rubikitch
;; Make sure to display the other window when persistent action.
;;
;; Revision 1.96 2008/08/31 20:55:20 rubikitch
;; define `buffer-modified-tick' for older emacs.
;;
;; Revision 1.95 2008/08/30 04:55:51 rubikitch
;; fixed a bug of `anything-completing-read'
;;
;; Revision 1.94 2008/08/28 20:18:03 rubikitch
;; added some tests
;;
;; Revision 1.93 2008/08/25 20:18:46 rubikitch
;; `anything': set `anything-input' and `anything-pattern' before `anything-update'
;;
;; Revision 1.92 2008/08/24 22:38:46 rubikitch
;; *** empty log message ***
;;
;; Revision 1.91 2008/08/24 21:34:35 rubikitch
;; rewrite `with-anything-restore-variables'
;;
;; Revision 1.90 2008/08/24 20:33:02 rubikitch
;; prevent the unit test from byte-compiled.
;; macro bug fix.
;;
;; Revision 1.89 2008/08/24 08:35:27 rubikitch
;; *** empty log message ***
;;
;; Revision 1.88 2008/08/24 08:22:19 rubikitch
;; Rename `anything-candidates-buffer' -> `anything-candidate-buffer'
;;
;; Revision 1.87 2008/08/23 22:27:04 rubikitch
;; New hook: `anything-cleanup-hook'
;;
;; Revision 1.86 2008/08/23 22:05:42 rubikitch
;; `anything-original-source-filter' is removed.
;; Now use `anything-restored-variables' and `with-anything-restore-variables'.
;;
;; Revision 1.85 2008/08/23 21:23:21 rubikitch
;; inhibit-read-only = t in anything-buffer
;;
;; Revision 1.84 2008/08/23 21:18:33 rubikitch
;; *** empty log message ***
;;
;; Revision 1.83 2008/08/23 20:44:20 rubikitch
;; `anything-execute-persistent-action': display-to-real bug fix
;;
;; Revision 1.82 2008/08/23 20:19:12 rubikitch
;; New `anything-sources' attribute: get-line
;;
;; Revision 1.81 2008/08/23 19:32:14 rubikitch
;; `anything-attr': Return t in (attribute-name) case.
;;
;; Revision 1.80 2008/08/22 21:25:05 rubikitch
;; anything-candidates-in-buffer-1:
;; Open a line at the BOB to make use of `search-forward' for faster exact/prefix match.
;; Of course, restore the buffer contents after search.
;;
;; Revision 1.79 2008/08/22 17:11:00 rubikitch
;; New hook: `anything-before-initialize-hook', `anything-after-initialize-hook'
;;
;; Revision 1.78 2008/08/21 18:37:03 rubikitch
;; Implemented dummy sources as plug-in.
;;
;; Revision 1.77 2008/08/21 17:40:40 rubikitch
;; New function: `anything-set-sources'
;;
;; Revision 1.76 2008/08/21 12:25:02 rubikitch
;; New variable: `anything-version'
;;
;; Revision 1.75 2008/08/21 12:13:46 rubikitch
;; New variable: `anything-in-persistent-action'
;;
;; Revision 1.74 2008/08/21 10:34:22 rubikitch
;; New function `anything-mklist'
;;
;; Revision 1.73 2008/08/21 09:41:38 rubikitch
;; accept multiple init/cleanup functions so that plug-ins can add new function.
;;
;; Revision 1.72 2008/08/20 22:51:53 rubikitch
;; New `anything-sources' attribute: candidate-number-limit
;;
;; Revision 1.71 2008/08/20 21:45:42 rubikitch
;; added many tests.
;;
;; Revision 1.70 2008/08/20 18:51:45 rubikitch
;; `anything-preselect' bug fix.
;; refactoring.
;;
;; Revision 1.69 2008/08/20 17:57:51 rubikitch
;; Extended `anything' optional arguments: preselect
;;
;; Revision 1.68 2008/08/20 16:39:07 rubikitch
;; Nested `anything' invocation support, ie. `anything' can be invoked by anything action.
;;
;; (anything '(((name . "nested anything invocation test")
;; (candidates "anything-c-source-buffers" "anything-c-source-man-pages")
;; (display-to-real . intern)
;; (action . anything))))
;;
;; Revision 1.67 2008/08/20 00:08:28 rubikitch
;; `anything-candidates-in-buffer-1': add code when pattern == ""
;;
;; Revision 1.66 2008/08/19 23:31:52 rubikitch
;; Removed `anything-show-exact-match-first' because it should be provided as a plug-in.
;;
;; Revision 1.65 2008/08/19 23:18:47 rubikitch
;; *** empty log message ***
;;
;; Revision 1.64 2008/08/19 23:15:43 rubikitch
;; `anything-compute-matches': short-cut when match == '(identity)
;;
;; Revision 1.63 2008/08/19 23:06:42 rubikitch
;; Use hash table to speed uniquify candidates.
;;
;; Revision 1.62 2008/08/19 22:40:57 rubikitch
;; `anything-test-candidates': additional optonal argument
;;
;; Revision 1.61 2008/08/19 18:13:39 rubikitch
;; search attribute: multiple search functions
;;
;; Revision 1.60 2008/08/19 15:07:39 rubikitch
;; New function: `anything-attr'
;;
;; Revision 1.59 2008/08/19 15:01:59 rubikitch
;; arranged code
;; added unit tests
;; update doc
;;
;; Revision 1.58 2008/08/19 13:40:52 rubikitch
;; `anything-get-current-source': This function can be used in
;; init/candidates/action/candidate-transformer/filtered-candidate-transformer
;; display-to-real/cleanup function.
;;
;; Revision 1.57 2008/08/19 03:43:57 rubikitch
;; `anything-process-delayed-sources': delay = anything-idle-delay - anything-input-idle-delay
;;
;; Revision 1.56 2008/08/18 06:37:51 rubikitch
;; Make `anything-input-idle-delay' ineffective when the action list is shown.
;;
;; Revision 1.55 2008/08/18 06:35:00 rubikitch
;; New variable: `anything-show-exact-match-first'
;;
;; Revision 1.54 2008/08/17 23:22:24 rubikitch
;; *** empty log message ***
;;
;; Revision 1.53 2008/08/17 23:15:38 rubikitch
;; bind `anything-source-name' when executing action to enable to use `anything-candidate-buffer' in action.
;;
;; Revision 1.52 2008/08/17 15:21:27 rubikitch
;; `anything-test-candidates': accept a symbol for source
;; New variable: `anything-input-idle-delay'
;;
;; Revision 1.51 2008/08/17 12:45:30 rubikitch
;; (buffer-disable-undo) in anything-buffer
;;
;; Revision 1.50 2008/08/16 22:21:37 rubikitch
;; `anything-saved-sources': removed
;; `anything-action-buffer': action selection buffer
;; `anything-select-action': toggle actions <=> candidates
;;
;; Revision 1.49 2008/08/16 19:46:11 rubikitch
;; New function: `anything-action-list-is-shown'
;;
;; Revision 1.48 2008/08/16 17:03:02 rubikitch
;; bugfix: cleanup
;;
;; Revision 1.47 2008/08/16 16:35:24 rubikitch
;; silence byte compiler
;;
;; Revision 1.46 2008/08/16 14:51:27 rubikitch
;; *** empty log message ***
;;
;; Revision 1.45 2008/08/16 11:27:59 rubikitch
;; refactoring
;; `anything-aif': Anaphoric if.
;; `anything-compile-source-functions': make `anything-get-sources' customizable.
;;
;; Revision 1.44 2008/08/16 09:38:15 rubikitch
;; *** empty log message ***
;;
;; Revision 1.43 2008/08/15 11:44:28 rubikitch
;; `anything-read-string-mode': minor mode for `anything' version of read functions. (experimental)
;;
;; Revision 1.42 2008/08/15 11:03:20 rubikitch
;; update docs
;;
;; Revision 1.41 2008/08/14 20:51:28 rubikitch
;; New `anything-sources' attribute: cleanup
;;
;; Revision 1.40 2008/08/14 10:34:04 rubikitch
;; `anything': SOURCES: accept symbols
;;
;; Revision 1.39 2008/08/10 22:46:01 rubikitch
;; `anything-move-selection': avoid infinite loop
;;
;; Revision 1.38 2008/08/09 21:38:25 rubikitch
;; `anything-read-file-name': experimental implementation.
;;
;; Revision 1.37 2008/08/09 17:54:25 rubikitch
;; action test
;;
;; Revision 1.36 2008/08/09 17:13:00 rubikitch
;; fixed test
;;
;; Revision 1.35 2008/08/09 10:43:08 rubikitch
;; New `anything-sources' attribute: display-to-real
;;
;; Revision 1.34 2008/08/07 13:15:44 rubikitch
;; New `anything-sources' attribute: search
;;
;; Revision 1.33 2008/08/05 23:14:20 rubikitch
;; `anything-candidate-buffer': bugfix
;;
;; Revision 1.32 2008/08/05 21:42:15 rubikitch
;; *** empty log message ***
;;
;; Revision 1.31 2008/08/05 21:06:23 rubikitch
;; `anything-candidate-buffer': candidates buffer registration
;;
;; Revision 1.30 2008/08/05 19:46:36 rubikitch
;; New `anything-sources' attribute: candidates-in-buffer
;;
;; Revision 1.29 2008/08/05 17:58:31 rubikitch
;; *** empty log message ***
;;
;; Revision 1.28 2008/08/05 17:46:04 rubikitch
;; memoized `anything-get-sources'
;;
;; Revision 1.27 2008/08/05 17:29:40 rubikitch
;; update doc
;;
;; Revision 1.26 2008/08/05 08:35:45 rubikitch
;; `anything-completing-read': accept obarray
;;
;; Revision 1.25 2008/08/05 07:26:17 rubikitch
;; `anything-completing-read': guard from non-string return value
;;
;; Revision 1.24 2008/08/04 12:05:41 rubikitch
;; Wrote Tips and some docstrings.
;; `anything-candidate-buffer': buffer-local by default
;;
;; Revision 1.23 2008/08/04 05:29:46 rubikitch
;; `anything-buffer-file-name': `buffer-file-name' when `anything' is invoked.
;;
;; Revision 1.22 2008/08/04 00:10:13 rubikitch
;; `anything-candidate-buffer': new API
;;
;; Revision 1.21 2008/08/03 22:05:08 rubikitch
;; `anything-candidate-buffer': Return a buffer containing candidates of current source.
;;
;; Revision 1.20 2008/08/03 20:47:56 rubikitch
;; `anything-current-buffer-is-modified': modify checker
;;
;; Revision 1.19 2008/08/03 19:06:18 rubikitch
;; `anything-candidates-in-buffer': use `with-current-buffer' instead.
;;
;; Revision 1.18 2008/08/03 05:55:01 rubikitch
;; `anything-candidates-in-buffer': extract candidates in a buffer for speed.
;;
;; Revision 1.17 2008/08/02 21:31:29 rubikitch
;; Extended `anything' optional arguments.
;; `anything-completing-read': experimental implementation.
;;
;; Revision 1.16 2008/08/02 20:32:54 rubikitch
;; Extended `anything' optional arguments.
;;
;; Revision 1.15 2008/08/02 16:53:40 rubikitch
;; Fixed a small bug of `anything-test-candidates'.
;;
;; Revision 1.14 2008/08/02 16:48:29 rubikitch
;; Refactored to testable code.
;; Added many candidate tests with `anything-test-candidates'.
;;
;; Revision 1.13 2008/08/02 15:08:14 rubikitch
;; *** empty log message ***
;;
;; Revision 1.12 2008/08/02 14:29:31 rubikitch
;; `anything-sources' accepts symbols. (patched by Sugawara)
;;
;; Revision 1.11 2008/08/02 10:20:36 rubikitch
;; `anything-resume' is usable with other (let-binded) `anything-sources'.
;;
;; Revision 1.10 2008/08/01 19:44:01 rubikitch
;; `anything-resume': resurrect previously invoked `anything'.
;;
;; Revision 1.9 2008/07/30 15:44:49 rubikitch
;; *** empty log message ***
;;
;; Revision 1.8 2008/07/30 15:38:51 rubikitch
;; *** empty log message ***
;;
;; Revision 1.7 2008/07/30 15:21:48 rubikitch
;; `anything-scroll-other-window', `anything-scroll-other-window-down':
;; Scroll other window (for persistent action).
;;
;; Revision 1.6 2008/07/30 15:12:36 rubikitch
;; *** empty log message ***
;;
;; Revision 1.5 2008/07/30 15:06:32 rubikitch
;; `anything-select-2nd-action', `anything-select-3rd-action', `anything-select-4th-action':
;; Select other than default action without pressing Tab.
;;
;; Revision 1.4 2008/07/30 14:58:27 rubikitch
;; `anything-current-buffer': Store current buffer when `anything' is invoked.
;; `anything-current-position': Restore position when keyboard-quitted.
;;
;; Revision 1.3 2008/07/30 14:38:04 rubikitch
;; Implemented persistent action.
;;
;; Revision 1.2 2008/07/30 13:37:16 rubikitch
;; Update doc.
;;
;; Revision 1.1 2008/07/30 13:22:06 rubikitch
;; New maintainer.
;;
(defvar anything-version "$Id: anything.el,v 1.201 2009/08/08 13:25:30 rubikitch Exp rubikitch $")
(require 'cl)
;; (@* "User Configuration")
;; This is only an example. Customize it to your own taste!
(defvar anything-sources `(((name . "Buffers")
(candidates
. (lambda ()
(remove-if (lambda (name)
(or (equal name anything-buffer)
(eq ?\ (aref name 0))))
(mapcar 'buffer-name (buffer-list)))))
(type . buffer))
((name . "File Name History")
(candidates . file-name-history)
(match (lambda (candidate)
;; list basename matches first
(string-match
anything-pattern
(file-name-nondirectory candidate)))
(lambda (candidate)
;; and then directory part matches
(let ((dir (file-name-directory candidate)))
(if dir
(string-match anything-pattern dir)))))