Hacker News new | past | comments | ask | show | jobs | submit login

I work mostly inside git repositories, so this has been really valuable for scoping commands to the current repository:

  (defun my-git-root () 
    (if buffer-file-name
        (let* ((current-directory (file-name-directory buffer-file-name))
               (git-directory (concat current-directory ".git")))
          (while (and 
                  current-directory 
                  (not (file-exists-p git-directory)))
            (setq current-directory (file-name-directory (substring current-directory 0 -1)))
            (setq git-directory (concat current-directory ".git")))
          current-directory)))
I also hated editing system files until I added this function, which I almost definitely cribbed from somewhere:

  (defun sudo-find-file (file-name)
    (interactive "FFind file (sudo): ")
    (find-file (concat "/sudo::" file-name)))
I got sick of having to context-switch to the browser when I needed to do a quick search, which is where these come in:

  (defun go-to-doc (base-url)
    (let ((default (symbol-name (symbol-at-point))))
      (browse-url (concat base-url (read-string "Search term: " nil nil default)))))
  
  (defun rails-doc ()
    (interactive)
    (go-to-doc "http://apidock.com/rails/search?query="))
  
  (defun ruby-doc ()
    (interactive)
    (go-to-doc "http://apidock.com/ruby/search?query="))
I really, really hope package.el is built-in soon:

  (when
      (load
       (expand-file-name "~/.emacs.d/elpa/package.el"))
    (package-initialize))
and by far the most important line in the whole file:

  (server-start)



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: