(defcustom minibuffer-history-uniquify t
"*Non-nil means when adding an item to a minibuffer history, remove
-previous occurances of the same item from the history list first,
+previous occurrences of the same item from the history list first,
rather than just consing the new element onto the front of the list."
:type 'boolean
:group 'minibuffer)
(define-key map "\M-\t" 'comint-dynamic-complete)
(define-key map "\M-?" 'comint-dynamic-list-completions)
map)
- "Minibuffer keymap used by shell-command and related commands.")
+ "Minibuffer keymap used by `shell-command' and related commands.")
(defcustom use-dialog-box t
"*Variable controlling usage of the dialog box.
Seventh arg DEFAULT, if non-nil, will be returned when user enters
an empty string.
-See also the variable completion-highlight-first-word-only for control over
- completion display."
+See also the variable `completion-highlight-first-word-only' for
+ control over completion display."
(if (and (not enable-recursive-minibuffers)
(> (minibuffer-depth) 0)
(eq (selected-window) (minibuffer-window)))
(defun minibuffer-smart-maybe-select-highlighted-completion
(event &optional click-count)
- "Like minibuffer-smart-select-highlighted-completion but does nothing if
+ "Like `minibuffer-smart-select-highlighted-completion' but does nothing if
there is no completion (as opposed to executing the global binding). Useful
as the value of `mouse-track-click-hook'."
(interactive "e")
current-minibuffer-point (point)))
(let ((narg (- minibuffer-history-position n))
(minimum (if minibuffer-default -1 0)))
+ ;; a weird special case here; when in repeat-complex-command, we're
+ ;; trying to edit the top command, and minibuffer-history-position
+ ;; points to 1, the next-to-top command. in this case, the top
+ ;; command in the history is suppressed in favor of the one being
+ ;; edited, and there is no more command below it, except maybe the
+ ;; default.
+ (if (and (zerop narg) (eq minibuffer-history-position
+ initial-minibuffer-history-position))
+ (setq minimum (1+ minimum)))
(cond ((< narg minimum)
(error (if minibuffer-default
"No following item in %s"
(progn
(insert current-minibuffer-contents)
(goto-char current-minibuffer-point))
- (let ((elt (if (>= narg 0)
+ (let ((elt (if (> narg 0)
(nth (1- minibuffer-history-position)
(symbol-value minibuffer-history-variable))
minibuffer-default)))
(setq n (1+ n))))
new)))
+
+;; Wrapper for `directory-files' for use in generating completion lists.
+;; Generates output in the same format as `file-name-all-completions'.
+;;
+;; The EFS replacement for `directory-files' doesn't support the FILES-ONLY
+;; option, so it has to be faked. The listing cache will hopefully
+;; improve the performance of this operation.
+(defun minibuf-directory-files (dir &optional match-regexp files-only)
+ (let ((want-file (or (eq files-only nil) (eq files-only t)))
+ (want-dirs (or (eq files-only nil) (not (eq files-only t)))))
+ (delete nil
+ (mapcar (function (lambda (f)
+ (if (file-directory-p (expand-file-name f dir))
+ (and want-dirs (file-name-as-directory f))
+ (and want-file f))))
+ (delete "." (directory-files dir nil match-regexp))))))
+
+
(defun read-file-name-2 (history prompt dir default
must-match initial-contents
completer)
(reset-buffer completion-buf)
(let ((standard-output completion-buf))
(display-completion-list
- (delete "." (directory-files full nil nil nil (if dir-p 'directory)))
+ (minibuf-directory-files full nil (if dir-p 'directory))
:user-data dir-p
:reference-buffer minibuf
:activate-callback 'read-file-name-activate-callback)
must-match initial-contents
completer)
(if (should-use-dialog-box-p)
- ;; this calls read-file-name-2
- (mouse-read-file-name-1 history prompt dir default must-match
- initial-contents completer)
+ (condition-case nil
+ (let ((file
+ (apply #'make-dialog-box
+ 'file `(:title ,(capitalize-string-as-title
+ ;; Kludge: Delete ": " off the end.
+ (replace-in-string prompt ": $" ""))
+ ,@(and dir (list :initial-directory
+ dir))
+ :file-must-exist ,must-match
+ ,@(and initial-contents
+ (list :initial-filename
+ initial-contents))))))
+ ;; hack -- until we implement reading a directory properly,
+ ;; allow a file as indicating the directory it's in
+ (if (and (eq completer 'read-directory-name-internal)
+ (not (file-directory-p file)))
+ (file-name-directory file)
+ file))
+ (unimplemented
+ ;; this calls read-file-name-2
+ (mouse-read-file-name-1 history prompt dir default must-match
+ initial-contents completer)
+ ))
(add-one-shot-hook
'minibuffer-setup-hook
(lambda ()
((eq action 't)
;; all completions
(mapcar #'un-substitute-in-file-name
- (file-name-all-completions name dir)))
+ (if (string= name "")
+ (delete "./" (file-name-all-completions "" dir))
+ (file-name-all-completions name dir))))
(t;; nil
;; complete
(let* ((d (or dir default-directory))
#'(lambda (action orig string specdir dir name)
(let* ((dirs #'(lambda (fn)
(let ((l (if (equal name "")
- (directory-files
+ (minibuf-directory-files
dir
- nil
""
- nil
'directories)
- (directory-files
+ (minibuf-directory-files
dir
- nil
(concat "\\`" (regexp-quote name))
- nil
'directories))))
(mapcar fn
;; Wretched unix
;; a specifier would be nice.
(set (make-local-variable 'frame-title-format)
(capitalize-string-as-title
- ;; Delete ": " off the end. There must be an easier way!
- (let ((end-pos (length prompt)))
- (if (and (> end-pos 0) (eq (aref prompt (1- end-pos)) ? ))
- (setq end-pos (1- end-pos)))
- (if (and (> end-pos 0) (eq (aref prompt (1- end-pos)) ?:))
- (setq end-pos (1- end-pos)))
- (substring prompt 0 end-pos))))
+ ;; Kludge: Delete ": " off the end.
+ (replace-in-string prompt ": $" "")))
;; ensure that killing the frame works right,
;; instead of leaving us in the minibuffer.
(add-local-hook 'delete-frame-hook
(let ((standard-output (window-buffer window)))
(condition-case nil
(display-completion-list
- (directory-files dir nil nil nil t)
+ (minibuf-directory-files dir nil t)
:window-width (window-width window)
:window-height (window-text-area-height window)
:completion-string ""
(let ((standard-output (window-buffer window)))
(condition-case nil
(display-completion-list
- (delete "." (directory-files dir nil nil nil 1))
+ (minibuf-directory-files dir nil 1)
:window-width (window-width window)
:window-height (window-text-area-height window)
:completion-string ""