diff options
author | Philipp Stephani <phst@google.com> | 2017-04-20 15:41:15 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2017-04-23 18:42:42 +0200 |
commit | a1f93c1dfa53dbe007faa09ab0c6e913e86e3ffe (patch) | |
tree | 4468a3c2fa5e83ced8a42378e4b2453199d1f5b8 | |
parent | a02885a37031ec0e199dcb38ff9cb93e65e7b7cb (diff) | |
download | emacs-a1f93c1dfa53dbe007faa09ab0c6e913e86e3ffe.tar.gz |
Add missing remappings for Ido mode
Among others, add a remapping for C-x 4 d, cf. Bug#26360.
* lisp/ido.el (ido-mode): Remap missing commands.
(ido-file-internal, ido-visit-buffer): Add support for new
methods.
(ido-display-buffer-other-frame)
(ido-find-alternate-file-other-window, ido-dired-other-window)
(ido-dired-other-frame): New commands.
* test/lisp/ido-tests.el (ido-tests--other-window-frame): Add unit
test for the bindings.
-rw-r--r-- | etc/NEWS | 7 | ||||
-rw-r--r-- | lisp/ido.el | 61 | ||||
-rw-r--r-- | test/lisp/ido-tests.el | 47 |
3 files changed, 112 insertions, 3 deletions
@@ -555,6 +555,13 @@ replaced by the real images asynchronously, which will also now respect width/height HTML specs (unless they specify widths/heights bigger than the current window). +** Ido + +*** The commands 'find-alternate-file-other-window', +'dired-other-window', 'dired-other-frame', and +'display-buffer-other-window' are now remapped to Ido equivalents if +Ido mode is active. + ** Images +++ diff --git a/lisp/ido.el b/lisp/ido.el index 293c8e28570..318f2fe082a 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -1640,10 +1640,14 @@ This function also adds a hook to the minibuffer." 'ido-find-file-other-window) (define-key map [remap find-file-read-only-other-window] 'ido-find-file-read-only-other-window) + (define-key map [remap find-alternate-file-other-window] + #'ido-find-alternate-file-other-window) + (define-key map [remap dired-other-window] #'ido-dired-other-window) (define-key map [remap find-file-other-frame] 'ido-find-file-other-frame) (define-key map [remap find-file-read-only-other-frame] - 'ido-find-file-read-only-other-frame)) + 'ido-find-file-read-only-other-frame) + (define-key map [remap dired-other-frame] #'ido-dired-other-frame)) (when (memq ido-mode '(buffer both)) (define-key map [remap switch-to-buffer] 'ido-switch-buffer) @@ -1653,7 +1657,9 @@ This function also adds a hook to the minibuffer." 'ido-switch-buffer-other-frame) (define-key map [remap insert-buffer] 'ido-insert-buffer) (define-key map [remap kill-buffer] 'ido-kill-buffer) - (define-key map [remap display-buffer] 'ido-display-buffer)) + (define-key map [remap display-buffer] 'ido-display-buffer) + (define-key map [remap display-buffer-other-frame] + #'ido-display-buffer-other-frame)) (if ido-minor-mode-map-entry (setcdr ido-minor-mode-map-entry map) @@ -2443,7 +2449,14 @@ If cursor is not at the end of the user input, move to end of input." (ido-record-work-directory) (find-alternate-file filename)) - ((memq method '(dired list-directory)) + ((eq method 'alt-file-other-window) + (ido-record-work-file filename) + (setq default-directory ido-current-directory) + (ido-record-work-directory) + (find-alternate-file-other-window filename)) + + ((memq method '(dired dired-other-window dired-other-frame + list-directory)) (if (equal filename ".") (setq filename "")) (let* ((dirname (ido-final-slash @@ -4108,6 +4121,9 @@ Record command in `command-history' if optional RECORD is non-nil." (switch-to-buffer-other-frame buffer) (select-frame-set-input-focus (selected-frame))) + ((eq method 'display-other-frame) + (display-buffer-other-frame buffer)) + ((and (memq method '(raise-frame maybe-frame)) window-system (setq win (ido-buffer-window-other-frame buffer)) @@ -4193,6 +4209,15 @@ For details of keybindings, see `ido-switch-buffer'." (ido-buffer-internal 'display 'display-buffer nil nil nil 'ignore)) ;;;###autoload +(defun ido-display-buffer-other-frame () + "Display a buffer preferably in another frame. +The buffer name is selected interactively by typing a substring. +For details of keybindings, see `ido-switch-buffer'." + (interactive) + (ido-buffer-internal 'display-other-frame #'display-buffer-other-frame + nil nil nil #'ignore)) + +;;;###autoload (defun ido-kill-buffer () "Kill a buffer. The buffer name is selected interactively by typing a substring. @@ -4291,6 +4316,14 @@ For details of keybindings, see `ido-find-file'." (ido-file-internal 'alt-file 'find-alternate-file nil "Find alternate file: ")) ;;;###autoload +(defun ido-find-alternate-file-other-window () + "Find file as a replacement for the file in the next window. +The file name is selected interactively by typing a substring. +For details of keybindings, see `ido-find-file'." + (interactive) + (ido-file-internal 'alt-file-other-window #'find-alternate-file-other-window)) + +;;;###autoload (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. @@ -4364,6 +4397,28 @@ For details of keybindings, see `ido-find-file'." (ido-auto-merge-work-directories-length -1)) (ido-file-internal 'dired 'dired nil "Dired: " 'dir))) +;;;###autoload +(defun ido-dired-other-window () + "\"Edit\" a directory. Like `ido-dired' but selects in another window. +The directory is selected interactively by typing a substring. +For details of keybindings, see `ido-find-file'." + (interactive) + (let ((ido-report-no-match nil) + (ido-auto-merge-work-directories-length -1)) + (ido-file-internal 'dired-other-window #'dired-other-window nil + "Dired: " 'dir))) + +;;;###autoload +(defun ido-dired-other-frame () + "\"Edit\" a directory. Like `ido-dired' but makes a new frame. +The directory is selected interactively by typing a substring. +For details of keybindings, see `ido-find-file'." + (interactive) + (let ((ido-report-no-match nil) + (ido-auto-merge-work-directories-length -1)) + (ido-file-internal 'dired-other-frame #'dired-other-frame nil + "Dired: " 'dir))) + (defun ido-list-directory () "Call `list-directory' the Ido way. The directory is selected interactively by typing a substring. diff --git a/test/lisp/ido-tests.el b/test/lisp/ido-tests.el new file mode 100644 index 00000000000..df110969312 --- /dev/null +++ b/test/lisp/ido-tests.el @@ -0,0 +1,47 @@ +;;; ido-tests.el --- unit tests for ido.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Philipp Stephani <phst@google.com> + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Unit tests for ido.el. + +;;; Code: + +(ert-deftest ido-tests--other-window-frame () + "Verifies that Bug#26360 is fixed." + (should-not ido-mode) + (unwind-protect + (progn + (ido-mode) + (should (equal ido-mode 'both)) + (should (equal (key-binding [remap find-alternate-file-other-window]) + #'ido-find-alternate-file-other-window)) + (should (commandp #'ido-find-alternate-file-other-window)) + (should (equal (key-binding (kbd "C-x 4 d")) #'ido-dired-other-window)) + (should (commandp #'ido-dired-other-window)) + (should (equal (key-binding (kbd "C-x 5 d")) #'ido-dired-other-frame)) + (should (commandp #'ido-dired-other-frame)) + (should (equal (key-binding (kbd "C-x 5 C-o")) + #'ido-display-buffer-other-frame)) + (should (commandp #'ido-display-buffer-other-frame))) + (ido-mode 0))) + +;;; ido-tests.el ends here |