help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs Book Vs Emacs Manuals


From: MBR
Subject: Re: Emacs Book Vs Emacs Manuals
Date: Sat, 27 Jun 2015 15:29:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Thunderbird/38.0.1

There are often multiple ways of accomplishing the same thing. Sometimes one approach is faster or easier to compose than others. Sometimes one approach is more errorprone. For this particular data, a macro vs. a regular expression is about the same effort.

But what if the table had 200 lines so you might not have noticed that somewhere off the bottom of the screen was a line with 5 columns instead of 4? For any such line, the first ".*" in your regular expression would do a greedy match which would include the first "&".

Another approach when dealing with things that line up visually in columns, is Emacs' rectangle commands. Using the same LaTeX table:

\begin{longtable}
  1 & 2 & 3 & 4 \\\\
  a & b & c & d \\\\
  A & B & C & D
\end{longtable}

Position mark on the "3" in line 2 and point on the "D" in line 4.
Now type:

   C-x r k

Done!

   Mark (not Point) Rosenthal


On 6/26/15 6:42 PM, Emanuel Berg wrote:
Marcin Borkowski <mbork@mbork.pl> writes:

What do you typically produce with your macros?
If you give me a good example where the macro is
the life saver, I can think how I would do the
same thing.
What about this: you have a LaTeX table with 4
columns, and you want to delete the second one.
While you /can/ do it with LaTeX hackery
(essentially making one of the columns invisible),
you want to deal with it at the level of the source
file. You put the point at the beginning of the
first row and do something along these lines:

F3 C-s & RET C-SPC C-s C-s RET C-w C-a C-n F4

and then press F4 once for each row (or even C-8 F4
if you know you have 8 more rows to go).

I cannot see how Elisp could be faster for this,
even if you /think/ in Elisp /and/ can touch-type.
Oh, yeah?

\begin{longtable}
   1 & 2 & 3 & 4 \\\\
   a & b & c & d \\\\
   A & B & C & D
\end{longtable}

%% (replace-regexp "^\\(.*&.*&\\).*&\\(.*\\)" "\\1\\2")

\begin{longtable}
   1 & 2 & 4 \\\\
   a & b & d \\\\
   A & B & D
\end{longtable}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]