2009-10-26

PowerShell version number confusing

with Windows 7 coming out, i thought there's a later version of PowerShell, so i tried to upgrade.

After downloading (have to download File Transfer Manger first), then i type $PSVersionTable, i get:

Name Value
---- -----
CLRVersion 2.0.50727.4200
BuildVersion 6.0.6002.18139
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1


but back in 2009-08-01, the output was:

PS C:\Users\xah\web\powershell> $psversiontable

Name Value
---- -----
CLRVersion 2.0.50727.4016
BuildVersion 6.1.6949.0
PSVersion 2.0
PSCompatibleVersions {1.0, 2.0}



the download location and the new requirment of FTM is quite confusing. The method to find out the version number of PowerShell is also confusing...

Compare the BuildVersion. Did i just downgraded?

I downloaded from
http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx
on the top right link, which points to
https://connect.microsoft.com/windowsmanagement/Downloads
and requires FTM installed.

This is supposed to be a release candidate.

My previous version, downloaded around month July, is 2.0, CTP 2 i think, also from
http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx
but the download is a direct install, not requiring FTM.

Xah
∑ http://xahlee.org/

2009-10-18

unicode in newsgroup posts

On Oct 17, 6:46 pm, dkco...@panix.com (David Combs) wrote:
> In article ,
> Xah Lee wrote:
>
> Please -- I know you love your nice control-chars your posts
> always include, but it sure makes it near IMPOSSIBLE for us
> to read, or especially to NICELY save, them.
>
> Suggestion:
>
> Each post you make, DOUBLE it: first part "your way", then
> a dashed line or lines, then again, but without that stuff
> in it. Just plain ascii, minus any within-line control-chars.
>
> (Presumably you take the trouble to write your posts, to think
> them through, etc, because you want us to READ them, to BENEFIT
> from them, perhaps to even SAVE them. Seems to me that it would
> thus be to YOUR benefit to make them as easy as possible to read,
> and likewise to save away, maybe even for OTHERS to read (attributed
> to you, of course).)
>
> Thanks for at least considering the above.

Hi David,

was it you who wrote me at least twice about this issue in the past in separate times?

If i didn't recall incorrectly, i never got any reasons what is the problem.

The "control chars" you mention, are unicode characters, and pretty standard ones, such as curly quotes and bullets.

I wrote all my posts using just emacs, and they show correctly in just about all web browsers from groups.google.com. There is no problem in copy and pasting them, nor can i imagine there any problem in saving them as file, in any of Windows, Mac, or linux. the encoding used is utf-8, default in mac, linuxes, and fully supported Windows.

unicode is charset in langs like xml, java... etc.

can you be explicit exactly what is the problem? is it some news reader that does not support unicode? i haven't tried, but it'd be a major shame if u telling me emacs+gnus or Mozilla's Thunderbird does not support unicode out of the box?

Xah
∑ http://xahlee.org/

2009-10-15

how to add words in aspell with emacs

On Oct 15, 2:47 am, Water Lin wrote:
> Two more question about using Aspell with flyspell mode.
>
> The first question:
>
> When Aspell finds an incorrect word, it will mark the incorrect word
> with special underline and color. But there are also a lot of special
> words like Flyspell, Aspell etc. which are meaningful but incorrect.
>
> I want to let Flyspell to ignore these words. What's the command?

right click on the word, and there's a menu command to add the word to your personal dict.

aspell creates your personal words file by default at
~/.aspell.en.pws

you can add or delete words there directly.

to find out what keyboard shortcut or command is called when right click the menu item, you can use describe-key.


> The second question:
>
> After successfully installed Flyspell with Aspell, I find that the input
> speed of my keyboard is a little slow and panic. It seems that flyspeel
> will influence my input speed. What can I do with it?
>
> My solution is:
> -------
> I disable Flyspell mode, but after I finish the email edition, I
> will use M-x ispell-region to check my spell. Is it a good way?

this solution is what i use. In fact, i use speck-mode (look at emacswiki.org for it). In my experience, it's faster, more robust. It doesn't do spell checking as you type though. It's batch, but faster than flyspell-buffer...

------------

spell checking is a critical feature of text editors. Spell checking frustration with Emacs on the Windows OS is a frequently asked question here. (the installation, configuration, is a huge pain in the ass even for professional unix sys admins and longtime emacs users) The GNU Emacs people, for some political, social , philosophical, or technical reasons, do not or will not make emacs work out of box on the Windows platform (their perspective may differ than the way i expressed it here). This, in my opinion, is a major problem of advancing emacs.

