From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1MMHei-00024T-LJ for garchives@archives.gentoo.org; Thu, 02 Jul 2009 08:28:33 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 346D4E0651; Thu, 2 Jul 2009 08:28:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C5C0EE0651 for ; Thu, 2 Jul 2009 08:28:31 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 64169B4025 for ; Thu, 2 Jul 2009 08:28:31 +0000 (UTC) Received: from fauli by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1MMHeh-0007GX-3G for gentoo-commits@lists.gentoo.org; Thu, 02 Jul 2009 08:28:31 +0000 To: gentoo-commits@lists.gentoo.org From: "Christian Faulhammer (fauli)" Subject: [gentoo-commits] emacs r1283 - / emacsguide X-VCS-Repository: emacs X-VCS-Revision: 1283 X-VCS-Files: emacsguide/ emacsguide/emacsguide.xml X-VCS-Directories: / emacsguide X-VCS-Committer: fauli X-VCS-Committer-Name: Christian Faulhammer Content-Type: text/plain; charset=UTF-8 Message-Id: Sender: Christian Faulhammer Date: Thu, 02 Jul 2009 08:28:31 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 21581e80-84ee-4c9f-8038-fb8042eb2b92 X-Archives-Hash: 75df68c33149cb5cad3f3acab9238c0b Author: fauli Date: 2009-07-02 08:28:30 +0000 (Thu, 02 Jul 2009) New Revision: 1283 Added: emacsguide/ emacsguide/emacsguide.xml Log: temporary location for Emacs user guide, provided by Marc Murphy Added: emacsguide/emacsguide.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- emacsguide/emacsguide.xml (rev 0) +++ emacsguide/emacsguide.xml 2009-07-02 08:28:30 UTC (rev 1283) @@ -0,0 +1,482 @@ + + + + + + GNU Emacs Introduction + + + Marc Murphy + + + Christian Faulhammer + + + + This guide is meant to be a nice introduction to GNU Emacs in Gentoo= . + + + + + + + 0.44 + 2009-07-02 + + + Installation and setup +
+ Installing + +

First, you must install Emacs.

+=09 +
+	  # emerge --pretend --verbose app-editors/emacs
+	
+ + + + + + + + + alsa + Determine if ALSA should be used + Emacs autodetects ALSA. That test is removed by the ebuild if + the flag is not set. This is for cases where ALSA is installed b= ut + the user does not wish support for it in Emacs. + + + dbus + Make Emacs D-Bus aware (Emacs 23 only). + + + + gif + Support for GIF images. + + + + gpm + Support for console-based mouse driver (Emacs 23 only). + + + + gtk + Use the GIMP Toolkit (GTK+) as windowing toolkit (menu bar + etc.) + When this toolkit is activated along with alternative ones (see + other USE flags), GTK+ is chosen. This is in sync with upstream's + wishes. + + + gzip-el + Zip up all el files. + The zip binary is autodetected. So even when this USE flag is + disabled but the binary is found, all el files will be compressed= . + The ebuild takes of that care by confusing the configure + script. + + + hesiod + Use the Hesiod name service system. + + + + jpeg + Support for JPEG images. + + + + kerberos + Support for the Kerberos network authentication protocol. + + + + leim + Extended methods for input encodings (Emacs 21 only). + + + + m17n-lib + Use the m17n-lib multilingual library for complex text layout, + e.g. for Indic scripts (Emacs 23 only). + Only available if "xft" is enabled too. + + + motif + A windowing toolkit. + + + + nls + This makes use of gettext, an easy way to provide translations + of strings (Emacs 21 only). + + + + png + Support for PNG images. + + + + sendmail + Build with support for mail transfer agent (Emacs 21 only). + + + + sound + Control the availability of sound support. + + + + source + Install the C source files and make them available in the + internal documentation system of GNU Emacs. + + + + svg + Support for SVG images (Emacs 23 only). + + + + tiff + Support for TIFF images. + + + + toolkit-scroll-bars + Instead of the internal scroll bars, the ones from the windowin= g + toolkit are used. + You will lose some functionality (split windows by clicking on + the scroll bar for example). + + + X + Let Emacs use an X session if available. Text mode can always + be forced. + + + + Xaw3d + A windowing toolkit. + + + + xft + Choose an alternative font renderer (Emacs 23 only). + + + + xpm + Support for XPM images. + If disabled, all logos, icons etc. in Emacs are displayed in + grayscale. This flag is forced through EAPI 1 features. + +
FlagDescriptionNotes
+

