emacs delete-selection property



> > Hope this helps, Ilya
> Hope it helped you.  I have my doubts that it helped anyone else.

lol. funny. I see a flamewar brewing, and am getting into the fray here by participating.

I think both Drew and Llya or even me adds good points in the discussion.

The way i see this is a bug is in the sense that the purpose of delete-selection property seems to be thwarted by specific way how emacs works. Namely, the final effect is that it makes a distinction on whether the command is invoked by M-x or by a hotkey.

so, i tend to see this is not a desired behavior (call it “bug” or “feature” or “design” or whatnot).

but overall i guess this is trivial? It would be fruitful if someone do a survey on how many functions actually use the delete-selection property, or if some emacs oldbie can tell us that property's history. Am guessing, these days, if elisp programer want the behavior of deleting existing text selection in commands they write, a reliable and easy and explicit way is simply to put in the code

  (when (region-active-p)
    (delete-region (region-beginning) (region-end) )

instead of relying on delete-region property. I think elisp function property is rather esoteric (e.g. it is not a feature in most langs, and i don't think it is that much widely known or used in elisp) I think i learned about it when diddling with cua-mode around 2007. The fact i learned it i think introduced more trouble, because otherwise i'd put the explicit code above and i wouldn't have posted this or the bug report. (does anyone know a list of all built-in lisp properties? (havn't spend any effort to search the manual...))

i think a good question is: from a core emacs developer's point of view (such as Richard Stallman, or perhaps Drew Adamns and Llya Z. who designed the system or know the core system well), would you advice to actually make use of the delete-selection proprety or just use the explicit code above?



emacs delete-selection property


---------- Forwarded message ----------
From: Xah Lee
Date: Dec 22, 6:33 pm
Subject: can a command specify overwrite selection behavior?
To: gnu.emacs.help

On Dec 22, 9:12 am, "Drew Adams" wrote:

> > Drew, what i didn't understand is why the insert-date property makes a
> > distinction on whether a command is called by name or by a keyboard
> > shortcut?

> Ah, good question.  Here's the answer:

