Live data from Hacker News

Ask HN: What's in your .emacs file?

news.ycombinator.com

51–60 of 60 posts

Re: Ask HN: What's in your .emacs file?

#52
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)

Re: Ask HN: What's in your .emacs file?

#53
post #42

Some key ones (setq transient-mark-mode t) ; visually show region (setq line-number-mode t) ; show line numbers (setq global-font-lock-mode 1) ; everything should use font (windmove-default-keybindings) ; shift-arrow key moves to window in that direction I set up `webjump' to search online API documentation http://justinsboringpage.blogspot.com/2009/05/emacs-searchin... I like to send gmail http://justinsboringpage.b…

I used to set transient-mark-mode to t myself. But being able to set a mark and use C-xC-x to switch the cursor and the mark point is too powerful. It allows you to set a mark, go edit something else, and then go back to where you were. Granted, you could probably do that with transient mark mode, but seeing everything highlighted would be too annoying.

You can do the same thing with bm.el, but you also get multiple bookmarks (visible in the buffer) which you can then cycle through. I find it helpful to have bookmarks and the region decoupled.

http://www.nongnu.org/bm/

Re: Ask HN: What's in your .emacs file?

#54
post #4

Most important: ;; Don't mix tabs and spaces (setq-default indent-tabs-mode nil) ;; Use "newline-and-indent" when you hit the Enter key so ;; you don't need to keep using TAB to align each line. (global-set-key "\C-m" 'newline-and-indent) ;; Get rid of the with duplicate file names (require 'uniquify) (setq uniquify-buffer-name-style 'post-forward-angle-brackets) And then a whole bunch of autoload statements for diff…

;; Use "newline-and-indent" when you hit the Enter key so ;; you don't need to keep using TAB to align each line. (global-set-key "\C-m" 'newline-and-indent) That's what C-j is for.

True, but I'm pretty sure mapping to C-m also maps it to the enter key.

Re: Ask HN: What's in your .emacs file?

#55
post #17

You'll want to check out dotfiles.com also, btw. I considered putting this in a separate link, but thought that since you asked, it wouldn't be too terrible to post here. There are a few things I include in every .emacs file I have across multiple shell accounts, and this is more or less the entirety of it: ;; how emacs behaves generally (setq scroll-step 1) (setq next-line-add-newlines nil) (setq search-highlight t)…

Wait - I thought it was dotfiles.org? It went down a few months ago and hasn't returned. I'm not getting a response from dotfiles.com either.

Re: Ask HN: What's in your .emacs file?

#58

I am completely surprised no one has linked to technomancy's emacs-start-kit: https://github.com/technomancy/emacs-starter-kit Clone that as your emacs.d, add a .el file named the same as your logged in user, and add your specific preferences there. (I like to have it include stuff in a jmhodges directory in emacs.d, of course.) On that note, my own fork of it with very minor personal changes: https://github.com/jmho…

technomancy is a great developer and an excellent teacher

Re: Ask HN: What's in your .emacs file?

#59
post #9
post #5

178 lines of crap accumulated over about 20 years. I think I only use an indent variable setting, one key binding, and a handful of language autoloads. delete-delete-delete save-buffer Much better.

lines of crap accumulated over about 20 years I hear ya. One of the things I started doing lately is not moving any dotfiles automatically when I get a new machine. After 3 days of moaning, I go and dig out just the stuff that I have noticed I am missing. (I do the same for firefox plugins and so on). It has definitely helped with the historical crud.

Yeah it really forces you to look into those dotfiles you haven't read in two years, or that hack script you banged out in 5 minutes, and give them all a bit of thought. That "Just get it into my PATH so I can try it out!" impulse has definitely gotten the better of me a number of times.

Re: Ask HN: What's in your .emacs file?

#60
post #42

Some key ones (setq transient-mark-mode t) ; visually show region (setq line-number-mode t) ; show line numbers (setq global-font-lock-mode 1) ; everything should use font (windmove-default-keybindings) ; shift-arrow key moves to window in that direction I set up `webjump' to search online API documentation http://justinsboringpage.blogspot.com/2009/05/emacs-searchin... I like to send gmail http://justinsboringpage.b…

I used to set transient-mark-mode to t myself. But being able to set a mark and use C-xC-x to switch the cursor and the mark point is too powerful. It allows you to set a mark, go edit something else, and then go back to where you were. Granted, you could probably do that with transient mark mode, but seeing everything highlighted would be too annoying.

C-u C-SPC cycles through the mark ring and works with transient-mark. Just use C-g to deactivate the region so everything isn't highlighted.
Post reply on HN