2

with (ido-switch-buffer), when I type stuff, "*magit: stuff*" comes before Stuff.txt.

the sorting seems to be done by recency, rather than the buffer name. more generally, a custom sort function would be nice.

1

Here is what I use:

(require 'dash)
(require 's)

(add-hook 'ido-make-buffer-list-hook 'my/ido-stars-to-end)
(defun my/ido-stars-to-end ()
  "Put \"*starred*\" buffers at the end of the ido candidates list."
  (ido-to-end (--filter (s-starts-with-p "*" it)
                        ido-temp-list)))
1

If you want just for ido locally and not across tramp listings, then try this function that was originally made for buffers with @ in names and I modified for * in names:

(defun ido-sort-on-stars-to-end ()
    (message ido-current-directory)
    (setq ido-temp-list
        (sort ido-temp-list
            (lambda (a b)
              if (not (or (char-equal (string-to-char a) ?*) (char-equal (string-to-char b) ?*)))
            (time-less-p
             (sixth (file-attributes (concat ido-current-directory b))
                    (sixth (file-attributes (concat ido-current-directory a)))))
             nil)))
                  (ido-to-end
                   (delq nil (mapcar
                              (lambda (x) (and (string-match-p "^\\.." x) x))
                              ido-temp-list))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.