Guest User

emacs-recent-files

a guest
Nov 22nd, 2011
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; f1 giver en liste over nyligt åbnede filer.
  2. ;; M-f1 giver en søgbar liste. Som C-x b for buffer.
  3. ;; Kræver ido, http://www.emacswiki.org/emacs/InteractivelyDoThings
  4.  
  5. ;; keybindinger
  6. (global-set-key [f1] 'recentf-open-files)
  7. (global-set-key [(meta f1)] 'recentf-interactive-complete) ;; use ido to search recently opened files
  8.  
  9.  
  10. ;; funktioner
  11. ;; M-[f1] søg efter nyligt åbede filer
  12. (defun recentf-interactive-complete ()
  13.   "find a file in the recently open file using ido for completion"
  14.   (interactive)
  15.   (let* ((all-files recentf-list)
  16.      (file-assoc-list (mapcar (lambda (x) (cons (file-name-nondirectory x) x)) all-files))
  17.      (filename-list (remove-duplicates (mapcar 'car file-assoc-list) :test 'string=))
  18.      (ido-make-buffer-list-hook
  19.       (lambda ()
  20.         (setq ido-temp-list filename-list)))
  21.      (filename (ido-read-buffer "Find Recent File: "))
  22.      (result-list (delq nil (mapcar (lambda (x) (if (string= (car x) filename) (cdr x))) file-assoc-list)))
  23.      (result-length (length result-list)))
  24.          (find-file
  25.       (cond
  26.        ((= result-length 0) filename)
  27.        ((= result-length 1) (car result-list))
  28.        ( t
  29.          (let ( (ido-make-buffer-list-hook
  30.              (lambda ()
  31.                (setq ido-temp-list result-list))))
  32.            (ido-read-buffer (format "%d matches:" result-length))))
  33.        ))))
  34.  
RAW Paste Data