diff options
| author | Philipp Stephani | 2017-04-20 15:41:15 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-04-23 18:42:42 +0200 |
| commit | a1f93c1dfa53dbe007faa09ab0c6e913e86e3ffe (patch) | |
| tree | 4468a3c2fa5e83ced8a42378e4b2453199d1f5b8 | |
| parent | a02885a37031ec0e199dcb38ff9cb93e65e7b7cb (diff) | |
| download | emacs-a1f93c1dfa53dbe007faa09ab0c6e913e86e3ffe.tar.gz emacs-a1f93c1dfa53dbe007faa09ab0c6e913e86e3ffe.zip | |
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 | |||
| 555 | respect width/height HTML specs (unless they specify widths/heights | 555 | respect width/height HTML specs (unless they specify widths/heights |
| 556 | bigger than the current window). | 556 | bigger than the current window). |
| 557 | 557 | ||
| 558 | ** Ido | ||
| 559 | |||
| 560 | *** The commands 'find-alternate-file-other-window', | ||
| 561 | 'dired-other-window', 'dired-other-frame', and | ||
| 562 | 'display-buffer-other-window' are now remapped to Ido equivalents if | ||
| 563 | Ido mode is active. | ||
| 564 | |||
| 558 | ** Images | 565 | ** Images |
| 559 | 566 | ||
| 560 | +++ | 567 | +++ |
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." | |||
| 1640 | 'ido-find-file-other-window) | 1640 | 'ido-find-file-other-window) |
| 1641 | (define-key map [remap find-file-read-only-other-window] | 1641 | (define-key map [remap find-file-read-only-other-window] |
| 1642 | 'ido-find-file-read-only-other-window) | 1642 | 'ido-find-file-read-only-other-window) |
| 1643 | (define-key map [remap find-alternate-file-other-window] | ||
| 1644 | #'ido-find-alternate-file-other-window) | ||
| 1645 | (define-key map [remap dired-other-window] #'ido-dired-other-window) | ||
| 1643 | (define-key map [remap find-file-other-frame] | 1646 | (define-key map [remap find-file-other-frame] |
| 1644 | 'ido-find-file-other-frame) | 1647 | 'ido-find-file-other-frame) |
| 1645 | (define-key map [remap find-file-read-only-other-frame] | 1648 | (define-key map [remap find-file-read-only-other-frame] |
| 1646 | 'ido-find-file-read-only-other-frame)) | 1649 | 'ido-find-file-read-only-other-frame) |
| 1650 | (define-key map [remap dired-other-frame] #'ido-dired-other-frame)) | ||
| 1647 | 1651 | ||
| 1648 | (when (memq ido-mode '(buffer both)) | 1652 | (when (memq ido-mode '(buffer both)) |
| 1649 | (define-key map [remap switch-to-buffer] 'ido-switch-buffer) | 1653 | (define-key map [remap switch-to-buffer] 'ido-switch-buffer) |
| @@ -1653,7 +1657,9 @@ This function also adds a hook to the minibuffer." | |||
| 1653 | 'ido-switch-buffer-other-frame) | 1657 | 'ido-switch-buffer-other-frame) |
| 1654 | (define-key map [remap insert-buffer] 'ido-insert-buffer) | 1658 | (define-key map [remap insert-buffer] 'ido-insert-buffer) |
| 1655 | (define-key map [remap kill-buffer] 'ido-kill-buffer) | 1659 | (define-key map [remap kill-buffer] 'ido-kill-buffer) |
| 1656 | (define-key map [remap display-buffer] 'ido-display-buffer)) | 1660 | (define-key map [remap display-buffer] 'ido-display-buffer) |
| 1661 | (define-key map [remap display-buffer-other-frame] | ||
| 1662 | #'ido-display-buffer-other-frame)) | ||
| 1657 | 1663 | ||
| 1658 | (if ido-minor-mode-map-entry | 1664 | (if ido-minor-mode-map-entry |
| 1659 | (setcdr ido-minor-mode-map-entry map) | 1665 | (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." | |||
| 2443 | (ido-record-work-directory) | 2449 | (ido-record-work-directory) |
| 2444 | (find-alternate-file filename)) | 2450 | (find-alternate-file filename)) |
| 2445 | 2451 | ||
| 2446 | ((memq method '(dired list-directory)) | 2452 | ((eq method 'alt-file-other-window) |
| 2453 | (ido-record-work-file filename) | ||
| 2454 | (setq default-directory ido-current-directory) | ||
| 2455 | (ido-record-work-directory) | ||
| 2456 | (find-alternate-file-other-window filename)) | ||
| 2457 | |||
| 2458 | ((memq method '(dired dired-other-window dired-other-frame | ||
| 2459 | list-directory)) | ||
| 2447 | (if (equal filename ".") | 2460 | (if (equal filename ".") |
| 2448 | (setq filename "")) | 2461 | (setq filename "")) |
| 2449 | (let* ((dirname (ido-final-slash | 2462 | (let* ((dirname (ido-final-slash |
| @@ -4108,6 +4121,9 @@ Record command in `command-history' if optional RECORD is non-nil." | |||
| 4108 | (switch-to-buffer-other-frame buffer) | 4121 | (switch-to-buffer-other-frame buffer) |
| 4109 | (select-frame-set-input-focus (selected-frame))) | 4122 | (select-frame-set-input-focus (selected-frame))) |
| 4110 | 4123 | ||
| 4124 | ((eq method 'display-other-frame) | ||
| 4125 | (display-buffer-other-frame buffer)) | ||
| 4126 | |||
| 4111 | ((and (memq method '(raise-frame maybe-frame)) | 4127 | ((and (memq method '(raise-frame maybe-frame)) |
| 4112 | window-system | 4128 | window-system |
| 4113 | (setq win (ido-buffer-window-other-frame buffer)) | 4129 | (setq win (ido-buffer-window-other-frame buffer)) |
| @@ -4193,6 +4209,15 @@ For details of keybindings, see `ido-switch-buffer'." | |||
| 4193 | (ido-buffer-internal 'display 'display-buffer nil nil nil 'ignore)) | 4209 | (ido-buffer-internal 'display 'display-buffer nil nil nil 'ignore)) |
| 4194 | 4210 | ||
| 4195 | ;;;###autoload | 4211 | ;;;###autoload |
| 4212 | (defun ido-display-buffer-other-frame () | ||
| 4213 | "Display a buffer preferably in another frame. | ||
| 4214 | The buffer name is selected interactively by typing a substring. | ||
| 4215 | For details of keybindings, see `ido-switch-buffer'." | ||
| 4216 | (interactive) | ||
| 4217 | (ido-buffer-internal 'display-other-frame #'display-buffer-other-frame | ||
| 4218 | nil nil nil #'ignore)) | ||
| 4219 | |||
| 4220 | ;;;###autoload | ||
| 4196 | (defun ido-kill-buffer () | 4221 | (defun ido-kill-buffer () |
| 4197 | "Kill a buffer. | 4222 | "Kill a buffer. |
| 4198 | The buffer name is selected interactively by typing a substring. | 4223 | The buffer name is selected interactively by typing a substring. |
| @@ -4291,6 +4316,14 @@ For details of keybindings, see `ido-find-file'." | |||
| 4291 | (ido-file-internal 'alt-file 'find-alternate-file nil "Find alternate file: ")) | 4316 | (ido-file-internal 'alt-file 'find-alternate-file nil "Find alternate file: ")) |
| 4292 | 4317 | ||
| 4293 | ;;;###autoload | 4318 | ;;;###autoload |
| 4319 | (defun ido-find-alternate-file-other-window () | ||
| 4320 | "Find file as a replacement for the file in the next window. | ||
| 4321 | The file name is selected interactively by typing a substring. | ||
| 4322 | For details of keybindings, see `ido-find-file'." | ||
| 4323 | (interactive) | ||
| 4324 | (ido-file-internal 'alt-file-other-window #'find-alternate-file-other-window)) | ||
| 4325 | |||
| 4326 | ;;;###autoload | ||
| 4294 | (defun ido-find-file-read-only () | 4327 | (defun ido-find-file-read-only () |
| 4295 | "Edit file read-only with name obtained via minibuffer. | 4328 | "Edit file read-only with name obtained via minibuffer. |
| 4296 | The file name is selected interactively by typing a substring. | 4329 | The file name is selected interactively by typing a substring. |
| @@ -4364,6 +4397,28 @@ For details of keybindings, see `ido-find-file'." | |||
| 4364 | (ido-auto-merge-work-directories-length -1)) | 4397 | (ido-auto-merge-work-directories-length -1)) |
| 4365 | (ido-file-internal 'dired 'dired nil "Dired: " 'dir))) | 4398 | (ido-file-internal 'dired 'dired nil "Dired: " 'dir))) |
| 4366 | 4399 | ||
| 4400 | ;;;###autoload | ||
| 4401 | (defun ido-dired-other-window () | ||
| 4402 | "\"Edit\" a directory. Like `ido-dired' but selects in another window. | ||
| 4403 | The directory is selected interactively by typing a substring. | ||
| 4404 | For details of keybindings, see `ido-find-file'." | ||
| 4405 | (interactive) | ||
| 4406 | (let ((ido-report-no-match nil) | ||
| 4407 | (ido-auto-merge-work-directories-length -1)) | ||
| 4408 | (ido-file-internal 'dired-other-window #'dired-other-window nil | ||
| 4409 | "Dired: " 'dir))) | ||
| 4410 | |||
| 4411 | ;;;###autoload | ||
| 4412 | (defun ido-dired-other-frame () | ||
| 4413 | "\"Edit\" a directory. Like `ido-dired' but makes a new frame. | ||
| 4414 | The directory is selected interactively by typing a substring. | ||
| 4415 | For details of keybindings, see `ido-find-file'." | ||
| 4416 | (interactive) | ||
| 4417 | (let ((ido-report-no-match nil) | ||
| 4418 | (ido-auto-merge-work-directories-length -1)) | ||
| 4419 | (ido-file-internal 'dired-other-frame #'dired-other-frame nil | ||
| 4420 | "Dired: " 'dir))) | ||
| 4421 | |||
| 4367 | (defun ido-list-directory () | 4422 | (defun ido-list-directory () |
| 4368 | "Call `list-directory' the Ido way. | 4423 | "Call `list-directory' the Ido way. |
| 4369 | The directory is selected interactively by typing a substring. | 4424 | 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 @@ | |||
| 1 | ;;; ido-tests.el --- unit tests for ido.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Philipp Stephani <phst@google.com> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; Unit tests for ido.el. | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (ert-deftest ido-tests--other-window-frame () | ||
| 29 | "Verifies that Bug#26360 is fixed." | ||
| 30 | (should-not ido-mode) | ||
| 31 | (unwind-protect | ||
| 32 | (progn | ||
| 33 | (ido-mode) | ||
| 34 | (should (equal ido-mode 'both)) | ||
| 35 | (should (equal (key-binding [remap find-alternate-file-other-window]) | ||
| 36 | #'ido-find-alternate-file-other-window)) | ||
| 37 | (should (commandp #'ido-find-alternate-file-other-window)) | ||
| 38 | (should (equal (key-binding (kbd "C-x 4 d")) #'ido-dired-other-window)) | ||
| 39 | (should (commandp #'ido-dired-other-window)) | ||
| 40 | (should (equal (key-binding (kbd "C-x 5 d")) #'ido-dired-other-frame)) | ||
| 41 | (should (commandp #'ido-dired-other-frame)) | ||
| 42 | (should (equal (key-binding (kbd "C-x 5 C-o")) | ||
| 43 | #'ido-display-buffer-other-frame)) | ||
| 44 | (should (commandp #'ido-display-buffer-other-frame))) | ||
| 45 | (ido-mode 0))) | ||
| 46 | |||
| 47 | ;;; ido-tests.el ends here | ||