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

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

Re: Tidying up some elisp


From: Leon
Subject: Re: Tidying up some elisp
Date: Tue, 29 Aug 2006 13:35:48 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (gnu/linux)

On Tue, 29 Aug 2006 01:41:03 +0200, Hadron Quark wrote:

> I was just tidying up my .emacs to make things a little bit more modular
> and mode specific. I changed a load og global-set-key calls to the
> following so that after I loaded a c file, the other bufefrs werent
> accessing these c specific key bindings:
>
>   (define-key c-mode-map [f5] 'find-tag-noconfirm)
>   (define-key c-mode-map [f6] 'find-tag-repeat)
>   (define-key c-mode-map [f7] 'pop-tag-mark)
>
>   (define-key c-mode-map [f2] 'gdb-restore-windows)
>   (define-key c-mode-map [f10] 'compile)
>   (define-key c-mode-map [(f11)] 'next-error)
>   (define-key c-mode-map [(f12)] 'gdba)
>
>
> Is there some kind of "with" statement or "Lisp approach" which would
> make this more "Lisp"y? Something like an array of pairs and a loop to
> call define key for this mode?
>
> Something like
>
>    for(all in arr)
>            define-key c-mode-map @index @value
>
> if you get my meaning. Am beginning so am looking for pointers in how to
> approach things or "think" in order to best use Lisp.

For example:

(let ((dl '(
            ([f5] . find-tag)
            ([f6] . find-tag-other-window))))
  (dolist (i dl)
    (define-key c-mode-map (car i) (cdr i))))

-- 
Leon





reply via email to

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