[Top][All Lists]

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

Re: A problem with eval-after-load

From: Emanuel Berg
Subject: Re: A problem with eval-after-load
Date: Sat, 19 Oct 2013 02:43:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Marcin Borkowski <address@hidden> writes:

> Wow, now I feel guilty of wasting your time on this
> lengthy email...  Thanks for the tips!

No, on the contrary! I love to talk about such
things. All those shortcuts were setup when I needed
them - they are from my initialization files.

If I put them at one place, as I just did, perhaps I can
detect some new things, or someone else will comment,
etc. So it is useful for me too.

I have had *a lot* of troubles with those keys, but now
everything works (and has for some time), so for this
reason I was a bit surprised there was zero consistency
how it was done.

> No need to add/update after writing my code - but my
> solution was indeed a bit faster, as I mentioned.

Did you re-write the key map in the original mode
source? Share if you like. Did you do that in root or
user space? I wonder if an update of Emacs will
overwrite those changes?

>> (define-key input-decode-map [?\u0113] [S-caps])
>> (global-set-key (kbd "<S-caps>") 'buffer-menu)
>> To get weird keys to work. You have to set them up in
>> the ttys (or "the Linux VTs" so they will send those
>> Unicode chars instead of what they normally do).

> I'm not sure I fully understand this, but it seems to
> me to low-level for me.

If you use Emacs in a tty, some of the keystrokes are
undetectable in Emacs unless you have them send
something else, that *is* detectable. In the above case,
shift plus the caps lock key is made to send the Unicode
char (described by the code, whatever that is) and
*this* in turn is used to setup the shortcut. This hack
is one of the coolest and most useful I ever saw, and I
learned it on this very list. More on this, and other

>> (defun init-C-o-prefix ()
>>   (interactive)
>>   (define-prefix-command 'C-o-prefix)
>>   (global-set-key "\C-o" 'C-o-prefix)
>>   (init-C-o-keys) )
>> (add-hook 'after-init-hook 'init-C-o-prefix)
>> A new prefix key. Initialized after everything is done,
>> probably so not to get reset by something else, later.
>> (defun init-C-o-keys ()
>>   (interactive)
>>   (let ((the-map (current-global-map)))
>>     (define-key the-map "\C-od"     'eval-defun)
>>     (define-key the-map "\C-o\C-om" 'man) ; etc.
>> How that happens (same old).
> Did not understand this.  (I could RTFM, of course,
> but I'm too lazy after a day's work...  I'll look into
> this later.)

You know the M-x prefix, that is used for "long"
shortcuts. If you are running out of M-x [whatever]
shortcuts, *or* you think the M-x is located at an
un-ergonomic place, you can setup new prefixes (prefix
keys) wherever you want. Above, C-o is made such a

> This is more or less what I wanted to achieve in the
> first place.
>> (global-set-key [(control x) (k)] 'kill-this-buffer)
>> Yet another notation.
> And an interesting one.

Yeah, I don't know what separates all those
styles. Perhaps if you move around different systems
a lot, it matters. To me, they seem the same.

>> (defun sentmail ()
>>   "Dired the outbox directory, then focus the most recent mail."
>>   (interactive)
>>   (dired "~/Mail/sent")
>>   (local-set-key (kbd "I") 'sentmail-show-prev-mail)
>>   (local-set-key (kbd "K") 'sentmail-show-next-mail)
>>   (revert-buffer)
>>   (end-of-buffer)
>>   (dotimes (i 7) (backward-word)) )
>> Set keys *locally*.
> "Locally" in the sense of "this mode", not "this
> buffer", I guess?

No, the buffer. You see, that way it won't affect
regular Dired use. That was a workaround to use Dired as
a "sent mail" archive viewer. Now, thankfully I use Gnus
so I manage without it.

Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:

reply via email to

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