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

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

Re: if I set home key to this macro then shift+home does not select text


From: Xah Lee
Subject: Re: if I set home key to this macro then shift+home does not select text in cua-mode
Date: Tue, 25 Nov 2008 12:20:25 -0800 (PST)
User-agent: G2/1.0

On Nov 25, 8:14 am, "Tolkin, Steve" <Steve.Tol...@FMR.COM> wrote:
>         Thanks.  Why did I have to compile it for it to work?
> First I added this to my _emacs init file and then I tried it by doing a 
> load-file of ~/_emacs
> But it did not work.
> Then I ran byte-compile-file ~/_emacs and then a load-file of ~/_emacs.elc

Basically, when you modify a mode's hook, and that mode has already
been loaded, it won't re-load your new hook's value.

there are ways... but the simplest method is to restart emacs when you
modified a hook.

You don't need to byte compile it, and byte compiling shouldn't have
anything to do with this.

On Nov 25, 8:56 am, "Tolkin, Steve" <Steve.Tol...@FMR.COM> wrote:
> Sorry, my earlier statement that compiling the _emacs file changed the 
> behavior was wrong.
> Pressing Shift+home sometimes does the selection and sometimes it does not.
> I do not know what causes this.

Looking at your function, you probably also want to add back-to-
indentation the CUA property of “'move”. So, try this new hook:

(add-hook 'cua-mode-hook
 (lambda ()
    (put 'my-home 'CUA 'move)
    (put 'back-to-indentation 'CUA 'move)
   )
 )

basically, what the above hooks do is that when cua mode is loaded,
add the property of “'move” to the symbol “'my-home”. Same for the
other. In lisp, symbols can have properties... this “symbol” concept
and its “property” is not something typical programing langs has. (the
other symbolic lang i know, Mathematica, has the same symbol and
property concepts. But i don't think any other functional langs such
as Haskell, OCml, erlang ... has it.)

Overall, what you are doing is not something simple. Because the
implementation of CUA mode is rather a complex. The reason it is
complex because it has to remain compatible with emacs's ways. Namely,
first: C-x key for copy has to remain functional for emacs's
traditional use of C-x key as a prefix. Secondly, the model of holding
Shift down while pressing other cursor movement key to cause text
selection is not something emacs do. So, making these work takes some
exploitation of elisp system. And now, you wanted to added your own
rather non-standard cursor movement function, and want the Shift+move
model to work on that too...

if the above works for you, that's great... but i think exploring
other ways of editing of doing what you want might be worthwhile.

  Xah
∑ http://xahlee.org/

reply via email to

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