阻止lisp要求用户输入

时间:2013-08-01 21:10:09

标签: emacs lisp prompt

我正在尝试修改igrep.el包以执行特定功能。 执行M-x igrep-find时,程序包会询问用户默认情况下具有“当前缓冲区”类型的文件类型。 我想默认文件类型grep on是*。[sch]所以我添加了一行:

(defvar default-files-string-new“*。[sch]”)

我正在尝试修改以下函数以停止向用户询问文件类型,并默认默认为上面指定的变量。

(defvar default-files-string-new "*.[sch]")
(defun igrep-read-files (&optional prompt-prefix)
  "Read and return a file name pattern from the minibuffer.
If `current-prefix-arg' is '(16) or '(64), read multiple file name
patterns and return them in a list.  Optional PROMPT-PREFIX is
prepended to the \"File(s): \" prompt."
  (let* ((default-files (igrep-default-files))
         (default-files-string (mapconcat 'identity default-files " "))
         (insert-default-directory igrep-insert-default-directory)
         (file (igrep-read-file-name
                (igrep-prefix prompt-prefix
                              (if default-files
                                  (format "File(s) [default: %s]: "
                                          default-files-string)
                                "File(s): "))
                nil (if default-files default-files-string "") nil nil
                'igrep-files-history))
         (files (list file)))
    (if (or igrep-read-multiple-files
            (and (consp current-prefix-arg)
                 (memq (prefix-numeric-value current-prefix-arg)
                       '(16 64))))
        (let* ((key (igrep-default-key 'exit-minibuffer
                                       minibuffer-local-completion-map
                                       "\r"))
               (prompt
                (igrep-prefix prompt-prefix
                              (if igrep-verbose-prompts
                                  (format "File(s): [Type `%s' when done] "
                                          (key-description key))
                                "File(s): "))))
          (while (and (setq file
                            (igrep-read-file-name prompt
                                                  nil "" nil nil
                                                  'igrep-files-history))
                      (not (equal file "")))
            (setq files (cons file files)))))
    (mapcar (lambda (file)
              (if (file-directory-p file)
                  ;; really should map expand-file-name over default-files:
                  (expand-file-name (if default-files default-files-string-new "*")
                                    file)
                file))
            (nreverse files))))

1 个答案:

答案 0 :(得分:1)

也许我误解了。如果你不想输入那么完全​​替换函数会不会更容易?

(defvar default-files-string-new "*.sch")
(defun igrep-read-files (&optional prompt-prefix)
  `(,(expand-file-name (concat default-directory
                               default-files-string-new))))