For issues related to this, see:

• Emacs Does Not Support Viewing Images Files In Windows
http://xahlee.org/emacs/modernization_image_support.html

• Problems of Emacs Supporting Obsolete Systems
http://xahlee.org/emacs/emacs_supporting_DOS.html

Xah
∑ http://xahlee.org/

2009-10-14

run current file

On Oct 12, 3:39 am, wdysun wrote:
> Hello dears,
>
> suppose I have a script in /bin, let us assume it is called mytex. Suppose I
> am editing a file called filename.tex.
>
> If I run the following command from the console:
>
> $ mytex filename
>
> this will do several things (tex the filename with several options, then
> convert the dvi to pdf and it deletes all aux files I don't need).
>
> There is a way to launch the script from emacs or even to build a function
> so that I can run the command just with M - something?

have a look here:

• Elisp Lesson: Execute/Compile Current File
http://xahlee.org/emacs/elisp_run_current_file.html

excerpt:

(defun run-current-file ()
"Execute or compile the current file.
For example, if the current buffer is the file x.pl,
then it'll call “perl x.pl” in a shell.
The file can be php, perl, python, ruby, javascript, bash, ocaml, java.
File suffix is used to determine what program to run."
(interactive)
(let (ext-map fname suffix progName cmdStr)
(setq ext-map ; a keyed list of file suffix to comand-line program to run
'(
("php" . "php")
("pl" . "perl")
("py" . "python")
("rb" . "ruby")
("js" . "js")
("sh" . "bash")
("ml" . "ocaml")
("lsl" . "lslint")
("vbs" . "cscript")
("java" . "javac")
)
)
(setq fname (buffer-file-name))
(setq suffix (file-name-extension fname))
(setq progName (cdr (assoc suffix ext-map)))
(setq cmdStr (concat progName " \"" fname "\""))

(if (string-equal suffix "el")
(load-file fname)
(progn
(message "Running...")
(shell-command cmdStr)))
))

Xah
∑ http://xahlee.org/

2009-10-11

elisp text processing: disable undo, etc

On Oct 10, 6:49 pm, Decebal wrote:
> I am doing a lot of work on a big buffer (65 MB). I understood that
> there is a possibility to disable the undo functionality. Something
> that is not used in batch-mode. So this could give a performance
> boost.
> How can I disable undo?
> Are there other things that could be usefull performance wise?

buffer-disable-undo

you find it by calling “elisp-index-search” with search word “undo”.

for batch processing, you want to disable undo, also turn off syntax coloring, possibly turn off auto save, auto back up, ...etc.

best do it with temp buffer

e.g.

(defun my-process-file (fpath)
"Process the file at path FPATH ..."
(let ()
;; create temp buffer without undo record.
;; first space in temp buff name is necessary
(set-buffer (get-buffer-create " myTemp"))
(insert-file-contents fpath nil nil nil t)

;; process it ...
;; (goto-char 0) ; move to begining of file's content
;; ...
;; (write-file fpath) ;; write back to the file

(kill-buffer " myTemp")))

or use with-temp-buffer or with-temp-file.

for more tips on using elisp as a text processing lang like perl, python, see:

• Text Processing with Emacs Lisp
http://xahlee.org/emacs/elisp_idioms_batch.html

Xah
∑ http://xahlee.org/

2009-10-06

ergonomics and efficiency

On Oct 5, 2:39 am, Johan Andersson wrote:
> Xah Lee, You say this at your site: "This shortcut set is designed based on
> ergonomic principles". What about efficiency? I guess ergonomics and
> efficiency could be related. But not necessarily.

typically efficiency is part of the consideration of ergonomics.

See:
http://en.wikipedia.org/wiki/Ergonomics

Quote: «Ergonomics (or human factors) is the scientific discipline concerned with the understanding of interactions among humans and other elements of a system, and the profession that applies theory, principles, data and methods to design in order to optimize human well-being and overall system performance.»

Note the last few words: “... and overall system performance”.

Xah
∑ http://xahlee.org/

trade off for better but uncommon

On Oct 5, 12:57 am, Johan Andersson wrote:
> Raven, looking at those movement keys, they are almost like Xah Lee's
> "ergonomic emacs keybindings".
>
> Xah Lee, looking through the dvorak lisp file you provided at your site, I
> think that I could really dig those bindings, with a few modifications.
> However, I was thinking about these bindings and the shell. How do you
> survive (if you use a shell outside of Emacs) that the shell C-a, C-e almost
> always means beginning and end of line? Of do you change them there aswell?

