]> code.delx.au - gnu-emacs/blobdiff - lisp/ido.el
(gdb-if-arrow): New macro.
[gnu-emacs] / lisp / ido.el
index 6c51fb075cddb50f9754c18e12b74c9127dacc14..ad3f4329e6bc4a6f7e3b14ccb2a1c89d119b3fd0 100644 (file)
@@ -1040,6 +1040,10 @@ so that it doesn't interfere with other minibuffer usage.")
 (defvar ido-incomplete-regexp nil
   "Non-nil if an incomplete regexp is entered.")
 
+(defvar ido-initial-position nil
+  "Non-nil means to explicitly cursor on entry to minibuffer.
+Value is an integer which is number of chars to right of prompt.")
+
 ;;; Variables with dynamic bindings.
 ;;; Declared here to keep the byte compiler quiet.
 
@@ -1852,6 +1856,8 @@ If INITIAL is non-nil, it specifies the initial input string."
        (if (member ido-default-item ido-ignore-item-temp-list)
            (setq ido-default-item nil))
        (ido-trace "new default" ido-default-item)
+       (if ido-default-item
+           (setq ido-initial-position 0))
        (setq ido-set-default-item nil))
 
       (if ido-process-ignore-lists-inhibit
@@ -2122,11 +2128,14 @@ If INITIAL is non-nil, it specifies the initial input string."
     ido-selected))
 
 (defun ido-edit-input ()
-  "Edit absolute file name entered so far with ido; terminate by RET."
+  "Edit absolute file name entered so far with ido; terminate by RET.
+If cursor is not at the end of the user input, move to end of input."
   (interactive)
-  (setq ido-text-init (if ido-matches (ido-name (car ido-matches)) ido-text))
-  (setq ido-exit 'edit)
-  (exit-minibuffer))
+  (if (not (eobp))
+      (end-of-line)
+    (setq ido-text-init (if ido-matches (ido-name (car ido-matches)) ido-text))
+    (setq ido-exit 'edit)
+    (exit-minibuffer)))
 
 ;;; MAIN FUNCTIONS
 (defun ido-buffer-internal (method &optional fallback prompt default initial switch-cmd)
@@ -2394,8 +2403,8 @@ If INITIAL is non-nil, it specifies the initial input string."
 (defun ido-set-common-completion  ()
   ;; Find common completion of `ido-text' in `ido-matches'
   ;; The result is stored in `ido-common-match-string'
-  (let* (val)
-    (setq  ido-common-match-string nil)
+  (let (val)
+    (setq ido-common-match-string nil)
     (if (and ido-matches
             (not ido-enable-regexp) ;; testing
              (stringp ido-text)
@@ -2544,6 +2553,10 @@ C-x C-b C-b  fallback to non-ido `switch-to-buffer'."
   (cond
    ((> (point) (minibuffer-prompt-end))
     (forward-char -1))
+   ((eq last-command this-command)
+    (when (and (memq ido-cur-item '(file dir))
+              (not (bobp)))
+      (ido-push-dir))) ; else do nothing
    ((eq ido-cur-item 'buffer)
     (ido-fallback-command))
    (ido-context-switch-command
@@ -2593,14 +2606,16 @@ C-x C-f ... C-d  enter dired on current directory."
 (defun ido-toggle-ignore ()
   "Toggle ignoring files specified with `ido-ignore-files'."
   (interactive)
-  (if ido-directory-too-big
-      (progn
-       (message "Reading directory...")
-       (setq ido-directory-too-big nil))
-    (setq ido-process-ignore-lists (not ido-process-ignore-lists)))
-  (setq ido-text-init ido-text)
-  (setq ido-exit 'refresh)
-  (exit-minibuffer))
+  (if (and (not (eobp)) (> (point) (minibuffer-prompt-end)))
+      (goto-char (minibuffer-prompt-end))
+    (if ido-directory-too-big
+       (progn
+         (message "Reading directory...")
+         (setq ido-directory-too-big nil))
+      (setq ido-process-ignore-lists (not ido-process-ignore-lists)))
+    (setq ido-text-init ido-text)
+    (setq ido-exit 'refresh)
+    (exit-minibuffer)))
 
 (defun ido-toggle-vc ()
   "Disable version control for this file."
@@ -3785,39 +3800,45 @@ for first matching file."
 
 ;;; KILL CURRENT BUFFER
 (defun ido-kill-buffer-at-head ()
-  "Kill the buffer at the head of `ido-matches'."
+  "Kill the buffer at the head of `ido-matches'.
+If cursor is not at the end of the user input, delete to end of input."
   (interactive)
-  (let ((enable-recursive-minibuffers t)
-       (buf (ido-name (car ido-matches))))
-    (when buf
-      (kill-buffer buf)
-      ;; Check if buffer still exists.
-      (if (get-buffer buf)
-         ;; buffer couldn't be killed.
-         (setq ido-rescan t)
-       ;; else buffer was killed so remove name from list.
-       (setq ido-cur-list (delq buf ido-cur-list))))))
+  (if (not (eobp))
+      (kill-line)
+    (let ((enable-recursive-minibuffers t)
+         (buf (ido-name (car ido-matches))))
+      (when buf
+       (kill-buffer buf)
+       ;; Check if buffer still exists.
+       (if (get-buffer buf)
+           ;; buffer couldn't be killed.
+           (setq ido-rescan t)
+         ;; else buffer was killed so remove name from list.
+         (setq ido-cur-list (delq buf ido-cur-list)))))))
 
 ;;; DELETE CURRENT FILE
 (defun ido-delete-file-at-head ()
-  "Delete the file at the head of `ido-matches'."
+  "Delete the file at the head of `ido-matches'.
+If cursor is not at the end of the user input, delete to end of input."
   (interactive)
-  (let ((enable-recursive-minibuffers t)
-       (file (ido-name (car ido-matches))))
-    (if file
-       (setq file (concat ido-current-directory file)))
-    (when (and file
-              (file-exists-p file)
-              (not (file-directory-p file))
-              (file-writable-p ido-current-directory)
-              (yes-or-no-p (concat "Delete " file "? ")))
-      (delete-file file)
-      ;; Check if file still exists.
-      (if (file-exists-p file)
-         ;; file could not be deleted
-         (setq ido-rescan t)
-       ;; else file was killed so remove name from list.
-       (setq ido-cur-list (delq (car ido-matches) ido-cur-list))))))
+  (if (not (eobp))
+      (kill-line)
+    (let ((enable-recursive-minibuffers t)
+         (file (ido-name (car ido-matches))))
+      (if file
+         (setq file (concat ido-current-directory file)))
+      (when (and file
+                (file-exists-p file)
+                (not (file-directory-p file))
+                (file-writable-p ido-current-directory)
+                (yes-or-no-p (concat "Delete " file "? ")))
+       (delete-file file)
+       ;; Check if file still exists.
+       (if (file-exists-p file)
+           ;; file could not be deleted
+           (setq ido-rescan t)
+         ;; else file was killed so remove name from list.
+         (setq ido-cur-list (delq (car ido-matches) ido-cur-list)))))))
 
 
 ;;; VISIT CHOSEN BUFFER
@@ -3918,7 +3939,7 @@ in a separate window.
 (defun ido-switch-buffer-other-window ()
   "Switch to another buffer and show it in another window.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido'."
+For details of keybindings, see `ido-switch-buffer'."
   (interactive)
   (ido-buffer-internal 'other-window 'switch-to-buffer-other-window))
 
@@ -3926,7 +3947,7 @@ For details of keybindings, do `\\[describe-function] ido'."
 (defun ido-display-buffer ()
   "Display a buffer in another window but don't select it.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido'."
+For details of keybindings, see `ido-switch-buffer'."
   (interactive)
   (ido-buffer-internal 'display 'display-buffer nil nil nil 'ignore))
 
@@ -3934,7 +3955,7 @@ For details of keybindings, do `\\[describe-function] ido'."
 (defun ido-kill-buffer ()
   "Kill a buffer.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido'."
+For details of keybindings, see `ido-switch-buffer'."
   (interactive)
   (ido-buffer-internal 'kill 'kill-buffer "Kill buffer: " (buffer-name (current-buffer)) nil 'ignore))
 
@@ -3942,7 +3963,7 @@ For details of keybindings, do `\\[describe-function] ido'."
 (defun ido-insert-buffer ()
   "Insert contents of a buffer in current buffer after point.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido'."
+For details of keybindings, see `ido-switch-buffer'."
   (interactive)
   (ido-buffer-internal 'insert 'insert-buffer "Insert buffer: " nil nil 'ido-enter-insert-file))
 
@@ -3950,7 +3971,7 @@ For details of keybindings, do `\\[describe-function] ido'."
 (defun ido-switch-buffer-other-frame ()
   "Switch to another buffer and show it in another frame.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido'."
+For details of keybindings, see `ido-switch-buffer'."
   (interactive)
   (if ido-mode
       (ido-buffer-internal 'other-frame)
@@ -4013,7 +4034,7 @@ in a separate window.
 (defun ido-find-file-other-window ()
   "Switch to another file and show it in another window.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'other-window 'find-file-other-window))
 
@@ -4021,7 +4042,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-find-alternate-file ()
   "Switch to another file and show it in another window.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'alt-file 'find-alternate-file nil "Find alternate file: "))
 
@@ -4029,7 +4050,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-find-file-read-only ()
   "Edit file read-only with name obtained via minibuffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'read-only 'find-file-read-only nil "Find file read-only: "))
 
@@ -4037,7 +4058,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-find-file-read-only-other-window ()
   "Edit file read-only in other window with name obtained via minibuffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'read-only 'find-file-read-only-other-window nil "Find file read-only other window: "))
 
@@ -4045,7 +4066,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-find-file-read-only-other-frame ()
   "Edit file read-only in other frame with name obtained via minibuffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'read-only 'find-file-read-only-other-frame nil "Find file read-only other frame: "))
 
@@ -4053,7 +4074,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-display-file ()
   "Display a file in another window but don't select it.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'display nil nil nil nil nil 'ignore))
 
@@ -4061,7 +4082,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-find-file-other-frame ()
   "Switch to another file and show it in another frame.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'other-frame 'find-file-other-frame))
 
@@ -4069,7 +4090,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-write-file ()
   "Write current buffer to a file.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (let ((ido-process-ignore-lists t)
        (ido-work-directory-match-only nil)
@@ -4083,7 +4104,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-insert-file ()
   "Insert contents of file in current buffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (ido-file-internal 'insert 'insert-file nil "Insert file: " nil nil 'ido-enter-insert-buffer))
 
@@ -4091,7 +4112,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-dired ()
   "Call `dired' the ido way.
 The directory is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (let ((ido-report-no-match nil)
        (ido-auto-merge-work-directories-length -1))
@@ -4100,7 +4121,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 (defun ido-list-directory ()
   "Call `list-directory' the ido way.
 The directory is selected interactively by typing a substring.
-For details of keybindings, do `\\[describe-function] ido-find-file'."
+For details of keybindings, see `ido-find-file'."
   (interactive)
   (let ((ido-report-no-match nil)
        (ido-auto-merge-work-directories-length -1))
@@ -4453,7 +4474,10 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
     (when (featurep 'xemacs)
       (ido-exhibit)
       (goto-char (point-min)))
-    (run-hooks 'ido-minibuffer-setup-hook)))
+    (run-hooks 'ido-minibuffer-setup-hook)
+    (when ido-initial-position
+      (goto-char (+ (minibuffer-prompt-end) ido-initial-position))
+      (setq ido-initial-position nil))))
 
 (defun ido-tidy ()
   "Pre command hook for `ido'."