From 4c6ff7f8290a57e5060bdda7e4b60c523461583d Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 30 Nov 2013 16:14:04 -0800 Subject: Use ido for completion of buffers/files Ido supersedes ffap for most use cases. diff --git a/init.el b/init.el index c26bdb7..8ed7423 100644 --- a/init.el +++ b/init.el @@ -54,7 +54,8 @@ (require 'use-package) (require 'diminish) -;; Initialize appearnace +;; Initialize appearance +(require 'ravi-init-ido) (require 'ravi-init-marks) (require 'ravi-init-appearance) (require 'ravi-init-files) diff --git a/ravi-init-files.el b/ravi-init-files.el index 1341b21..0a2d2a1 100644 --- a/ravi-init-files.el +++ b/ravi-init-files.el @@ -24,10 +24,6 @@ ;;; Code: -;; Find file based on context -(require 'ffap) -;; \todo Prevent opening of remote files via ffap - (setq delete-auto-save-files t) (setq dired-listing-switches "-Flag") (setq completion-ignored-extensions diff --git a/ravi-init-ido.el b/ravi-init-ido.el new file mode 100644 index 0000000..8173353 --- /dev/null +++ b/ravi-init-ido.el @@ -0,0 +1,125 @@ +;;; ravi-init-ido.el --- ido initialization + +;; Copyright (C) 2013 + +;; Author: +;; Keywords: + +;; This program 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. + +;; This program 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 this program. If not, see . + +;;; Commentary: + +;; Ido initialization + +;;; Code: + +;; Almost all of the code below is stolen from jwiegley's .emacs.d. + +(use-package ibuffer + :bind ("C-x C-b" . ibuffer)) + +;;;_ , ido + +(use-package ido + :defines (ido-cur-item + ido-require-match + ido-selected + ido-final-text + ido-show-confirm-message) + :init + (ido-mode 1) + + :config + (progn + (use-package ido-hacks + :init + (ido-hacks-mode 1) + :ensure t + ) + + (use-package flx-ido + :init + (progn + (use-package flx + :ensure t) + (flx-ido-mode 1) + ) + :ensure t + ) + (setq ido-use-filename-at-point 'guess) + (setq ido-use-virtual-buffers t) + (setq ido-create-new-buffer 'always) + + (use-package ido-ubiquitous + :init + (ido-ubiquitous-mode t) + :ensure t + ) + + (defun ido-smart-select-text () + "Select the current completed item. Do NOT descend into directories." + (interactive) + (when (and (or (not ido-require-match) + (if (memq ido-require-match + '(confirm confirm-after-completion)) + (if (or (eq ido-cur-item 'dir) + (eq last-command this-command)) + t + (setq ido-show-confirm-message t) + nil)) + (ido-existing-item-p)) + (not ido-incomplete-regexp)) + (when ido-current-directory + (setq ido-exit 'takeprompt) + (unless (and ido-text (= 0 (length ido-text))) + (let ((match (ido-name (car ido-matches)))) + (throw 'ido + (setq ido-selected + (if match + (replace-regexp-in-string "/\\'" "" match) + ido-text) + ido-text ido-selected + ido-final-text ido-text))))) + (exit-minibuffer))) + + (add-hook 'ido-minibuffer-setup-hook + #'(lambda () + (bind-key "" 'ido-smart-select-text + ido-file-completion-map))) + + (defun ido-switch-buffer-tiny-frame (buffer) + (interactive (list (ido-read-buffer "Buffer: " nil t))) + (with-selected-frame + (make-frame '((width . 80) + (height . 22) + (left-fringe . 0) + (right-fringe . 0) + (vertical-scroll-bars . nil) + (unsplittable . t) + (has-modeline-p . nil) + ;;(background-color . "grey80") + (minibuffer . nil))) + (switch-to-buffer buffer) + (set (make-local-variable 'mode-line-format) nil))) + + (bind-key "C-x 5 t" 'ido-switch-buffer-tiny-frame))) + +(use-package smex + :init + (global-set-key [remap execute-extended-command] 'smex) + :ensure t + ) + +(provide 'ravi-init-ido) +;;; ravi-init-ido.el ends here -- cgit v0.10.1