Skip navigation

Tag Archives: editor

This is a way to select whatever text we had just inserted inside a buffer. I forgotten this trick until now that used it again. A small tip worth annotating that might come in handy for somebody else as well:
1) yank(paste) the text “C-y”
2) mark the point where the cursor landed, (using point-to-register), do “C-x r SPC” and pick any letter ( a-z)
3) go back to the point where you initially were, by doing “C-u SPC”
4) set the mark there,“C-SPC”
5) use “C-x r j” (+ the letter picked) to go up the point where the yanked text ends inside your buffer.
6) Voila, the text yanked is highlighted ready for whatever manipulation you need to do onto it.

ps: Of course in case you pasted text at the end of the buffer is simpler,
just a matter of:
“C-u SPC”
“C-SPC” to mark
“M – >” to go to the end

UPDATE: Actually, thanks to Peter (see comment below) I learned that this is possible just doing “C-x C-x after the yank if you have transient mark mode enabled” .

Advertisements

When in need to enter special character inside emacs you can quote it with “C-q” and enter the octal character code, so for instance to type “ñ” you will do: “C-q 361

I found a thorough description of iso-latin-1 on the web, plus a great deal of general info on character and encodings available there as well http://www.cs.tut.fi/~jkorpela/chars/index.html

Within emacs it’s easy to pull any charset-table by doing “M-x list-charset-chars“, say if we type latin-iso8859-1 at the prompt the program shows:

character set

Then, for specifics about any character, simply highlight it and do “M-x describe-char” to get a full detailed view like:

character: ñ (241, #o361, #xf1)
preferred charset: latin-iso8859-1
(Right-Hand Part of ISO/IEC 8859/1 (Latin-1): ISO-IR-100)
code point: 0x71
syntax: w which means: word
category: .:Base, j:Japanese, l:Latin
buffer code: #xC3 #xB1
file code: #xF1 (encoded by coding system iso-latin-1-unix)
display: by this font (glyph code)
uniscribe:-outline-Bitstream Vera Sans Mono-normal-normal-normal-mono-13-*-*-*-c-*-iso8859-1 (#x78)

Character code properties: customize what to show
name: LATIN SMALL LETTER N WITH TILDE
old-name: LATIN SMALL LETTER N TILDE
general-category: Ll (Letter, Lowercase)
decomposition: (110 771) (‘n’ ‘̃’)

There are text properties here:
charset latin-iso8859-1

Awesome power!

I had an encoding issue that was bugging me inside the remember-data-file. I don’t know exactly how some latin-1 characters copy-pasted there ended up being saved as raw-text and were shown like non-ASCII characters (so a multibyte characters like “é” will appear with it’s escaped octal code “303\251” )

I tried at first setting the file’s encoding system with the tag “-*-coding: utf-8 -*-“, though it seemed not sufficient. The raw characters remained there and I soon grew tired of having to type in: “utf-8” at the prompt to select the encoding every time I needed to save the file.

Today searching the manual found here one easy cure on the command “recode-region” which allows to convert the text that was decoded with the wrong coding system.

Really all it took after marking the whole buffer (C-x h) was doing: “M-x recode-region RET” “Text was was really in: utf-8” “But was interpreted as: raw-text”

That was it!, the drag is over, I’m back to storing notes quickly doing just C-c r and C-c C-x with the worthy remember mode.

(This is mainly a remainder post for myself)
For certain reasons I sometimes have to edit text pasted from an emacs buffer that I was editing with the longlines-mode enabled. Hence as this mode does, the paragraphs are hard wrapped beyond a certain amount of characters (when they extend over ‘fill-column’ lenght).

Although “the soft newlines used for line wrapping will not show up when the text is yanked or saved to disk”, they will remain if, say, I had carelessly pasted it directly into a gmail form to save for later reuse there.

My way to remove those artificially-inserted line breaks, is running this oneliner on the text region.

sed -ne '1h;1!H;${;g;s#\n\([^\n]\)# \1#g;p}' | sed -e 's#^[ \t]*\(.*\)$#\1#g'

(The first sed command tells to put a space and remove the line break. using the multiline search and replace method
The second just gets rid of the leading white space at the beginning of line)

This seems a bit idiosincratic, in emacs the way to paste (yank) text in the search minibuffer is doing M-y not C-y (that is Meta-y not Control-y, as is the default way for all other matters)
It’s funny that I didn’t realize something so basic until now. I don’t know what the reason might be, but this is still the way at least in emacs 23.1.91
(R. Stallman answered the same question in 2005 here at http://www.mail-archive.com/emacs-pretest-bug@gnu.org/msg03693.html)

UPDATE: maybe worth pointing that when editing a search (M-E) you need to use the canonical C-y to yank instead of M-y as it is the case in the search

Ok this is is kind of a loud statement, I know. I’m not a member of any religion nor I want to convert anybody’s faith in the tools they choose, a highly subjective matter indeed . I just happen to feel enchanted by this editor which runs in all platforms, is totally flexible and configurable. Emacs bears a lot of history in its back -which turns it into one of the most ancient, more mature pieces of software there exists. It was coded by the genius work of Richard Stallman, father of the Free Software Foundation, a key figure in shaping the digital era as we know it today.

For me, having a windows background, starting to use emacs felt kind of awkward at the beginning. Due to some kind of inertia I was rather content with Dreamweaver and didn’t even know how much I was missing from a more powerful editor. Getting familiar with emacs (which I now use under Windows and Unix) took some dedication. A selling argument for me was the idea that picking the right editor was a lifetime investment (Steve Yegge in one of his eloquent posts). Anyway there’s something both exciting and challenging in getting the most out this program will such versatility and power to be discovered and mastered.