aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-10-03 11:03:00 -0400
committerStefan Monnier2011-10-03 11:03:00 -0400
commit3dc61a0913bb72f576cfbd18ef31299f8548ab19 (patch)
tree21e3e698184ecadb233b66503b1ada4e3d93719e
parent8ea0a99305da16de73e508c943db3e844eda2e9e (diff)
downloademacs-3dc61a0913bb72f576cfbd18ef31299f8548ab19.tar.gz
emacs-3dc61a0913bb72f576cfbd18ef31299f8548ab19.zip
* lisp/minibuffer.el (completion-table-case-fold): Use currying.
(completion--styles-type, completion--cycling-threshold-type): New constants. (completion-styles, completion-category-overrides) (completion-cycle-threshold): Use them. * lisp/pcomplete.el (pcomplete-completions-at-point): Adjust call to completion-table-case-fold.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/minibuffer.el35
-rw-r--r--lisp/pcomplete.el3
3 files changed, 32 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0dab1a4f224..2a08568e74f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12011-10-03 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * minibuffer.el (completion-table-case-fold): Use currying.
4 (completion--styles-type, completion--cycling-threshold-type):
5 New constants.
6 (completion-styles, completion-category-overrides)
7 (completion-cycle-threshold): Use them.
8 * pcomplete.el (pcomplete-completions-at-point): Adjust call to
9 completion-table-case-fold.
10
12011-10-03 Stephen Berman <stephen.berman@gmx.net> 112011-10-03 Stephen Berman <stephen.berman@gmx.net>
2 12
3 * minibuffer.el (completion-category-overrides): Fix type of styles 13 * minibuffer.el (completion-category-overrides): Fix type of styles
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index ba07a119d92..e2ed07f1ef1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -216,9 +216,13 @@ You should give VAR a non-nil `risky-local-variable' property."
216 (setq ,var (,fun))) 216 (setq ,var (,fun)))
217 ,var)))) 217 ,var))))
218 218
219(defun completion-table-case-fold (table string pred action) 219(defun completion-table-case-fold (table &optional dont-fold)
220 (let ((completion-ignore-case t)) 220 "Return new completion TABLE that is case insensitive.
221 (complete-with-action action table string pred))) 221If DONT-FOLD is non-nil, return a completion table that is
222case sensitive instead."
223 (lambda (string pred action)
224 (let ((completion-ignore-case (not dont-fold)))
225 (complete-with-action action table string pred))))
222 226
223(defun completion-table-with-context (prefix table string pred action) 227(defun completion-table-with-context (prefix table string pred action)
224 ;; TODO: add `suffix' maybe? 228 ;; TODO: add `suffix' maybe?
@@ -468,6 +472,15 @@ ALL-COMPLETIONS is the function that lists the completions (it should
468follow the calling convention of `completion-all-completions'), 472follow the calling convention of `completion-all-completions'),
469and DOC describes the way this style of completion works.") 473and DOC describes the way this style of completion works.")
470 474
475(defconst completion--styles-type
476 `(repeat :tag "insert a new menu to add more styles"
477 (choice ,@(mapcar (lambda (x) (list 'const (car x)))
478 completion-styles-alist))))
479(defconst completion--cycling-threshold-type
480 '(choice (const :tag "No cycling" nil)
481 (const :tag "Always cycle" t)
482 (integer :tag "Threshold")))
483
471(defcustom completion-styles 484(defcustom completion-styles
472 ;; First, use `basic' because prefix completion has been the standard 485 ;; First, use `basic' because prefix completion has been the standard
473 ;; for "ever" and works well in most cases, so using it first 486 ;; for "ever" and works well in most cases, so using it first
@@ -486,8 +499,7 @@ The available styles are listed in `completion-styles-alist'.
486 499
487Note that `completion-category-overrides' may override these 500Note that `completion-category-overrides' may override these
488styles for specific categories, such as files, buffers, etc." 501styles for specific categories, such as files, buffers, etc."
489 :type `(repeat (choice ,@(mapcar (lambda (x) (list 'const (car x))) 502 :type completion--styles-type
490 completion-styles-alist)))
491 :group 'minibuffer 503 :group 'minibuffer
492 :version "23.1") 504 :version "23.1")
493 505
@@ -501,19 +513,16 @@ an association list that can specify properties such as:
501 :type `(alist :key-type (choice :tag "Category" 513 :type `(alist :key-type (choice :tag "Category"
502 (const buffer) 514 (const buffer)
503 (const file) 515 (const file)
516 (const unicode-name)
504 symbol) 517 symbol)
505 :value-type 518 :value-type
506 (set :tag "Properties to override" 519 (set :tag "Properties to override"
507 (cons :tag "Completion Styles" 520 (cons :tag "Completion Styles"
508 (const :tag "Select a style from the menu;" styles) 521 (const :tag "Select a style from the menu;" styles)
509 (repeat :tag "insert a new menu to add more styles" 522 ,completion--styles-type)
510 (choice ,@(mapcar (lambda (x) (list 'const (car x)))
511 completion-styles-alist))))
512 (cons :tag "Completion Cycling" 523 (cons :tag "Completion Cycling"
513 (const :tag "Select one value from the menu." cycle) 524 (const :tag "Select one value from the menu." cycle)
514 (choice (const :tag "No cycling" nil) 525 ,completion--cycling-threshold-type))))
515 (const :tag "Always cycle" t)
516 (integer :tag "Threshold"))))))
517 526
518(defun completion--styles (metadata) 527(defun completion--styles (metadata)
519 (let* ((cat (completion-metadata-get metadata 'category)) 528 (let* ((cat (completion-metadata-get metadata 'category))
@@ -599,9 +608,7 @@ If nil, cycling is never used.
599If t, cycling is always used. 608If t, cycling is always used.
600If an integer, cycling is used as soon as there are fewer completion 609If an integer, cycling is used as soon as there are fewer completion
601candidates than this number." 610candidates than this number."
602 :type '(choice (const :tag "No cycling" nil) 611 :type completion--cycling-threshold-type)
603 (const :tag "Always cycle" t)
604 (integer :tag "Threshold")))
605 612
606(defun completion--cycle-threshold (metadata) 613(defun completion--cycle-threshold (metadata)
607 (let* ((cat (completion-metadata-get metadata 'category)) 614 (let* ((cat (completion-metadata-get metadata 'category))
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 4ac69df8e3a..4b25c1643af 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -523,8 +523,7 @@ Same as `pcomplete' but using the standard completion UI."
523 (funcall norm-func (directory-file-name f)) 523 (funcall norm-func (directory-file-name f))
524 seen))))))) 524 seen)))))))
525 (when pcomplete-ignore-case 525 (when pcomplete-ignore-case
526 (setq table 526 (setq table (completion-table-case-fold table)))
527 (apply-partially #'completion-table-case-fold table)))
528 (list beg (point) table 527 (list beg (point) table
529 :predicate pred 528 :predicate pred
530 :exit-function 529 :exit-function