Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Last active September 25, 2016 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wilfred/31e8e0b24e3820c24850920444dd941d to your computer and use it in GitHub Desktop.
Save Wilfred/31e8e0b24e3820c24850920444dd941d to your computer and use it in GitHub Desktop.
(require 'dash)
(defun wh/ido-switch-buffer-with-filename ()
"Switch to a buffer with ido, including the filename in the prompt."
(interactive)
(let* ((bufs (buffer-list))
(bufs-with-paths
(--map (with-current-buffer it
(if (buffer-file-name)
(format "%s <%s>" (buffer-name) (buffer-file-name))
(buffer-name)))
bufs))
(chosen-index
(-elem-index
(ido-completing-read
"Switch to buffer: " bufs-with-paths)
bufs-with-paths)))
(switch-to-buffer (nth chosen-index bufs))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment