forked from emacs-helm/helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helm.el
5658 lines (5081 loc) · 233 KB
/
helm.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
;;; helm.el --- Emacs incremental and narrowing framework -*- lexical-binding: t -*-
;; Copyright (C) 2007 Tamas Patrovics
;; 2008 ~ 2011 rubikitch <[email protected]>
;; 2011 ~ 2015 Thierry Volpiatto <[email protected]>
;; This is a fork of anything.el wrote by Tamas Patrovics.
;; Authors of anything.el: Tamas Patrovics
;; rubikitch <[email protected]>
;; Thierry Volpiatto <[email protected]>
;; Author: Thierry Volpiatto <[email protected]>
;; URL: http://github.com/emacs-helm/helm
;; This program 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 3 of the License, or
;; (at your option) any later version.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'advice) ; Shutup byte compiler about ad-deactivate.
(require 'helm-lib)
(require 'helm-multi-match)
(require 'helm-source)
;;; Multi keys
;;
;;
;;;###autoload
(defun helm-define-multi-key (keymap key functions &optional delay)
"In KEYMAP, define key sequence KEY for function list FUNCTIONS.
Each function runs sequentially for each KEY press.
If DELAY is specified, switch back to initial function of FUNCTIONS list
after DELAY seconds.
The functions in FUNCTIONS list take no args.
e.g
\(defun foo ()
(message \"Run foo\"))
\(defun bar ()
(message \"Run bar\"))
\(defun baz ()
(message \"Run baz\"))
\(helm-define-multi-key global-map \"<f5> q\" '(foo bar baz) 2)
Each time \"<f5> q\" is pressed, the next function is executed. Waiting
more than 2 seconds between key presses switches back to executing the first
function on the next hit."
(define-key keymap key (helm-make-multi-command functions delay)))
;;;###autoload
(defmacro helm-multi-key-defun (name docstring funs &optional delay)
"Define NAME as a multi-key command running FUNS.
After DELAY seconds, the FUNS list is reinitialized.
See `helm-define-multi-key'."
(declare (indent 2))
(setq docstring (if docstring (concat docstring "\n\n")
"This is a helm-ish multi-key command."))
`(defalias (quote ,name) (helm-make-multi-command ,funs ,delay) ,docstring))
(defun helm-make-multi-command (functions &optional delay)
"Return an anonymous multi-key command running FUNCTIONS.
Run each function in the FUNCTIONS list in turn when called within DELAY seconds."
(declare (indent 1))
(let ((funs functions)
(iter (cl-gensym "helm-iter-key"))
(timeout delay))
(eval (list 'defvar iter nil))
(lambda () (interactive) (helm-run-multi-key-command funs iter timeout))))
(defun helm-run-multi-key-command (functions iterator delay)
(let ((fn (lambda ()
(cl-loop for count from 1 to (length functions)
collect count)))
next)
(unless (and (symbol-value iterator)
;; Reset iterator when another key is pressed.
(eq this-command real-last-command))
(set iterator (helm-iter-list (funcall fn))))
(setq next (helm-iter-next (symbol-value iterator)))
(unless next
(set iterator (helm-iter-list (funcall fn)))
(setq next (helm-iter-next (symbol-value iterator))))
(and next (symbol-value iterator) (call-interactively (nth (1- next) functions)))
(when delay (run-with-idle-timer delay nil `(lambda ()
(setq ,iterator nil))))))
(helm-multi-key-defun helm-toggle-resplit-and-swap-windows
"Multi key command to re-split and swap helm window.
First call runs `helm-toggle-resplit-window',
and second call within 0.5s runs `helm-swap-windows'."
'(helm-toggle-resplit-window helm-swap-windows) 1)
(put 'helm-toggle-resplit-and-swap-windows 'helm-only t)
;;;###autoload
(defun helm-define-key-with-subkeys (map key subkey command
&optional other-subkeys menu exit-fn)
"Defines in MAP a KEY and SUBKEY to COMMAND.
This allows typing KEY to call COMMAND the first time and
type only SUBKEY on subsequent calls.
Arg MAP is the keymap to use, SUBKEY is the initial short key-binding to
call COMMAND.
Arg OTHER-SUBKEYS is an alist specifying other short key-bindings
to use once started.
e.g:
\(helm-define-key-with-subkeys global-map
\(kbd \"C-x v n\") ?n 'git-gutter:next-hunk '((?p . git-gutter:previous-hunk))\)
In this example, `C-x v n' will run `git-gutter:next-hunk'
subsequent \"n\"'s run this command again
and subsequent \"p\"'s run `git-gutter:previous-hunk'.
Arg MENU is a string displayed in minibuffer that
describes SUBKEY and OTHER-SUBKEYS.
Arg EXIT-FN specifies a function to run on exit.
For any other keys pressed, run their assigned command as defined
in MAP and then exit the loop running EXIT-FN, if specified.
NOTE: SUBKEY and OTHER-SUBKEYS bindings support char syntax only
(e.g ?n), so don't use strings or vectors to define them."
(declare (indent 1))
(define-key map key
(lambda ()
(interactive)
(unwind-protect
(progn
(call-interactively command)
(while (let ((input (read-key menu)) other kb com)
(setq last-command-event input)
(cond
((eq input subkey)
(call-interactively command)
t)
((setq other (assoc input other-subkeys))
(call-interactively (cdr other))
t)
(t
(setq kb (vector last-command-event))
(setq com (lookup-key map kb))
(if (commandp com)
(call-interactively com)
(setq unread-command-events
(nconc (mapcar 'identity kb)
unread-command-events)))
nil)))))
(and exit-fn (funcall exit-fn))))))
;;; Keymap
;;
;;
(defvar helm-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-map)
(define-key map (kbd "<down>") 'helm-next-line)
(define-key map (kbd "<up>") 'helm-previous-line)
(define-key map (kbd "C-n") 'helm-next-line)
(define-key map (kbd "C-p") 'helm-previous-line)
(define-key map (kbd "<C-down>") 'helm-follow-action-forward)
(define-key map (kbd "<C-up>") 'helm-follow-action-backward)
(define-key map (kbd "<prior>") 'helm-previous-page)
(define-key map (kbd "<next>") 'helm-next-page)
(define-key map (kbd "M-v") 'helm-previous-page)
(define-key map (kbd "C-v") 'helm-next-page)
(define-key map (kbd "M-<") 'helm-beginning-of-buffer)
(define-key map (kbd "M->") 'helm-end-of-buffer)
(define-key map (kbd "C-g") 'helm-keyboard-quit)
(define-key map (kbd "<right>") 'helm-next-source)
(define-key map (kbd "<left>") 'helm-previous-source)
(define-key map (kbd "<RET>") 'helm-maybe-exit-minibuffer)
(define-key map (kbd "C-i") 'helm-select-action)
(define-key map (kbd "C-z") 'helm-execute-persistent-action)
(define-key map (kbd "C-j") 'helm-execute-persistent-action)
(define-key map (kbd "C-o") 'helm-next-source)
(define-key map (kbd "C-l") 'helm-recenter-top-bottom-other-window)
(define-key map (kbd "M-C-l") 'helm-reposition-window-other-window)
(define-key map (kbd "C-M-v") 'helm-scroll-other-window)
(define-key map (kbd "M-<next>") 'helm-scroll-other-window)
(define-key map (kbd "C-M-y") 'helm-scroll-other-window-down)
(define-key map (kbd "C-M-S-v") 'helm-scroll-other-window-down)
(define-key map (kbd "M-<prior>") 'helm-scroll-other-window-down)
(define-key map (kbd "<C-M-down>") 'helm-scroll-other-window)
(define-key map (kbd "<C-M-up>") 'helm-scroll-other-window-down)
(define-key map (kbd "C-@") 'helm-toggle-visible-mark)
(define-key map (kbd "C-SPC") 'helm-toggle-visible-mark)
(define-key map (kbd "M-SPC") 'helm-toggle-visible-mark)
(define-key map (kbd "M-[") nil)
(define-key map (kbd "M-(") 'helm-prev-visible-mark)
(define-key map (kbd "M-)") 'helm-next-visible-mark)
(define-key map (kbd "C-k") 'helm-delete-minibuffer-contents)
(define-key map (kbd "C-x C-f") 'helm-quit-and-find-file)
(define-key map (kbd "M-m") 'helm-toggle-all-marks)
(define-key map (kbd "M-a") 'helm-mark-all)
(define-key map (kbd "M-U") 'helm-unmark-all)
(define-key map (kbd "C-w") 'helm-yank-text-at-point)
(define-key map (kbd "C-M-a") 'helm-show-all-in-this-source-only)
(define-key map (kbd "C-M-e") 'helm-display-all-sources)
(define-key map (kbd "C-r") 'undefined)
(define-key map (kbd "C-s") 'undefined)
(define-key map (kbd "M-s") 'undefined)
(define-key map (kbd "C-}") 'helm-narrow-window)
(define-key map (kbd "C-{") 'helm-enlarge-window)
(define-key map (kbd "C-c -") 'helm-swap-windows)
(define-key map (kbd "C-c C-y") 'helm-yank-selection)
(define-key map (kbd "C-c C-k") 'helm-kill-selection-and-quit)
(define-key map (kbd "C-c C-i") 'helm-copy-to-buffer)
(define-key map (kbd "C-c C-f") 'helm-follow-mode)
(define-key map (kbd "C-c C-u") 'helm-refresh)
(define-key map (kbd "C-c >") 'helm-toggle-truncate-line)
(define-key map (kbd "M-p") 'previous-history-element)
(define-key map (kbd "M-n") 'next-history-element)
(define-key map (kbd "C-!") 'helm-toggle-suspend-update)
(define-key map (kbd "C-x b") 'helm-resume-previous-session-after-quit)
(define-key map (kbd "C-x C-b") 'helm-resume-list-buffers-after-quit)
;; Disable `file-cache-minibuffer-complete'.
(define-key map (kbd "<C-tab>") 'undefined)
;; Multi keys
(define-key map (kbd "C-t") 'helm-toggle-resplit-and-swap-windows)
;; Debugging command
(define-key map (kbd "C-h C-d") 'undefined)
(define-key map (kbd "C-h C-d") 'helm-enable-or-switch-to-debug)
;; Allow to eval keymap without errors.
(define-key map [f1] nil)
(define-key map (kbd "C-h C-h") 'undefined)
(define-key map (kbd "C-h h") 'undefined)
;; Use `describe-mode' key in `global-map'.
(cl-dolist (k (where-is-internal 'describe-mode global-map))
(define-key map k 'helm-help))
(define-key map (kbd "C-c ?") 'helm-help)
;; Bind all actions from 1 to 12 to their corresponding nth index+1.
(cl-loop for n from 0 to 12 do
(define-key map (kbd (format "<f%s>" (1+ n)))
`(lambda ()
(interactive)
(helm-select-nth-action ,n))))
;; Bind keys to allow executing default action
;; on first 9 candidates before and after selection.
(cl-loop for n from 1 to 9
for key = (format "C-c %d" n)
for key- = (format "C-x %d" n)
for fn = `(lambda ()
(interactive)
(helm-execute-selection-action-at-nth ,n))
for fn- = `(lambda ()
(interactive)
(helm-execute-selection-action-at-nth ,(- n)))
do (progn
(define-key map (kbd key) fn)
(define-key map (kbd key-) fn-)))
map)
"Keymap for helm.")
(defgroup helm nil
"Open helm."
:prefix "helm-" :group 'convenience)
(defcustom helm-completion-window-scroll-margin 5
" `scroll-margin' to use for helm completion window.
Set to 0 to disable.
NOTE: This has no effect when `helm-display-source-at-screen-top'
id is non-`nil'."
:group 'helm
:type 'integer)
(defcustom helm-display-source-at-screen-top t
"Display candidates at the top of screen.
This happens with `helm-next-source' and `helm-previous-source'.
NOTE: When non-`nil' (default), disable `helm-completion-window-scroll-margin'."
:group 'helm
:type 'boolean)
(defcustom helm-candidate-number-limit 100
"Global limit for number of candidates displayed.
When the pattern is empty, the number of candidates shown will be
as set here instead of the entire list, which may be hundreds or
thousands. Since narrowing and filtering rapidly reduces
available candidates, having a small list will keep the interface
responsive.
Set this value to nil for no limit."
:group 'helm
:type '(choice (const :tag "Disabled" nil) integer))
(defcustom helm-idle-delay 0.01
"Update delayed sources after this idle delay, specified in seconds.
Helps curtail unnecessary retrieval of candidates from sources as
the user is typing.
Such delay also helps de-clutter the results in helm displays in
the short elapsed time between successive characters typed by the
user."
:group 'helm
:type 'float)
(defcustom helm-input-idle-delay 0.01
"Idle time before updating, specified in seconds.
This delay applies to non-delayed sources as well. Whereas
`helm-idle-delay' applies only to delayed sources.
When set to nil, collects candidates without delay.
Safe value for this is >= `helm-idle-delay' to avoid duplicates
when using multiple sources.
Default value for this is set equal to `helm-idle-delay'."
:group 'helm
:type 'float)
(defcustom helm-exit-idle-delay 0
"Idle time before exiting minibuffer while helm is updating.
Has no affect when helm-buffer is up to date \(i.e exit without
delay in this condition\)."
:group 'helm
:type 'float)
(defcustom helm-full-frame nil
"Use current window for showing candidates.
If t, then Helm does not pop-up new window."
:group 'helm
:type 'boolean)
(defvaralias 'helm-samewindow 'helm-full-frame)
(make-obsolete-variable 'helm-samewindow 'helm-full-frame "1.4.8.1")
(defcustom helm-quick-update nil
"When non-`nil', helm suppresses displaying sources which at first are out of screen.
They are updated as if they are delayed sources. This flag makes
`helm' interaction a bit faster with many sources."
:group 'helm
:type 'boolean)
(defcustom helm-candidate-separator
"--------------------"
"Candidates separator of `multiline' source."
:group 'helm
:type 'string)
(defcustom helm-save-configuration-functions
'(set-window-configuration . current-window-configuration)
"Functions used to restore or save configurations for frames and windows.
Specified as a pair of functions, where car is the restore function and cdr
is the save function.
To save and restore frame configuration, set this variable to
'\(set-frame-configuration . current-frame-configuration\)
NOTE: This may not work properly with own-frame minibuffer
settings. Older versions saves/restores frame configuration, but
the default has changed now to avoid flickering."
:group 'helm
:type 'sexp)
(defcustom helm-persistent-action-use-special-display nil
"If non-`nil', use `special-display-function' in persistent action."
:group 'helm
:type 'boolean)
(defcustom helm-display-function 'helm-default-display-buffer
"Function to display *helm* buffer.
By default, it is `helm-default-display-buffer', which affects
`helm-full-frame'."
:group 'helm
:type 'symbol)
(defcustom helm-case-fold-search 'smart
"Adds 'smart' option to `case-fold-search'.
Smart option ignores case for searches as long as there are no
upper case characters in the pattern.
Use nil or t to turn off smart behavior and use
`case-fold-search' behavior.
Default is smart.
NOTE: Case fold search has no effect when searching asynchronous
sources, which rely on customized features implemented directly
into their execution process. See helm-grep.el for an example."
:group 'helm
:type '(choice (const :tag "Ignore case" t)
(const :tag "Respect case" nil)
(other :tag "Smart" 'smart)))
(defcustom helm-file-name-case-fold-search
(if (memq system-type
'(cygwin windows-nt ms-dos darwin))
t
helm-case-fold-search)
"Local setting of `helm-case-fold-search' for reading filenames.
See `helm-case-fold-search' for more info."
:group 'helm
:type 'symbol)
(defcustom helm-reuse-last-window-split-state nil
"Use the same state of window split, vertical or horizontal.
`helm-toggle-resplit-window' for the next helm session will use
the same window scheme as the previous session unless
`helm-split-window-default-side' is 'same or 'other."
:group 'helm
:type 'boolean)
(defcustom helm-split-window-preferred-function 'helm-split-window-default-fn
"Default function used for splitting window."
:group 'helm
:type 'function)
(defcustom helm-split-window-default-side 'below
"The default side to display `helm-buffer'.
Must be one acceptable arg for `split-window' SIDE,
that is `below', `above', `left' or `right'.
Other acceptable values are `same' which always display
`helm-buffer' in current window and `other' that display
`helm-buffer' below if only one window or in
`other-window-for-scrolling' when available.
A nil value has same effect as `below'.
If `helm-full-frame' is non-`nil', it take precedence over this setting.
See also `helm-split-window-in-side-p' and `helm-always-two-windows' that
take precedence over this.
NOTE: this have no effect if `helm-split-window-preferred-function' is not
`helm-split-window-default-fn' unless this new function can handle this."
:group 'helm
:type 'symbol)
(defcustom helm-display-buffer-default-size nil
"Initial height of `helm-buffer', specified as an integer or a function.
The function should take one arg and the responsibility for
re-sizing the window; function's return value is ignored. See
`display-buffer' for more info."
:group 'helm
:type '(choice integer function))
(defcustom helm-split-window-in-side-p nil
"Forces split inside selected window when non-`nil'.
See also `helm-split-window-default-side'.
NOTE: this has no effect if
`helm-split-window-preferred-function' is not
`helm-split-window-default-fn' unless this new function can
handle this."
:group 'helm
:type 'boolean)
(defcustom helm-always-two-windows nil
"When non-`nil' helm uses two windows in this frame.
To display `helm-buffer' in one window and `helm-current-buffer'
in the other.
Note: this has no effect when `helm-split-window-in-side-p' is non-`nil',
or when `helm-split-window-default-side' is set to 'same.
When `helm-autoresize-mode' is enabled, setting this to nil
will have no effect.
Also when non-`nil' it overrides the effect of `helm-split-window-default-side'
set to `other'."
:group 'helm
:type 'boolean)
(defcustom helm-sources-using-default-as-input '(helm-source-imenu
helm-source-imenu-all
helm-source-info-elisp
helm-source-etags-select
helm-source-man-pages
helm-source-occur
helm-source-moccur)
"List of helm sources that need to use `helm--maybe-use-default-as-input'.
When a source is a member of this list, default `thing-at-point'
will be used as input."
:group 'helm
:type '(repeat (choice symbol)))
(defcustom helm-delete-minibuffer-contents-from-point t
"When non-`nil', `helm-delete-minibuffer-contents' delete region from `point'.
Otherwise delete `minibuffer-contents'.
See documentation for `helm-delete-minibuffer-contents'."
:group 'helm
:type 'boolean)
(defcustom helm-follow-mode-persistent nil
"When non-`nil', use last state of `helm-follow-mode' for the next helm session.
To make this behavior persistent across emacs sessions, set the
`follow' attribute explicitly in the source."
:group 'helm
:type 'boolean)
(defcustom helm-prevent-escaping-from-minibuffer t
"Prevent escape from minibuffer during the helm session."
:group 'helm
:type 'boolean)
(defcustom helm-move-to-line-cycle-in-source nil
"Cycle to the beginning or end of the list after reaching the bottom or top.
This applies when using `helm-next/previous-line'."
:group 'helm
:type 'boolean)
(defcustom helm-fuzzy-match-fn 'helm-fuzzy-match
"The function for fuzzy matching in `helm-source-sync' based sources."
:group 'helm
:type 'function)
(defcustom helm-fuzzy-search-fn 'helm-fuzzy-search
"The function for fuzzy matching in `helm-source-in-buffer' based sources."
:group 'helm
:type 'function)
(defcustom helm-fuzzy-sort-fn 'helm-fuzzy-matching-default-sort-fn
"The sort transformer function used in fuzzy matching.
When nil, sorting is not done."
:group 'helm
:type 'function)
(defcustom helm-fuzzy-matching-highlight-fn 'helm-fuzzy-default-highlight-match
"The function to highlight fuzzy matches.
When nil, no highlighting is done."
:group 'helm
:type 'function)
(defcustom helm-autoresize-max-height 40
"Specifies maximum height and defaults to percent of helm window's frame height.
See `fit-window-to-buffer' for more infos."
:group 'helm
:type 'integer)
(defcustom helm-autoresize-min-height 10
"Specifies minimum height and defaults to percent of helm window's frame height.
If nil, `window-min-height' is used.
See `fit-window-to-buffer' for details."
:group 'helm
:type 'integer)
(defcustom helm-input-method-verbose-flag nil
"The default value for `input-method-verbose-flag' used in helm minibuffer.
It is nil by default, which does not turn off input method. Helm
updates and exits without interruption -- necessary for complex methods.
If set to any other value as per `input-method-verbose-flag',
then use `C-\\' to disable the `current-input-method' to exit or update helm"
:group 'helm
:type '(radio :tag "A flag to control extra guidance for input methods in helm."
(const :tag "Never provide guidance" nil)
(const :tag "Always provide guidance" t)
(const :tag "Provide guidance only for complex methods" complex-only)))
(defcustom helm-display-header-line t
"Display header-line when non nil."
:group 'helm
:type 'boolean)
(defcustom helm-inherit-input-method t
"Inherit `current-input-method' from `current-buffer' when non-`nil'.
The default is to enable this by default and then toggle
`toggle-input-method'."
:group 'helm
:type 'boolean)
(defcustom helm-echo-input-in-header-line nil
"Send current input in header-line."
:group 'helm
:type 'boolean)
;;; Faces
;;
;;
(defgroup helm-faces nil
"Customize the appearance of helm."
:prefix "helm-"
:group 'faces
:group 'helm)
(defface helm-source-header
'((((background dark))
:background "#22083397778B"
:foreground "white"
:weight bold :height 1.3 :family "Sans Serif")
(((background light))
:background "#abd7f0"
:foreground "black"
:weight bold :height 1.3 :family "Sans Serif"))
"Face for source header in the helm buffer."
:group 'helm-faces)
(defface helm-visible-mark
'((((min-colors 88) (background dark))
(:background "green1" :foreground "black"))
(((background dark))
(:background "green" :foreground "black"))
(((background light)) :background "#d1f5ea")
(((min-colors 88))
(:background "green1"))
(t (:background "green")))
"Face for visible mark."
:group 'helm-faces)
(defface helm-header
'((t (:inherit header-line)))
"Face for header lines in the helm buffer."
:group 'helm-faces)
(defface helm-candidate-number
'((((background dark)) :background "Yellow" :foreground "black")
(((background light)) :background "#faffb5" :foreground "black"))
"Face for candidate number in mode-line." :group 'helm-faces)
(defface helm-selection
'((((background dark)) :background "ForestGreen"
:distant-foreground "black")
(((background light)) :background "#b5ffd1"
:distant-foreground "black"))
"Face for currently selected item in the helm buffer."
:group 'helm-faces)
(defface helm-separator
'((((background dark)) :foreground "red")
(((background light)) :foreground "#ffbfb5"))
"Face for multiline source separator."
:group 'helm-faces)
(defface helm-action
'((t (:underline t)))
"Face for action lines in the helm action buffer."
:group 'helm-faces)
(defface helm-prefarg
'((((background dark)) :foreground "green")
(((background light)) :foreground "red"))
"Face for showing prefix arg in mode-line."
:group 'helm-faces)
(defface helm-match
'((((background light)) :foreground "#b00000")
(((background dark)) :foreground "gold1"))
"Face used to highlight matches."
:group 'helm-faces)
(defface helm-header-line-left-margin
'((t (:foreground "black" :background "yellow")))
"Face used to highlight helm-header sign in left-margin."
:group 'helm-faces)
;;; Variables.
;;
;;
(defvar helm-type-attributes nil
"It's a list of \(TYPE ATTRIBUTES ...\).
ATTRIBUTES are the same as attributes for `helm-sources'. TYPE
connects the value to the appropriate sources. Don't set this
directly, use `define-helm-type-attribute' instead.
This alist is for specifying common attributes for multiple
sources. For example, sources which provide files can specify
common attributes with a `file' type.")
(defvar helm-source-filter nil
"A list of source names to be displayed.
Other sources won't appear in the search results.
If nil, no filtering is done.
See also `helm-set-source-filter'.")
(defvar helm-selection-overlay nil
"Overlay used to highlight the currently selected item.")
(defvar helm-async-processes nil
"List of information about asynchronous processes managed by helm.")
(defvar helm-before-initialize-hook nil
"Runs before helm initialization.
This hook runs before init functions in `helm-sources', which is
before creation of `helm-buffer'. Set local variables for
`helm-buffer' that need a value from `current-buffer' with
`helm-set-local-variable'.")
(defvar helm-after-initialize-hook nil
"Runs after helm initialization.
This hook runs after `helm-buffer' is created but not from
`helm-buffer'. The hook needs to specify in which buffer to run.")
(defvar helm-update-hook nil
"Run after the helm buffer is updated.
This hook runs at the beginning of buffer. The first candidate is
selected after running this hook. See also
`helm-after-update-hook'.")
(defvar helm-after-update-hook nil
"Runs after updating the helm buffer with the new input pattern.
This is very similar to `helm-update-hook' except the selection
is not moved. Hook is useful for selecting a particular object
instead of the first one.")
(defvar helm-cleanup-hook nil
"Runs after exiting the minibuffer and before performing an
action.
This hook runs even if helm exits the minibuffer abnormally (e.g.
via `helm-keyboard-quit').")
(defvar helm-select-action-hook nil
"Runs when opening the action buffer.")
(defvar helm-before-action-hook nil
"Runs before executing action.
Unlike `helm-cleanup-hook', this hook runs before helm closes the
minibuffer and also before performing an action.")
(defvar helm-after-action-hook nil
"Runs after executing action.")
(defvar helm-exit-minibuffer-hook nil
"Runs just before exiting the minibuffer.
This hook runs when helm exits the minibuffer normally (e.g. via
candidate selection), but does NOT run if helm exits the
minibuffer abnormally (e.g. via `helm-keyboard-quit').")
(defvar helm-after-persistent-action-hook nil
"Runs after executing persistent action.")
(defvar helm-move-selection-before-hook nil
"Runs before moving selection in `helm-buffer'.")
(defvar helm-move-selection-after-hook nil
"Runs after moving selection in `helm-buffer'.")
(defvar helm-after-preselection-hook nil
"Runs after pre-selection in `helm-buffer'.")
(defvar helm-window-configuration-hook nil
"Runs when switching to and from the action buffer.")
(defconst helm-restored-variables
'(helm-candidate-number-limit
helm-source-filter
helm-map
helm-sources)
"Variables restored after an `helm' invocation.")
(defvar helm-execute-action-at-once-if-one nil
"With the only remaining candidate, executes the default action and then exits.
This variable accepts a function with no args and returns a boolean
value.")
(defvar helm-quit-if-no-candidate nil
"When non-`nil', quits if there are no candidates.
This variable accepts a function.")
(defvar helm-debug-variables nil
"A list of helm variables that `helm-debug-output' displays.
If `nil', `helm-debug-output' includes only variables with
`helm-' prefixes.")
(defvar helm-debug-buffer "*Debug Helm Log*")
(defvar helm-debug nil
"If non-`nil', write log message to `helm-debug-buffer'.
Default is `nil', which disables writing log messages because the
size of `helm-debug-buffer' grows quickly.")
(defvar helm-compile-source-functions
'(helm-compile-source--type
helm-compile-source--dummy
helm-compile-source--candidates-in-buffer)
"Functions to compile elements of `helm-sources' (plug-in).")
(defvar helm-mode-line-string "\
\\<helm-map>\
\\[helm-help]:Help \
\\[helm-select-action]:Act \
\\[helm-maybe-exit-minibuffer]/\
f1/f2/f-n:NthAct \
\\[helm-toggle-suspend-update]:Tog.suspend"
"Help string displayed by helm in the mode-line.
It is either a string or a list of two string arguments where the
first string is the name and the second string is displayed in
the mode-line. When `nil', uses default `mode-line-format'.")
(defvar helm-minibuffer-set-up-hook nil
"Hook that runs at minibuffer initialization.
A hook useful for modifying minibuffer settings in helm.
An example that hides the minibuffer when using
`helm-echo-input-in-header-line':
(add-hook 'helm-minibuffer-set-up-hook #'helm-hide-minibuffer-maybe)
Note that we check `helm-echo-input-in-header-line' value
from `helm-buffer' which allow detecting possible local
value of this var.")
(defvar helm-help-message
"* Helm Generic Help
\\<helm-map>`helm' is an Emacs framework for incremental
completions and narrowing selections.
Helm narrows the list of candidates as the pattern is typed and
updates the list in a live feedback. Helm accepts multiple
patterns (entered with a space between patterns). Helm uses
familiar Emacs navigation keys to move up and down the list.
`RET' selects the candidate from the list.
** Helm Help
C-h m\t\tShows this generic Helm help.
** Helm's Basic Operations and Default Key Bindings
| Key | Alternative Keys | Command |
|---------+------------------+-----------------------------------------------------------|
| C-p | Up | Previous Line |
| C-n | Down | Next Line |
| M-v | PageUp | Previous Page |
| C-v | PageDown | Next Page |
| Enter | | Execute first (default) action / Select |
| M-< | | First Line |
| M-> | | Last Line |
| C-M-S-v | M-PageUp, C-M-y | Previous Page (other-window) |
| C-M-v | M-PageDown | Next Page (other-window) |
| Tab | C-i | Show action list |
| Left | | Previous Source |
| Right | C-o | Next Source |
| C-k | | Delete pattern (with prefix arg delete from point to end) |
| C-j | C-z | Persistent Action (Execute and keep helm session) |
** Shortcuts For nth Action
f1-12: Execute nth Action where n is 1 to 12.
** Shortcuts for executing Default Action on the nth candidate
C-x <n> => executes default action on number <n> candidate before currently selected candidate.
C-c <n> => executes default action on number <n> candidate after current selected candidate.
n is limited only to 1 through 9. For larger jumps use other
navigation keys. Also note that Helm candidates list by default
do not display line numbers. Line numbers can be enabled with the
linum-relative package.
** Visible Marks
Visible marks are displayed next to selected candidates, if any.
Some Helm actions operate on marked candidates.
** Frequently Used Commands
\\[helm-toggle-resplit-and-swap-windows]\t\tToggle vertical/horizontal split on first hit and swap helm window on second hit.
\\[helm-quit-and-find-file]\t\tDrop into `helm-find-files'.
\\[helm-kill-selection-and-quit]\t\tKill display value of candidate and quit (with prefix arg, kill the real value).
\\[helm-yank-selection]\t\tYank current selection into pattern.
\\[helm-follow-mode]\t\tToggle automatic execution of persistent action.
\\[helm-follow-action-forward]\tRun persistent action and then select next line.
\\[helm-follow-action-backward]\t\tRun persistent action and then select previous line.
\\[helm-refresh]\t\tRecalculate and redisplay candidates.
\\[helm-toggle-suspend-update]\t\tSuspend/reenable updates to candidates list.
** Global Commands
\\<global-map>\\[helm-resume] revives the last `helm' session.
Very useful for resuming previous Helm. Binding a key to this
command will greatly improve `helm' interactivity especially
after an accidental exit.
** Helm Map
\\{helm-map}"
"Message string containing detailed help for `helm'.
It also accepts function or variable symbol.")
(defvar helm-autoresize-mode) ;; Undefined in `helm-default-display-buffer'.
;;; Internal Variables
;;
;;
(defvar helm-current-prefix-arg nil
"Record `current-prefix-arg' when exiting minibuffer.")
(defvar helm-saved-action nil
"Saved value of the currently selected action by key.")
(defvar helm-saved-current-source nil
"Value of the current source when the action list is shown.")
(defvar helm-compiled-sources nil
"Compiled version of `helm-sources'.")
(defvar helm-in-persistent-action nil
"Flag whether in persistent-action or not.")
(defvar helm-last-buffer nil
"`helm-buffer' of previously `helm' session.")
(defvar helm-saved-selection nil
"Value of the currently selected object when the action list is shown.")
(defvar helm-sources nil
"[INTERNAL] Value of current sources in use, a list.")
(defvar helm-buffer-file-name nil
"Variable `buffer-file-name' when `helm' is invoked.")
(defvar helm-candidate-cache (make-hash-table :test 'equal)
"Holds the available candidate within a single helm invocation.")
(defvar helm-input ""
"The input typed in the candidates panel.")
(defvar helm-input-local nil
"Internal, store locally `helm-pattern' value for later use in `helm-resume'.")
(defvar helm-source-name nil)
(defvar helm-current-source nil)
(defvar helm-candidate-buffer-alist nil)
(defvar helm-tick-hash (make-hash-table :test 'equal))
(defvar helm-issued-errors nil)
(defvar helm-debug-root-directory nil
"When non-`nil', saves helm log messages to `helm-last-log-file'.
Use only for debugging purposes because of the size of the log files.
See `helm-log-save-maybe' for more info.")
(defvar helm-last-log-file nil
"The name of the log file of the last helm session.")
(defvar helm-follow-mode nil)
(defvar helm--local-variables nil)
(defvar helm-split-window-state nil)
(defvar helm--window-side-state nil)
(defvar helm-selection-point nil)
(defvar helm-alive-p nil)
(defvar helm-visible-mark-overlays nil)
(defvar helm-update-blacklist-regexps '("^" "^ *" "$" "!" " " "\\b"
"\\<" "\\>" "\\_<" "\\_>" ".*"))
(defvar helm-force-updating-p nil)
(defvar helm-exit-status 0
"Flag to inform if helm did exit or quit.
0 means helm did exit when executing an action.
1 means helm did quit with \\[keyboard-quit]
Knowing this exit-status could help restore a window config when helm aborts
in some special circumstances.
See `helm-exit-minibuffer' and `helm-keyboard-quit'.")
(defvar helm-minibuffer-confirm-state nil)
(defvar helm-quit nil)
(defvar helm-attributes nil "List of all `helm' attributes.")
(defvar helm-buffers nil
"Helm buffers listed in order of most recently used.")
(defvar helm-current-position nil
"Cons of \(point . window-start\) when `helm' is invoked.
`helm-current-buffer' uses this to restore position after
`helm-keyboard-quit'")
(defvar helm-last-frame-or-window-configuration nil
"Used to store window or frame configuration at helm start.")
(defvar helm-onewindow-p nil)
(defvar helm-types nil)
(defvar helm--mode-line-string-real nil) ; The string to display in mode-line.
(defvar helm-persistent-action-display-window nil)
(defvar helm-marked-candidates nil
"Marked candadates. List of \(source . real\) pair.")
(defvar helm--mode-line-display-prefarg nil)
(defvar helm--temp-follow-flag nil
"[INTERNAL] A simple flag to notify persistent action we are following.")
(defvar helm--reading-passwd-or-string nil)
(defvar helm--in-update nil)
(defvar helm--in-fuzzy nil)
(defvar helm--maybe-use-default-as-input nil
"Flag to notify the use of use-default-as-input.
Use only in let-bindings.
Use :default arg of `helm' as input to update display.
Note that if also :input is specified as `helm' arg, it will take
precedence on :default.")
(defvar helm--temp-hooks nil
"Store temporary hooks added by `with-helm-temp-hook'.")
(defvar helm-truncate-lines nil
"[Internal] Don't set this globally, it is used as a local var.")
(defvar helm--prompt nil)
(defvar helm--file-completion-sources
'("Find Files" "Read File Name" "Read File Name History")
"Sources that use the *find-files mechanism can be added here.
Sources generated by `helm-mode' don't need to be added here
because they are automatically added.
You should not modify this yourself unless you know what you are doing.")
;; Same as `ffap-url-regexp' but keep it here to ensure `ffap-url-regexp' is not nil.
(defvar helm--url-regexp "\\(news\\(post\\)?:\\|mailto:\\|file:\\|\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\)://\\)")
;; Utility: logging
(defun helm-log (format-string &rest args)
"Log message `helm-debug' is non-`nil'.