Red Antigua Logo slogan
Ads by Goooooogle
Search this site (by Google)
Menu
Home
About
Tools
Perl modules
Perl tutorials
C tutorials
Server configurations
UNIX on Windows
Misc. FreeBSD/UNIX
Redirect a web page
JavaScript
Virus list
Old stuff
Off topic

Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Mail::POP3Client
Mail::Send
MIME::Tools
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
UnxUtils
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - make-in-a-shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
CD and DVD creation on FreeBSD using 'k3b' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
Boot floppies for FreeBSD
Problems with old disks/controllers and the 'ata' driver
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Sendmail tips
GKrellm
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Virus list    (top)
Latest viruses - Computer Virus HQ (external)
Latest 10 viruses - Sophos

Links    (top)
HTML and PHP Scripts - Html Web Template

Old stuff    (top)
POP3 server setup
About AnyMail
AnyMail downloads

Off topic    (top)
Personal links

Validated by
Valid HTML 4.01!
Valid CSS!
Powered by
apache.org
Emacs tips
Emacs tips

See also:
Emacs setup on Windows
Absolute beginner's Emacs

Emacs .Xdefaults
emacs*Background: DarkSlateGray
emacs*Foreground: Wheat
emacs*pointerColor: Orchid
emacs*cursorColor: Orchid
emacs*bitmapIcon: on
emacs*font: fixed
emacs.geometry: 80x25
Sample Emacs .emacs file
Sample .emacs file can be found here.
You need several emacs packages for the above sample file - browse packages here.

Reload .emacs file
If you modify .emacs, changes normally take place next time you start Emacs.
To "reload" .emacs, that is, to make the changes take place immediately, open .emacs and type:
M-x eval-buffer

cperl-mode
By default, perl-mode is loaded automatically when editing a .pl, .cgi, or .pm file.
You can switch between perl-mode and cperl-mode by typing
M-x perl-mode
M-x cperl-mode
I prefer cperl-mode by default, so I added the following lines to my .emacs file:
(require 'cperl-mode)
;; Perl file extension associations
(add-to-list 'auto-mode-alist '("\\.pl$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.cgi$" . cperl-mode))
(add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
;; BSD/Allman indentation style using cperl-mode
(cperl-set-style "BSD")
You can view the available indentation style and switch between them interactively using
M-x cperl-set-style ENTER TAB

html-helper-mode
Assuming you have the html-helper-mode package installed in the emacs-packages directory, you can add the following lines to .emacs file:
;; HTML helper mode
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
  (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
The html-helper-mode adds an HTML menu to Emacs, where you can use shortcuts for almost any HTML tags/entities/elements.


Reloading an Emacs feature
Let's say you hacked the html-helper-mode.el file to suit your needs. Changes in the files do not reflect the behaviours of html-helper-mode immediately - you have to reload the package first:
M-x unload-feature
RET
html-helper-mode
RET
If you have added the line (autoload 'html-helper-mode ... (see above) to your .emacs file, it is sufficient to open a new file with the .html to reload html-helper-mode. You can also reload the feature manually:
M-x load-library
RET
html-helper-mode
RET
(Remember that in the case of html-helper-mode, the package tempo.el is also loaded, so if you want to disable all html-helper-mode features manually, you have to unload-feauture tempo as well.)
Of course, unloading/loading a feature isn't limited to html-helper-mode, but can be applied to any Emacs feature. You can get a list of loaded features:
M-x unload-feature
RET
(press TAB here to see a list of loaded features)


replace-regexp (or query-replace-regexp)

Search and replace:
M-x query-replace-regexp

Replace 4 or more digits at the beginning of a line with the sign '>':
M-x replace-regexp RET
^[0-9]\{4,\} RET
> RET		    

Search and replace 6 digits with an empty string:
M-x query-replace-regexp
[0-9]\{6\}
RET
RET

Search and replace 6 or more digits followed by a space with an empty string:
M-x query-replace-regexp
[0-9]\{5,\}[ ]
RET
RET

Search and replace 3 or more digits preceded by possible space(es) and followed by a space, with one space:
M-x query-replace-regexp
[ ]*[0-9]\{3,\}[ ]
RET
RET

Search the first occurence of a dot in a line (.) and remove the rest of the line, including the dot:
M-x query-replace-regexp
[.].*$
RET
RET

The same as above, but with a colon instead as a dot:
(This is useful when you have a file with a grep results from various files, and just want a list of the files; use sort -u from the command line to sort the list and eliminate duplicates.)
M-x query-replace-regexp
:.*$
RET
RET

Insert a TAB at the beginning of a line, and add a continuation character at the end:
(This is useful when for example you have a list of files, and want to list them in a Makefile or a shell script.)

M-x query-replace-regexp
^\(.*\)$
RET
C-q (prepare for control character)
RET
TAB\1 \\ (TAB means "just press TAB!")
RET

Timestamp regexp: Search and replace hours and minutes (separated by colon) followed by a space with an empty string:
M-x query-replace-regexp
[0-9]\{2\}[:][0-9]\{2\}[ ]
RET
RET

Timestamp regexp: Search and replace hours and minutes (separated by colon) preceded and followed by a space with an empty string:
M-x query-replace-regexp
[ ][0-9]\{2\}[:][0-9]\{2\}[ ]
RET
RET

Timestamp regexp: Search and replace non-formatted timestamp (hhmmss) with a formatted one (hh:mm:ss):
M-x query-replace-regexp
\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)
RET
\1:\2:\3
RET

Control characters: Replace Newline or Carriage Return (NL/CR) for any other string:
M-x query-replace-regexp
C-q (prepare for control character)
CTRL-j (UNIX NL - use CTRL-m for DOS CR)
RET
<replace-string>
RET

Read more about replace-regexp syntax at
http://www.gnu.org/software/emacs/manual/html_node/Regexp-Replace.html

Rectangles in Emacs
You can cut and paste rectangles, i.e. columns, in emacs.
Put the cursor at the first row and column of the rectangle you want to cut or copy.
Select the rectangle (C-SPC) and move the cursor to the last row and column you want to include.
To cut (kill) a rectangle:
C-x r k
To paste (yank) a rectangle (starting where the cursor is positioned):
C-x r y
Read more about rectangels at
http://www.gnu.org/software/emacs/manual/html_node/Rectangles.html


Shell commands in Emacs
Obviously this requires a working shell (which can be a problem on Windows).
The general syntax for a shell command is
M-! shell command
Examples:
To count the characters in a selected area:
M-! wc -c
To count the words in a selected area:
M-! wc -w
Read more about shell commands at
http://www.gnu.org/software/emacs/manual/html_node/Shell.html


Sort lines alphabetically in Emacs
Select the lines you want to sort.
M-x sort-lines


Kill various buffers in Emacs
C-x C-b (List all buffers - splits window into two buffers)
C-x o (Switch to buffer list)
d (shows a D at the beginning of each line with the name of the buffer to be deleted)
x (kill all selected buffers, i.e. beginning with a D)
C-x k (kill the buffer list itself)
C-x 1 (unsplit window)


Emacs as external editor for KMail
Check the following checkbox: KMail -> Settings -> Configure KMail... -> Composer -> Use external editor instead of composer
Specify editor:
emacs %f -f iso-accents-mode
The -f iso-accents-mode arguments are not necessary, but convienient when typing in other languages than English.
Note: In Emacs 22, iso-accents-mode is deprecated. Use C-\ latin-1-prefix instead (inside Emacs, not as a command line option).

Last modified: Wed Nov 21 12:44:13 Romance Standard Time 2007