when you opt for something that's less conventional, such as dvorak layout, you trade for certain disadvantage... e.g. unable to touch-type at public library, inconvenient to have co-work type on your keyboard, some inconvenience when using some software, such as some gaming software that doesn't respect your OS wide layout setting, some inconvenience in using some hardware, such as those palm-sized mini-computer that comes with a hardware keyboard with qwerty printed on them and too small to be touch-typed even software mapped to dvorak... etc.

similarly, if you adopt the ErgoEmacs Keybinding for your emacs... you stop using the conventional emacs keybindings for bash... either you spend time to tweak your keybinding system wide, or spend time to tweak your shell's binding... or just switch memory when in shell as you do between different apps or OSes. etc. For me, i just use emacs default keybinding when i'm in shell... but 99% of the time i run shell inside emacs.

Xah
∑ http://xahlee.org/



On Oct 6, 10:20 am, "B. T. Raven" wrote:
> > when you opt for something that's less conventional, such as dvorak
> > layout, you trade for certain disadvantage... e.g. unable to touch-
> > type at public library, inconvenient to have co-work type on your
> > keyboard, some inconvenience when using some software, such as some
> > gaming software that doesn't respect your OS wide layout setting, some
> > inconvenience in using some hardware, such as those palm-sized mini-
> > computer that comes with a hardware keyboard with qwerty printed on
> > them and too small to be touch-typed even software mapped to dvorak...
> > etc.
>
> Blackberries are supposed to be thumbed anyway. Layout on such a
> miniscule keyboard isn't a touch typing issue since the method will
> always be essentially hunt and peck.

So, that means, when you use Blackberries, you have to thumb them, and when you thumb them, you have to face qwerty buttons. For a person who are used to Dvorak, that is a inconvenience, even though the person is not touch typing.

> Of course libraries should have a Dvorak keyboard option available with
> a one-click or one-keychord method of changing keyboards.

Library is a example of the thesis.

> In practice,
> at libraries, you're typing a few search terms or short commands so that
> two-fingered typing doesn't have to be endured for long.

many libraries in the US, in tech advanced cities anyway, such as the San Francisco Bay Area of California , have internet terminals that lets library users use for prolonged period of time. (when there are a lot people in waiting, typically 20 min or 30 min per person)

Again, library is just a example of the thesis.

For example, besides libraries, there are companies, any public terminal, public exhibitions, meuseums, ... etc. The point being, that if u chose dvorak layout, you encounter many inconveniences in lots of places and situations. Many of these situation are trivial, insignificant, can be worked around, but nevertheless, they are inconveniences and annoyances.

The more general point being, there is inconvenience when you choose something that is less common, even if superior. This applies to the dvorak layout users, as well as Mac users in the PC world, as well as Linux users in the PC world.

Xah wrote:
> > similarly, if you adopt the ErgoEmacs Keybinding for your emacs... you
> > stop using the conventional emacs keybindings for bash... either you
> > spend time to tweak your keybinding system wide, or spend time to
> > tweak your shell's binding... or just switch memory when in shell as
> > you do between different apps or OSes. etc. For me, i just use emacs
> > default keybinding when i'm in shell... but 99% of the time i run
> > shell inside emacs.

B T Raven wrote:
> In both Linux and w32 environments you have the same keyboard layout in
> Emacs, shell and in all other apps. You wouldn't expect to have Emacs
> keybindings outside of Emacs in either enviroment unless you explicitly
> set them up as shortcut keys on a per app basis, as in Firemacs.

not sure what is your point or what are you trying to say. Are these general remarks, or as counter argument to my previous post? As general remark, i don't think it is true or exact enough. For example, you said:

> In both Linux and w32 environments you have the same keyboard layout in
> Emacs, shell and in all other apps

Hum?? i assume w32 means Microsoft Windows? In Microsoft Windows, the general common keybinding, or common shortcuts for text editing related applications, certainly isn't like emacs. At best, we can say that emacs also support some of it.

In unixes, typically the bash shell supports *PARTS* of emacs's text editing shortcuts. If you are using other shell, they don't suppor emacs keyboard shortcuts for text editing by default. Some can be customived to, and i'm not sure they all can.

