Feeds:
Posts

## Emacs Tip: Using Macros

Yesterday I started to edit an old $\LaTeX$  file, and it happened that in my set of definitions I changed a bold math-operator with no arguments \df, by a math-operator with one argument (which happens to by the following word) \de{#1}.

## The problem

The issue now is that I should go all over the text finding the \df command and replaced by \de{#1}. But note that the is a delimiter with the curly bracket!

## The solution

A while ago I found a page called , and I learn about emacs’ macro, i.e., a set of rules you define and then can be applied recursively.

### How is it done?

A short explanation is given at .

In my case I follow that rules below:

• Press F3 to start recording the macro.
• Look for the initial command and change it by the other using M-% \df (press enter) \de{ (press enter)
• Move the cursor forward until the end of the next word using the command M-f
• In that cursor place close the curly bracket }
• Finish the recording of the macro by pressing F4.

Finally, to apply the macro use F4 to apply it once, M-4 F4 to apply it 4 times or M-0 F4 to apply it until it fails.

## Linux Tip: Archiving and Compressing Files

Two of the most useful commands for archiving and compressing in Linux are tar and gzip.

gzip stands for GNU zip, which is a similar tool to ZIP (for Windows). Files which end in .gz are GNUzipped. One can decompressed them using the gunzip command.

\$ gunzip file.gz

For compressing a file one uses the gzip command,

\$ gzip file

To create an archive, i.e., to bound a bunch of files, one uses the tar command. However, there are some flags (or options) should be activated:

• c: creates an archive,
• f: for given a file name. It is mandatory
• v: verbose mode, allows to visualise all files of the archive.
• x: extracts files from an archive.

#### Examples

\$ tar cf archive.tar file1 file2 ...

Creates an archive (archive.tar) with files file1, file2, and the others (denoted by the ellipsis).

\$ tar tvf archive.tar

\$ tar xf archive.tar

Extracts the files of archive.tar in the current directory (pwd).

\$ tar xvf archive.tar

Extract the files of archive.tar in verbose mode. The files ar placed at the pwd.

\$ tar xf archive.tar /your/optional/path

Extracts the files of archive.tar into /your/optional/path.

#### Archiving and compressing… together

tar and gzip can work together. It’s not rare to find compressed archive, whose extensions are .tar.gz, .tar.lzma, .tar.b2 and so on.

In order to decompress and extract these files one needs to include extra flags (options):

• z: for uncompressing .gz files.
• j: for uncompressing .b2 files.
• --lzma: for uncompressing .lzma files.

#### More examples

\$ tar xzf archive.tar.gz

Extracts the files of archive.tar.gz in the current directory.

\$ tar xjf archive.tar.b2

Extracts the files of archive.tar.b2 in the current directory.

\$ tar --lzma xf archive.tar.lzma

Extracts the files of archive.tar.lzma in the current directory.
Enjoy.

DOX