Hacker News new | ask | show | jobs
by curiousdude99 3614 days ago
You don't need tabs in Emacs; use buffer instead. Helm has a really good interface to navigate open buffers. I usually have 30-50 buffers open in my emacs. Now how does vim handle that many buffers?
2 comments

For what is worth, I have currently 755 buffers open on my emacs session. That's probably on the low side as I restarted my session recently (i.e. in the last 7 days). I usually have 8 buffers showing (vertical + horizontal split across two windows) at any one time. I don't even known how a tabbed interface would look like in this setup.

I use ido-switch-buffer instead of helm for quick switching. Should I switch to helm?

I have an elisp function that opens every file in the projects I'm currently working on. I run it when I start a new session.

  1790 buffers        20295782                  1774 files, 1 process
I prefer lazy-loading both packages and files, but still having recently-worked-on files available for quick opening, since I sometimes do restart Emacs :)

With the below form in my .emacs.d/init.el, I can restart Emacs and the first time I do C-x b I get to pick from files I had opened in the previous session:

    (use-package ido
      :init
      (setq ido-use-virtual-buffers t) ; treat closed files as open buffers for C-x b
      :config
      (ido-mode 1)
      (ido-everywhere 1)
      (use-package recentf
        :init
        (setq recentf-auto-cleanup 7200 ; clean list on idle rather than startup
              recentf-max-saved-items 2000)
        :config
        (recentf-mode 1)))
That is, ido-use-virtual-buffers will put closed buffers at the end of the buffer list, while recentf makes that list of previously closed buffers persistent across sessions.

Also, after opening vc-tracked files, I want subsequent find-file calls to match on all non-ignored subdirectories of that repo, not just the directory of the current file, so I use ffir to add tracked subdirectories to ido's work directories:

    (use-package find-file-in-repository
      :ensure t
      :config
      (setq ffir-avoid-HOME-repository nil)
      (defun ffir-repo-subdirectories ()
        "Use ffir to put projects into ido-work-directories.
    This makes useful files show up even if you haven't been to that
    sub-folder yet."
        ;; TODO: compare emacs25 project-find-file
        (interactive)
        (let* ((repo-directory (expand-file-name
                                (ffir-locate-dominating-file
                                 default-directory
                                 (lambda (directory)
                                   (ffir-directory-contains-which-file
                                    ffir-repository-types directory)))))
               (file-list (funcall (ffir-directory-contains-which-file
                                    ffir-repository-types repo-directory)
                                   repo-directory))
               dir-list)
          (mapc (lambda (p)
                  (add-to-list 'dir-list (file-name-directory (cdr p))))
                file-list)
          dir-list))
      (defadvice ido-merge-work-directories (before advice-merge-repo-subdirs first nil activate)
        (mapc (lambda (d) (add-to-list 'ido-work-directory-list d))
              (ffir-repo-subdirectories))))
    
(ffir is a fairly small dependency for a vc-general "list-non-ignored-files", though perhaps there's something built-in in Emacs' vc.el I should be using instead)
There are multiple helm-like plugins for vim, which can be used to change buffers. Tabs, on the other hand, are used so that you can, for example, have a tab with a vertical split and buffers A and B, and another tab with just one big buffer, and so on.
Well then you could try perspective-el for emacs