+ You could unpack the Emacs sources and run ./configure + --help to see the optional support. If you don't use the X + or gtk flags, you will rely on the keyboard to use Emacs. + Otherwise, emacs -nw is the terminal mode. +

+ +
+
+ Eselect + +
+	  # emerge app-admin/eselect
+	  # eselect emacs list
+	  Available Emacs symlink targets:
+	  [1]   emacs-22
+	  [2]   emacs-23 *
+    	  # eselect emacs set 1
+	  Switching emacs to emacs-22 ...
+	  Switching ctags to exuberant-ctags ...
+	  Switching etags to etags-emacs-22 ...
+	  # eselect emacs list
+	  Available Emacs symlink targets:
+	  [1]   emacs-22 *
+	  [2]   emacs-23
+	
+ +
+
+ Client/Server + +

+ Emacs can work as a server for emacsclient. To use this type M-x + server-start in a running Emacs session. Then it's emacsclient + file1 file2 file3 to edit your files or mail. +

+ +
+
+ Modes + +

+ Some types of files have modes created for them. If you edit + Python or PHP code, this piece of information is for you. This + is a convenient way to install elisp files (.el and + byte-compiled .elc) thanks to the Emacs team! This is done as + root. Note the # prompt. +

+
+	  # emerge --pretend --verbose app-emacs/python-mode
+	  # emerge --pretend --verbose app-emacs/php-mode
+	  Cscope can work with Emacs very conveniently.
+	  # echo "dev-util/cscope emacs" >> /etc/portage/package.use
+	  That will append the quoted text to the file "/etc/portage/package.us=
e".
+	  # emerge dev-util/cscope
+	
+ +
+
+ Built-in tutorial + +

There is a tutorial for Emacs available.

+
+	  M-x help-with-tutorial
+	
+

+ That is Meta then x. The Meta key is escape or possibly Alt. Next + you need to type help and use tab twice to see the completions. +

+ +
+
+ + + Dired + +

Lets start by looking at some files.

+
+      Control-x, control-f, enter
+    
+ =20 +

+ Now you have dired, the directory editor. When you press enter on + directories, you traverse the file structure. It is possible to + quickly back up the tree with ^, shift-6. Over the course of edit= ing, + you may open many files. +

+
+      Control-x, control-b
+    
+ =20 +

That will split your screen and show the buffers that are open. = When you want to split the screen, use control-x followed by a number. +

+      C-x 0 This makes the current buffer go away.
+      C-x 1 This makes the current buffer take full screen.
+      C-x 2 This will initiate the split and you can browse two=
 different parts of a file.
+      C-x 3 This is useful if you have a wide screen.
+    
+ +
+ =20 + + Invoking Processes + +

Emacs can start subprocesses, like a shell or a debugger or even = find and grep.

+
+      

M-x shell

+

M-x gdb

+

M-x find-grep

+
+
+ =20 + Emacs can be used on compressed text in the gzip and bzip2 for= mats by invoking decompressors. + +
+ =20 + + Emacs and Bash Equivalents + +

Bash has some keystrokes in common with Emacs. You can search + your shell history with control-r but not control-s. If you try + control-s in bash, it will hide your typing. You can type + control-q to see input to bash again. To cancel a search, type + control-g. Just like Emacs, you can kill text several times with + control-k and get it back with control-y. You can then use + escape-y repetitions. You can suspend Emacs with control-z. Try + the jobs command to see what is suspended. Then type fg or fg 1 + to get back to Emacs.

+ +
+ + + Speedbar for Debugging and Navigation + =20 +

+ If you're coding C, and you use gcc -g for debugging + symbols, Emacs can split your screen and follow the current line + of source code. If you use Emacs with X try speedbar. +

+
+      M-x speedbar
+    
+ =20 +

+ Now watch variables change just like any other development + environment. You could also browse directories in speedbar or do + other things by right-clicking. +

+ +
+ =20 + + Complete Text + +

