emacs-devel
[Top][All Lists]
Advanced

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

Re: Customize key bindings?


From: Simon Josefsson
Subject: Re: Customize key bindings?
Date: Sun, 04 Jan 2004 00:25:45 +0100
User-agent: Gnus/5.1005 (Gnus v5.10.5) Emacs/21.3.50 (gnu/linux)

I realized this same idea can be applied to customizing environment
variables and autoload cookies too.  Here's an improved version of
custom-key.el, now renamed to cus-misc.el because it is no longer key
binding specific.  I suspect there may be other similar things that
can be customized using the same approach, but these cover what I
need.

An approach like this could be used to provide facilities to add paths
to `load-path' and regexps to `auto-mode-alist' too, but I'm not sure
that is a good idea.  Those variables could be properly customizable
with the "difflist" custom :type discussed here earlier.

;;; cus-misc.el --- Customize key bindings, autoloads and env. variables.
;; Copyright (C) 2003, 2004 Free Software Foundation, Inc.

;; Author: Simon Josefsson <address@hidden>

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Put this file in your load-path, evaluate it, and run M-x
;; customize-variable RET custom-key-alist RET and add some key
;; bindings, for example:
;;
;; custom-key-alist's value is
;; (("<f5>" . compile)
;;  ("<f6>" . next-error)
;;  ("<f7>" . previous-error)
;;  ("C-x 4h" . gtk-doc-insert))
;;
;; Click on 'Save', and restart Emacs to enjoy the now (hopefully)
;; automagically configured new global key bindings.
;;
;; Similarly, customize `custom-autoload-alist' and
;; `custom-environment-variable-alist' to add autoload cookies and
;; environment variables, respectively.  For example:
;;
;; custom-autoload-alist's value is
;; ((mail-add-payment . "hashcash"))
;;
;; custom-environment-variable-alist's value is
;; (("CVS_RSH" . "ssh"))

;;; History:

;; 2003-12-30 initial release
;; 2003-12-30 second release, fixed comments and added :require to defcustom.
;; 2004-01-04 added autoloads and environment variables,
;;            renamed to cus-misc.el.

(defcustom custom-key-alist nil
  "Association list with key bindings and functions."
  :type '(alist :key-type (string :tag "Key")
                :value-type (function :tag "Command"))
  :set '(lambda (symbol infolist)
          (set-default symbol infolist)
          (mapcar (lambda (info)
                    (global-set-key (read-kbd-macro (car info)) (cdr info)))
                  infolist))
  :require 'cus-misc)

(defcustom custom-autoload-alist nil
  "Association list with autoload definitions to set on startup."
  :type '(alist :key-type (symbol :tag "Function")
                :value-type (string :tag "Elisp file"))
  :set '(lambda (symbol infolist)
          (set-default symbol infolist)
          (mapcar (lambda (info)
                    (autoload (car info) (cdr info)))
                  infolist))
  :require 'cus-misc)

(defcustom custom-environment-variable-alist nil
  "Association list with environment variables to `setenv' on startup."
  :type '(alist :key-type (string :tag "Environment Variable")
                :value-type (string :tag "Value"))
  :set '(lambda (symbol infolist)
          (set-default symbol infolist)
          (mapcar (lambda (info)
                    (setenv (car info) (cdr info)))
                  infolist))
  :require 'cus-misc)

(provide 'cus-misc)

;;; cus-misc.el ends here





reply via email to

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