> (defun delete-selection-pre-hook ()
>   (when (and delete-selection-mode
>              transient-mark-mode mark-active
>                (not buffer-read-only))
>     (let ((type (and (symbolp this-command)
>                          (get this-command ; <=======
>                           'delete-selection))))

> If you debug this (use `message', not `debug-on-entry'!), you'll see that when
> you use `M-x' the value of `this-command' is `execute-extended-command', not
> `insert-date'.  And `execute-extended-command' does not have a non-nil
> `delete-selection' property.

> `execute-extended-command' is a bit special wrt `this-command' and
> `last-command'.  It DTRT in the end, essentially removing itself from the party,
> but that's only at the end.  While `execute-extended-command' is executing, it
> is the value of `this-command'.

> People sometimes get thrown off by this kind of thing, and similar things wrt
> `M-:' (and `C-x C-e', `C-M-x'...).

> The thing to remember is that `M-x' and `M-:' are themselves keys that are bound
> to commands, and that even though they invoke or evaluate other stuff (and that
> other stuff is what we focus on), that is not the same as just invoking or
> evaluating the other stuff directly.  They add their bit to the mix, and
> sometimes that makes a difference.

> It can help to remember that EVERYTHING in Emacs is a COMMAND.  Or, rather,
> every user interaction is via a command.  Outside Emacs we are not used to
> thinking that way (because outside Emacs it is not true).  But even when you hit
> a letter key such as `g' Emacs invokes a command (by default,
> `self-insert-command').

> Always.  Well no, you can undefine keys: (global-unset-key "a") etc., but as a
> general rule it is true.

> (I know that you know all of this, but I find it's worth reminding myself from
> time to time.  Emacs interaction is all about commands.)

hi Drew. Very useful info i do not know about. Thanks.



unicode and LaTeX abbrevs list


does anyone know a page that list all TeX/LaTeX's math symbols abbrevation together with a unicode character?

i need the glyph to be unicode char, not a image.

i spent 20 min but couldn't find it.

closest i found is http://ia.wikipedia.org/wiki/Wikipedia:LaTeX_symbols
but it uses images. If it uses unicode char, that'd be perfect.


Mathematica aliases for special chars

there's this page listing all named chars in Mathematica

is there a page listing all possible input alias for a special symbol?

(also including TeX abbrevs, e.g. Esc \forall Esc)

i searched the doc for a while but couldn't find it.

(i know that any named char can be input like \[Name] and unicode can be input like \:nnnn. Am interested in the special aliases)

programmatically getting the list also welcome. Thanks.

Xah ∑ http://xahlee.org/ ☄


xah lee, sexual harassment


> On Dec 3, 8:20 pm, duckblue wrote:
> > why is xah lee posting this information?
> > sites with more external links pointing to them are given a higher
> > ranking by search engines such as google. as a result they appear
> > closer to the top of the search engine results pages ('SERPs' in SEO
> > lingo).
> > xah's posting here is part of active an SEO campaign that he is
> > carrying out in order bring traffic to his site.- Hide quoted text -

On Dec 3, 9:16 pm, small Pox wrote:
> Xah Lee writes good articles. She has a helpful attitude. Do you want
> her to become so financially dependent like that innocent looking
> rabbit teeth Adelyn Lee so she become a prostitute of Larry Ellis
> Islander who has gobbled up Sun, mysql, cray and so many software and
> hardware companies to make the largest and possibly going to be a most
> evil monopoly on earth ?


interesting mention about Adelyn Lee.

I looked up,

〈Woman Who Accused Oracle Chief Guilty of Perjury〉 January 29, 1997, By Benjamin Pimentel, Chronicle Peninsula Bureau. SFGate Articles.
〔 http://articles.sfgate.com/1997-01-29/news/17741019_1_mr-ellison-adelyn-lee-e-mail 〕


«A San Mateo woman accused of forging e-mail to sue Oracle Corp. was found guilty yesterday of perjury and falsification of evidence.»

«Adelyn Lee, a 33-year-old former girlfriend of Oracle Chief Executive Officer Larry Ellison, was convicted by a San Mateo County jury, ending a Silicon Valley soap opera that revealed some of the inner workings of the world's second-largest software company. »

«In 1995, Lee won a $100,000 settlement of a wrongful termination suit in which she claimed that she was fired from her job as an executive assistant after she refused to have sex with Ellison. »

interesting. Yeah, the 1990s, everything is sexual harassment.

it so happpens, i have a story to tell as well. I was officially accused of sexual harassment in around 2000 while working at Netopia. The whole case is ridiculous. The woman who accused me, was romantically interested in me. She's got some personal psychological problems. We both are sys admins (but i also do dev). She lives and work at the Kansas branch, while i work in California. Once or twice a year, the company has her flew over for business, typically lasting just a day. I'm not her superior or vice versa. Our relationship started when she started to IM me and got me to use AOL. The AOL chat is kinda used for business discussions as well, since it's just convenient, and apparantly it became popular in the company. (remember, this is 1999.) When she came over, i think the second time, then later, she filed a sexual harassment to Netopia. (i didn't even know before) We did not sleep together. The closest physical contact might be holding hands, which, i don't remember we actually did. All i know after the whole thing is that she's got some kinda love hang-over.

At the end, they (the human resource woman who handles this) ask me to sign a paper, which, if i recall correctly, basically want me to admit some wrong doing or something like that. I do not agree to it, i refused to sign. And that basically is the end of it. She quit or was fired sometimes later on (don't think it has anything to do with this). I was laid off in 2002. (Netopia got bought by Motorola in ~2005)

I may write up a blog, with full disclosure of all documents of the case and emails sometimes later.



list processing: mathematica vs lisp

in lisp lang, often there's pure exercise posted about manipulating lists.

here's a old Mathematica post that Google recently dig'd up and notified me (apparantly, it means people's been reading that post)


i hope that in this post, if anything, it gives lispers some idea about how Mathematica is similar to lisp, and if i may say so, how Mathematica is some order of magnitude easier to do complex list manipulation problems than lisps.

(me, being a Mathematica fan, like to say this. Of course, this does not mean Mathematica is “better” for everything. But take what you will.)

for list manipulation, i think langs that might be comparable to Mathematica's capabilities are those so-called array programing langs. (e.g. APL. see http://en.wikipedia.org/wiki/Array_programming )

when i first ventured into lisp in ~1999 (or any lang other than Mathematica), i was naive and was rather surprised that in lisp, list structure programing is not much done at all (in comparison to my experiences with Mathematica) Then in around 2004, i was naively surprised that even in Haskell, there's even no default data type of nested list. (i was naive because i thought every functional lang relies on arbitrarily nested list as its main data structure. But with about 10 years of industrial programing experience now, i think hardly any programing or lang relies on nested list as its main data structure. At most, there's just 2 or 3 levels of nesting as in matrices.)

the post is pasted in the following:

From: Xah Y Lee
Date: Apr 7 1995, 11:00 pm
Subject: Summary:Ways to get Odd Columns&Rows of Matrix
To: comp.soft-sys.math.mathematica

This is a summary of Ways to get only odd rows and columns of a matrix.

Problem: Suppose we have a mxn matrix. We want to cross out the even rows
and columns, and get the remaining matrix. How to do that?

This is built-in in mma. The simplest way to do it is
Part[myMatrix,{1,3,5...},{1,3,5...}]. See section 3.7.2, p.651 of the mma

Below is a collection of various ways to write this program. Some of them
are general that can work on matrices with more than 2 dimensions, and
user can choose odd only, even only, or generalized such as every third
member in the tensor. Most others are included not as a practical solution but
as programming examples.

These pieces of codes are contributed by various members of mathgroup.
I've taken the liberty to modify some of them to make this a coherent

myList = Array[a,{10,18}];
(*Using Part*)
(*From: Robert Villegas *)
(*From: Count Dracula *)
In my opinion this is the best solution.
Use Map[Select[Range[#], OddQ] &, Dimensions[myMatrix]] to generate a
list {{1,3,5,..}, {1,3,5,7...}}, then feed it to Part to extract, like
Part[myMatrix, {1,3,5}, {1,3,5,7}].*)

MatrixSieve1a[myMatrix_] :=
      Sequence@@ Map[ Range[1, #, 2]&, Dimensions[myMatrix]]

MatrixSieve1b[myMatrix_, sel_:OddQ] :=
      Sequence@@ Map[(Select[Range[#], sel] &) , Dimensions[myMatrix]]

(*Using Table.*)
(*From: Lou Talman *)
(*easiest to understand.*)

MatrixSieve2[myMatrix_] :=
      Table[ myMatrix[[i, j]],
         {i, 1, Length[myMatrix], 2},
         {j, 1, Length[First@myMatrix], 2}
(*using Partition. *)
(*From: Xah Lee <74631....@compuserve.com>*)
This one is hard to understand. It's not easy to generalize as well. It
will not work if the matrix contain odd number of row or column, but it's
got the potential to become the most elegant solution. It's the fastest
among all.
MatrixSieve3[myMatrix_] := Map[ First, Partition[myMatrix,{2,2}],{2,3}]

(*Recursively elimate the second term.*)
(*From: Tyler Perkins *)
Define OddOnly[], that will get rid of the second element in a list.
This is repeated recursively in a nested way so that at the end only the
odd terms of the list is left.
Map OddOnly to every level of myList.

OddOnly[{first_, second_, rest___}] := Join[{first}, OddOnly[{rest}]];
OddOnly[singleExpr_] := singleExpr;
MatrixSieve4[myMatrix_] := MapAll[ OddOnly, myMatrix]

(*using Array and Part*)
(*From: "L. Hannibal" *)

      myMatrix[[2 #1 -1,2 #2-1]]&,
         {Ceiling[Length[myMatrix]/2], Ceiling[Length@First@myMatrix/2]}
(*using Pattern and ReplaceRepeated*)
(*From: Robert Zimmerman *)
(*This is not a general method, but included here as a extra example of
programming techniques. It only works on matrices whos elements have the
form head[x,y]. It works by first flatten myList, then replace elements
with even index with 0, then eliminate the zeros in the list. Lastly,
Partition them into the correct form.
   (Flatten@myList)//.{a[x_  ,y_?EvenQ ] ->0, a[x_?EvenQ  ,y_ ] ->0}//.
   { head___ ,0, tail___ } :> {head, tail}
(* using Fold and Drop *)
(*From: bob Hanlon *)
(*works on matrices with even number of terms.
Not a good example of coding.
The use of Fold, Transpose and Drop are too complex.
Slow as well.

   Fold[ Drop,
         Fold[ Drop, myList,

 Xah Lee

svn rename letter case issue

a quick web search indicates that renaming files with only letter case changes on Windows client is a known issue.


the solution seems require editing the repository data, quote:

“Rename the file from UPPERcase to upperCASE directly in the repository using the repository browser. ”

anyone know how that's done?


On Dec 1, 2:21 am, Xah Lee wrote:
> Thanks bohuslav.krivosik.
> does anyone know if svn can properly rename the same file with just
> letter case difference?
> i cluelessly tried a combination of
> svn rm Tabbar.el
> svn add tabbar.el
> svn commit tabbar.el
> svn rename Tabbar.el tabbar.el
> in random order over the past few days...
> the repository shown on Google sitehttp://code.google.com/p/ergoemacs/source/browse/#svn/trunk/packages
> seems to still have cap letter version.
> i think i can solve one way or another by some brute force, but wonder
> if svn is capable of renaming file just for letter case changes.
> (same issue for twit.el)
> -------------------------
> a separate issue/question, is whether emacs packages should have cap
> letters. From my experience, the answer is no by convention. If that
> is correct, this means we also need to change the comment in the
> package's header so that the file name is lower case.
> e.g. the first line in twit.el content is this
> ;;; Twit.el --- interface with twitter.com
> it should be lower case too.
>  Xah
> On Nov 23, 3:30 am, ergoem...@googlecode.com wrote:
> > Status: New
> > Owner: ----
> > Labels: Type-Defect Priority-Medium
> > New issue 89 by bohuslav.krivosik: Wrong filename: Tabbar.elhttp://code.google.com/p/ergoemacs/issues/detail?id=89
> > Emacs version: 23.2.1
> > Ergoemacs version: 1.9.1.
> > OS: Linux Ubuntu
> > Install ergoemacs. Run emacs.
> > Emacs will start with following error message:
> > "File error: Cannot open load file, tabbar"
> > How to fix this bug:
> > Rename file "packages/Tabbar.el" to "packages/tabbar.el" (linux is  
> > case-sensitive)
> > Is there same problem for file Twit.el ?