Now is where some completion becomes useful. There is M-/ to com= plete a string and also some elisp that does much more.

+
+      M-x hippie-expand
+    
+ =20 +

+ This has try-expand-list, try-expand-line, + try-complete-file-name and many other things. It will cycle + through trying to match what is immediately on the left of the + cursor. It is much nicer to bind this to a key. +

+
+      M-x global-set-key
+    
+ =20 +

This could be persistent in a .emacs file.

+
+      $ echo "(global-set-key [(f2)] 'hippie-expand)" >> ~/.emacs.d/init=
.el
+    
+ =20 + man man has this tip: (global-set-key [(f1)] (lambda = () (interactive) (manual-entry (current-word)))) + +
+ =20 + + Emacs Lisp +

+ You could use the lisp interpreter to make lists or do some + simple math. Type these in and then type control-x, control-e + with the cursor at the end of them. Watch the minibuffer at the + bottom of the screen. +

+
+      

(list 'a 'b 'c)

+

(+ 1 2 3)

+

(* (* 2 2) (/ 22 7))

+

(message "%s" "This is an introduction to using Emacs in Gentoo= .")

+
+

+ Understanding how to navigate the cursor over lists is quite + useful. With the cursor pointed on a [, (, or {, use M-C-f to + go to the end. Use M-C-b to go to the beginning of the list. + That is escape, control-f and escape, control-b + respectively. +

+ +

You could load your elisp.

+
+      M-x load-file
+    
+ =20 +

+ Now, you may want to clean up your code or make replacements in a + function. Click and drag or use control-space to set a mark. +

+
+      M-x transient-mark-mode
+    
+ =20 +

+ That will toggle the highlighting of selected text. Now, M-% will + prompt you to search and replace or query-replace. Also, + global-font-lock-mode will toggle the syntax highlighting; + indent-region will nicely indent nested code blocks or HTML. A qu= ick + comment comes from M-; or escape-semicolon. +

+
+ =20 + + More Dired +

Now you may wish to do replacements in many files.

+
+      

M-x dired<TAB><TAB>

+

M-x command-apropos This can show any dired command.

+
+ =20 +

Now you see what is available. Here is one strategy.

+
+      

M-x find-grep-dired

+

%-m c$ This will mark C sources or filenames ending in= c.

+

M-x dired-do-query-replace-regexp

+
+
+ =20 + + Remove Comments +

+ One common thing for Gentoo users is to strip comments from + configuration files. This is convenient in Emacs with flush-lines +

+
+      

M-x flush-lines

+

^#

+

That will match lines beginning with a # which is a comment in= most /etc configuration files.

+
+
+ =20 + + Ediff +

+ Since Gentoo respects your /etc/ configuration files, you may + like ediff for file foo and ._cfg0000_foo. +

+
+      

+ You could run M-x find-dired with an argument like this: -name + \._cfg* +

+

Control-x, control-f, control-a, control-k, /etc, enter.

+

M-x ediff

+
+
+ =20 + =20 + + Macros +

+ An introduction to Emacs would not be complete without a section + on macros. This is "Editor MACroS". In a buffer, type + control-x, ( to begin. Then type what you want in the macro. + You are recording keystrokes. Now type control-x, ) to finish + the macro. Naming the macro is next with M-x + name-last-kbd-macro. You could insert-kbd-macro into a .emacs + file if you find it very useful. Perhaps you want to use that + macro 10 times in a row. This is awkward, but control-u, 10, + M-x mymacro. +

+
+ =20 + + Sample .emacs +
+      

$ cat ~/.emacs.d/init.el

+

(prefer-coding-system 'utf-8)

+

(setq transient-mark-mode t)

+

(show-paren-mode t)

+

(setq column-number-mode t)

+

(global-set-key [(f5)] (lambda() (interactive) (woman (current-= word))))

+

(global-set-key [(f6)] 'hippie-expand)

+

(global-set-key [(f7)] 'replace-regexp)

+

(global-set-key [(f8)] 'flush-lines)

+

(global-set-key [(f9)] 'dired-do-delete)

+

+

# cat /root/.emacs.d/init.el

+

(load "/home/username/.emacs.d/init.el")

+
+
+ +