Slashdot Mirror


(Stupid) Useful Emacs Tricks?

Count Fenring writes "Since the Vi version of this question was both interesting and popular, let's hear from the other end of the spectrum. What are your favorite tricks, macros, extensions, and techniques for any of the various Emacs? Myself, I like 'M-x dunnet' ;-)"

17 of 412 comments (clear)

  1. Re:A favourite (works well on both Ubuntu and Debi by rallymatte · · Score: 5, Funny

    There, fixed that for me!

    I've found this very useful whenever I'm put in front of emacs
    C-x C-c
    sudo apt-get -y purge emacs
    vi

  2. XKCD by WK2 · · Score: 5, Funny

    C-X M-C M-butterfly

    --
    Write your own Choose Your Own Adventure. http://www.freegameengines.org/gamebook-engine/
  3. grep and emacs integration by meta+slash · · Score: 5, Interesting

    Of all the Elisp I've written this grep is what I most miss when I use a coworker's environment.

    (defun my-grep ()
      "grep the whole directory for something defaults to term at cursor position"
      (interactive)
      (setq default (thing-at-point 'symbol))
      (setq needle (or (read-string (concat "grep for <" default "> ")) default))
      (setq needle (if (equal needle "") default needle))
      (grep (concat "egrep -s -i -n " needle " * /dev/null")))
    (global-set-key "\C-x." 'my-grep)
    (global-set-key [f8] 'next-error)

    1. Re:grep and emacs integration by Anonymous Coward · · Score: 5, Informative

      Like M-x rgrep? It's builtin now.

    2. Re:grep and emacs integration by gowen · · Score: 5, Informative

      Isn't that usually spelled

      M-| wc

      Meta-pipe is a great one -- it's "pipe region to external command" (M-x shell-command-on-region)

      --
      Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
  4. Re:A big disappointment by include($dysmas) · · Score: 5, Funny

    it was posted from emacs, took a while to press all the keys.

  5. editing over ssh by tuffy · · Score: 5, Informative
    Always handy when doing a bit of work remotely. Put:

    (require 'tramp)
    (setq tramp-default-method "scp")

    in one's .emacs file. Then open remote files with:

    /username@host:remote_path

    --

    Ita erat quando hic adveni.

  6. AUCTeX with preview-latex by P-Nuts · · Score: 5, Informative

    When writing scientific papers in LaTeX, there's nothing else that comes close to the power of AUCTeX with preview-latex http://www.gnu.org/software/auctex/preview-latex.html. It allows you to view typeset equations inline with the rest of the document, but on moving the cursor into an equation, shows the original code. After editing, one brief command, and the new equation is typeset and displayed.

  7. Re:A favourite (works well on both Ubuntu and Debi by pivo · · Score: 5, Funny

    Hmm.. that didn't work well for me. I tried it, but I ended up in an editor with functionality that was one step above punch cards.

  8. there's a whole wiki to answer this question by felipecs · · Score: 5, Informative
  9. some of mine by flynt · · Score: 5, Informative

    1)First, ESS, Emacs speaks statistics, found at http://ess.r-project.org/ . This lets you interface interactively with R, SAS, Stata, etc., all from the common Emacs interface. As a statistician, it's the one piece of software I could not do very well without!

    2) The 'ido' package, with flex matching, in my .emacs,

    (require 'ido)
    (ido-mode t)
    (setq ido-enable-flex-matching t)

    This lets you open files and switch buffers with fuzzy matching, really nice when you have lots of things open.

    See: http://www.emacsblog.org/2008/05/19/giving-ido-mode-a-second-chance/

    3) Make the mouse jump away when you type over it.
    (mouse-avoidance-mode 'cat-and-mouse)

    4) Open two windows side-by-side (C-x 3) one with LaTeX code, one with a pdf, then use this in your .emacs, (add-hook 'doc-view-mode-hook 'auto-revert-mode), when you compile the .tex file into PDF, the PDF automatically updates in Emacs, I used that a lot while working on my CV.

    5) The thunderbird extension that lets me compose replies in Emacs using emacsclient.

    6) org-mode http://www.org-mode.org/

    7) preview-latex, now part of AUCTeX, this lets you see preview versions of formulae and graphics inline in your .text file, *while you edit*. Your formula is replaced by what it will look like when compiled.

    8) EmacsWiki: http://www.emacswiki.org/

  10. Beginning of line by vslashg · · Score: 5, Informative

    My two .emacs modifications I find essential follow.

    First, turning off of obnoxious misfeatures:

    (fset 'yes-or-no-p 'y-or-n-p) ; stop forcing me to spell out "yes"
    (setq inhibit-startup-message t)
    (setq backup-directory-alist '(("." . "~/.emacs-backups"))) ; stop leaving backup~ turds scattered everywhere

    And second, stealing the beginning-of-line behavior from Dev Studio: if you invoke the command at the beginning of the line, advance to the first non-whitespace-character instead.

    (defun dev-studio-beginning-of-line (arg)
      "Moves to beginning-of-line, or from there to the first non-whitespace character.
     
    This takes a numeric prefix argument; when not 1, it behaves exactly like
    \(move-beginning-of-line arg) instead."
      (interactive "p")
      (if (and (looking-at "^") (= arg 1)) (skip-chars-forward " \t") (move-beginning-of-line arg)))
    (global-set-key "\C-a" 'dev-studio-beginning-of-line)
    (global-set-key [home] 'dev-studio-beginning-of-line)

  11. Re:Please Stop by alta · · Score: 5, Funny

    A whole series...
    Useful(Stupid) things to say to get modded Insightful
    Useful(Stupid) things to say to get modded Interesting
    Useful(Stupid) things to say to get modded Funny
    Useful(Stupid) things to say to get modded Troll
    Useful(Stupid) things to say to get modded Redundant
    Useful(Stupid) things to say to get modded Flamebate
    Useful(Stupid) things to say to get modded Overrated
    Useful(Stupid) things to say to get modded Stupid
    Useful(Stupid) things to say to get modded Useful

    --
    Do not meddle in the affairs of sysadmins, for they are subtle, and quick to anger.
  12. Re:Please Don't Stop by Just+Some+Guy · · Score: 5, Insightful

    This is the first content I've seen in years that appeals to Slashdot's original demographics: hardcore geeks who are passionate about the tools they use. I've picked up a few tips in this series of articles and have enjoyed hearing other people learn about "old" stuff for the first time.

    If "(Stupid) Useful $GEEK Tricks" isn't your cup of tea, then please feel free to look elsewhere.

    --
    Dewey, what part of this looks like authorities should be involved?
  13. The old Emacs vs Vi story by raffe · · Score: 5, Funny

    I asked my email-pal: "UNIX or Windoze?". He replied "UNIX". I said "Ah...me too!".

    I asked my email-pal: "Linux or AIX?". He said "Linux, of course". I said "Me too".

    I asked him: "Emacs or vi". He replied "Emacs". I said "Me too. Small world."

    I asked him: "GNU Emacs or XEmacs?", and he said "GNU Emacs". I said "oh, me too."

    I asked him "GNU Emacs 19 or GNU Emacs 20"? and he said "GNU Emacs 19". I said "oh, me too."

    I asked him, "GNU Emacs 19.29 or GNU Emacs 19.34", and he replied "GNU Emacs 19.29". I said "DIE YOU OBSOLETE NOGOOD SOCIALLY MALADJUSTED CELIBATE COMMIE FASCIST DORK!", and never emailed him again.

    From an old slashdot story

  14. Re:Huh? by Anonymous Coward · · Score: 5, Funny

    Emacs has a text editor now?

  15. Re:Please Don't Stop by DiegoBravo · · Score: 5, Funny

    So by the next week we may the OpenOffice tricks?