From 4b833096df82aabe2258af265d3c06203b45c100 Mon Sep 17 00:00:00 2001 From: Thierry Volpiatto Date: Sun, 2 Oct 2011 23:25:05 +0200 Subject: [PATCH] Fix input and default args in *completing-read functions. * anything-config.el (anything-comp-read): New key 'default'. (anything-completing-read-default): Use new 'default' key. * anything.el (anything-argument-keys, anything-internal, anything-read-pattern-maybe): new arg 'default'. --- anything-config.el | 8 +++++++- anything.el | 16 ++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/anything-config.el b/anything-config.el index 8db0f46..632250b 100644 --- a/anything-config.el +++ b/anything-config.el @@ -9857,6 +9857,8 @@ Do nothing, just return candidate list unmodified." &key test initial-input + default + preselect (buffer "*Anything Completions*") must-match (requires-pattern 0) @@ -9926,6 +9928,8 @@ It support now also a function as argument, See `all-completions' for more detai (or (anything :sources `(,hist ,src) :input initial-input + :default default + :preselect preselect :prompt prompt :resume 'noresume :buffer buffer) @@ -9954,7 +9958,7 @@ Don't use it directly, use instead `anything-comp-read' in your programs \ which is more powerful. See documentation of `completing-read' and `all-completions' for details." - (let ((init (or def initial-input))) + (let ((init initial-input)) (anything-comp-read prompt collection :test predicate @@ -9965,6 +9969,8 @@ See documentation of `completing-read' and `all-completions' for details." :history (eval (or (car-safe hist) hist)) :must-match require-match :alistp nil + :default def + :preselect def :initial-input init))) (defun anything-generic-read-file-name diff --git a/anything.el b/anything.el index 50067d6..bc988ff 100644 --- a/anything.el +++ b/anything.el @@ -1531,7 +1531,8 @@ This is used in transformers to modify candidates list." ;; (@* "Core: entry point") (defconst anything-argument-keys - '(:sources :input :prompt :resume :preselect :buffer :keymap)) + '(:sources :input :prompt :resume :preselect :buffer :keymap :default)) + ;;;###autoload (defun anything (&rest plist) "Main function to execute anything sources. @@ -1654,12 +1655,13 @@ Call `anything' with only ANY-SOURCES and ANY-BUFFER as args." (defun anything-internal (&optional any-sources any-input any-prompt any-resume - any-preselect any-buffer any-keymap) + any-preselect any-buffer + any-keymap any-default) "The internal anything function called by `anything'. For ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT ANY-BUFFER and ANY-KEYMAP See `anything'." (anything-log "++++++++++++++++++++++++++++++++++++++++++++++++++++++++") - (anything-log-eval any-prompt any-preselect any-buffer any-keymap) + (anything-log-eval any-prompt any-preselect any-buffer any-keymap any-default) (unwind-protect (condition-case v (let ( ;; It is needed because `anything-source-name' is non-nil @@ -1677,7 +1679,7 @@ ANY-KEYMAP See `anything'." (anything-log "show prompt") (unwind-protect (anything-read-pattern-maybe - any-prompt any-input any-preselect any-resume any-keymap) + any-prompt any-input any-preselect any-resume any-keymap any-default) (anything-cleanup))) (prog1 (unless anything-quit (anything-execute-selection-action-1)) (anything-log "end session --------------------------------------------"))) @@ -1844,7 +1846,7 @@ It use `switch-to-buffer' or `pop-to-buffer' depending of value of (defvar anything-reading-pattern nil "Whether in `read-string' in anything or not.") (defun anything-read-pattern-maybe (any-prompt any-input - any-preselect any-resume any-keymap) + any-preselect any-resume any-keymap any-default) "Read pattern with prompt ANY-PROMPT and initial input ANY-INPUT. For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `anything'." (if (anything-resume-p any-resume) @@ -1873,7 +1875,9 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `anything'." (funcall anything-quit-if-no-candidate))) (t (let ((anything-reading-pattern t) - (tap (with-anything-current-buffer (thing-at-point 'symbol)))) + (tap (or any-default + (with-anything-current-buffer + (thing-at-point 'symbol))))) (read-string (or any-prompt "pattern: ") any-input nil tap))))))) (defun anything-create-anything-buffer (&optional test-mode) -- 2.11.4.GIT