In linuxes, which i haven't used for about 7 years, i assume it is still similar to unixes in this context, as explained in above paragraph.

Xah
∑ http://xahlee.org/

2009-10-03

Window's way to input unicode vs Emacs

Hi David & Fra,

on issue 34:
http://code.google.com/p/ergoemacs/issues/detail?id=34

it is about adopting Windows's UI for entering unicode by the unicode's code point using decimal or hex.
e.g. Hold down Alt then press 0 2 0 0 on the num pad, to insert È.

I don't think this is a good idea. Here's the reasons and some thoughts.

Emacs has a complete system to input unicode chars, and a much superior one.

• by name, with wildcard support. Call ucs-insert. It supports name completion with wildcard.
• by unicode's code point with hexadecimal. Call ucs-insert, then type a hex.

I'm not sure there's a way out of the box to input by decimal. But if needed, it can be implemented in 5 min.

These are emacs standard way to input unicode, and a much superior one than the Windows way with Alt and keypad.

The inputting unicode with code point is not much used by vast majority of emacs users or programers (say, probably 1% of all professional programer would use it). Because, it requires the user to be familiar with unicode code points, and have somehow memorized the number for the char, or on special situations where he is working with unicode and have reference to insert the char he needed (such as in i18n programing or web dev).

So, inputting unicode by code point is only used for special occasions. If user needs to input unicode by code point, emacs ucs-insert provides a superior way with familiar interface. Emacs also provides many more convenient ways for entering unicode or frequently used non-latin-alphabet based langs. (e.g. set input system to one of the iso ones or ucs, or with shortcut C-x 8 ‹ascii art char›)

Introducing Windows's Alt+ num keypad way also is a major incompatibility of the way keyboard shortcuts are used. The Windows way is not a key combination nor a key sequence. It somewhat is a sticky key system, yet requires the Alt be down at all subsequent keys...

if we were to improve, i think a much more needed regarding to inputing unicode is a app is a visual character palette... On Windows, it has charmap but it quite sucks compared to Mac...

• the Windows way is not used on Mac. (am not sure about linuxes)

• the Windows way is dependent on code page...

some references:

• http://en.wikipedia.org/wiki/Windows_Alt_keycodes

• http://en.wikipedia.org/wiki/Charmap

• http://en.wikipedia.org/wiki/Windows_Alt_keycodes (there are some problems discussed there too)

• OS X's Character Palette (a much better analog to Windows's charmap) http://images.google.com/images?hl=en&source=hp&q=mac%20character%20palette&um=1&ie=UTF-8&sa=N&tab=wi

• OS X's keyboard viewer. http://images.google.com/images?hl=en&um=1&sa=1&q=mac+keyboard+viewer&aq=f&oq=&aqi=&start=0

• Emacs and Unicode Tips (discusses many of the ways to input unicode in emacs)
http://xahlee.org/emacs/emacs_n_unicode.html

• How To Create Your Own Keybinding In Mac OS X
http://xahlee.org/emacs/osx_keybinding.html
(shows screenshot of the Keyboard Viewer, and how to create your own unicode input layout on the Mac with its Keyboard Viewer)

Xah

emacs and dvorak

i've been a professional qwerty typist hired for data entry for 1+ year in early 1990s.

I've been a dvorak touch typist since ~1993.

Started to use emacs, and daily, since 1998.

So, my emacs experience is all dvorak, and it's all good.

if you are thinking some sort of dvorak for typing and qwerty for hotkeys, don't do that.

there are quite a few pages about dvorak and emacs... how much time did you google?

if you want to try dvorak, just switch to the layout in your OS, and use emacs as is. That's the best way.

a lot people uses dvorak with emacs too... too lazy to cite them here. You can find them on blogs...etc. Try to spend a hour web search, you'll find probably more info or blogs, comments, etc that will take more than 4 hours to read, at least.

i have written quite a lot on the subject myself... you can read:

• Xah's Emacs Tutorial
http://xahlee.org/emacs/emacs.html

• All About Keyboards, Keyboard Layouts, Shortcuts, Macros
http://xahlee.org/Periodic_dosage_dir/keyboarding.html

Xah
∑ http://xahlee.org/



