unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
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 05:57:15 -0800 (PST)	[thread overview]
Message-ID: <12ab47cd-8a08-4210-b827-f31c56a09a1d@c36g2000prc.googlegroups.com> (raw)
In-Reply-To: mailman.1213.1227617025.26697.help-gnu-emacs@gnu.org

On Nov 24, 4:21 pm, "Tolkin, Steve" <Steve.Tol...@FMR.COM> wrote:
> Summary: If I bind the home key to the macro below and press shift+home
> it does not select the text.
>
> Details:
> I am running GNU Emacs 22.3.1 on of 2008-09-96 on SOFT-MJASON. On
> windows XP SP2.
> This used to work in emacs 22.  I suspect the problem has to do with
> changes to cua-mode (which I have on) and/or transient mark-mode (which
> I explicitly set on in v. 22,but now seems to be part of cua-mode.)
>
> Here is the macro definition:
>
> ;; Posted to comp.emacs by:
> ;; Kai Grossjohann <Kai.Grossjoh...@CS.Uni-Dortmund.DE>
> (defun my-home ()
>   "Toggle the point between the beginning of the current line, and the
> first non-whitespace character on the line."
>   (interactive)
>   (let ((pos (save-excursion (back-to-indentation) (point))))
>     (if (equal pos (point))
>         (beginning-of-line)
>       (back-to-indentation))))
>
>  (global-set-key [home] 'my-home)
>
> My current workaround is simply to comment out the global-set-key line.
> Is there a fix to the macro to get the old behavior?  Even better would
> be something already in cua-mode or simple.el etc that i could use.
>
> Note: I am now also sending this to help-gnus-emacs because it was
> suggested on the h-e-w list that this was not specific to Windows.


Few notes and answers.

• what you called a macro is not a macro. It is just a lisp function,
or call it user written emacs command. A macro in emacs has 2
meanings: keyboard macro, and elisp macro. Keyboard macro is software
application feature that allows you to record your keystrokes and play
them back. It's purpose is to let you do a lot automations. As a
example, a OS wide macro system is QuicKeys. A lisp macro is a fetarue
of the computer language that allows you do do source code
transformation. In some sense, it is a crude form of term rewriting
languages. (e.g. Mathematica)

you can read about these here:

http://en.wikipedia.org/wiki/Macro_(computer_science)
http://en.wikipedia.org/wiki/Rewriting
http://en.wikipedia.org/wiki/Mathematica

As to your question, you can make it work by this:

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

probably best to rename your function to something more descriptive,
such as
line-beginning-dwim . (the “dwim” means “do what i mean”, as in
comment-dwim.)

also, you might be interested in these commands:

just-one-space
delete-horizontal-space

both have default keyboard shortcuts.

  Xah
∑ http://xahlee.org/

       reply	other threads:[~2008-11-25 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1213.1227617025.26697.help-gnu-emacs@gnu.org>
2008-11-25 13:57 ` Xah Lee [this message]
2008-11-25 16:14   ` if I set home key to this macro then shift+home does not select text in cua-mode Tolkin, Steve
2008-11-25 16:56     ` Tolkin, Steve
     [not found]     ` <mailman.1236.1227635531.26697.help-gnu-emacs@gnu.org>
2008-11-25 20:20       ` Xah Lee
2008-11-25 16:27   ` Lennart Borgman
2008-11-25  0:21 Tolkin, Steve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12ab47cd-8a08-4210-b827-f31c56a09a1d@c36g2000prc.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).