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' ;-)"

412 comments

  1. A favourite (works well on both Ubuntu and Debian by rallymatte · · Score: 4, Funny

    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. Please Stop by TubeSteak · · Score: 0, Offtopic

    Hopefully this is the last story before we start with "Stupid pet tricks"

    --
    [Fuck Beta]
    o0t!
    1. Re:Please Stop by Rennt · · Score: 2

      Indeed. If this keeps up we'll need a whole new Stupid Tricks section.

      I can see it now -
      Useful (Stupid) Things to Say on a Internet Forum!

    2. Re:Please Stop by cjfs · · Score: 4, Funny

      Hopefully this is the last story before we start with "Stupid pet tricks"

      Seeing as this is about emacs tricks, everything else is a subset. Including pet tricks.

      Don't get me wrong: Emacs is a great operating system -- it lacks a good editor, though.

    3. 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.
  3. 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

  4. 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/
    1. Re:XKCD by orclevegam · · Score: 1

      DAMMIT, EMACS.

      --
      Curiosity was framed, Ignorance killed the cat.
    2. Re:XKCD by Anonymous Coward · · Score: 1, Funny

      C-C-C-COMBO BREAKER!

    3. Re:XKCD by mseidl · · Score: 1

      for $i in $(ps ax | grep -i emacs); do \
      kill $i
      done; \
      vi

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

    the Vi version of this question was both interesting and popular

    Indeed. Probably because Vi is a popular and usable text editor (unlike Emacs).

    1. Re:Huh? by ByOhTek · · Score: 1

      Sadly enough, sed is a more usable text editor than vi/vim. All the mode switching - the only time I ever use vi/vim is when I want to do deletions from a file. The rest of the time, I use ANY other editor that is available.

      --
      Self proclaimed typo king, and inventor of the bear destroying coffee table (patent not pending).
    2. Re:Huh? by ByOhTek · · Score: 2, Insightful

      deletions, and ONLY deletions from a file. If there is any adding/changing, I'd sooner sue cat+sed.

      --
      Self proclaimed typo king, and inventor of the bear destroying coffee table (patent not pending).
    3. Re:Huh? by Dr+Caleb · · Score: 3, Funny

      I don't think cat+sed has any money. Plus, you'd have to prove damages.

      --
      "History doesn't repeat itself, but it does rhyme." Mark Twain
    4. Re:Huh? by Anonymous Coward · · Score: 5, Funny

      Emacs has a text editor now?

    5. Re:Huh? by volxdragon · · Score: 2, Insightful

      See, there's your problem....Emacs isn't a text editor, it's a development environment with a Turing-complete language in it.

    6. Re:Huh? by EvanED · · Score: 1

      Indeed. Probably because Vi is a popular and usable text editor (unlike Emacs).

      To paraphrase Arthur Dent, "this is obviously some strange usage of the word 'usable' that I wasn't previously aware of." ;-)

      (I kid, for my preference is Emacs.)

    7. Re:Huh? by yukk · · Score: 2, Insightful

      Emacs has a text editor now?

      See, this is why I hate mod points. They're never around when you need them.

      --
      The trouble with the rat race is that even if you win, you're still a rat." Lily Tomlin
    8. Re:Huh? by Count+Fenring · · Score: 1

      Yeah... Usability is in the eye of the beholder I know of several fairly productive programmers using emacsen, including (not included for name-check sake, just for "people have heard of him") Linus Torvalds. Whatever you think of Linux, I don't think anyone can deny that he's productive with his text editor.

      As for popular... well, people keep using it, despite it not being bundled with every Unix ;-)

  6. A big disappointment by kayumi · · Score: 0

    I am disappointed. I expected this topic a few hours earlier.

    1. Re:A big disappointment by include($dysmas) · · Score: 5, Funny

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

    2. Re:A big disappointment by Count+Fenring · · Score: 1

      It actually took less time to press them... I just had to stretch my fingers for an hour beforehand. ;-)

  7. 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 fortunatus · · Score: 1

      Nice! Just stuck it in my .emacs!

    3. Re:grep and emacs integration by Beezlebub33 · · Score: 3, Interesting

      Damn, and me with no mod points. Someone please mod this up. It is a good example of the neat sort of thing that you can do with emacs.

      Since I use Eclipse a lot, I don't use emacs nearly as much as I used to, but there are somethings that emacs just makes easier. One of them is performing a complicated command many times over. I copy from Eclipse, paste in emacs, do a C-x (, do what I need it to do, C-x ), and then C-u 10000 C-x e. Then, copy and paste it back into Eclipse. Saves lots and lots of time.

      Here's something I have in my .emacs:

      ;;--
      ;; This will count the number of words in a highlighted region
      ;;--

      (global-set-key "\C-x5c" 'word-count )
      (defun word-count (start end)
          (interactive "r")
          (let ((words 0) (lines 0) (chars 0))
              (save-excursion
                  (goto-char start)
                  (while ( (point) end) (forward-word 1) (setq words (1+ words))))
              (setq lines (count-lines start end) chars (- end start))
              (message "Region has %d lines; %d words; %d characters."
                                lines words chars)))

      --
      The more people I meet, the better I like my dog.
    4. Re:grep and emacs integration by Dolda2000 · · Score: 2, Interesting

      Of all the elisp I've written, this is the one I miss the most when I don't use my own EMACS:

      (defun get-previous-buffer (numbufs blist)
        (if (not blist) (signal 'no-such-buffer ()))
        (if (not (buffer-file-name (car blist)))
            (get-previous-buffer numbufs (cdr blist))
          (if (> numbufs 0)
          (get-previous-buffer (1- numbufs) (cdr blist))
            (car blist))))

      (defun switch-to-previous-buffer (numbufs)
        "Switches to the previous file-associated buffer in the buffer
      list."
        (interactive "p")
        (switch-to-buffer (get-previous-buffer numbufs (buffer-list))))

      (global-set-key "\M-\C-m" 'switch-to-previous-buffer)

      In short, it allows you to switch back and forth between your two most recently used buffers with M-RET, or between elder buffers with a prefix argument. It's a very convenient alternative to C-x b (though it doesn't replace it, obviously).

    5. Re:grep and emacs integration by orclevegam · · Score: 1

      I know for a fact they have a vi keys plugin for Eclipse, and I'd assume they have an emacs one as well. You might be able to save some time by getting one of those plugins and eliminating a second application.

      --
      Curiosity was framed, Ignorance killed the cat.
    6. Re:grep and emacs integration by try_anything · · Score: 1

      There's an emacs keybinding, but as far as I can tell, it just handles navigation within a file and basic editing commands: cut, copy, and paste.

    7. Re:grep and emacs integration by Wolfbone · · Score: 1

      Word count in region?

      M-x how-many RET \> RET

    8. Re:grep and emacs integration by soloport · · Score: 1

      Emacs saves me tons of time in two main ways:
      1) Macros (see Ctrl-Z or F5)
      2) Visual diff (see F7 and F8)

      Typical .emacs:
      ;; MACROS

      ;; define common macros
      (fset 'switch-buffers "\C-xb\C-m")
      (fset 'page-down-buffers "\C-v\C-xb\C-m\C-v")
      (fset 'sub-word "\C-f\C-[b\C-y\C-[d\C-@\C-[b\C-[w\C-[f")

      ;; map macro calls to single key-presses
      (global-set-key "\C-z" 'call-last-kbd-macro)
      (global-set-key [f5] 'call-last-kbd-macro)
      (global-set-key [f7] 'switch-buffers)
      (global-set-key [f8] 'page-down-buffers)
      (global-set-key "\C-[t" 'sub-word)

      ;; PREFERENCES

      ;; disable welcome message
      (setq inhibit-startup-message t)

      ;; disable backup files
      (setq make-backup-files nil)

      ;; ask for y/n instead of yes/no
      (fset 'yes-or-no-p 'y-or-n-p)

      ;; enable font-lock mode
      (global-font-lock-mode t)

      ;; disable insert-tabs
      (setq-default indent-tabs-mode nil)

      ;; enable remove-trailing-whitespace
      (add-hook 'write-file-functions 'delete-trailing-whitespace)

      ;; re-map delete key
      (define-key global-map [delete] 'delete-char)

      ;; C/C++ STYLE

      ;; set C tab offset to 4-character
      (setq c-basic-offset 4)

      ;; set C/CC/C++ indent style to K&R
      (setq c-default-style '((c-mode . "k&r") (cc-mode . "k&r") (c++-mode . "k&r")))

      ;; PHP SUPPORT

      ;; php syntax highlighting
      (load-file "~/.emacs.d/php-mode.el")
      (require 'php-mode)
      (add-hook 'php-mode-user-hook 'turn-on-font-lock)

      ;; php file extensions to include .inc and .html
      (setq auto-mode-alist (append '(("\\.html\\'" . php-mode) ("\\.inc\\'" . php-mode)) auto-mode-alist))

    9. Re:grep and emacs integration by Q2Serpent · · Score: 1

      I hope you never have to grep for anything with shell meta-characters in it...

    10. Re:grep and emacs integration by orclevegam · · Score: 1

      There's an emacs keybinding, but as far as I can tell, it just handles navigation within a file and basic editing commands: cut, copy, and paste.

      That's unfortunate, the vi plugin is a nearly complete emulation.

      --
      Curiosity was framed, Ignorance killed the cat.
    11. 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.
    12. Re:grep and emacs integration by Agent+Orange · · Score: 1

      ZOMG! that's awesome! I've been using emacs for years, and never quite figured this out! SO helpful. no more saving things to a file called "foo" and dropping to a terminal to run wc, etc. :)

      also...rectangles are the shit! every time I show friend some emacs, this is one of the first things i give 'em. they never cease to be amazed :)

    13. Re:grep and emacs integration by Anonymous Coward · · Score: 0

      Wow. That's so cool.

      I don't need this for Lisp, since all the implementations record the source locations for functions, methods, variables, &c. But for editing in other languages (Python), this will be useful.

    14. Re:grep and emacs integration by Count+Fenring · · Score: 1

      I'm having a little trouble grokking what "/dev/null" is doing in your search string.

      Sadly, my elisp is weaker than my perl.

    15. Re:grep and emacs integration by Count+Fenring · · Score: 1

      I'd guess that's because so much vi functionality involves passing things to an external program; it seems like it would be much easier to just include those programs and pass the work out of eclipse than to, say, implement emacs style macros in eclipse.

    16. Re:grep and emacs integration by Count+Fenring · · Score: 1

      Hearts and flowers, here. I've been looking for something like that for a while.

      Sigh. I'm going to have to byte-compile my .emacs at the end of this, aren't I?

    17. Re:grep and emacs integration by The+boojum · · Score: 1

      Back in the day when I did Java, I'd do the same thing, keeping both Eclipse and XEmacs running. One thing I found, at least on their Windows version, was that dragging a dropping a file from the file tree to XEmacs worked just fine. Make my edits, save, alt-tab back to Eclipse and let it reload when it detects the external modifications.

      I'd be surprised if something similar didn't work with Eclipse/Emacs combinations on other platforms.

      Oh, and for the word count, I usually just do M-| wc RET, though I'll admit to having embedded other utilities such as uniq as Elisp scripts.

    18. Re:grep and emacs integration by Haeleth · · Score: 1

      Meta-pipe is a great one -- it's "pipe region to external command"

      I use M-| all the time. The prefix argument form, C-u M-|, is particularly useful -- it replaces the region with the output of the shell command. Ever wondered why there's a sort-lines function but not a unique-lines? Because for anything other than basic sorting, you can just do something like C-u M-| sort -u!

    19. Re:grep and emacs integration by PhrackCreak · · Score: 1

      Love it! Same thing with file pattern.

      (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))
        (setq pattern (or (read-string "in files [all]: ") "*"))
        (setq pattern (if (equal pattern "") "*" pattern))
        (grep (concat "egrep -s -n " needle " " pattern " /dev/null")))

      --
      - You don't know how to maintain a station wagon either!
    20. Re:grep and emacs integration by saccade.com · · Score: 1

      You do know about C-xC-b (buffer menu), right?

    21. Re:grep and emacs integration by Dolda2000 · · Score: 1

      I think so, but maybe you know more about it than I do. I don't see how it helps me switch buffers in a single keypress (or two, for older buffers).

    22. Re:grep and emacs integration by keramida · · Score: 1

      (setq pattern (or (read-string "in files [all]: ") "*"))
      (setq pattern (if (equal pattern "") "*" pattern))

      Using (setq ...) for local bindings is un-Lispy, and you don't really have to use (if ...) for conditional assigment, because `read-string' supports a default value:

      (let ((search-pattern (read-string "Search files [all]:" T "*")))
      (forms-for-searching search-pattern))

      What you have there is very similar to the built-in `lgrep', `rgrep', `find-grep' and `find-grep-dired' commands. Have a look in their help. They may be useful [I like find-grep-dired a *lot* :)].

      --
      My other computer runs FreeBSD too.
    23. Re:grep and emacs integration by meta+slash · · Score: 1

      Good point, that is not obvious.  grep behaves differently if you provide only one filename than if you provide more than one filename.  Adding /dev/null guarantees that I always get the multi-filename behavior.

  8. Lots of them by Anonymous Coward · · Score: 4, Interesting

    M-x tetris
    M-x doctor
    M-x yow
    M-x phases-of-moon

    1. Re:Lots of them by jbaltz · · Score: 2, Insightful

      M-x psychoanalyze-pinhead

      --
      I am the Lorvax, I speak for the machines.
    2. Re:Lots of them by gEvil+(beta) · · Score: 1
      Don't forget M-x dunnet

      Dead end
      You are at a dead end of a dirt road. The road goes to the east.
      In the distance you can see that it will eventually fork off. The
      trees here are very tall royal palms, and they are spaced equidistant
      from each other.
      There is a shovel here.
      >

      --
      This guy's the limit!
    3. Re:Lots of them by gEvil+(beta) · · Score: 1

      Derrrr. Helps to RTFS.

      --
      This guy's the limit!
    4. Re:Lots of them by haystor · · Score: 1

      rot13-region
      morse-region
      gomoku
      hanoi

      --
      t
    5. Re:Lots of them by haystor · · Score: 3, Interesting

      C-x r k ;; kill-rectangle
      C-x r y ;; yank-rectangle

      Cut and paste columns of text.

      --
      t
    6. Re:Lots of them by harry666t · · Score: 1

      Wow, I didn't know that there are default key bindings for this. Do you know of any quick way (other than grepping through elisp sources) to find if a command has a key bound to it?

    7. Re:Lots of them by Falstius · · Score: 1

      rectangle kill-yank (cut-paste) is probably the number one reason why I'll drop out of vi when editing a file and open it in emacs (for some reason I always edit config files in vi and code in emacs). So, can I do this in vi, or any other text editor?

      Don't get me wrong, I like emacs I just don't like having a 40MB text editor where it isn't needed.

    8. Re:Lots of them by flynt · · Score: 1

      Simple, C-h f RET RET

      For example C-h f RET kill-rectangle RET gives me:::

      kill-rectangle is an interactive autoloaded Lisp function.

      It is bound to C-x r k.

      (kill-rectangle start end &optional fill)

      Delete the region-rectangle and save it as the last killed one.

      When called from a program the rectangle's corners are start and end.
      You might prefer to use `delete-extract-rectangle' from a program.

      With a prefix (or a fill) argument, also fill lines where nothing has to be
      deleted.

      If the buffer is read-only, Emacs will beep and refrain from deleting
      the rectangle, but put it in the kill ring anyway. This means that
      you can use this command to copy text from a read-only buffer.
      (If the variable `kill-read-only-ok' is non-nil, then this won't
      even beep.)

    9. Re:Lots of them by EvanED · · Score: 1

      I think there's probably a better way, but describe-bindings (also accessible from the help menu, describe, list key bindings) will list all current bindings, then you can search for the command.

    10. Re:Lots of them by Anonymous Coward · · Score: 0
      M-x viper-mode

      Escape Meta Control Alt Shift (more at http://www.gnu.org/fun/jokes/gnuemacs.acro.exp.html)

    11. Re:Lots of them by Anonymous Coward · · Score: 1, Informative

      M-x where-is, also known as C-h w :)

    12. Re:Lots of them by iggya · · Score: 1

      I think there's probably a better way, but describe-bindings (also accessible from the help menu, describe, list key bindings) will list all current bindings, then you can search for the command.

      Since describe-bindings is bound to C-h b, you can see the bindings by typing in C-h b. You can also find out what some key sequence is bound to by using describe-key (C-h k) and then enter the key sequence you want to check. It will tell you which function that key sequence is bound to. For example, try this: C-h k C-h b

      There are various other useful things you can find out about with C-h ?, or help-for-help.

    13. Re:Lots of them by Anonymous Coward · · Score: 0

      Yeah, VIM has "block-visual" mode. Cut, copy 'n' paste rectangular selections.

  9. Notepad tricks by Anonymous Coward · · Score: 1, Funny

    Dear Slashdot,

    For us Windows users, I would be very much interested in a similar topic for useful Notepad tricks.
    Please take this seriously, and don't say that Alt-F4 (or Alt-F, X) is the best trick.

    Yours sincerely,

    Fred Anboy

    1. Re:Notepad tricks by gEvil+(beta) · · Score: 2, Insightful

      Well, if you're using Windows XP, the best trick is Win-U-U.

      --
      This guy's the limit!
    2. Re:Notepad tricks by orclevegam · · Score: 1

      Win-R format /Q c:

      --
      Curiosity was framed, Ignorance killed the cat.
    3. Re:Notepad tricks by harry666t · · Score: 1

      What does it do? Haven't seen MS Windows for years...

    4. Re:Notepad tricks by Anonymous Coward · · Score: 0

      shutdown

    5. Re:Notepad tricks by Haeleth · · Score: 2, Interesting

      Notepad has precisely one useful trick, documented here.

    6. Re:Notepad tricks by Count+Fenring · · Score: 1

      If you are serious (and I'll take you at your word for the moment), there really aren't many. Notepad is the lowest common denominator of editing text; there aren't really "tricks" for it, since all it can do is edit text files (limited to an arbitrary size) and display or print them.

      Honestly, if you're really looking to increase productive text editing, switch to one of the several less limited free text-editors (my personal favorite on Windows is called ConTEXT).

    7. Re:Notepad tricks by bobbozzo · · Score: 1

      It does a shUtdown

      --
      Nothing to see here; Move along.
    8. Re:Notepad tricks by bobbozzo · · Score: 1

      F5 works just as well.

      --
      Nothing to see here; Move along.
    9. Re:Notepad tricks by Philip+Shaw · · Score: 1

      The old MS-DOS editor (edit.exe) is better than Notepad, but you need to make sure the 16-bit subsystem is working.

      --
      "A fanatic is one who can't change his mind and won't change the subject."- Winston Churchill
  10. What is next ? by pirhana · · Score: 1

    (Stupid) Userful Bash Tricks ???

    1. Re:What is next ? by rallymatte · · Score: 2, Informative

      Well no, there were loads of bash tricks in the (Stupid) Useful Unix Tricks.

    2. Re:What is next ? by billybob2001 · · Score: 1

      Still waiting for...

      (Stupid) Useful Chat-up Lines

    3. Re:What is next ? by kv9 · · Score: 4, Funny

      (Stupid) Useful Chat-up Lines

      hey, sexy mama. wanna kill all the humans?

    4. Re:What is next ? by MadMidnightBomber · · Score: 1

      to girl on her own at the bar: "Can I buy both of you a drink?"

      --
      "It doesn't cost enough, and it makes too much sense."
    5. Re:What is next ? by bobbozzo · · Score: 1

      Hey baby, wanna see my spaceship?

      --
      Nothing to see here; Move along.
  11. Some favorites by bjourne · · Score: 4, Interesting

    (global-set-key (kbd "C-c c") 'comment-dwim)

    C-c c to either comment out a region or uncomment it depending on context. Lovely feature.

    (global-set-key "\M-g" 'goto-line)

    M-g to go to specified line in buffer. Useful for emacs 21.x users where the keybinding is not yet standard.

    (menu-bar-mode nil) (scroll-bar-mode nil) (tool-bar-mode nil)

    Gets rid of the ugly TK widgets.

    (iswitchb-mode t)

    Superboosts C-x b.

    (global-set-key "\C-z" 'undo)

    The normal binding for C-z is suspend-emacs but having it bound as undo is much more useful imo.

    1. Re:Some favorites by Just+Some+Guy · · Score: 2, Informative

      (global-set-key (kbd "C-c c") 'comment-dwim)

      Note: this is already bound to M-; by default.

      --
      Dewey, what part of this looks like authorities should be involved?
    2. Re:Some favorites by patro · · Score: 2, Interesting

      If we consider external packages too:

      The QuickSilver for Emacs: anything.el

    3. Re:Some favorites by Anonymous Coward · · Score: 0

      (global-set-key (kbd "C-c c") 'comment-dwim)

      C-c c to either comment out a region or uncomment it depending on context. Lovely feature.

      Already with standard keys: M-;

    4. Re:Some favorites by Anonymous Coward · · Score: 0

      (global-set-key (kbd "C-c c") 'comment-dwim)

      C-c c to either comment out a region or uncomment it depending on context. Lovely feature.

      Ok so I tried this one on a region, and it commented out each line individually. Then when I hit it again, it added a second set of comments on each line.

      ie:

      test
      this

      became:

      /* test */
      /* this */

      became:

      /* /\* test *\/ */
      /* /\* this *\/ */

    5. Re:Some favorites by Anonymous Coward · · Score: 0

      Ok, slashdot isn't letting me log in for some reason so I'll just post anon.

      I tried emacs for about a month, trying to give it an honest shot. I actually quite liked it for editing latex docs. The problem was, there was some key combination I was hitting on accident (probably since I am used to nano keybindings) that was causing me to delete large chunks of my document (usually everything above my current view). I didn't realize it, then I would save and have to restore the file from backup. This happened several times. I think it was happening as I was saving, but could never trace back my error.

      Second, although I've read Understanding GNU Emacs and Tabs I still couldn't get tabs to just be tabs, especially when using ruby-mode, which apparently sets it's own tab behavior and overwrote my own.

      Any ideas? I'd like to give it another shot someday...

    6. Re:Some favorites by jhol13 · · Score: 1

      Set indentation to 4 spaces:
      (defalias 'c4 (read-kbd-macro
      "ESC x set- variable RET c- basic- offset RET 4 RET"))
      (global-set-key 'f4 'c4)

      This setting has changed four (4) times while I have been using (X)Emacs. Before the last change it was possible to put it into init.el, it no longer is. The whole bullshit is the reason I stopped using XEmacs, forever.

      ;; Function keys:
      (global-set-key 'f1 'help-command)
      (global-set-key 'f2 'dabbrev-expand)
      (global-set-key 'f7 'call-last-kbd-macro)
      (global-set-key 'f12 'compile)

      ;; Change a little closer to Gnome/Windows, etc.
      (global-set-key "\C-s" 'save-buffer)
      (global-set-key "\C-o" 'find-file)
      (global-set-key "\C-v" 'yank)
      (global-set-key "\C-z" 'advertised-undo)
      (global-set-key "\C-q" 'save-buffers-kill-emacs)
      ;; Reset needed stuff
      (global-unset-key "\C-b" )
      (global-set-key "\C-b?" 'describe-key-briefly)
      (global-set-key "\C-b\C-q" 'quoted-insert)
      (global-set-key "\C-b\C-w" 'kill-region)
      (global-set-key "\C-b\C-o" 'open-line)

    7. Re:Some favorites by bjourne · · Score: 1

      True, but it requires three simultaneous keypresses on my keboard (two for ';').

    8. Re:Some favorites by Just+Some+Guy · · Score: 1

      Ah. ';' is unshifted on American keyboards, so M-; takes two keypresses.

      --
      Dewey, what part of this looks like authorities should be involved?
    9. Re:Some favorites by An+ominous+Cow+art · · Score: 1

      (global-set-key 'f7 'call-last-kbd-macro)

      I agree, that's an extremely useful one. The default is very awkward.

    10. Re:Some favorites by Dolda2000 · · Score: 3, Insightful

      (global-set-key "\C-z" 'undo)

      You mention undo only as such, but I'd like to add that the undo functionality really is one of Emacs' killer functions. See, when you undo a string of commands in Emacs, it doesn't just discard that part of the undo history as most (all?) other editors do, but it folds it backwards onto the undo stack, which is unbelievably useful.

      I often use it as a sort of short-term, local version control. I can type something, try it, undo it and type something else, try that, and then undo back to the first version if I weren't satisfied with the second. It also enables me to use undo as a sort of short-term memory extension in that I can hack around a bit, and then interrupt myself for a visit to the toilet or similar. Then, when I get back, I can check exactly what I was doing before I left by just undoing a bit, and then undo the undoings.

      I don't think I'd ever be able to use an editor that doesn't have Emacs' killer undo.

    11. Re:Some favorites by 0123456789 · · Score: 1
      This is now bound to f4 by default, see:

      here.

    12. Re:Some favorites by An+ominous+Cow+art · · Score: 1

      Thanks, that's good to know!

    13. Re:Some favorites by piojo · · Score: 1

      Do you know how to increase the size of the undo buffer? It doesn't seem big enough by default to use it how you're describing... and I would like a bigger safety net.

      --
      A cat can't teach a dog to bark.
    14. Re:Some favorites by againjj · · Score: 1
      (require 'redo)

      It's awesome.

  12. 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.

    1. Re:editing over ssh by eggnoglatte · · Score: 1

      Whoa. Thanks for that!

    2. Re:editing over ssh by Falkkin · · Score: 1

      I used to use this, but haven't for the last year or two because of sshfs, since sshfs lets you run arbitrary shell commands on the remote files as well.

  13. Favorite Acronym by florescent_beige · · Score: 1

    Forget where I read this...

    EMACS: Equine Mammals are Considerably Smaller

    --
    Equine Mammals Are Considerably Smaller
    1. Re:Favorite Acronym by Simon+Brooke · · Score: 1

      EMACS: Eight Megabytes And Constant Swapping.

      GNU Emacs: Generally Not Used Except by Middle Aged Computer Scientists.

      (I resemble that remark)

      Oh, and, of course, ESC-X doctor - what use is a text editor if it can't psychoanalise you?

      --
      I'm old enough to remember when discussions on Slashdot were well informed.
    2. Re:Favorite Acronym by soboroff · · Score: 1

      The funny thing is, those jokes about Emacs being slow date back to the 80s. These days, I find that Emacs is about the fastest app to start on a modern Linux distribution.

      The rest of userland has gotten fatter and fatter, but Emacs has stayed about the same.

      Since the story asks for favorite things about Emacs, I will just add: Gnus. The best email app bar none.

    3. Re:Favorite Acronym by Simon+Brooke · · Score: 2, Informative

      The funny thing is, those jokes about Emacs being slow date back to the 80s. These days, I find that Emacs is about the fastest app to start on a modern Linux distribution.

      The rest of userland has gotten fatter and fatter, but Emacs has stayed about the same.

      Since the story asks for favorite things about Emacs, I will just add: Gnus. The best email app bar none.

      Back in the early nineties, I had an Acorn R140 with 4Mb of core; it ran RISC iX, which was basically BSD 4.2. It could just about run X11; and it could happily run a full Emacs development session (but not under X11). Pretty soon after that I got an R280, which had 8Mb of core; and that ran Emacs under X11 really nicely...

      It's a long time since Emacs has really been slow, but the jokes have long memories.

      --
      I'm old enough to remember when discussions on Slashdot were well informed.
    4. Re:Favorite Acronym by 0xABADC0DA · · Score: 4, Funny

      It's a long time since Emacs has really been slow, but the jokes have long memories.

      Performance jokes are never garbage collected -- it would take too many cycles.
      Performance jokes are never garbage collected -- there's always a weak reference to them.

      I'll be here all week... or until tuesday if the alternate pickup schedule is in effect due to holiday or inclement weather.

    5. Re:Favorite Acronym by An+ominous+Cow+art · · Score: 1

      > Eight Megabytes And Constantly Swapping

      I used to use emacs on a Vax 11/750, which was max'd out at 6 or 7 megabytes of RAM. It wasn't quite as bad as the joke acronym, but emacs did use a big chunk.

      Others I recall:

      Eventually malloc()s All Computer Storage

      Escape Meta Alt Control Shift

    6. Re:Favorite Acronym by ferguson731 · · Score: 1
      Except that the acronym needs to be recursive. This is the best I can do:

      GNUEMACS Not Used Except By Middle Aged Computer Scientists

    7. Re:Favorite Acronym by jonadab · · Score: 1

      I believe the correct acronym was Eight Megabytes And Constantly Swapping. Eight megabytes is an exaggeration, of course, intended to be a ludicrously large number. The joke dates to the era when eight megabytes was such a preposterously large amount of physical RAM, nobody would even have that much, much less want to dedicate that much to one application. Yes, I remember that time. My first computer had 640K of RAM. I experimented with various text editors but eventually settled on UED, which packed some really nice functionality, and a great interface for the time, into 38704 bytes. I used that editor for years.

      I even wrote some elisp to emulate some of UED's functionality and interface, when I first started using Emacs. At that time I believe my computer had 32MB of RAM...

      --
      Cut that out, or I will ship you to Norilsk in a box.
    8. Re:Favorite Acronym by florescent_beige · · Score: 1

      The first editor I can remember using was some thing I found on the VAX 11 780, I think it was called YALOE (Yet Another Line Oriented Editor). My favorite was the Panvalet editor, it had code folding and all sorts of (for those days) advanced things. Maybe YALOE was on the PDP 11. Good times, good times.

      --
      Equine Mammals Are Considerably Smaller
  14. Outlines w/ org-mode by Khelder · · Score: 4, Interesting

    I've recently discovered and almost instantly become a fan of org-mode, which is a great outlining tool (including folding, numbering, and other similar things you'd probably expect).

    It's also good for lists of things to do, schedules, deadlines, and related stuff. It uses its own really simple markup langauge (similar to trac wiki), but you can include LaTeX and HTML inline.

    It comes with exporters to HTML and LaTeX (and iCal for date stuff). You can also put tables inline, and the table editor is excellent for simple tables.

    I use it every day for my list of things to do, and use it regularly for outlining text documents, pseudocode, and meeting notes.

  15. 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.

    1. Re:AUCTeX with preview-latex by Anonymous Coward · · Score: 0

      Even nicer than preview-latex: Whizzytex

      http://cristal.inria.fr/whizzytex/

    2. Re:AUCTeX with preview-latex by mu22le · · Score: 0

      You should probably try http://www.lyx.org/

  16. macros are cool by Anonymous Coward · · Score: 3, Informative

    C-x ( -- start a macro definition

    -- type some commands

    C-x ) -- end the macro

    C-x e -- execute the last macro

    For certain repetitive tasks which didn't warrent a new script I though this macro capability was awesome.

    1. Re:macros are cool by armanox · · Score: 1

      Looks awfully similar to the start of a fork bomb...

      --
      I'm starting to think GNU is the problem with "GNU/Linux" these days.
    2. Re:macros are cool by Dolda2000 · · Score: 1

      Yes, and don't forget C-x z for repeating a command such as C-x e. The convenient thing about it is that you can keep pressing just the z key afterwards to keep repeating.

      I find it especially useful when re-indenting code blocks that are a bit to irregular to use C-c C-q: Just do C-x ( TAB C-n C-x ) C-x e C-x z z z z...

    3. Re:macros are cool by tjwhaynes · · Score: 1

      Or hold down Control, type in the number of times you want to repeat the macro, and then type C-x e. Very useful for those "search, replace and do stuff" macros because when the interactive search fails, the macros stop.

      --
      Anything I post is strictly my own thoughts and doesn't necessarily have anything to do with the opinions of IBM.
    4. Re:macros are cool by Haeleth · · Score: 2, Informative

      This feature is built into C-x e as well: `C-x e e e e e' is exactly the same as `C-x e C-x z z z z'. :)

    5. Re:macros are cool by againjj · · Score: 1

      I often like to bind the macros for the session:

      ;;; name-last-kbd-macro takes the last keyboard macro and names it.
      ;;; This binds it to a key sequence (and names it as a side effect).
      ;;; Now I can create more than one macro without losing any.
      (defun bind-last-kbd-macro ()
      "Assigns a global key binding to the last keyboard macro defined.
      Prompts for a key sequence that the macro should be bound to.
      As a side effect, the macro is named \"my-temporary-macro\"
      concatenated with the key sequence, using `name-last-kbd-macro'."
      (interactive)
      (let* ((key-sequence (events-to-keys
      (read-key-sequence "Key sequence to bind: ")))
      (last-kbd-macro-name (concat "my-temporary-macro"
      (prin1-to-string key-sequence)))
      (last-kbd-macro-symbol (intern last-kbd-macro-name)))
      (name-last-kbd-macro last-kbd-macro-symbol)
      (global-set-key key-sequence last-kbd-macro-symbol)
      (message (concat "Macro " last-kbd-macro-name " defined and bound."))))

      Sorry, I can't figure out a good way to tab.

    6. Re:macros are cool by Anonymous Coward · · Score: 0

      Or you can use Control-U (which I have bound to universal-argument).

      E.g. C-x( ...macro... C-x)
      Then: C-u 10 C-x e
      To execute the macro 10 times.

      Or select a region and use apply-macro-to-region-lines .

    7. Re:macros are cool by Anonymous Coward · · Score: 0

      Seems complicated.
      Why not just use 'name-last-kbd-macro'?

      E.g. C-x( ...macro... C-x)
      Then: M-x name-last-kbd-macro foo

      Invoke via: "M-x foo"

      Bind to keystroke via "M-x global-set-key [keystroke] foo"
      (Where [keystroke] is something like control-1. Press the keystroke.)

      If you wanted to save the macro, there is:
      "M-x insert-kbd-macro foo"

      Or, in a lisp-interaction buffer (like *scratch*), you can type
      (insert-kbd-macro 'foo) [control-j]

      (Where my control-j is bound to 'eval-print-last-sexp.)

      (Hint: It won't be saved unless you copy that fset declaration over to your .emacs file.)

      To just view the macro there is:
      (format-kbd-macro)

      Or edit-last-keyboard-macro.

    8. Re:macros are cool by againjj · · Score: 1

      Seems complicated. Why not just use 'name-last-kbd-macro'?

      E.g. C-x( ...macro... C-x) Then: M-x name-last-kbd-macro foo

      Invoke via: "M-x foo"

      Bind to keystroke via "M-x global-set-key [keystroke] foo" (Where [keystroke] is something like control-1. Press the keystroke.)

      That is basically what my function does, but with a nice interface. I go:

      M-x bind-last-keyboard-macro [keystroke]

      Much nicer than:

      M-x name-last-kbd-macro foo M-x global-set-key [keystroke] foo

      This is especially true since I never see a point in naming a macro that I don't save, though my function gives a names should you want it.

      Though I realize I could do this:

      (defun bind-last-kbd-macro2 (key-sequence)
      (interactive "KKey sequence to bind: ")
      (let* ((key-sequence (events-to-keys key-sequence))

  17. Not much of a trick... BUT... by McNihil · · Score: 2, Insightful

    CTRL-X 1|2|3 to divide the editing area according to wish. I simply can't live without this functionality.

    Now if anyone makes a Firefox plugin making it possible to do the same in a web browser that would be friggin awesome.

    1. Re:Not much of a trick... BUT... by Anonymous Coward · · Score: 1, Informative

      you can actually do something similar with Konqueror:
      Window -> Split View Left/Right or Split View Top/Bottom.

      it also comes with keyboard shortcuts.

    2. Re:Not much of a trick... BUT... by homer_s · · Score: 2, Funny

      Now if anyone makes a Firefox plugin making it possible to do the same in a web browser that would be friggin awesome.

      So, you don't use Emacs to browse the web?

    3. Re:Not much of a trick... BUT... by AaronW · · Score: 1

      This is one of the killer features, plus C-x 5 2. Both of these allow me to view multiple sections of the same file, basically multiple views. This is what caused me to adopt Emacs almost 20 years ago because my previous programming editor did this. I'm constantly editing several sections of the same file. Another common use for this is if I need to look up a tag, I'll just split the window then M-. to show the tag in the other window without having to leave the file I'm working on.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    4. Re:Not much of a trick... BUT... by Count+Fenring · · Score: 1

      Second, although I do wish resizing the windows sans mouse was more straightforward... Actually, I wish I could find the documentation that covered it, to tell the truth!

    5. Re:Not much of a trick... BUT... by Anonymous Coward · · Score: 0

      from my .xemacs (AFAIK this keybinding style doesn't work in GNU Emacs so you may have to RTFM):

      (global-set-key [(control \;)] 'shrink-window)
      (global-set-key [(control \')] 'enlarge-window)

    6. Re:Not much of a trick... BUT... by Count+Fenring · · Score: 1

      Thank you. That does the trick.

    7. Re:Not much of a trick... BUT... by Anonymous Coward · · Score: 0

      I use:

      (global-set-key "\C-x\C-z" 'shrink-window)
      (global-set-key "\C-xz" 'enlarge-window)

      (global-set-key "\C-xd" 'delete-window)

      (global-set-key "\C-xn" 'gosmacs-next-window)
      (global-set-key "\C-xp" 'gosmacs-previous-window)

      (global-set-key "\e!" 'line-to-top-of-window)

      (global-set-key "\C-z" 'scroll-one-line-up)
      (global-set-key "\ez" 'scroll-one-line-down)

      ; And don't overlook:
      (global-set-key "\C-x+" 'balance-windows )

      But then my .emacs is really weird. I still use gosmacs bindings.

  18. Edit files from anywhere w/ tramp by Khelder · · Score: 4, Informative

    One of my favorite emacsisms a long time ago was ange-ftp, and the modern descendant, tramp, is one of my current faves. It lets you edit remote files over lots of protocols, including: ssh, scp, ftp, rsync, ftp, and smb.

    Most emacs stuff works transparently, like dired and archive browsing. When you edit a file and save it, it's automatically put back on the remote machine. I have had trouble with psvn, but that's about the only thing that I kinda expected to work that didn't.

    If you edit remote files and you use emacs, you want to start using this.

    1. Re:Edit files from anywhere w/ tramp by legirons · · Score: 1

      One of my favorite emacsisms a long time ago was ange-ftp, and the modern descendant, tramp, is one of my current faves. It lets you edit remote files over lots of protocols, including: ssh, scp, ftp, rsync, ftp, and smb.

      Seems to lose your context/edits if the SSH connection is dropped while you're editing though?

      compare to editing with kate over a fish:// connection (again, insert juvenile jokes here), which lets you retry or save locally after a dropped SSH connection

      problem with kate over fish being, that it deletes remote file before overwriting it, which can be inconvenient/dangerous

    2. Re:Edit files from anywhere w/ tramp by Risen888 · · Score: 3, Interesting

      Tramp is also extremely useful for editing files as root without opening a root emacs session. If you use sudo on your system, it's C-x C-f /sudo::/path/to/file, or su: C-x C-f /root@localhost:/path/to/file.

      --
      Hey, I finally got my first freak! Took you long enough!
  19. 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.

  20. Editing recorded keystrokes by david.emery · · Score: 2

    A couple of times the ability of Emacs to record keystrokes and then edit them has been a real power tool, particularly when I've needed to do very complex edits over a set of files.

    So I'd record edits on the first file, look at the keyboard recording (doing any substitutes if necessary), bind that to a key combination, then iterate over the list of files. Now if I were a good Emacs hacker, I could have automated the iteration step, too :-)

    1. Re:Editing recorded keystrokes by Beezlebub33 · · Score: 1

      How do you see the keyboard recording?

      --
      The more people I meet, the better I like my dog.
    2. Re:Editing recorded keystrokes by david.emery · · Score: 2, Informative

      This is covered in Chapter 10 of that invaluable reference "Learning GNU Emacs" (now in its 3rd edition, I need to 'upgrade' my 1st edition so the chapter organization might have changed) (http://oreilly.com/catalog/9780596006488/index.html)

      You can do M-x apropos macro to get info. There's an edit-kbd-macro command as well as a whole bunch of other useful things.

      dave

    3. Re:Editing recorded keystrokes by Anonymous Coward · · Score: 0

      That'd be tags-replace-regex.

  21. I replaced it by ColonelPanic · · Score: 2, Interesting

    After 25 years of vi and Emacs, I got fed up and wrote something better. And at 6k lines of C, it's not much bigger than my .emacs file was. :-)

    Seriously, people: you don't have to live with the available options. Writing an editor is a easy job.

    And yes, I GPL'd it. Have fun.

    http://code.google.com/p/aoeui/

    --
    "Skill shows through where genius wears thin." -Wittgenstein || Religion: uniting aviation and architecture.
    1. Re:I replaced it by fortunatus · · Score: 1

      you waited 25 years? in 1982 my girlfriend wrote an editor for the freshman data structures class at our university. some folks used their editors from then on through school.

    2. Re:I replaced it by MosesJones · · Score: 3, Insightful

      Congratulations, beating out hot favourites Karl Rove and Dick Cheney you have just won single most arrogant statement of the year

      "I wrote something better"

      When you get several million users then call, until then you've got a pet project doing something that loads of people before you have done, and lots of people after you have done.

      and more people will still be using VI and Emacs

      --
      An Eye for an Eye will make the whole world blind - Gandhi
    3. Re:I replaced it by Just+Some+Guy · · Score: 1

      you have just won single most arrogant statement of the year "I wrote something better"

      Of course it's better, at least in his opinion. If it wasn't he wouldn't have written it. His opinion of "better" may be wildly different from yours, but he's 100% correct from his perspective.

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:I replaced it by trjonescp · · Score: 1

      I find that http://aoeui.googlecode.com/ is a slightly shorter and prettier URL to direct users to, IMHO.

      --
      Only speak when it improves the silence.
    5. Re:I replaced it by Ardeaem · · Score: 1

      ------------------
      Colonel Panic: After 25 years of vi and Emacs, I got fed up and wrote something better. And at 6k lines of C, it's not much bigger than my .emacs file was. :-)
      ------------------

      Whatever. I wrote an editor in one line of HTML.

      <html><head><title>My Editor (beta)</title></head><body><textarea></textarea></body></html>

    6. Re:I replaced it by starfishsystems · · Score: 1

      Interesting. About 25 years ago I wrote something similar.

      Although I got the concept of modularity insofar as providing a set of functions for primitive screen and keyboard operations which the rest of the application could use to build higher-order behaviors, I didn't expose these functions in an extensible way, nor did I provide a means of binding keys to them.

      That's because I'd never heard of emacs. So, while my little display editor was a lot more efficient to use than the primitive line editor available to me at the time, I look back on its lack of configurability and extensibility with some embarrassment.

      --
      Parity: What to do when the weekend comes.
    7. Re:I replaced it by dunkelfalke · · Score: 2, Insightful

      there are far more notepad users than vi and emacs users together.
      that does not mean, that notepad is a great text editor, though.

      --
      "It's such a fine line between stupid and clever" -- David St. Hubbins, Spinal Tap
    8. Re:I replaced it by Anonymous Coward · · Score: 0

      Thanks, i've been looking to bootstrap an editor, but didn't know where to start.

    9. Re:I replaced it by Anonymous Coward · · Score: 0

      Congratulations, beating out hot favourites Karl Rove and Dick Cheney you have just won single most arrogant statement of the year

      "I wrote something better"

      When you get several million users then call, until then you've got a pet project doing something that loads of people before you have done, and lots of people after you have done.

      and more people will still be using VI and Emacs

      It was better for him.

      That's the beauty of open source, we're just forking all day long ;)

    10. Re:I replaced it by Matchstick · · Score: 1

      Scott Adams logical fallacy #3, "I am the world". Thank you, anonymous slashdot moderator, for your "Troll" judgment.

    11. Re:I replaced it by jonadab · · Score: 1

      > he's 100% correct from his perspective.

      That's really only true if his perspective is completely egocentric. Just saying.

      Not that I don't understand the value of writing your own. I do. I have written my own of several things, rather than use generally available alternatives. Writing your own means you are intimately acquainted with every aspect of the code, so if you need to tweak the behavior in minor ways, it's easy. But just because you, the author, can use your own code to better effect, doesn't actually mean it *is* better. It means you understand it better, and that's not the same thing.

      OTOH, tweaking the behavior of Emacs is pretty easy too, with elisp, and I know I don't have time to write my own text editor with all the features of Emacs that I use regularly, and anyone who does probably has pretty low feature requirements for a text editor, especially compared to Emacs.

      --
      Cut that out, or I will ship you to Norilsk in a box.
  22. Stupid trick #1 by Anonymous Coward · · Score: 0

    Stupid trick #1: Vi emulation.

    Turning an excellent editor into a piece of rubbbihs,

  23. My fave by scubamage · · Score: 2, Interesting

    M-x hanoi - plays tower of hanoi for n number of towers

  24. Modifying variables by dkf · · Score: 2, Informative

    If you've got a file that you always want to set some specific variable to a non-default value for when editing, use something like this (taken from the end of a C file...)

    /*
      * Local Variables:
      * fill-column: 78
      * c-basic-offset: 4
      * End:
      */

    --
    "Little does he know, but there is no 'I' in 'Idiot'!"
  25. Open jars, wars, ears with archive-mode by wytten · · Score: 2, Informative

    Configure emacs auto-mode-alist to open Java archives with archive-mode, and then edit deployment descriptors contained in the archive without having to extract the archive. Bliss.

  26. Re:heres my favorite by mebrahim · · Score: 1

    You must have forgotten order of ln parameters. It is just like cp: ln -s /usr/bin/vim /usr/bin/emacs

  27. Re:Emacs... by armanox · · Score: 1

    What, don't remember the eMac?

    --
    I'm starting to think GNU is the problem with "GNU/Linux" these days.
  28. Window switching by Anonymous Coward · · Score: 0

    I only started to feel like I was beginning to have a clue with emacs when I learned to manage windows .. from then on the learning curve is easy because you're no longer humiliated by the inability to do something you take for granted so much in any GUI

    C-x 3 split vertically
    C-x 2 split horizontally
    C-x o change to the other window
    C-x 1 delete the opposite window
    C-x 0 delete all other windows

    Org-mode is really neat also

    m-x org mode
    m-x-describe-bindings / C-h b

    Also you can use the meta key to access almost any command that also has a C- combination, by its literal full name. You can then use tab completion to jog your memory

    eg.

    m-x desc gives you the hint for the above, and when the command runs the minibuffer tells you to try C-h b next time

    Emacs is surprisingly user friendly, once you get into into the swing of things!

  29. Who needs tricks? by dkixk · · Score: 1

    My favorite Emacs trick is defun.

  30. Mistake made by jez9999 · · Score: 2, Informative

    I think this article has been incorrectly filed; please fix, editors. It's been put under "News".

    1. Re:Mistake made by TheRaven64 · · Score: 1

      That people still use EMACS is news!

      - a Vim user.

      --
      I am TheRaven on Soylent News
  31. recentf mode by wytten · · Score: 1

    recentf mode, which keeps a list of recently opened files:

    (require 'recentf)
    (recentf-mode 1)

    For bonus points, set a PROJECT environment variable before starting eclipse, and maintain project-specific lists of recently opened files:

    (when (getenv "PROJECT")
        ; project-specific recently opened files
        (setq recentf-save-file (concat (getenv "PROJECT") "/.recentf"))
        ; project-specific emacs config
        (when (file-exists-p (concat (getenv "PROJECT") "/.emacs"))
            (load-file (concat (getenv "PROJECT") "/.emacs")))
        ; project-specific TAGS file
        (when (file-exists-p (concat (getenv "PROJECT") "TAGS"))
            (visit-tags-table (concat (getenv "PROJECT") "TAGS"))))

  32. there's a whole wiki to answer this question by felipecs · · Score: 5, Informative
  33. 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/

    1. Re:some of mine by Anonymous Coward · · Score: 0

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

      Oh dear god ... thank you! I realize I've been annoyed by this, yet never for a second paused to even consider something could be done xD

      It sucks you can't C-kill when writing a post about xemacs ...

    2. Re:some of mine by Anonymous Coward · · Score: 0

      Much appreciated.

    3. Re:some of mine by Haeleth · · Score: 1

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

      Good start. Next step is to ditch Thunderbird completely and read your mail with one of the many Emacs packages designed for that purpose. Gnus is good, if you can cope with learning a new set of keybindings.

  34. Meta-/ by giblfiz · · Score: 4, Informative

    auto completes based on words that have been seen in the buffer.

  35. Re:A favourite (works well on both Ubuntu and Debi by dar · · Score: 1

    Then you forgot to install vim.

    --
    My other Slashdot ID is much lower.
  36. Check hard drive by digitalhermit · · Score: 4, Funny

    It's often the case when you need to check the sectors on your disk for corruption, or just during hard drive testing. One of the coolest things that Emacs allows you to do is check your filesystem. For example on CentOS:

          yum -y install emacs*

    This will proceed to fill up your hard drive with tons of software until the filesystem is full.

    (I kid, I kid)

  37. Emacs Lisp by tjwhaynes · · Score: 4, Funny

    Lisp is a language that CompScis see for two months at University before leaving it behind. But if you really want to learn tricks with Emacs, you should learn Emacs Lisp - I have all sorts of specials, such as "move text to marker" and modes for handling internal IBM dump formats, that would be impossible in vi.

    But if you want one quick piece of advice, here's one that should make someone smile

    M-x hippie-expand RET

    The ultimate, expand-this-thing-dammit-from-whatever-you-like completion trick.

    Cheers,
    Toby Haynes

    --
    Anything I post is strictly my own thoughts and doesn't necessarily have anything to do with the opinions of IBM.
    1. Re:Emacs Lisp by TheRaven64 · · Score: 1
      While I usually consider ESR to be an idiot, he did say something sensible about Lisp:

      LISP is worth learning for a different reason â" the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot

      EMACS is a fantastic Lisp environment (although it's a shame that most people use the C version now - EMACS on MULTICS was written in Lisp and so introspection and reflection worked everywhere, and most Lisp machines came with a version too). I'm not a huge fan of it as a text editor, but every time I write a script in Vim's scripting language I consider switching.

      --
      I am TheRaven on Soylent News
    2. Re:Emacs Lisp by dkixk · · Score: 1

      Lisp is a language that CompScis see for two months at University before leaving it behind. [...]

      Not necessarily true. Search /. archives for Paul Graham for a "famous" example of someone successfully using Lisp in a commercial product. Personally, I find the Emacs dialect of Lisp to be unfortunately restrictive, lacking even lexical closures. The Common Lisp emulation package helps out quite a bit but then one is still left without things like loop or CLOS. And the addition of SLIME and things like slime-eval are also, IMO, quite useful. However, I'm keeping an eye on Climacs because I would love to have an Emacs written with/in Common Lisp.

  38. The apocryphal command by digitalderbs · · Score: 3, Funny

    I once knew a man that typed an emacs sequence, once locked in hidden, ancient papyri. Emacs conducted all of the research for his PhD, typed his dissertation, correctly formatted his bibliography (the most astounding feat of all), setup the defense with his advisory committee, presented and defended his thesis, printed, bound and submitted the dissertation.

    1. Re:The apocryphal command by Anonymous Coward · · Score: 0

      I'm using the same methodology right now, the magic command is M-x psychoanalyze-pinhead :)

    2. Re:The apocryphal command by Anonymous Coward · · Score: 1, Funny

      I know that man, I am his boss now. Imagine had he used vim, like me...

  39. Obligatory link by fprintf · · Score: 3, Informative
    --
    This post brought to you by your friendly neighborhood MBA.
  40. Re:Emacs... by xouumalperxe · · Score: 1

    I'll take it you don't eat macaroni then. And that you hated the Macarena. And that you'll steer clear from John Carmack's games. Or...

    Troll.

    (Full disclaimer: I'm a Mac-loving Vim user)

  41. align-regexp by Just+Some+Guy · · Score: 3, Interesting

    (Pretend that '.'==' ' because Slashdot hates programmers.)

    Before:

    a.= 1
    longer.= 2
    some_variable.= None
    foo.= 'bar'

    After running M-xalign-regexp=:

    a...............= 1
    longer..........= 2
    some_variable...= None
    foo.............= 'bar'

    --
    Dewey, what part of this looks like authorities should be involved?
    1. Re:align-regexp by Halo- · · Score: 1

      Wow! An emacs trick I actually like! Thank you!

    2. Re:align-regexp by Ant+P. · · Score: 1

      Well you could always use the "make this post ugly" option... having to choose is pretty retarded though.

      a               = 1
      longer          = 2
      some_variable   = None
      foo             = 'bar'

    3. Re:align-regexp by trjonescp · · Score: 1

      That's rad. And even better is this which automatically DWYW (does what you want):

      align

      or

      align-current

      See 'C-h f align' for more

      --
      Only speak when it improves the silence.
    4. Re:align-regexp by jamesswift · · Score: 1

      a = 1
      longer = 2
      some_variable = None
      foo = 'bar'

      a               = 1
      longer          = 2
      some_variable   = None
      foo             = 'bar'

      Slashdot hates programmers who don't RTFM ;)

      --
      i wish i could stop
    5. Re:align-regexp by Gumby · · Score: 1

      THANK YOU!!!!!

  42. C-u to delete line backward by Anonymous Coward · · Score: 1, Interesting

    (defun my-kill-prev-line ()
      "Kills from the cursor to the beginning of the line."
      (interactive)
      (kill-line 0))
    (global-set-key "\C-u" 'my-kill-prev-line)

    Makes Control-U do what it does in every other place on your computer.

  43. Keyboard macros and query-replace-regexp by try_anything · · Score: 1

    There are a two general and powerful emacs tools that every user should know: keyboard macros and query-replace-regexp.

    To record a keyboard macro, hit C-x ( to start recording, type your macro, and hit C-x ) to stop. Bind F5 or another function key to call-last-kbd-macro so it's easy to run a macro many times.

    Then practice ;-) Learn to use C-a, C-e, and incremental search in your macros, so you can just hit F5 F5 F5... to perform a repetitive editing task across an entire file. You will be slow at composing the macros at first, but once you get the hang of it, you'll want to do everything using keyboard macros. (That might be a reasonable approach for some folks, but I recommend you keep going -- there's treasure everywhere!)

    Once you're good at keyboard macros, the next thing to learn is query-replace-regexp. The hardest thing about query-replace-regexp is that emacs regexp syntax is a bit of an outlier in the regexp family. Once you get over that (which I haven't entirely) you're a ninja.

    After those two, you should google around for more tips of enthusiastic emacs users, and generally keep an ear to the ground. Occasionally you'll hear of some command that is a perfect fit for your work or your brain or both.

    Finally, elisp programming is essential for serious users. You don't have to immediately set aside time to learn it, but definitely do not shy away from it when you need it. You'll need a very basic understanding to tweak your .emacs file, and your knowledge can grow from there. I've only written half a dozen elisp functions for editing (rather than configuration) but I use a couple of them at least once a week. The first editing command I created in elisp took me half a day to write and debug, but then I used it dozens of times a day for three weeks -- pretty good ROI!

  44. My Favorite... by awshidahak · · Score: 3, Funny

    is M-x Viper \[esc]x eshell All the obscureness of vim combined with the bloat of emacs. Then I have lots of fun letting people borrow my computer and watch them get mad at my custom xmodmap while trying to figure out how to get to the "Start" menu because they don't know ratpoison.

  45. Why don't we do the same every week? by War+Geese · · Score: 2, Interesting

    We can pick a topic (C++ STL,C++ boost, Eclipse, Electioneering, etc) and then post the many clever/stupid tricks we have learnt.

    1. Re:Why don't we do the same every week? by Kent+Recal · · Score: 1

      You mean like stackoverflow.com?
      Dear slashdot, we know your traffic figures are declining and you're dying for cheap and effective (ad revenue) content. But really, this is becoming a tragedy...

  46. Re:Emacs... Troll by Anonymous Coward · · Score: 0

    well...it worked didn't it? :D

  47. zippy the pinhead! by sl0ppy · · Score: 2, Informative

    M-x yow

    and of course, the ever relevant:

    M-x psychoanalyze-pinhead

  48. Re: by Anonymous Coward · · Score: 2, Interesting

    For GNU emacs:

            (require 'ffap)

    This means "find file at point." If the cursor is on anything that looks like a file (or URL, etc) it'll try to do the right thing for you automatically. RTFM for delicious details.

    "M-q" will reindent a paragraph nicely.
    "C-x ." will set a fill prefix, i.e., if you need to reparagraph something with the " >" prefix for mail replies

    Keyboard macros are great for mass editing files. "C-x (" to start recording, "C-x )" to stop, "C-x e" to execute. Once you've got the macro working, repeat as needed, "C-u 99 C-x e".

  49. 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)

    1. Re:Beginning of line by LordOfTheNoobs · · Score: 1
      I hate seeing the ~ turds when I list, but liked having them in their directory when I need them. Thus prefixing save files with a dot to merely hide them. Breaks dired-mode, but I don't really use it. If anyone knows why offhand, please share the knowledge.

      ;; hidden backup files - i hate seeing them in listings...
      ;; prefix with a dot as well as postfix with a tilde
      (defun custom-make-backup-file-name ( file )
      (let ((d (file-name-directory file))
      (f (file-name-nondirectory file)))
      (concat d "." f "~")))
      (setq make-backup-file-name-function 'custom-make-backup-file-name)

      (defun backup-file-name-p ( file )
      (let ((letters (string-to-list (file-name-nondirectory file))))
      (and (> 2 (length letters))
      (equal "." (first letters))
      (equal "~" (last letters)))))

      (defun file-name-sans-versions ( file )
      (if (not (backup-file-name-p file))
      file
      (let ((d (file-name-directory file))
      (f (file-name-nondirectory file)))
      (let ((letters (string-to-list f)))
      (concat d (subseq letters 1 (- (length f) 1)))))))

      Proper indentation is left as an exercise for the slashdot administrators.

      --
      They're there affecting their effect.
    2. Re:Beginning of line by Anonymous Coward · · Score: 0

      M-m runs the command back-to-indentation

      Exactly what you need :) .

    3. Re:Beginning of line by martin-boundary · · Score: 1
      If you use the shell to view file listings, you should try aliasing ls -B, ie in bash: alias ls='ls -B'

      This hides the *~ files from the listing, but they're still there of course and you don't need to muck around with changing the extension in emacs.

    4. Re:Beginning of line by Anonymous Coward · · Score: 0

      wtf my comment disappeared ?
      I said, your "dev-studio-beginning-of-line" function is identical to the "back-to-indentation" built in Emacs.

    5. Re:Beginning of line by Anonymous Coward · · Score: 0

      Why not just use M-m (back-to-indentation)?

  50. 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?
  51. Fun with Prompts by zeugma-amp · · Score: 1

    PS1="\w \`if [ \$? = 0 ]; then echo :\\\); else echo :\\\(; fi\` "

    ~ :) false
    ~ :( true
    ~ :)

    --
    This is an ex-parrot!
    1. Re:Fun with Prompts by marcosdumay · · Score: 1

      That is great, I use 'if command; then echo true; else echo false' all the time.

      But, unfortunely, this thread is about emacs.

  52. Here's one by jonaskoelker · · Score: 1

    When in bash, I like this trick:

    sudo apt-get -y install zsh; exec zsh

    1. Re:Here's one by EvanED · · Score: 1

      You forgot to chsh to zsh

  53. I don't know how I programmed without this by dollargonzo · · Score: 1

    This is some e-lisp to do auto-completion (using dabbrev-expand). If after a semicolon at the end of a line or in the initial whitespace, TAB will indent as usual, otherwise it will auto-complete. C-TAB is mapped to always indent

    (add-hook 'c-mode-common-hook 'autotab)
    (add-hook 'perl-mode-hook 'autotab)
    (add-hook 'cperl-mode-hook 'autotab)

    (defun dabbrev-quick ()
        (interactive)
        (if (save-excursion
                    (if (not (looking-at "^")) (backward-char))
                    (while (and (looking-at "[ \t]") (not (looking-at "^"))) (backward-char))
                    (looking-at "^\\|;")) (indent-for-tab-command) (dabbrev-expand nil))
    )

    (defun autotab ()
        (local-set-key [tab] 'dabbrev-quick)
        (local-set-key [C-tab] 'indent-for-tab-command)
    )

    --
    BSD is for people who love UNIX. Linux is for those who hate Microsoft.
  54. trying to figure something out by viridari · · Score: 4, Funny

    I like emacs but I'm not ready to change over to it 100% yet.

    Is there a way to dual boot between Vista and emacs?

    1. Re:trying to figure something out by master_p · · Score: 1

      Not until DNF gets re-written in ELISP...

    2. Re:trying to figure something out by MikeyO · · Score: 1

      > Is there a way to dual boot between Vista and emacs?

      There is no reason to dual boot, you can boot emacs as a guest OS in most other OSs

    3. Re:trying to figure something out by Anonymous Coward · · Score: 0

      I like emacs but I'm not ready to change over to it 100% yet.

      Is there a way to dual boot between Vista and emacs?

      http://www.informatimago.com/linux/emacs-on-user-mode-linux.html

  55. tetris! by lophophore · · Score: 1

    M-x tetris

    Yes, I am working, thank you very much.

    --
    there are 3 kinds of people:
    * those who can count
    * those who can't
  56. C/C++ Fast File Editing by yumyum · · Score: 1

    ;;
    ;; Functions to find the 'twin' of the currently-edited file. For instance,
    ;; executing my-c-find-twin [C-C C-f]] while editing a *.cc file will
    ;; bring up in a different buffer the *.h file that matches the '*'.
    ;;

    (defun my-c-find-file-with-extension (base extensions default)
      (if (null extensions)
          (concat base "." default)
        (let ((filename (concat base "." (car extensions))))
          (if (file-exists-p filename)
          filename
        (my-c-find-file-with-extension base (cdr extensions) default)))))

    (defun my-c-twin-file ()
      ""
      (let ((extension (file-name-extension (buffer-file-name)))
        (sans (file-name-sans-extension (buffer-file-name))))
        (cond
         ((string-match "[hH]\\(pp\\)?" extension)
          (cond
           ((string-equal "ObjC" mode-name)
        (my-c-find-file-with-extension sans '("m" "mm") "mm"))
           ((string-equal "C++" mode-name)
        (my-c-find-file-with-extension sans '("cc" "cpp" "C") "cc"))
           (t
        (my-c-find-file-with-extension sans '("m" "mm" "cc" "cpp"
                              "c" "C" "cp") "cc"))))
         (t
          (my-c-find-file-with-extension sans '("h" "hpp") "h")))))

    (defun my-c-find-twin ()
      ""
      (interactive)
      (find-file (my-c-twin-file)))

    (defun my-c-find-twin-other-window ()
      ""
      (interactive)
      (find-file-other-window (my-c-twin-file)))

    (defun my-c-find-twin-other-frame ()
      ""
      (interactive)
      (find-file-other-frame (my-c-twin-file)))

    (defun my-c-mode ()
      (unless (boundp 'my-c-c-c-4-keymap)
        (define-prefix-command 'my-c-c-c-4-keymap))

      (local-set-key [(control c)(control f)] 'my-c-find-twin)

      (local-set-key [(control c)(?4)] 'my-c-c-c-4-keymap)
      (local-set-key [(control c)(?4)(?f)] 'my-c-find-twin-other-window)

      (unless (boundp 'my-c-c-c-5-keymap)
        (define-prefix-command 'my-c-c-c-5-keymap))

      (local-set-key [(control c)(?5)] 'my-c-c-c-5-keymap)
      (local-set-key [(control c)(?5)(?f)] 'my-c-find-twin-other-frame)

      (show-paren-mode t))

  57. A few of my favorite things by Anonymous Coward · · Score: 0

    My favorite extensions are GNUS, VM, pcl-cvs, and psvn.

    My favorite extension that I do not actually use is AUC-TeX.

    My favorite extension that I wrote is scroll-in-place.

    The command that gets me the most mileage when people ask me how to do some crazy editing task is query-replace-regexp.

    Best wishes ---

    Eric.

  58. Or you can just... by jonaskoelker · · Score: 1

    After editing, one brief command, and the new equation is typeset and displayed.

    You could just use fontenc and set up a good ~/.XCompose that lets you input most of the symbols you need.

    There's no \mathbb{F} that I could find, and taller-than-one-line \Sigma{}s don't show up well in an xterm. But it works.

  59. 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

    1. Re:The old Emacs vs Vi story by Anonymous Coward · · Score: 0

      Maybe you need to talk to someone about your anger issues: M-x doctor

    2. Re:The old Emacs vs Vi story by sootman · · Score: 2, Funny

      As the original post hints, this is an adaptation of and old Emo Phillips bit.

      I was walking across a bridge one day, and I saw a man standing on the edge, about to jump off. So I ran over and said "Stop! don't do it!"
      "Why shouldn't I?" he said.
      I said, "Well, there's so much to live for!"
      He said, "Like what?"
      I said, "Well...are you religious or atheist?"
      He said, "Religious."
      I said, "Me too! Are you christian or buddhist?"
      He said, "Christian."
      I said, "Me too! Are you catholic or protestant?"
      He said, "Protestant."
      I said, "Me too! Are you episcopalian or baptist?"
      He said, "Baptist!"
      I said,"Wow! Me too! Are you baptist church of god or baptist church of the lord?"
      He said, "Baptist church of god!"
      I said, "Me too! Are you original baptist church of god, or are you reformed baptist church of god?"
      He said,"Reformed Baptist church of god!"
      I said, "Me too! Are you reformed baptist church of god, reformation of 1879, or reformed baptist church of god, reformation of 1915?"
      He said, "Reformed baptist church of god, reformation of 1915!"
      I said, "Die, heretic scum", and pushed him off.

      --
      Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
    3. Re:The old Emacs vs Vi story by eureka1 · · Score: 1

      The system they use is not Unix, and it's not Linux. It's GNU, and GNU's Not Unix. (See http://www.gnu.org/gnu/the-gnu-project.html.)

  60. Two tips for trailing whitespace by stevey · · Score: 2, Informative

    There are a lot of things that you can do with Emacs, but I find the two simplest to share would be related to trailing whitespace:

    ;; Show trailing whitespace by default
    (when (>= emacs-major-version 21)
    (setq-default show-trailing-whitespace t))

    ;;
    ;; kill trailing white space on save
    ;;
    (add-hook 'write-file-hooks
    'delete-trailing-whitespace)

    1. Re:Two tips for trailing whitespace by Anonymous Coward · · Score: 0

      I like the first one. Any idea how I change the color from red?

    2. Re:Two tips for trailing whitespace by stevey · · Score: 1

      If you run M-x apropos you can search for "trailing-whitespace" and read the documentation.

      The short version though is that you need to set a custom face. For example:

      (custom-set-faces
      '(trailing-whitespace
      ((((class color) (background dark)) (:background "blue")))))

  61. Rmail base64 decoder by Lew+Perin · · Score: 1

    These days more and more email I get is base64-encoded (usually for no good reason.) Since I'm the kind of caveman who still uses Rmail, I came up with this annoyance-avoider:

    (defun rmail-base64-decode ()
        "Decode a base64-encoded RMAIL message body or its base64-encoded MIME parts"
        (interactive)
        (set-buffer rmail-buffer)
        (goto-char (point-min))
        (while (search-forward-regexp "^[Cc]ontent-[Tt]ransfer-[Ee]ncoding: +base64"
                                                                    (point-max) t)
                (if (search-forward "\n\n")
                        (let ((inhibit-read-only t)
                                    (base64-start (point)))
                            (if (search-forward-regexp "\\(^$\\|^-\\)")
                                    (let ((base64-end (- (point) 1)))
                                        (base64-decode-region base64-start base64-end))
        )))))

    --
    Sorry, I forgot there are ads on the Web; I use Lynx.
  62. What?? by jonaskoelker · · Score: 1

    What, you run a window manager at all??

  63. vi / emacs Rosetta stone by jabberw0k · · Score: 1

    There's also this Side-by-side quick-reference chart for (emacs/vi) users stuck with (vi/emacs).

    1. Re:vi / emacs Rosetta stone by Haeleth · · Score: 1

      Unfortunately it's inaccurate. For example, it claims that "forward one page" is Alt+V in Emacs. But pressing Alt+V in Emacs just gives the message "A-v is undefined", unless of course you happen to be using a computer where the Alt key has been configured to send Meta.

      (Yes, Windows and many Linux boxes are set up to do that by default. But that just means you'll end up cursing the first time you find yourself in front of a Solaris box, or a Linux box that's been configured in any of the dozens of other possible ways.)

  64. Favorite obscure command - C-x RET f by Anonymous Coward · · Score: 1

    For people who deal with a lot of DOS/UNIX end of line issues. With this command you can get rid of those pesky ^M's when editing files from another OS.


    C-x RET f runs the command set-buffer-file-coding-system
          which is an interactive compiled Lisp function in `international/mule'.
    (set-buffer-file-coding-system CODING-SYSTEM &optional FORCE)

    Set the file coding-system of the current buffer to CODING-SYSTEM.
    This means that when you save the buffer, it will be converted
    according to CODING-SYSTEM. For a list of possible values of CODING-SYSTEM,
    use M-x list-coding-systems.

  65. Hide passwords by FlyingBishop · · Score: 1

    I don't know who decided this was a good idea, but if you run any sort of terminal in emacs ( M-x ansi-term or M-x shell or ...)
    the terminal displays your passwords in plain text.

    (add-hook 'comint-output-filter-functions
                        'comint-watch-for-password-prompt)

    Will make Emacs hide it if you're typing in passwords. This is also useful for, say, SQL interpreters, which are much easier to use out of emacs than bash.

    These set control-shift-v and c to paste and save from the gnome clipboard. (this is in line with gnome-terminal's hotkeys) When I'm alt-tabbing between Firefox and Emacs, this means I don't have to leave the keyboard to copy-paste.

    (define-key global-map (kbd "C-S-v") 'clipboard-yank)
    (define-key global-map (kbd "C-S-c") 'clipboard-kill-ring-save)

    One of my favorite general-purpose commands is "M-|". It lets you run a shell command on a region. Usually, I'll select the whole buffer, then run it. It's useful for testing out scripts (M-| perl RET) or word count (M-| wc RET)

  66. Re:A favourite (works well on both Ubuntu and Debi by aproposofwhat · · Score: 3, Funny

    I started on punch cards, you insensitive clod!

    --
    One swallow does not a fellatrix make
  67. My two cents by Anonymous Coward · · Score: 1, Interesting

    ;; Color parenthesis matching
    (show-paren-mode t)
    (setq show-paren-style 'parenthesis)
    (setq blink-matching-paren-distance 51200)

    ;; Scrollbar on the right hand side
    (set-scroll-bar-mode 'right)

    ;; Alt-G to jump to certain line number
    (global-set-key "\M-g" 'goto-line)

    ;; Remove the annoying toolbar
    (tool-bar-mode 0)

    ;; Turn off beeping
    (setq visible-bell t)

    ;; No backup files to cleanup later
    (setq make-backup-files nil
                backup-inhibited t)

    ;; No more blinking cursor
    (blink-cursor-mode nil)

    ;; Make pgup/dn behavior sane
    (setq scroll-preserve-screen-position 1)

    ;; Highlight current line
    (global-hl-line-mode 1)

    ;; No more annoying startup message
    (setq inhibit-startup-message t)

  68. Elscreen by fsmunoz · · Score: 1

    One thing that I use alot is Elscreen (http://www.morishima.net/~naoto/software/elscreen/index.php.en), which basically extends the regular window/buffer functions and adds different "tabs", just like GNU screen does for the shell.

    This allows me to have my editing session in one tab, my IRC session on another and my GNUS state in yet another, each screen with his own frame arrangement.

    The Emacs Wiki site is probably the best site to find out similar packages and useful tricks (http://www.emacswiki.org/). The sheer breadth of what Emacs provides makes the "vi" comments redundant.

  69. macros by Anonymous Coward · · Score: 1

    Being able to write a macro in emacs is unbelievably powerful. I use these for a million purposes, every day.

    C-x ( to start defining a macro
    C-e M-b M-u C-n
    C-x ) to end definition ...now you have a handy macro to capitalize the last word of a line.

    C-x e run the macro once
    C-u C-x e run the macro four times
    C-u C-u C-u C-u C-x e run the macro 256 times

    By using other powerful tools like regexp search in a macro, you can do almost anything. You can bind the new macro to a key, but it's so easy to define a new one (once it seeps into the subconscious) that I never bother.

  70. Completion and incremental search are... by StressedEd · · Score: 2, Interesting
    very useful and extremely simple. Assuming [M] means "Meta-key".

    [M]/ Will attempt to complete the current word. This is done working backwards from the edit point and can look in other buffers.

    If (for example) you are editing a LaTeX document and you wish to cross reference an existing figure with label \label{f:my-figure} entering the following:

    \ref{f:[M]/ will repeatedly try to match everything starting with f: , namely all the existing figure labels.

    Likewise if referencing a citation in a BibTeX file that is open in another buffer, \cite{startofkey[M]/ works a treat!

    Incremental search is also wonderful. When correcting text from (say) a hard-copy simply do [M]S and start typing the first few words of the sentence before the edit point. Magically Emacs will take you there.

    This is also very useful for moving around in documents. Simply enter "??" or some other simple placemarker move around, then do [M]S?? and you'll fly back to where you were.

    For formatting "paragraphs" [M]Q is the way forward. Quite simply no other editor I have come across has a better understanding of the 'right' behaviour for this.

    If you have some text that looks like this (n.b. _ indicates space)

    ____Some text that is on a line that we wish to wrap around so that the new line starts aligned to the first line. Ordinarily there is no sensible way of doing this bar tab stops, however if you 'do a meta q' it will magically align this paragraph.

    Then after a [M]q (fill-paragraph) you will get

    ____Some text that is on a line that we wish to wrap around so that
    ____the new line starts aligned to the first line. Ordinarilly there
    ____is no sensible way of doing this bar tab stops, however if you 'do
    ____a meta q' it will magically align this paragraph.

    So that the paragraph is left aligned to the first line. Finally, as others have said regexp replace and various other packages (e.g. AucTeX) are unparalleled!

    --
    Be nice to people on the way up. You will meet them again on your way down!
  71. A URL shortener by Wolfbone · · Score: 1

    ;; URL shortener especially useful with the It's All Text mozilla addon

    (defun wb/web-urlp (string)
      "Is STRING a web browsable sort of URL?"
      (let ((type (aref (url-generic-parse-url string) 1)))
        (cond ((eq type nil) nil)
          ((string= type "http") t)
          ((string= type "https") t)
          ((string= type "ftp") t)
          (t nil))))

    (require 'mm-url)

    (defun wb/shorten-url ()
      "Replace the URL around point with an equivalent shortened one.
    The short URL is provided by metamark (URL `http://metamark.net')"
      (interactive)
      (catch 'not-web-url
        (let* ((bounds (bounds-of-thing-at-point 'url))
           (longurl (buffer-substring (car bounds)
                          (cdr bounds)))
           (url (if (wb/web-urlp longurl)
                (concat "http://metamark.net/api/rest/simple?"
                    (mm-url-encode-www-form-urlencoded
                     (list (cons "long_url" longurl))))
              (throw 'not-web-url (message "Not a web URL"))))
           (short-url
            (save-excursion
              (with-temp-buffer
            (mm-url-insert url)
            (let* ((bounds (bounds-of-thing-at-point 'url))
                   (metamark-url (buffer-substring (car bounds)
                                   (cdr bounds))))
              (unless (wb/web-urlp metamark-url)
                (throw 'not-web-url
                   (message (car (split-string
                          (buffer-string) "[\r\n]+")))))
              (kill-ring-save (car bounds) (cdr bounds))
              metamark-url)))))
          (if (or buffer-read-only
              (text-property-any (car bounds)
                     (cdr bounds)
                     'read-only t))
          (message "Yankable shortened URL: %s" short-url)
        (kill-region (car bounds) (cdr bounds))
        (insert short-url)
        (message "Yank to recover the original URL")))))

  72. Emacs without X by thetartanavenger · · Score: 1

    One thing I'd like to know how to do is to stop emacs from ever loading an X window.

    I do a lot of work over ssh and sometimes need X-forwarding to be on. Unfortunately this means by default that emacs will load in an X window taking easily 30 seconds longer to load. I know the command emacs-nox but that's a bitch to type especially when you're in the habit of typing emacs. I do not have any root access to the machines being used so I can't install just emacs-nox.

    So, does anyone know of any script or setting I can change for my account only that would prevent this?

    --
    Who need's speling and grammar?
    1. Re:Emacs without X by fsmunoz · · Score: 1

      $ emacs -nx

      This is not a different binary, simply a flag.

    2. Re:Emacs without X by thetartanavenger · · Score: 1

      $ emacs -nx

      This is not a different binary, simply a flag.

      Doesn't work with the versions I'm using for some reason. Also, I'd like it so that I never have to type something different. With most of the systems I'm using typing "emacs" will only bring up the console version, except the occasional networks where it doesn't and it drives me up the wall. So I want a permanent setting on those networks local to m user that stops it using the X version when typing emacs. Cheers btw..

      --
      Who need's speling and grammar?
    3. Re:Emacs without X by tehshen · · Score: 1

      It doesn't work because the switch is emacs -nw. Either set an alias, install emacs-nox if you have it, or start emacs with an empty $DISPLAY variable.

      --
      Guy asked me for a quarter for a cup of coffee. So I bit him.
    4. Re:Emacs without X by thetartanavenger · · Score: 1

      Wonderful, I didn't know about aliases so I've set up a permanent one and it works hunky dory. Cheers.

      --
      Who need's speling and grammar?
    5. Re:Emacs without X by Solra+Bizna · · Score: 1

      So, does anyone know of any script or setting I can change for my account only that would prevent this?

      I have the same problem.

      alias emacs="emacs -nw"

      in my .bashrc fixes it on that machine.

      -:sigma.SB

      --
      WARN
      THERE IS ANOTHER SYSTEM
    6. Re:Emacs without X by flolo · · Score: 1

      emacs -nw

  73. Rectangle Cut and Paste by rockmuelle · · Score: 4, Informative

    Working with rectangular regions is a breeze in emacs (very useful for quickly swapping columns in csv-type files):

    Set the mark at the upper left of the rectangle... move the cursor the lower right...

    Kill rectangle: c-x r k

    Move somewhere else...

    Yank rectangle: c-x r y

    There are some other rectangle commands, but these are probably the two most useful "unknown" emacs commands I've come across.

    -Chris

    1. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      My favorite:

      M-x string-insert-rectangle

    2. Re:Rectangle Cut and Paste by Just+Some+Guy · · Score: 1

      The only thing that annoys me that I haven't bothered to look up yet is how to move past the end of a line when selecting a rectangle. Suppose I have:

      Item 1: short
      Item 2: long text here
      Item 3: foo

      and want to delete everything from the colon onward. (Also suppose I'm dead set on using rectangle commands for the purposes of illustration and don't want a workaround :-) ). I'd normally move to the colon after "Item 1" and set the mark. Then I'd move to the end of the "Item 3" line. If I press C-x r d now, I'll end up with:

      Item 1: rt
      Item 2: g text here
      Item 3:

      How do I say "yes, I know I'm at the end of the line, but keep moving anyway"?

      --
      Dewey, what part of this looks like authorities should be involved?
    3. Re:Rectangle Cut and Paste by StressedEd · · Score: 1

      How do I say "yes, I know I'm at the end of the line, but keep moving anyway"?

      I think that's the crux of your question, the kill-rectangle thing is a sideline (the correct way is a regexp replace, but I guess you know that).

      I don't know if there's a general way to do this. I think it's a feature a 'line' means something specific in Emacs. You can't simply place your edit cursor at any position, there has to be text preceding the cursor.

      To solve your specific problem consider a suggestion by another member of the forum regexp-align, for the dollar symbol (the regexp indicating the end of the line).

      Item 1: short
      Item 2: long text here
      Item 3: foo

      First, move your cursor to the first colon, then select the region to the end of "foo" as before. Now do regexp-align and enter a dollar sign as the regular expression to align (end of line). This will now align all the end of lines by adding white space (usually tabs) in that region. Since Emacs still remembers the region (including the added whitespace) now do kill-rectangle and boom, job done! I feel dirty now!

      As to the general problem. Perhaps the only way I think is to change Emacs so it silently inserts spaces as you move character by character past the end of a line removing them as you move back. This could be nasty though as it could insert spaces without you being aware of them. Of course there's probably a lisp add-on to do this!

      Bottom line, "if you want to get there, don't start from here"!

      --
      Be nice to people on the way up. You will meet them again on your way down!
    4. Re:Rectangle Cut and Paste by Just+Some+Guy · · Score: 1

      To solve your specific problem consider a suggestion by another member of the forum regexp-align, for the dollar symbol (the regexp indicating the end of the line).

      That was me, but that hack hadn't occurred to me. Clever! Another workaround would to go to the end of the last line and press C-u 100 SPC C-SPC to make it much longer than the other lines and mark the new end-of-line position. Then, move back to the colon after "Item 1" and delete the rectangle.

      Bottom line, "if you want to get there, don't start from here"!

      Oh, sure. I was just bemoaning a common situation I seem to find a lot.

      --
      Dewey, what part of this looks like authorities should be involved?
    5. Re:Rectangle Cut and Paste by jrvz · · Score: 1

      Actually I use C-x r t much more often, to insert a string at the beginning of several lines. For example, write out a multi-line help message, then prefix everything with ' printf("', or manually add a "> " prefix to quoted lines in a message. It can also replace the first several characters of every line with a common prefix. The one thing it cannot do is remove the first several characters (i.e. replace them with nothing). For that, you need C-x r k.

    6. Re:Rectangle Cut and Paste by An+ominous+Cow+art · · Score: 1

      As to the general problem. Perhaps the only way I think is to change Emacs so it silently inserts spaces as you move character by character past the end of a line removing them as you move back. This could be nasty though as it could insert spaces without you being aware of them. Of course there's probably a lisp add-on to do this!

      Although Emacs was my first love, one of the things Brief had which won my heart was the concept of 'virtual whitespace' (I believe that was the name of the feature). Basically you could move your cursor anywhere, but unless you actually typed something, it wouldn't actually add anything to the file. This was great for rectangular cutting and pasting.

    7. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      - and always convenient to enter "comment" characters
      C-x r t - string-rectable or "rectangle type"

    8. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      CUA-mode makes this much easier. M-x cua-mode, then mark with C-RET instead of shift-space. This will mark a rectangular area that can be cut, copied and pasted with the windowsy C-x, C-c and C-v.

    9. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      Working with rectangular regions is a breeze in emacs (very useful for quickly swapping columns in csv-type files):

      Set the mark at the upper left of the rectangle... move the cursor the lower right...

      Does that involve moving the cursor downwards 20000000 times?

      not exactly 'selecting a column' is it?

    10. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      Genius - thanks so much!

    11. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      I use the space bar for "yes, I know I'm at the end of the line, but keep moving anyway". It works fine for the purpose of rectangular selection.

    12. Re:Rectangle Cut and Paste by Anonymous Coward · · Score: 0

      Don't forget C-x r t which inserts a string in every line of the selected rectangle.

      Especially when editing source code it often happens to me that I need to modify several lines of the same structure. The simplest example is of course to add comment signs in front of all rows but there are many other use cases once you look for them.

  74. Re:One reason why VI is better... by haystor · · Score: 1

    Except for:
    1. constantly moving in and out of command mode
    2. reaching for ESC
    3. wtf is with the movement keys being shifted one off from the home position for the right hand?

    vi seems to be optimized for hunt and peck typers.

    Complaining that your pinky buckles under heavy emacs use may be a more valid, but saying that vi is more efficient on typing is only true if you can't really type.

    --
    t
  75. I suggest the following to the OP by Anonymous Coward · · Score: 0

    Take the shovel.
    Eat the shovel.

  76. Re:Please Don't Stop by DiegoBravo · · Score: 0, Flamebait

    From the resume:

    >> Since the Vi version of this question was both interesting and popular, let's hear from the other end of the spectrum

    A bit suspicious, but is there any reason the VIM story ran first than the Emacs one? (and the Emacs' smells like a sort of concession) ... Taco's preferences lurking? It would be interesting to see if the ./ crowd has a marked statistical preference for one of the editors independently of the (religious) reasons; I'd speculate that Vim is a lot more used because its ubiquity in almost every Linux fresh installation.

  77. Keyboard Macros by Anonymous Coward · · Score: 0

    This is a simple example of something that I've occasionally found really helpful. Split the frame into two windows and create two new buffers. In one buffer type numbers*, eg:

    0
    1
    2

    In the other window write some skeletal code, eg:

    x[] =

    And copy that line twice, eg:

    x[] =
    x[] =
    x[] =

    Move the cursor so it's over the x in the first line. Now switch back to the numbers buffer and put the cursor on the first number. Now type C-x ( to start defining a keyboard macro. Type C-space to set the mark, C-e to move to the end of the line, M-w to copy the region, C-a to move to the beginning of the line and C-n to move to the next line. Now type C-x o to move to the other window. Type C-f twice to move the cursor to be over the ] of the first line, then C-y, then C-e, then type space and C-y. Then type C-a and C-n then C-x o . Now type C-x ) and then C-u 2 C-x e.

    * These numbers can be auto generated, for when there are many of them, see, eg calc-mode (oh that's a another excellent feature that seems to be underused).

  78. It depends your level, what a trick is by dgerman · · Score: 1

    * gnus. The _best_ email reader.
    * remember, along with org make your life simpler
    * flyspell, for those times my fingers misbehave
    * auc-tex mode for writing latex
    * w3 for those times you have to cut and past nicely formatted web pages into a buffer
    * org-mode again, for table editing
    * calc, for a very powerful calculator
    * tetris to kill time
    * dired mode for browsing directories and acting upon files
    * edit-env for modifying environment variables in the running process (and future children)
    * mpg123 to play your mp3 collection
    * igrep: very nice grep, better than default one.
    * yasb: switch buffers via regular expression.

    Some nice tricks:

    * make-frame-on-display. Start a window of a running process in another Xserver (including a remote one)
    * emacs-client -n. Load file in running emacs (in server mode) without waiting

    * Being able to run emacs in a Nokia N810! With remember and org this is a killer application.

    --dmg

  79. Browsing Code: ecb-mode and etags by jonaskoelker · · Score: 2, Informative

    Whenever you download a bunch of code and want to dip your feet in it, it helps getting a good overview.

    To that end, ecb-mode can be greatly helpful. It displays navigable directory trees, a list of all symbols defined in your current file, a list of recently visited files, and a compile window. Double-click anything to jump to it, quite nice to use. The symbol list is really neat; I've thrown C, python and makefiles at it, much to my satisfaction. Haskell support is a bit rudimentary, but still very useful. It says it handles perl and TeX specially [they can't be parsed without being partially executed]. I don't know how well.

    If you just want to follow symbols around, use etags [use it anyways]. Run etags in your source root (zsh% etags **/*.[ch]), cursor-over a symbol, press M-. to jump to it.

  80. Questions for Emacs People by B1ackDragon · · Score: 1

    Reposting Logged in....

    I tried emacs for about a month, trying to give it an honest shot. I actually quite liked it for editing latex docs. The problem was, there was some key combination I was hitting on accident (probably since I am used to nano keybindings) that was causing me to delete large chunks of my document (usually everything above my current view). I didn't realize it, then I would save and have to restore the file from backup. This happened several times. I think it was happening as I was saving, but could never trace back my error.

    Second, although I've read Understanding GNU Emacs and Tabs [northpark.edu] I still couldn't get tabs to just be tabs, especially when using ruby-mode, which apparently sets it's own tab behavior and overwrote my own.

    Any ideas? I'd like to give it another shot someday...

    --
    The snow doesn't give a soft white damn whom it touches. -- ee cummings
    1. Re:Questions for Emacs People by An+ominous+Cow+art · · Score: 2, Informative

      The problem was, there was some key combination I was hitting on accident (probably since I am used to nano keybindings) that was causing me to delete large chunks of my document (usually everything above my current view). I didn't realize it, then I would save and have to restore the file from backup. This happened several times. I think it was happening as I was saving, but could never trace back my error.

      My guess would be that you were pressing ctrl-w, "kill-region", which removes everything between your cursor and the 'mark', and places it in the kill buffer. As with ctrl-k, pressing ctrl-y will 'yank' it out and insert it (insert juvenile jokes here :-)).

    2. Re:Questions for Emacs People by ericferris · · Score: 1

      BlackDragon,

      You were probably hitting the Control-W key. It doesn't write the file, it wipes the current region between curson and mark (you set the mark by hitting C-Space, defaults to top of the file).

      As for tabs, what exactly do you want to achieve?

      --
      Fantasy: http://ferrisfantasy.blogspot.com/
    3. Re:Questions for Emacs People by mortonda · · Score: 1

      (insert juvenile jokes here :-)).

      Isn't there an emacs command for that?

    4. Re:Questions for Emacs People by dkixk · · Score: 1

      C-h l runs the command view-lossage
        which is an interactive compiled Lisp function in `help.el'.
      It is bound to C-h l, M-? l, <f1> l, <help> l.
      (view-lossage)

      Display last 100 input keystrokes.

      To record all your input on a file, use `open-dribble-file'.

      [back]

  81. Re:Please Don't Stop by Falkkin · · Score: 3, Insightful

    Yeah, given that the *nix thread had over 2000 comments, I'd say there's a significant demand for more of these sorts of posts.

    My only regret is that I wish they'd spaced out the articles a bit, so that I had some time to digest the tricks in one article before reading the next one -- I find that if I add too many tricks to my toolbox at once I tend to forget about some of them. I guess I should just re-read the articles in another month or so. (Also an indication that these are quality articles -- there's not many discussion threads on Slashdot that I'd even consider going back and re-reading later.)

  82. Re:Young people being led astray? by Anonymous+Brave+Guy · · Score: 1

    It would be tragic to think that bad habits from 20 years ago would be inflicted on a new generation.

    The tragic thing is that the new generation are still using 20-year-old ideas for operating systems, databases, text editors and the like, because nothing that's coming along since has managed to do much better.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  83. vi is for building emacs by mkcmkc · · Score: 1

    I know just enough vi to build emacs (back in the olden days, there were machines that didn't come with emacs).

    I've looked at vim before, but emacs has a lot of features I wouldn't want to live without. Not to mention that I've spent 20 years learning it. :-)

    I still recall my first session of vi. It was on a 3B2, and I had to unplug the box to exit vi, as there was no documentation available...

    I might have converted at some point if the "arrow keys" were on j-k-l-; instead of h-j-k-l. Who thought that would be a good idea?

    --
    "Not an actor, but he plays one on TV."
    1. Re:vi is for building emacs by DHalcyon · · Score: 1

      :q!

      All I ever needed.

    2. Re:vi is for building emacs by i.of.the.storm · · Score: 2, Interesting

      Haha, I really don't understand why vi doesn't have anything helpful at all when you start it up. Emacs' tutorial is so nice and helpful, whereas every time I start vi I have that same experience and just keyboard mash until I manage to quit. I admit that I haven't spent much time trying to learn vi, and only really started using emacs this semester (first semester of college) but if I'm ever on a system that doesn't have emacs nano is better since I can actually figure out how to save and quit without reading documentation. I think that has to be one of the tenets of good UI design; if it isn't completely obvious how to operate a program, it should at least be obvious how to get help within the program. Once I'm in vi and don't know anything knowing to check the manpage isn't going to be much help. I picked up some basic knowledge from the vi thread here but sheesh, that kind of stuff should be readily available inside the program.

      --
      All your base are belong to Wii.
    3. Re:vi is for building emacs by i.of.the.storm · · Score: 1

      Aha! I just ran vi on my own computer and it was vim, which actually does show you how to get help. But the CS Solaris servers here only have vi, ugh.

      --
      All your base are belong to Wii.
    4. Re:vi is for building emacs by hdparm · · Score: 1

      1] Type: vim and press
      2] What is not so obvious on the next screen?

    5. Re:vi is for building emacs by mkcmkc · · Score: 1

      Now you tell me. Where were you in 1986?

      --
      "Not an actor, but he plays one on TV."
    6. Re:vi is for building emacs by DHalcyon · · Score: 1

      I wasn't quite born at the time, but had I been alive, I'd have made sure to tell you! ;)

    7. Re:vi is for building emacs by tygt · · Score: 1

      Actually old ADM3A terminals (and possibly even earlier ones)...... oh hang on, a "terminal" for those too young to remember was a device with a CRT and a keyboard which you used to interface to the computer, typically via a modem; the terminal had minimal smarts and was purely an I/O device... Anyhow ADM3A terminals had arrows printed on their HJKL keys, which is probably where the vi commands got their bindings.

    8. Re:vi is for building emacs by StandardDeviant · · Score: 2, Informative

      Solaris, it's been said, has a great kernel and an utterly shit userland (i.e. the tools you actually interact with). I can almost guarantee you that at some point the admins of your system have gotten pissed off at the Sun-shipped utils (from hell's heart, sun tar, I stab at thee) and have installed some variety of 3rd-party-freeware utilities on the system (either Sun's freeware, Sun Freeware [different], or Blastwave freeware come to mind). You might try looking, if you haven't yet, in /opt and /usr/local to see if bin dirs exist under there somewhere as these are common locations for these packages. If so, adding them into your shell's $PATH will make interactive use a lot more pleasant.

    9. Re:vi is for building emacs by Anonymous Coward · · Score: 0

      What is a CRT?

    10. Re:vi is for building emacs by mkcmkc · · Score: 1

      Actually, as I recall I learned emacs on some sort of ADM terminal. Not the 3a, though--this one had some sort of half-assed keypad on it (that was way more trouble to set up than it was worth).

      Strictly speaking, though, that still leaves the question of why the designers of the ADM3a put the arrows where they did...

      --
      "Not an actor, but he plays one on TV."
    11. Re:vi is for building emacs by mkcmkc · · Score: 1

      Some kid programmer referred to me the other day as "someone from your generation". Whippersnappers everywhere! :-)

      --
      "Not an actor, but he plays one on TV."
    12. Re:vi is for building emacs by i.of.the.storm · · Score: 2, Funny

      I was talking about vi, I didn't know about vim to be honest. On Linux on my computer vi is aliased to vim but not on our Solaris servers at Berkeley.

      Also, a fun related quote from one of the professors here, Paul Hilfinger:

      In the interests of truth, beauty, and justice -- and to undo, in some small part, the damage Berkeley has done by foisting vi on an already-unhappy world -- Emacs will be the official CS61A text editor this semester

      --
      All your base are belong to Wii.
    13. Re:vi is for building emacs by i.of.the.storm · · Score: 1

      Cool, thanks. We do have directories like that and I think they're already in the path. On a related note, I've been trying to change my default shell by setting $SHELL and I can echo $SHELL and it says bash but every time I log on I get csh which is annoying for me because I like tab completion. I don't really know what other benefits there are to bash but I would much rather prefer to use it than csh if possible, without having to type bash at every logon.

      --
      All your base are belong to Wii.
    14. Re:vi is for building emacs by thebjorn · · Score: 1

      man chsh

    15. Re:vi is for building emacs by i.of.the.storm · · Score: 1

      chsh isn't present on Solaris. I already tried that.

      --
      All your base are belong to Wii.
    16. Re:vi is for building emacs by Anonymous Coward · · Score: 0

      The $SHELL environment variable is more a reflection of what shell you're using than a means of controlling which shell you use.

      If you just want to run a different shell temporarily, you can just run it. If you want to change your default shell, the chsh command is your friend (just make sure you know the full path to your new shell before you run it).

      Incidentally, tcsh is the improved csh, so you should use that instead if you actually want to use a csh variant. But, IMHO, zsh is the preferred option if it's available. Of course shell selection is a lesser-known holy war than the emacs-vi one you'll see in threads for this story, so YMMV.

    17. Re:vi is for building emacs by spitefulcrow · · Score: 1

      Ahh, a fellow Berkeley student. To give you a few hints, Instructional Support's Solaris boxes do in fact use the GNU userland utilities (Sun's userland sucks, as mentioned above). tcsh *should* be the default shell; if for whatever reason your account is screwed up, log in to update.cs to get a menu to change your shell, password, and so on. Emacs is most definitely installed, and you can invoke vim as 'vim'.

      --
      Sorry, my karma just ran over your dogma.
    18. Re:vi is for building emacs by i.of.the.storm · · Score: 1

      Ah, cool thanks. My class account uses tcsh, but my named account uses csh which is really annoying. Thanks a lot for that, I only used update the first time to change my password so I never really checked it again. I just use emacs for cs61a stuff mostly.

      --
      All your base are belong to Wii.
    19. Re:vi is for building emacs by sgbett · · Score: 1

      have root?

      set it in /etc/passwd

      username:x:100:1::/home/username:/usr/bin/bash

      --
      Invaders must die
    20. Re:vi is for building emacs by i.of.the.storm · · Score: 1

      Oh, someone else who goes to Berkeley showed me how to do it, I don't think students get root access lol.

      --
      All your base are belong to Wii.
    21. Re:vi is for building emacs by againjj · · Score: 1

      If you talk to the people in 395 Cory, you can often get anything done: root == god. Oh, and if you are inclined, ask Hilfinger about "Hilwhere". It's a fun story.

    22. Re:vi is for building emacs by i.of.the.storm · · Score: 1

      Ah, don't have Hilfinger unfortunately, and I'm taking CS61C next semester. Does it have something to do with aliases?

      --
      All your base are belong to Wii.
    23. Re:vi is for building emacs by againjj · · Score: 1

      http://catless.ncl.ac.uk/Risks/18.08.html#subj7

      Hilfinger's version is more enjoyable. He talks about the "blue-haired ladies" in power believed that "fingering someone" sounded obscene. They forced the computer admins to change the name of "finger", and they did it to Hilfinger's name as well to make a point. Hilfinger agreed with the point and went along with it.

  84. HTML shortcuts by miahfost · · Score: 1

    If you are editing html you can insert a link with C-c C-c h and an image with C-c C-c h. If you want to open your html in a browser you can do C-c C-v. When editing perl use cperl-mode for "canonical" syntax and indentation.

  85. ediff/emerge, code indenting, by mkcmkc · · Score: 1

    ediff/emerge is really pretty slick, once you figure out how to use it.

    C-x h M-C-\ reindents the whole buffer according to whatever the mode thinks is proper formatting (i.e., for C, Python, etc.) You have to be a little brave. (And of course you never want to reindent an external project's code before sending back patches)

    grep-find is handy.

    You can use tags-query-replace to do a multi-file find-and-replace. Just create a TAGS file first (with etags) that contains the files you want to modify.

    Incremental regexp search (M-C-r) is nice.

    In principal you can open up buffer windows on multiple displays, which would mean that you and your five buddies could all be typing into the same emacs simultaneously. I've never actually used this, though.

    You can copy virtually any text anywhere (not sure about the GUI and modeline). I'm always shocked at GUI editors that won't let me copy their messages with anything short of a screenshot. Useless.

    Continuous development and improvement over decades by some of the better programmers in the world, and little reason to believe this will ever cease. I wonder how many other pieces of software exist that this is true for. Not very many.

    --
    "Not an actor, but he plays one on TV."
    1. Re:ediff/emerge, code indenting, by AlejoHausner · · Score: 1
      I use the syntax-sensitive aspect of TAB to indent my code as I go. It's wonderful! It's a great way to catch mis-matched curly braces, parentheses, commas where semicolons should be, etc. As someone else just said, I just don't know how I could program without it.

      And, of course, M-x indent-region: are there any tools out there that will do what indent-region does? I would love to tell students to use such a tool, rather than force emacs on them.

      Alejo

    2. Re:ediff/emerge, code indenting, by Anonymous Coward · · Score: 0

      For C (and perhaps C++), there is GNU indent. For Perl, there is perltidy. Also, I think someone said emacs could be invoked in batch mode to do this, which might be more palatable.

      Generally I'm not sure a mass reindent is a good idea. I only use it on crap code I receive from external sources.

  86. Always-on Emacs by tjwhaynes · · Score: 1

    I'm a heavy user of GNU Screen - I'm constantly on and off around 20 machines so persistent terminals are a major time saver.

    Right now, you can start emacs with the "-nw" flag or you can unset the DISPLAY environment variable to force terminal mode. There is a space between DISPLAY= and the emacs command!

    env DISPLAY= emacs

    This is convenient in GNU Screen because I can connect right into an existing Emacs session.

    Now there are times when I would prefer to forward a display from Emacs over X. With GNU Emacs 22 you can have frames on multiple displays but not ttys and X at the same time. That should change with GNU Emacs 23 - it should be possible to stick an Emacs-terminal process inside a Screen session and ask for frames to opened on a remote display from that Emacs process.

    Cheers,
    Toby Haynes

    --
    Anything I post is strictly my own thoughts and doesn't necessarily have anything to do with the opinions of IBM.
    1. Re:Always-on Emacs by flynt · · Score: 1

      Yes, multi-tty, check out a video here: http://www.youtube.com/watch?v=GL534DarBNw

    2. Re:Always-on Emacs by cammoblammo · · Score: 1

      With the latest CVS Emacs you don't even need to start Emacs from inside a screen session. If you run `emacs --daemon` it'll start in headless mode, and you can use emacsclient to access the one instance from anywhere.

      It's the first thing I run when I boot my machine, and the response time is just about zero when I need the editor. What's more, all my files, IRC flame wars, email and whatever else are right where I left them.

      --

      Cogito, ergo sig.

  87. Clear your buffer using magic by Lord+Bitman · · Score: 1

    On starting emacs, I was presented with:
    "Get help C-h (Hold down CTRL and press h)"

    This sequence acts as a backspace key and has no effect on emacs itself other than to delete the random sentences it seems to have filled its default buffer with. Neat trick!

    It also seems to have a friendly menu at the top which cannot be reached by any key combination. Minimal browsing on the web suggests that emacs is actually a moded editor, but the normal mode only lasts one command before you need to press an obscure sequence to get back to it. Oops?

    --
    -- 'The' Lord and Master Bitman On High, Master Of All
    1. Re:Clear your buffer using magic by Sketch · · Score: 1

      On starting emacs, I was presented with:
      "Get help C-h (Hold down CTRL and press h)"

      This sequence acts as a backspace key and has no effect on emacs itself other than to delete the random sentences it seems to have filled its default buffer with. Neat trick!

      I realize you are probably just trolling, but this doesn't make much sense. In most applications, C-h acts as a backspace key. However in emacs, it acts as the help key prefix. Pressing C-h will not delete characters unless you first redefine it in your .emacs to do something else. So you were obviously pressing something other than C-h. Perhaps you were pressing backspace, mistakenly believing that it was sending C-h, when it was not...

      It also seems to have a friendly menu at the top which cannot be reached by any key combination.

      Try F11.

      --
      -- OpenVerse Visual Chat: http://openverse.com
    2. Re:Clear your buffer using magic by dhTardis · · Score: 1

      This sequence acts as a backspace key and has no effect on emacs itself other than to delete the random sentences it seems to have filled its default buffer with. Neat trick!

      C-h and Backspace are sometimes the same, and sometimes different, based your terminal. (Similarly for Backspace and Delete.) Emacs tries to guess which one is which; if it guesses wrong, typing M-x normal-erase-is-backspace-mode will probably fix it. (You can type that as ESC x normal-e TAB RET.)

    3. Re:Clear your buffer using magic by Lord+Bitman · · Score: 1

      So you were obviously pressing something other than C-h

      tqat's impossible! I tqink I am perfectly capable of finding tqe (copying and pasting here:)"C-h" key on my keyboard.

      Seriously, how much of a dipwad are you? "Well, it worked for me... clearly he's pressing completely random key combinations!"

      --
      -- 'The' Lord and Master Bitman On High, Master Of All
    4. Re:Clear your buffer using magic by Lord+Bitman · · Score: 1

      I'll give it a shot. Mostly I was put off when I tried googling for help on the situation and came across a "vi vs emacs" post which said something along the lines of "Emacs is the world's only completely self-documenting editor! The only command you'll ever need to memorize is 'emacs', after that the on-screen instructions tell you exactly what to do!" .. that experience pretty much told me I wanted to stick with an editor where I needed the huge learning curve of memorizing THREE commands right off, but which I could actually use.

      This was my second attempt at trying out emacs. First time I tried it, years ago, I tried XEmacs. This was before I'd ever tried vi/vim. I started it up and it asked for login information for a newsreader. Eventually I got as far as accidentally inserting an image and changing the font size. I determined that emacs was not a text editor, and moved on.

      --
      -- 'The' Lord and Master Bitman On High, Master Of All
    5. Re:Clear your buffer using magic by Philip+Shaw · · Score: 1

      The menu is accessed by M-`

      --
      "A fanatic is one who can't change his mind and won't change the subject."- Winston Churchill
  88. Re:Please Don't Stop by sik0fewl · · Score: 1

    I agree. I really enjoy reading through these, although I probably won't read through this entire thread, since I'm a vim user :)

    I have a suggestion/proposal, though: I find these threads really interesting, but they hardly qualify as news and I don't think we want to see them every day. Why not do something like this on Fridays instead of the mailbag? I think many people would prefer that.

    --
    I remember when legal used to mean lawful, now it means some kind of loophole. - Leo Kessler
  89. c-x roll by marcosdumay · · Score: 1

    c-x stop
    c-x bark

  90. Re:A favourite (works well on both Ubuntu and Debi by Ossifer · · Score: 1

    C234567

  91. Re:A favourite (works well on both Ubuntu and Debi by munch117 · · Score: 1

    Doesn't work for me either. Maybe because I got tired of accidentally hitting C-x C-c and added this to my .xemacs/init.el:

    (defun kill-emacs-did-you-really-mean-that ()
        (if (yes-or-no-p "Really really really quit Emacs?")
                t
            nil))
    (setq kill-emacs-query-functions (list 'kill-emacs-did-you-really-mean-that))

  92. Re:A favourite (works well on both Ubuntu and Debi by Anonymous Coward · · Score: 0

    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.

    ROFL!

  93. Set jump points on moving to EOF/BOF by Vizzie · · Score: 1

    The following functions will save the current location to a register when going to the beginning of the file or end of file with M-. You can then go back to the last place you were with C-x r j 1 ;;; a trick from ispell... ;;; Let ?1 do the right thing when compiled.
    (defun lrd-int-char (char)
        (cond
          ((and (fboundp 'characterp) (characterp char)) char)
          ((and (fboundp 'int-char) (integerp char)) (int-char char))
          ((integerp char) char)
          (t (error "arg is not an int or a character")))) ;;; ;;; misc. advice stuff

    (defadvice beginning-of-buffer
        (before bob-register first () activate)
        "When going to beginning of buffer, save point in register 1"
        (point-to-register (lrd-int-char ?1)))

    (defadvice end-of-buffer
        (before eob-register first () activate)
        "When going to end of buffer, save point in register 1"
        (point-to-register (lrd-int-char ?1)))

    1. Re:Set jump points on moving to EOF/BOF by The+boojum · · Score: 1

      M-< and M-> set the mark before they jump. You can get back to it with C-u C-SPC.

    2. Re:Set jump points on moving to EOF/BOF by Vizzie · · Score: 1

      Unless you perform a task that moves the mark before you jump back, of course :D

    3. Re:Set jump points on moving to EOF/BOF by The+boojum · · Score: 1

      That's true, so far as returning in a single step goes. But those commands also interact with the mark ring so pressing C-u C-SPC repeatedly still gets me back after a couple of hops.

  94. Vi Style Paren Matching by Greyfox · · Score: 1
    The one thing I always really miss from vi is the paren matching. The emacs manner of matching parens does not go far enough. Fortunately someone documented this: http://grok2.tripod.com/index.html#MatchParenthesis

    For a while I used emacs as my mail client and news reader. This far I haven't not found another mail client that can match the functionality provided by vm plus the MIT Remembrance Agent. Unfortunately it's something of a pain in the ass to set it all up and I don't get enough non-spam email outside of work to bother with it.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  95. How long must this (stupid) crap go on? by Zadaz · · Score: 1

    You're really trying my patience, Slashdot.

    Do you want me to turn Ad Block back on and go back into lurk mode?

    I didn't think so. Straighten up and fly right or you won't get anything useful from me.

    1. Re:How long must this (stupid) crap go on? by StressedEd · · Score: 1

      You're really trying my patience, Slashdot.

      Do you want me to turn Ad Block back on and go back into lurk mode?

      I didn't think so. Straighten up and fly right or you won't get anything useful from me.

      Huh? I don't see ads.

      Oh, wait. I've always been using adblock. My patience ran out ages ago -- only a geek-laden chat about Emacs could possibly pull me out of my shell -- the shame!

      --
      Be nice to people on the way up. You will meet them again on your way down!
  96. The best recent package for (X)Emacs: org-mode. by hardaker · · Score: 2, Interesting

    By far one of the best enhancement packages to come out for (X)Emacs in a long time is org-mode. It's a feature-full organization and agenda system that all operates on plain text files that are easy to read and write.

    --
    The next site to slashdot will be ready soon, but subscribers can beat the rush and start slashdotting it early!
  97. News: Slashdot properly follows editor history by hardaker · · Score: 1
    Vi came first, people realized it sucked and wrote Emacs: new and better.

    Slashdot posted a story about useful vi tips, realized that it sucked and wrote a story about Emacs: new and better.

    (yeah yeah yeah... slashdot doesn't write stories and just approves them; I know...)

    --
    The next site to slashdot will be ready soon, but subscribers can beat the rush and start slashdotting it early!
    1. Re:News: Slashdot properly follows editor history by LordOfTheNoobs · · Score: 1

      I just glanced on wikipedia. Apparently Bill Joy wrote vi the same year that Stallman et al wrote the macros for TECO. ( '76 for each )

      --
      They're there affecting their effect.
  98. Unicode input, startup stuff, and line wrapping by arensb · · Score: 1

    How to prevent long lines from wrapping: (setq truncate-lines t)

    How to make Emacs do things when it starts: (add-to-list 'command-line-functions 'my-startup-stuff)

    How to input a character for which you have the Unicode hex value: use the ucs input method.

  99. Not yet mentioned by flolo · · Score: 1

    speedbar mode

    1. Re:Not yet mentioned by trjonescp · · Score: 1

      Mod parent up. Speedbar is awesome (though I don't think it's a "mode")

      --
      Only speak when it improves the silence.
  100. This has its logic by gwolf · · Score: 1

    When you comment out a big chunk of code with M-;, you want to be able to un-comment it. And if that big chunk of code had comments in it, you don't want the comments to be uncommented ;-) You can comment a chunk containing a chunk, and the boundary between the regions still shows.
    This even happens in a recursive-friendly way - If I M-x it again (adding some not-yet-commented thing - Remember it's a DWIM, so it attempts to achieve intelligence, and there is nothing as stupd as artificial intelligence), it works correctly (/. "junk character" filter won't allow me to post it - but it adds a level of backslashes). Comments get nicely nested. And de-commentable, step by step.

  101. iso-accents-mode by jfernie · · Score: 1

    M-x iso-accents-mode.

    This is the easiest way I know to type accented characters on a US keyboard. The version of emacs that gets installed by default on recent Ubuntu versions does not have support for this, but I found that switching to a minor revision older (through synaptic) brings it back.

    1. Re:iso-accents-mode by Haeleth · · Score: 2, Interesting

      This is the easiest way I know to type accented characters on a US keyboard.

      Even easier: set one of your keys up as Compose (also known as Multi_key). Then you can type accented characters in any program, not just Emacs.

  102. Mod me everything! by hardaker · · Score: 4, Funny

    Useful(Stupid) things to say to get modded Insightful

    • Emacs rocks!

    Useful(Stupid) things to say to get modded Interesting

    • Escape-: (message "Emacs rocks")

    Useful(Stupid) things to say to get modded Funny

    • Emacs: Escape Meta Alt Control Shift

    Useful(Stupid) things to say to get modded Troll

    • Emacs is better than vi

    Useful(Stupid) things to say to get modded Redundant

    • Emacs is better than vi

    Useful(Stupid) things to say to get modded Flamebate

    • Emacs is better than vi (really... Trolls are just flamers with green skin)

    Useful(Stupid) things to say to get modded Overrated

    • Emacs rocks!

    Useful(Stupid) things to say to get modded Stupid

    • What's emacs anyway?

    Useful(Stupid) things to say to get modded Useful

    • The its-all-text firefox plugin lets you edit slashdot posts in emacs
    --
    The next site to slashdot will be ready soon, but subscribers can beat the rush and start slashdotting it early!
  103. Towers of Hanoi by IHTFISP · · Score: 1

    M-x hanoi

    Or, for added drama:

    M-8 M-x hanoi

    Consider it a benchmark.

    --
    Error: NSE - No Signature Error
  104. calc and pictures by porpnorber · · Score: 2, Interesting

    Much goodness has been mentioned here, but not the optional emacs-calc package (does vi do calculus? I think not). Plus picture-mode, great for drawing little boxes and, surprise surprise, putting the row of backslashes down the right edge of newly macrofied code blocks (M-x picture-mode C-c ., set typing direction to vertically downwards).

    1. Re:calc and pictures by martinw89 · · Score: 2, Informative

      (does vi do calculus? I think not).

      No, but it does edit files pretty well.

  105. Zap to char by Anonymous Coward · · Score: 0

    I use emacs and eclipse everyday. Strangely enough, the thing I miss in Eclipse is zap-to-char. Meta-Z then a character allows you to delete everything up to and including the next occurrence of that character in the file. Great for eating an entire string (zap "), xml tag (zap >), code block (zap }) etc.

  106. Resgisters: The best kept secret of Emacs by Ober · · Score: 0

    ant to book mark a spot in a buffer/file?
    C-x r C-SPACE a
    Will store the current place holder in register a.
    Move around the file, and to jump back just run
    C-x r j a

    Want to keep a cut and paste?
    High light an area and
    C-x r s a
    Will save the contents of what was high lighted to register a.
    To paste it just
    C-x r i a

    My favorite. Saving frame/buffer layout.
    Spent a lot of time arranging your frames and buffers in each and want to move back and forth?
    C-x r w a
    Will save frame layout in register a.
    Go full screen on a single buffer and to return just
    C-x r j a

    Presto you can jump between multiple layouts.

  107. cscope interface by PolygamousRanchKid+ · · Score: 1

    I find the cscope interface most useful: http://cscope.sourceforge.net/

    cscope is good if you get a ton of code that you know nothing about dumped on you. You can quickly jump around files by setting the cursor on a symbol, and it will also tell you stuff like "find functions calling a function."

    This also has the advantage of being religion-neutral: cscope also works with vi.

    P.S. Sorry to interrupt the flame wars with some potentially useful information.

    --
    Schroedinger's Brexit: The UK is both in and out of the EU at the same time!
  108. Re:heres my favorite by bob.appleyard · · Score: 1

    There's always the classic:

    Of course, on the system *I* administrate, vi is symlinked to ed. Emacs has been replaced by a shell script which 1) Generates a syslog message at level LOG_EMERG; 2) reduces the user's disk quota by 100K; and 3) RUNS ED!!!!!!

    Source

    --
    How dare you be so modest!! You conceited bastard!!
  109. M-/ completion by Kronos. · · Score: 1

    Tapping M-/ completes the word, great when coding and typing variables names, it'll search buffers for matching words. Saves on annoying typos. Repeatedly tapping M-/ cycles matches.

  110. M-x shell by MadMidnightBomber · · Score: 1

    gets you into this wicked adventure. I've collected all the good items, but I've yet to defeat the bad guy at the end of the subnet.

    --
    "It doesn't cost enough, and it makes too much sense."
  111. Replacing text en masse by Anonymous Coward · · Score: 0

    M-x query-replace

    using this, and holding down the y key after supplying the necessary parameters, I can blast through a long HTML file deleting thousands of redundant tags that were created by Dreamweaver or Frontpage or some crap.

    1. Re:Replacing text en masse by cgreuter · · Score: 1

      The really nice thing about query-replace and query-replace-regexp is that you can replace almost all items. It's great for cases where, say, you want to replace all uses of variable "count" while leaving the word alone when it's used in a comment.

      If you just want to replace everything, you use the non-query versions, replace-string and replace-regexp. That way, you don't need to hold down the 'y' key.

  112. Re:Please Don't Stop by Mikkeles · · Score: 4, Funny

    '... is there any reason the VIM story ran first than the Emacs one?'

    Emacs was still loading when it came time to run the story.

    --
    Great minds think alike; fools seldom differ.
  113. ASCII Painting by Anonymous Coward · · Score: 0

    M-x artist-mode

  114. iswitchb-mode by tamboril · · Score: 1

    Case-insensitive subword buffer switching.

  115. The EMACS equivalent of "." by Big_Monkey_Bird · · Score: 1

    Is there an EMACS equivalent of vi's "."? A repeat-last-command sort of deal?

    1. Re:The EMACS equivalent of "." by cgreuter · · Score: 1

      When I googled to see what the vi "." did, I found this, so the answer is no, but you can download an extension to do it.

      But what I was going to say was that there are two options that I can think of:

      • If you typed in the command at the M-x or M-: (lisp eval) prompts, you can always just use the command history and rerun the command that way.
      • Alternately, you can repeat the next command by typing C-u and the number of repetitions followed by the command. So "C-u 75 -" will draw a row of 75 dashes. You can do more complex things by first recording a keyboard macro ("C-x (", keystrokes, "C-x )" and then prefexing the macro eval command ("C-x e") with a repeat count. If you're afraid of going past a certain point and don't want to carefully figure out exactly how many times to repeat, you can use narrow-to-region first.

      Those two things, along with query-replace, automates most of my tasks for me.

    2. Re:The EMACS equivalent of "." by CityZen · · Score: 1

      Well, there is the command "repeat" (C-x z), but this tends to be less useful in emacs since you often want to repeat a sequence of commands rather than a single action.

      For repeating the sequence, there's keyboard macros. Use c-x ( to start recording the sequence, type the sequence, the use c-x ) to finish recording. Use c-x e (or just F4) to call the macro.

      You can edit the macro, save it, bind it to a key, and do all kinds of other stuff like that, too. Just type m-x apr (ret) macro (ret) to see the list of macro-related functions (click on any name for more details).

      Using keyboard macros in combination with search can lead to some very powerful editing. You could write a turing machine using this mechanism. I've used macros to do some massive reformatting of files, such as reordering lines and fields within lines.

      A useful trick for doing this is to:
      1) Put the cursor at the destination.
      2) Type a mark (a unique sequence of characters).
      3) Search for the desired text.
      4) Mark & cut the text.
      5) Reverse search for the mark.
      6) Paste the text. Edit as necessary.
      7) Make sure the mark is in the right place for the next iteration.

      Then I'll just type ctrl-u several times and ctrl-x e to execute the command many times over. It runs until the search fails (or stops because I didn't do enough repeats).

    3. Re:The EMACS equivalent of "." by Haeleth · · Score: 2, Interesting

      "C-x z". Then subsequent presses of "z" repeat the same command again.

      (You could have found that out for yourself by typing "C-h w repeat"...)

    4. Re:The EMACS equivalent of "." by Anonymous Coward · · Score: 0

      That's not really much lik . at all.

      vim:
      foo |bar - cwfoobar
      foo foobar| - 0.
      foobar| foobar

      . powers pretty much comes from the modeness of vim.

  116. Don't Stop (Believin' ?) by IorDMUX · · Score: 1

    These recent discussion-based articles are great additions to Slashdot. The UNIX/vi/emacs articles bring out Slashdot's aged sages and core demographic, and those of us who are new to the UNIX scene can learn plenty more from the discussion than a 'man' page.

    The political discussion articles were, IMHO, great additions to the site, too. Thanks to the brilliance of the moderation system and the myriad views of readers, I could read and participate in intelligent discussions about all 3-4 sides of very important issues and become a more intelligent voter.

    So keep the discussion articles coming, Slashdot! You're tapping into your greatest strengths: your readers and your forum/moderation software.

    --
    >> Standing on head makes smile of frown, but rest of face also upside down.
  117. Re:One reason why VI is better... by squiggleslash · · Score: 2, Interesting

    Plus for maximum fun, thinking you're in insert mode because you slipped and hit the wrong key, and actually finding you're in command mode and have just made about 452 different random changes to your document with no idea of what has happened or how to fix it...

    --
    You are not alone. This is not normal. None of this is normal.
  118. random emacs cool stuff by Tiny+Elvis · · Score: 1

    GNUS, CALC, electric-buffer-list, copy or delete rectangle, macros, narrow-to-region, desktop-save, slime

  119. All you need to know by Anonymous Coward · · Score: 0

    Ctrl-Z kill %1

  120. Re:Please Don't Stop by Count+Fenring · · Score: 1

    I personally just wanted to steal other people's emacs tricks, and didn't think of it until the vi question came up and I read the responses to that. Just as I imagine that the vi question came up in response to the Unix one.

    Sometimes there's no conspiracy except the conspiracy of coincidence.

  121. use etags or cscop (Re:grep and emacs integration) by Anonymous Coward · · Score: 0

    that grep macro is nice but if you're a programmer (and the constant need to grep through whole directories from within emacs suggests that you are), then you should really look at etags or cscope modes. etags mode comes built in to emacs (but you need to have etags program installed on the machine to generate the index).
        cscope mode AFAIK, doesn't come built in yet. Search for the file xcscope.el on google. And yes, you need to have the cscope program installed on your machine for building the index.

      I use the following two aliases to build the cscope and tags databases at the root of any new source tree I need to work in.

    alias scopeit='find . \( -iname "*.[ch]" -or -iname "*.rpc" \) -print |tee cscope.files |cscope -k -u -q -b -i - '

    alias tagit='find . \( -iname "*.[ch]" -or -iname "*.rpc" -or -iname "*.java" \) -print | etags - '

    Now assuming you have cscope and/or tags modes available and loaded, you'd be able to do things that you use your grep macro for but in a much more productive manner. e.g.

    (etags)

    M-. takes you to the definition of that symbol (function/variable etc.) anywhere in the source tree you indexed
    M-s searches for takes you to the first occurence of that symbol anywhere in your source tree and the repeated M-, iterates through all occurences of that symbol.

    (cscope)
    cscope-find-global-definition
    cscope-find-functions-calling-this-function
    .
    .
    etc etc... loads of things.

      I should mention cscope works well for C and to some extent for C++. etags works for a wider variety of languages (but your indexing has to include those files of course).

  122. Re:A favourite (works well on both Ubuntu and Debi by omar_armas · · Score: 1

    Real men use emacs.

  123. Chinese input and translation by jason8 · · Score: 1

    When I was learning Chinese I wrote a translation function, which would take the characters at point, look them up in a dictionary (which gets loaded into its own buffer) (the dictionary I used is cedict, available on the internets somewhere), and then display the translation in the minibuffer.

    This combined with an Emacs irc client, and an irc server located in China or Taiwan, was a great way to help out learning the language. And I don't think any of this could have been done in vi...

  124. emacs replies... by PPH · · Score: 4, Funny

    What are your favorite tricks?

    Why do you say what are my favorite tricks?

    --
    Have gnu, will travel.
  125. Revert-all-buffers by Urban+Garlic · · Score: 1

    I use cvs, and frequently have several files in emacs buffers when I do a commit. CVS modifies the buffers to put new time-stamps in them, and it used to be, every time I edit a buffer, I get one of these "File modified on disk, really edit? Revert?" things.

    So, I wrote my own "revert-all-buffers" command.

    Mangled to get through the Slashdot lameness filter.

    (defun revert-all-buffers () (interactive) (let ((bufcount 0)) (save-current-buffer
    (mapc (lambda (buf) (if (buffer-file-name buf)
    (if (verify-visited-file-modtime buf) nil
    (progn (set-buffer buf) (revert-buffer t t) (setq bufcount (1+ bufcount))
    )) nil )) (buffer-list) ) )
    (message "Buffers reverted: %d" bufcount)))

    --
    2*3*3*3*3*11*251
  126. Endless Fun by AttillaTheNun · · Score: 1
    Redirecting flame.el (random flames and insults) into doctor, the psychoanalyst, of course!

    Towers of Hanoi is a distant second-place.

  127. Backup file names by arensb · · Score: 1

    I don't care for the ~ extension for backup filenames. I grew up with Gosling Emacs, which uses .bak instead. So now my .emacs has

    (setq make-backup-file-name-function 'my-make-backup-file-name)
    (defun my-make-backup-file-name (file)
      "Create the non-numeric backup file name for FILE.
    This is a customized version of this function."
      (message "Inside my-make-backup-file-name")
      (concat file ".bak"))
     
    (defun backup-file-name-p (file)
      (string-match "\\(~\\|\\.bak\\)\\'" file))

  128. Drew Adams' icicles and... by Anonymous Coward · · Score: 0

    ... CUA-mode with the kiddy keybindings disabled.

    icicles is one of the systems that superpower tab completion, and CUA-mode gives your rectangle selections superpowers. I can't live with its "windowsy" C-x / C-c / C-v bindings, but those are easily disabled.

  129. An Emacs Article! by AttillaTheNun · · Score: 1
    I almost wet myself. Alas, there will be no Emacs vs. vi debate today.

    Why, oh why, do you deny us of something which would bring such pleasure to so many people?

    Like a Leafs/Habs, Yankees/Dodgers, Celtics/Lakers final, everyone wants to be a part of the ultimate showdown at least once in their life.

  130. Spook by Anonymous Coward · · Score: 0

    M-x spook

    Append it to the bottom of all your emails ;)

  131. For-each on region by The+boojum · · Score: 1

    This isn't one that I use every day, but I find it enormously handy when I do need it:

    (defun for-each (begin end place start stop step)
        "Copy the active region and replace a placeholder string with a number."
        (interactive "r\nsPlaceholder: \nn Start: \nn Stop: \nn Step: ")
        (let ((template (buffer-substring begin end))
                    (count (1+ (/ (- stop start) step))))
            (delete-region begin end)
            (dotimes (time count)
                (let ((value (number-to-string (+ start (* time step))))
                            (expansion template))
                    (while (string-match place expansion)
                        (setq expansion (replace-match value nil t expansion)))
                    (insert expansion)))))

    Select a region, do M-x for-each and then give it a placeholder in the region, starting and stopping numbers and an increment. For example, selecting a region with:

    "% bottles of beer on the wall.
    % bottles of beer on the wall, % bottles of beer.
    Take one down, pass it around, "

    and giving it % as the placeholder, 99 as the start value, 1 as the end value, and -1 as the increment will instantly expand it to most of the body of the old song:

    "99 bottles of beer on the wall.
    99 bottles of beer on the wall, 99 bottles of beer.
    Take one down, pass it around, 98 bottles of beer on the wall.
    98 bottles of beer on the wall, 98 bottles of beer.
    Take one down, pass it around, 97 bottles of beer on the wall.
    97 bottles of beer on the wall, 97 bottles of beer.
    Take one down, pass it around, 96 bottles of beer on the wall. ..."

    You can use multiple placeholders and apply it N times in succession to do N-dimensional expansions as well. I suspect that it has often saved me from what very likely could have been some nasty cut-and-paste errors.

    My favorite new-to-me trick by the way, is \, for Elisp code in regexp replacements, as described by Steve Yegge. I've only known about it for a few weeks now and I've already found a ton of handy uses: selectively deleting numbers from a list, converting hh:mm:ss to seconds, etc.

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

    So by the next week we may the OpenOffice tricks?

  133. Re:Please Don't Stop by sootman · · Score: 1

    Agreed. It reminds me of this thread from 2005 where, among other things, I and a few others collaborated to create a one-line script to answer the question "Which commands do I use the most?"This...

    cat .bash_history | awk '{print $1}' | sort | uniq -c | sort -nr | head -20

    ... will show you the twenty commands you use the most. I wanted to post this in the first thread of this series but I didn't have time. Luckily there have been these related threads--the next best thing to a dupe! :-)

    --
    Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
  134. Compiling over ssh by hmckee · · Score: 3, Interesting

    Plus you can compile over ssh.

    It's nice to be able to compile a local directory with M-x compile, then you can jump to errors in the offending file from the *compilation* window.

    You can also set to do remote compile from emacs by putting something similar to this in your .emacs:

    ;; remote compile support
    (setq remote-compile-host "hostname")
    (setq remote-shell-program "/usr/bin/ssh")
    (setq default-directory "/home/username/compileDir")

    No you can compile on the remote host AND bring up offending files from the compile output window with the click of a button.

  135. Dissociated Press by dacarr · · Score: 1

    People have already mentioned M-x psychoanalyze-pinhead, but then have you also considered piping the output through M-x dispress?

    --
    This sig no verb.
  136. align-regex by Anonymous Coward · · Score: 0

    Once you learn to use align-regex, you will look for ways to abuse it, and your code will look all the better for it.

    Oh yeah, about what it does: it aligns columns in multiple lines, the regular expression tells it what the column delimiter is.

    Enjoy.

    BTW, this is my first ever slashdot.org reply..

  137. Re:A favourite (works well on both Ubuntu and Debi by Roadkills-R-Us · · Score: 1

    I just hold down all the modifier keys within reach and roll my forehead across the keyboard, and something cool happens.

    Once it wrote a web browser for me.

    Once it summoned a powerful djinn with lots of dark chocolate.

    Once it washed and waxed my car.

    The other day it *almost* decided the US presidential election, but I ran out of swap space so that got decided the old way.

  138. Collaborative editing. by skeeto · · Score: 1

    Thanks to X, Emacs has built-in collaborative editing.

    M-x make-frame-on-display

    You can do this over ssh (X forwarding) to open a frame on someone else's computer (or several other's computers). They get their own cursor and everything, and, if you are looking in the same buffer, you can actively see the other person/people typing away. Just don't C-x C-c or you close it for everyone!

    Security note: watch out, because whoever you give a frame to can trivially get shell access in your account.

  139. Addition for Gnus by jesup · · Score: 1

    A useful addition to Gnus (it may be part of the distribution now):

    ;; Provide a function to switch to a *Summary buffer or the *Group buffer.
    ;; Let the user decide whether to bind it.  Written by Randell Jesup.
    ;;
    (defun switch-to-gnus ()
      "Switch to a *Summary whatever* buffer if one exists.  If none exist,
    switch to the *Group* buffer.  If that doesn't exist, complain."
      (interactive)
      ;;
      (let ((buflist (buffer-list))
            (done 0)
            (saw_group 0))
        (while (and (= done 0)
            (not (equal buflist nil)))
          (let ((candidate (car buflist)))
             (let ((candname (prin1-to-string candidate)))
              (if (string-match "#<buffer +\\*Summary.*\\*>" candname)
                  (progn
                (switch-to-buffer candidate)
                (setq done 1))
                (setq buflist (cdr buflist)))
              ;; remember if we saw *Group*
              (if (string-equal "#<buffer *Group*>" candname)
                  (progn
                (setq saw_group 1))))))
        (if (= done 0)
        (if (= saw_group 1)
            (switch-to-buffer "*Group*")
          (error "Gnus doesn't appear to be running")))))

    ;; This switches to the a *Summary buffer if one exists, else to *Group*
    (global-set-key [f9] 'switch-to-gnus)

    A couple of other goodies:

    ;; If invoked from a non-shell buffer, it changes to or opens a shell
    ;; buffer with the path set to that of the buffer from which this command
    ;; was invoked.  If invoked from a shell-mode buffer, it changes back to
    ;; the last buffer from which the shell was invoked whith this command.
    (global-set-key [f3] 'shell-pushd-to-buffer-path)

    ;; make switching buffers easy
    (global-set-key [f6] 'other-window)
    (defun prev-window ()
      "previous window"
      (interactive)
      (other-window -1))
    (global-set-key [S-f6] 'prev-window)

    ;; Windows-ish commands:
    ;; Block cut, copy, paste:
    ;;; KEY: [A-x]: Cut region.
    (global-set-key [?\A-x] 'kill-region)
    ;;; KEY: [A-c]: Copy region.
    (global-set-key [?\A-c] 'copy-region-as-kill)
    ;;; KEY: [A-v]: Paste.
    (global-set-key [?\A-v] 'yank)
    ;;; KEY: [ESC A-v]: If you've just used paste, use this key to cycle through
    ;;; KEY:            previous available pastes on the Emacs clipboard.
    (define-key esc-map [?\A-v] 'yank-pop)

  140. A small personal milestone by bXTr · · Score: 1

    I never had to write my own elisp function before, but just yesterday I did. I have been using both emacs and vi for years, and in vi I often used "J" to join the current line with the next while reducing whitespace between them to one space. Emacs has the (join-line &optional arg) function to do the same thing, but by default it works in the opposite direction; joining the current line with the previous. The optional arg, of any non-nil value, joins current with next like vi's "J".

    join-line is not bound to any key by default, so I bound it to "C-x j" which was unbound. However neither local-set-key or global-set-key would let me pass a non-nil argument to the function I'm binding the key to. So, I typed the following in the *scratch* buffer:

    (defun join-next-line ()
    __(interactive)
    __(join-line 1))
    (global-set-key "\C-x j" 'join-next-line)

    Eval'd both, and badda-boom, badda-bing, it works. Copied it to my .emacs, and now I'm shittin' in tall cotton.

    "_" in the code represent spaces thanks to /.'s braindead comment entry system.

    --
    It's a very dark ride.
    1. Re:A small personal milestone by dhTardis · · Score: 1

      C-h w join-line RET

      join-line is not on any key;
      its alias delete-indentation is on M-^

    2. Re:A small personal milestone by bXTr · · Score: 1

      join-line is not on any key;

      That's what *I* said.

      its alias delete-indentation is on M-^

      ...and, again, like I said, it joins the current line with the previous line. To get it to do the opposite *AND* bind it to a sequence of less than 6 keys, say "C-x j", you have to do what I did. If you know another way to do it, please share.

      --
      It's a very dark ride.
    3. Re:A small personal milestone by dhTardis · · Score: 1

      The alias is equivalent, so there is a default key that runs `join-line', which was my point. If you want to pass it an argument, you can type C-u (`universal-argument') before it. There are actually lots of ways of passing arguments, to make it convenient; since the value doesn't matter, here you might try M-6 M-^ so you just have to add Shift in the middle.

      Of course, C-n M-^ would have already gotten you that with about the same amount of effort; if you want it to be shorter, what you did is about the best way to do it.

  141. Re:Young people being led astray? by Haeleth · · Score: 2, Interesting

    What I find tragic is that people actually do say "it's tragic that we're still using the same tools as we used 20 years ago".

    Why wouldn't we be? We're pretty much the same people as we were 20 years ago. We still speak the same languages, wear the same clothes, drive vehicles that are only cosmetically different, perform very similar jobs. Sure, our computers are a bit faster, but there's no need to fundamentally change your interface just because there are more transistors behind it.

  142. Wanted: su for a buffer by crow · · Score: 1

    Suppose I pull up a buffer, like /etc/hosts, and I decide that I want to change it. I currently have to restart emacs as root. I would much prefer a "M-x su" option to become root (or some other user) for just that one buffer.

    I know that with the tramp extension, I can do this with an ssh connection to localhost; thanks to those who pointed that out!

    1. Re:Wanted: su for a buffer by dhTardis · · Score: 2, Informative

      Tramp will also let you use sudo or su to edit your files without SSH: C-x C-f /su::/etc/motd, for example.

  143. [ot] How long must this (stupid) crap go on? by wild_berry · · Score: 1

    Your unmoderated Score 1 comment needs to be expanded; the new Javascript-powered Slashcode puts adverts (mostly ThinkGeek) under the posts it hides. Riddle me this: as a subscriber, I could turn off the adverts, and also could use AdBlock to immunise myself elsewhere, but I don't -- am I really having an impact on the clickthrough rate by seeing but not clicking any ads?

  144. Re:A favourite (works well on both Ubuntu and Debi by Anonymous Coward · · Score: 0

    That didn't work for me:
    -bash: apt-get: command not found

    By the way, it figures that a vi user wouldn't know how to put commands on separate lines. :)

  145. Re:A favourite (works well on both Ubuntu and Debi by Anonymous Coward · · Score: 0

    There is more than vi, emacs and ed. The most likely editor that is installed as well is nano.

  146. Eliza vs. Zippy by DdJ · · Score: 1

    No discussion of obscure and strange Emacs features is complete without meta-X psychoanalize-pinhead.

    See, Emacs has a command to produce a random "Zippy the Pinhead" quote.

    And, Emacs has a command to start up the "Eliza" program, which pretends to do psychological analysis based on what you type into it.

    So someone wrote some glue code to fire up the Eliza program and feed the Zippy quotes into it, and you access that via meta-X psychoanalize-pinhead. Go ahead and try it out! It's enabled in the version of Emacs bundled with MacOS X, I just checked.

  147. Re:Please Don't Stop by slater86 · · Score: 1

    I agree, Don't Stop these articles.

    Maybe these "(Stupid) useful $RANDOM tricks" would make at least 1 decent article for idle.slashdot.org?
    i.e. its not exactly front page news as such but it is definitely interesting to read and it is news for nerds/stuff that matters.

    --
    When people ask if I'm an optimist, I say "I hope so". --Bill Bailey
  148. Better Lisp by dhTardis · · Score: 1

    It's easier to just write:

    (defun kill-emacs-did-you-really-mean-that ()
        (yes-or-no-p "Really really really quit Emacs?"))
    (setq kill-emacs-query-functions '(kill-emacs-did-you-really-mean-that))

    1. Re:Better Lisp by Matchstick · · Score: 1

      (setq kill-emacs-query-functions '(kill-emacs-did-you-really-mean-that))

      Using setq is antisocial. It blows away any other hooks that might have been set.

      I use the moral equivalent of this:

      (add-hook 'kill-emacs-query-functions (lambda () nil) 'append)

      When I want to quit, I use M-C-: (kill-emacs)

  149. Re:Please Don't Stop by DiegoBravo · · Score: 1

    Modded Flamebait for suggesting one editor is (maybe) more used than the other... I didn't suspect those old religious sentiments are so alive hitherto.

  150. Re:Please Don't Stop by pintpusher · · Score: 1

    I'm not sure what it means, but it sure is interesting.
              98 exit // I must do a lot of leaving
              60 mutt // I ssh in a lot and *always* check the mail.
              28 apt-cache // what package was that?
              26 cd // I'm in the wrong place
              20 man // I don't know how to get where I'm going
              19 sudo // I'm not who I claim to be
              19 grep // I can't find something
              17 mpc // tunes baby!
              17 ls // d
              13 less // is more
              12 emacs //always on, why bother to restart it?
              12 cat // dog
              10 runhaskell // reading Real World Haskell
              10 dtach // is teh r0X0r!
                9 ssh // sometimes I need to go other places
                8 ps // st! I've got a secret!
                7 dpkg // borked something again -- force-all
                5 tar // and feather
                5 darcs // Dave's alright
                5 cp // does this count for backups?

    That was fun and insightful for me. Thanks.

    oh, and if I ignore the `exit`s, I get
              4 vim // config files require vim. Don't know why, they just do.

    --
    man, I feel like mold.
  151. make-frame-on-display by Maexxus · · Score: 1

    I'm not an Emacs user, however I have lately tried to use it a little and become more comfortable with it. One thing I think is really cool is being able to do M-x make-frame-on-display and then have a new frame appearing on a display (obviously). This is pretty useful for collaborative editing more than anything. I wish such a feature existed in Vi/Vim :(

  152. Now doesn't break dired by dhTardis · · Score: 1

    ;; hidden backup files - i hate seeing them in listings...
    ;; prefix with a dot as well as postfix with a tilde
    (defun custom-make-backup-file-name ( file )
      (let ((d (file-name-directory file))
            (f (file-name-nondirectory file)))
        (expand-file-name (concat "." f "~") d)))
    (setq make-backup-file-name-function 'custom-make-backup-file-name)

    (defun backup-file-name-p ( file )
      (string-match "\\`\\..+~\\'" (file-name-nondirectory file)))

    (defun file-name-sans-versions ( file &optional keep-backups )
      (if (or keep-backups (not (backup-file-name-p file)))
          file
        (let ((d (file-name-directory file))
              (f (file-name-nondirectory file)))
          (expand-file-name (substring f 1 -1) d))))

  153. CL features by dhTardis · · Score: 1

    I'm not sure if it will be released in Emacs 23, but there is a branch of CVS Emacs that supports lexical binding. And my `cl-macs.el' in Emacs 22 has `loop'...

    1. Re:CL features by dkixk · · Score: 1

      Thanks for the information about loop. I hadn't noticed it had been added. Now all we need is CLOS and conditions with restarts.

  154. Dunnet must be run in batch mode! by aviators99 · · Score: 1

    For text adventures you must always RTFH!

    The preferred way to run dunnet is from the command line:

    emacs -batch -l dunnet

    I didn't really write it with curses mode in mind (although it is somewhat usable).

    #Ron (Dunnet author) :-)

    1. Re:Dunnet must be run in batch mode! by Count+Fenring · · Score: 1

      Oh, carp. That was a thing that I knew. My bad.

      Thanks for Dunnet, btw ;-)

  155. Re:Please Don't Stop by Annymouse+Cowherd · · Score: 1

    You all accidentally verbs so much! it!

  156. Re:Please Don't Stop by Annymouse+Cowherd · · Score: 1

    You most likely used apt-cache for apt-cache search and apt-cache show, to search through the package list and show details about a package, respectively.

  157. Re:use etags or cscop (Re:grep and emacs integrati by Count+Fenring · · Score: 1

    Hey, any chance you can point to a good etags tutorial? I've been interested in using it, but there seems to be a medium-steep learning curve, and the documentation seems somewhat lacking.

  158. Re:Young people being led astray? by Anonymous+Brave+Guy · · Score: 1

    But, in many respects, software today is in a different world to 20 years ago. Programming languages have moved on immensely, both in theory and in practice. Usability of end user software has improved greatly in many respects. The Internet was barely a dream at that time.

    Plenty of scope for improvement has been identified in the old-style text editors, OS models and DB theory as well, but for some reason possibly connected with a small number of very large software businesses, the world seems stuck in a time warp in these areas.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  159. Hack for iterating though a directory by SpammersAreScum · · Score: 1

    Here's a hack I use regularly to step through the files in a directory:

    (defun dired-next-file ()
      "Kill the current buffer, advance to next line in dired, get that file.
       Requires that 'other buffer' be a dired."
       (interactive)
       (when (eq (cdr (assoc 'major-mode (buffer-local-variables (other-buffer))))
             'dired-mode)
         (kill-buffer (current-buffer))
         (dired-next-line 1)
         (dired-find-file)))

    (global-set-key "\C-cf"   'dired-next-file)

  160. Emacs Myths by psyllo · · Score: 1

    I want to dispel some myths that are recurring here. I make reference to vi, vim and Eclipse to help explain.

    First of: To answer the question:
    A great command is M-Q. This is a minimal requirement for any good text editor IMPO.

    My recommended .emacs settings are the first things I turn off in emacs:
    (custom-set-variables
    '(make-backup-files nil)
    '(inhibit-splash-screen t))

    Emacs is a pig?

    There is some talk about Emacs being a heavy text editor and that installs lots of stuff when you install it. In response to that:
    - For the Windows binary (http://ftp.gnu.org/gnu/emacs/windows/emacs-22.3-bin-i386.zip) is 37MB. There is no installation required, you just extract the zip and run the 'runemacs.exe' command in the bin directory.
    - If you want to build Emacs on FreeBSD (for example) you will have to install all of it's build and runtime dependencies. That's a lot of stuff. It will want gnu build tools and X etc. If you pkg_add -r emacs to get the binary, you are not going to have to install as much. The point is: Depending on your OS and package manager you may have a different experience installing Emacs. In the case of Windows it's super easy. Not using Emacs because installing it is difficult just isn't a reality. (sure there are edge cases)
    - Emacs 22.3(latest) runs at about 20 or 25 MB resident memory in the latest Ubuntu(ubuntu8041) package and FreeBSD(7.0-R) port. To get a perspective, this is about as much as gnome-terminal. If you don't know if you are using gnome-terminal: If you use gnome2 (Ubuntu) the default terminal is gnome-terminal. (I personally use xterm with some .Xresources settings)
    - Emacs loads quickly (depending at what you want to run at init) and is small enough for most jobs. You will always be able to make the argument the vi is lighter. Yet for me I use Emacs everywhere someone might use vi.
    - Emacs also has an emacsclient executable that connects to an emacs server. This allows multiple 'clients' to connect to the server. It makes loading emacs quicker and multiple instances can share memory. I never use it because Emacs isn't that resource intensive in a modern Desktop environment. Even in my VMs.

    Emacs vs. Vi (and [insert editor here]):

    For the programmer and for text editing intensive work: From what I can tell comparing vi to Emacs, Emacs wins. Comparing vim to Emacs might be more appropriate.

    Power in text editors vary. Because there is variance we can say that one is more powerful than the other. That said, Emacs is the more powerful than vi (Remember I said this is a general statement. Such statements are helpful for newcomers to get a perspective not to state a holy war). Textmate, Vim, Eclipse and Visual Studio are all great at many different things. I think the reason we talk about vi and Emacs so much as because they run in terminals and fit into the average Unix user's work-flow much better. They are also old school as well as new school. Those other editors are better described as GUI IDEs. Of all of these vi is the lightest (smaller install, less memory). This is not a statement about what is better. Better is much more relative to the task at hand and the user's preference.

    The power of Emacs reveals itself when the editing is beyond basic conf file editing. One could even argue that vi is also too powerful for editing a conf file. But I guess that all depends on how you want to edit conf files. If you do a lot of other things in Emacs (as most users do) then editing a conf file is just one more thing you are doing. I guess it's important to ask why you would use vi if you already have an Emacs instance running? (Remember you can even edit a file over ssh or even FTP)

    Emacs as an OS?

    In some contexts it's a fair comparison. A better comparison would be to a development platform. Eclipse and Eclipse RCP come to mind (http://wiki.eclipse.org/index.php/Rich_Client_Platform).

    Emacs does have dired

  161. The best emacs trick... by afabbro · · Score: 1

    ...is obvious.

    (ducks)

    --
    Advice: on VPS providers
  162. A question.... by Count+Fenring · · Score: 1

    Does anyone know of a good way to get emacs to magically blink corresponding parens based on proximity to point, rather than just when deleted/typed/directly demanded by a keypress?

  163. What about the grand-daddy of them all: ed. by Anonymous Coward · · Score: 0

    I'm really enjoying this series, thanks ! How about one for stupid ed tricks.

    Perhaps I've been working in this field too long, but I sometimes feel some nostalga for ed.

  164. Improved compilation by geantvert · · Score: 0

    This one set the default command for 'compile'
    (setq compile-command "make -k")

    Add my favorite commands to the 'compile' history

    (setq compile-history
      ( list compile-command
              "cd $HOME/work/project ; make -k"
              "cd $HOME/work/project ; make -k build"
              "cd $HOME/work/project ; make -k clean all"
              "cd $HOME/work/project ; configure"
      ))

    Save all modified files at once

    (defun save-all ()
        "sauve tout les tampons"
        (interactive)
        (save-some-buffers 1)
    )

    Save all modified files and relaunch the last 'compile' command

    (defun save-all-and-recompile ()
        "Sauve tout les fichiers et lance une compilation"
        ( interactive)
        (save-some-buffers 1)
        ( recompile )
    )

    Some fast keyboard shortcuts for compilation

    (global-set-key [f6] 'save-all)
    (global-set-key [f7] 'compile)
    (global-set-key [f8] 'save-all-and-recompile)
    (global-set-key [f12] 'next-error)

  165. Fix slow start and set X11 parameters by geantvert · · Score: 0

    On some systems, gnu-emacs startup can be quite long because it is waiting for the Window Manager.

    The same command also set the colors, font and a few other settings that used to be controlled by the X resources.

    (if (eq window-system 'x)
            (if (x-display-color-p)
                    (progn
                        (modify-frame-parameters nil '((wait-for-wm . nil))) ;; prevent slow start
                        (set-background-color "#FFDDD0")
                        (set-foreground-color "black")
                        (set-frame-font "9x15")
                        (set-cursor-color "red")
                        (set-mouse-color "blue")
      )))

  166. lisp interaction mode by geantvert · · Score: 0

    M-x lisp-interaction-mode

    Allow the execution of any emacs lisp command in a buffer (no need to edit your .emacs)

    The *scratch* buffer is in that mode by default.

    Basically you can do the following:

        (1) copy any of the e-lisp examples given in other post
        (2) put the cursor after the last ')'
        (3) press C-j to execute the command

    For example (with indicates where you have to apply C-j):

    (defun save-all ()
        "sauve tout les tampons"
        (interactive)
        (save-some-buffers 1)
    )

    (global-set-key [f6] 'save-all)

    and you now have the function 'save-all' bind to F6 in your emacs session.

    1. Re:lisp interaction mode by geantvert · · Score: 0

      Emacs eat the C-J in my example, You need of course to apply one after the closing ) of defun and one at the end of the global-set-key line.
       

  167. Re:Please Don't Stop by pintpusher · · Score: 1

    yeah, that was a joke about "What dang package was I looking for again?"

    And to say moderately on topic, I agree with previous posters that these threads are a good thing. Keep 'em coming!

    --
    man, I feel like mold.
  168. Artist mode. by pranavpeshwe · · Score: 1

    M-x artist-mode
    Extremely useful for drawing ascii figures.
    ---
    http://pranavsbrain.peshwe.com/

  169. wdired-mode by rodo · · Score: 1

    From a dired buffer:

    M-x wdired-change-to-wdired-mode

    The dired buffer then becomes completely editable like a normal text buffer, so you can bulk change filenames, permissions etc., and on save it applies all the changes.

  170. Emacs --daemon by chmouel · · Score: 1

    latest cvs have a switch for emacs to run as daemon and have emacs frame (x or tty) spawning super fast

  171. Re:Please Don't Stop by dragonturtle69 · · Score: 1

    Hehe, just wait another day, then dupe 'em. :)

    --
    "What luck for the rulers that men do not think." - Adolph Hitler
  172. Re:Please Don't Stop by dragonturtle69 · · Score: 1

    Damn straight. I actually miss the kernel update submissions and discussions from '98 - '01 or so. There were several good bits of information, or items that started me down a path that proved useful.

    --
    "What luck for the rulers that men do not think." - Adolph Hitler
  173. jump-to-register by grogo · · Score: 1
    point-to-register and jump-to-register: allows you to define a 'jump-to' point. Very useful in you need to switch back and forth between two points in a file, or just jump to the same place you were before after roaming, searching, etc. I define these shortcuts:

    (global-set-key "\C-x/" 'point-to-register)
    (global-set-key "\C-xj" 'jump-to-register)

    Now, to save your current location, type C-x-/-X , where X is a number or letter. To jump back to the same point, type C-x-j-X. You can of course have many such points within a file, and it even works across buffers. Can't live without it.

    Also, time-stamp mode:

    in your .emacs, add:

    (add-hook 'write-file-hooks 'time-stamp)

    At the top of your files, put
    # Time-stamp: <>

    The timestamp is automatically inserted each time you save.

  174. PHP mode? by adnonsense · · Score: 1

    Anyone know a good extension for editng / managing PHP code? I currently use "php-mode.el" (http://php-mode.sourceforge.net/), while it's OK I have a feeling there could be something better out there.

  175. My configuration by againjj · · Score: 1

    http://svn.jamison.tk/repository/dotfiles/

    Some highlights:

    • A way to insert tabs instead on indenting when you want to.
    • Confirming an exit, since I accidentally hit C-x C-c too often.
    • A method of binding a macro to a key sequence for the remainder of the session
    • Utilities for line endings
    • A translation table to get back some functionality in a terminal window
    • Disable the insert key
    • Whitespace trim mode -- it trims extra whitespace from the end of the line
    • Pending delete mode
    • Resize-minibuffer mode

    Also, try C-w when in the middle of an incremental search.

  176. After Vi and Emacs, can we finally get to ED? by jokkebk · · Score: 1

    Now that this Emacs and Vi stuff is out of the system, could we please go on to ed?

    After all, it's the standard!

    --
    http://codeandlife.com