On Oct 3, 7:58 am, Johan Andersson wrote:
> Hi!
>
> I've been thinking for a while about testing Dvorak in Emacs (or Svorak for
> me since I'm from Sweden). Before I started I out, I googled a bit about
> "emacs dvorak", but to my suprise got really few hits about this. So I
> thought I'd ask here.
>
> First off I found out that you could do *C-\ english-dvorak RET*, which
> would activate Dvorak but still keep the the Emacs keybindings (So that you
> don't have to type C-l to go to the previous line). But that does not help
> me all the way, since I want to use Svorak. And by only switching the Xorg
> keyboard layout to Svorak, I'd still have to somehow remap all keybindings
> in Emacs.
>
> So the question is basically: How do I get Svorak working in Emacs? And do
> any of you even use Dvorak at all? I mean Emacs users often use Emacs
> because you can do things really fast, so I tought that many Emacs users
> would use Dvorak.
>
> Thanks!

2009-10-02

finding the syntax to define shortcuts in emacs

On Oct 1, 12:06 pm, quodlibetor wrote:
> I would really like to bind C-).
>
> I've tried: (all of the following with both local- and global- set
> key)
>
> (local-set-key "\C-)" 'foo) ;error, invalid modifier in string
> "\C-\S-0" ;same
> [C-)] ;unbalanced parenthesis.
> [C-S-0] ; no error, but doesn't work
> [C-(kbd (self-insert-command ")")] ;totally borked
> [C-(kbd ")")] ; doesn't error, but really weird result
>
> etc, i can't remember.
>
> I tried entering into edmacro-mode to figure it out, and it hasn't
> helped me.
>
> Any tips seriously welcome.


The issue about emacs's syntax for defining shortcuts is a frequently asked confusion. Part of it has to do with emacs's keybinding syntax's and emacs lisp's historical baggage.

If you just want a working syntax, the solution is quite symbol.

Press Ctrl+h k (calling describe-key), then type what you want. For example, if you type “Ctrl+Shift+0” (which is “Ctrl+)” in us keyboard layout), then you'll get this message:

C-) is undefined

which means, the correct syntax is: “(kbd "C-)")”.

This tip is given at

• How to Define Keyboard Shortcuts in Emacs
http://xahlee.org/emacs/keyboard_shortcuts.html

---------------------------------

A separate issue, is that there's inconsistency for the kbd function's syntax when the key combo involves Shift.

Here's a except from the above article:

****************
Note: A keypress-combination such as “Meta+Shift+2” can also be considered as “Meta+@”. So, in emacs, you might be thinking that both of these code: “(kbd "M-S-2")” and “(kbd "M-@")” will work. Actually, only the latter will work.

When writing a keybinding definition, for a key combination that involves “Meta+Shift+‹key›”, you must use a version without the shift key if possible. For keybinding involving “Ctrl+Shift+‹letter›”, you must use the "-S". Examples:
GOOD BAD Keystroke
(kbd "M-A") (kbd "M-S-a") Meta+Shift+a
(kbd "M-@") (kbd "M-S-2") Meta+Shift+2
(kbd "M-:") (kbd "M-S-;") Meta+Shift+;
(kbd "C-S-a") (kbd "C-A") Ctrl+Shift+a

A easy way to find out the proper syntax, is to call “Alt+x describe-key”, then type the keystroke.

Note also, that keys involving “Ctrl+Shift+‹key›” cannot be distinguished from “Ctrl+‹key›” when emacs runs in a text terminal (i.e. telnet/ssh). So, this means best to avoid any binding with both Control and Shift.
****************

I filed a bug report on this, but i think it didn't come to any result.

http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1111

(i'm pretty sure this particular inconsistency is in part of the thread bug#1111... but the website shows lots of spam now. Possibly it is in another bug report but don't have time to hunt it down at the moment. In particular, i remember Chong Yidong closed it or put it on wishlist or something.)

For more notes related to keyboard shortcut notations, see:

• The Confusion of Emacs's Keystroke Representation
http://xahlee.org/emacs/keystroke_rep.html

• Emacs's M-‹key› Notation vs Alt+‹key› Notation
http://xahlee.org/emacs/modernization_meta_key.html

• A Short Survey Of Keyboard Shortcut Notation
http://xahlee.org/emacs/modernization_hotkey_notation.html

Xah
∑ http://xahlee.org/

Haskell's new logo, and Social Illiteracy of Tech Geekers

Haskell has a new logo. A fantastic one. Beautiful. For creator, context, detail, see bottom of:

• A Lambda Logo Tour
http://xahlee.org/UnixResource_dir/lambda_logo.html

this is posted here because it relates to various computer software/language's logo, a subject discussed by me several times in the past years in comp.lang.lisp, comp.lang.scheme, comp.lang.python, as well discussed now and then in these communities often without my involvement.

