emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master a1f93c1: Add missing remappings for Ido mode


From: Philipp Stephani
Subject: [Emacs-diffs] master a1f93c1: Add missing remappings for Ido mode
Date: Sun, 23 Apr 2017 12:43:13 -0400 (EDT)

branch: master
commit a1f93c1dfa53dbe007faa09ab0c6e913e86e3ffe
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    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.
---
 etc/NEWS               |  7 ++++++
 lisp/ido.el            | 61 +++++++++++++++++++++++++++++++++++++++++++++++---
 test/lisp/ido-tests.el | 47 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 7281827..9d4c72d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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 293c8e2..318f2fe 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 0000000..df11096
--- /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 <address@hidden>
+
+;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]