for my criticism or comment on logos, typical response by these people are showcases of complete ignorance of social function of logos, and a complete iliteracy in visual design (that any art student learns in first year), usually coupled with a teen-age militant attitude. (usually, these tech geeker's mentality is like: “you are a fucking idiot... we don't need a logo. Logos are for kids and blood-sucking marketers.”)

Some of these tech geekers, are motherfucking aggresive, so that they would ban me, or call me as a troll, or call upon whatever rules to oust me (such as “off topicality”) , for any criticism on them. (if requested, i'll take some time to cite the exact url for numerous of these threads that happened in the past 5 years. My frustration in discussing logos happened in python, lojban, lisp communities. Note: not all people in these communities are idiotic about logos. Typically, it's just few of priest fuckheads (e.g. a newsgroup regular, or somewhat significant contributor of the particular community). This particularly happened in several threads in the lojban community where i criticized its logo during mid 2000s. (have a look at lojban's motherfucking idiotic logo here: http://en.wikipedia.org/wiki/Lojban ))

• The Purpose of Logos and Principles of Logo Design
http://xahlee.org/UnixResource_dir/logo_design.html

• Lisp Needs A Logo
http://xahlee.org/UnixResource_dir/writ/logo_lisp.html

----------------
computer language and software logo gallery:

• The Unix Pestilence
http://xahlee.org/UnixResource_dir/freebooks.html

• A Lambda Logo Tour
http://xahlee.org/UnixResource_dir/lambda_logo.html

• LISP Logo
http://xahlee.org/emacs/lisp_logo.html

• Qi Language Logo
http://xahlee.org/emacs/qi_logo.html

• Haskell Logo
http://xahlee.org/haskell/haskell-logo.html

• The Emacs Logo
http://xahlee.org/emacs/emacs_logo.html

• Xah's Java Logo
http://xahlee.org/java-a-day/java_logo.html

Xah
∑ http://xahlee.org/

emacs: inserting numbers into a column of text

On Oct 2, 7:05 am, Benjamin wrote:
> I use keyboard macros fairly frequently, but I often run into a
> situation where I would like to increment a number in the macro, e.g.,
> if I start with:
>
> tmp tmp tmp tmp
>
> and I want to end with:
> tmp1
> tmp2
> tmp3
> tmp4
>
> I know how to create the macro where it would result in:
> tmp1
> tmp1
> tmp1
> tmp1
>
> Is there a way to make the number increment each time the macro is
> executed?
> Otherwise I am forced to step down through each line and manually put
> the numbers in 1, 2, 3, 4, ...
> Naturally this is a greatly shortened example for illustration
> purposes, and often the incrementing takes place within a longer
> statement e.g., tmp(:,1) = function(x,y). My interest here is how to
> increment or decrement the number in a more automatic fashion.
>
> I don't mind doing something other than macros, or even external
> commands (perl/sed/awk, etc.)
> to assist with this.

This is a frequently asked question in emacs communities.

Different people has different solution. For me, i wrote a function to do it. I documented it in this page:

• Emacs Lisp Examples
http://xahlee.org/emacs/elisp_examples.html

The following is excerpt:
------------------------------------
Sometimes, you need to insert a vertical column of sequential integers into a block of text, like this:

do this x times
do this x times
do this x times
...

where the “x” should be 1, 2, 3, ... The following code does it.

(defun insert-counter-column (n)
"Insert a sequence of integers vertically.
Example:
do this 1 times
do this 2 times
do this 3 times
...

If there are not enough existing lines after the cursor
when this function is called, it aborts at the last line.

See also: `kill-rectangle' and `string-rectangle'."
(interactive "nEnter the max integer: ")
(let ((i 1) colpos)
(setq colpos (- (point) (point-at-bol)))
(while (<= i n)
(insert (number-to-string i))
(next-line) (beginning-of-line) (forward-char colpos)
(setq i (1+ i))
)))


--------------------------------------------------

Note: if you are a perl programer (or python, ruby, etc), you can easily write a function in your lang and have a emacs wrapper calling it. So that, you select you text, press a hotkey, and emacs call your script, feed it the current selection, and return the output replacing the current text selection.

This might be easier for many people.

• Elisp Wrapper For Perl Scripts
http://xahlee.org/emacs/elisp_perl_wrapper.html

Xah
∑ http://xahlee.org/