Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!jr@bbn.com From: jr@bbn.com (John Robinson) Newsgroups: gnu.emacs Subject: Re: Modifying mouse clicks in X Message-ID: <35624@bbn.COM> Date: 4 Feb 89 03:49:17 GMT References: <2811536549-55195@TM> Sender: news@bbn.COM Reply-To: jr@bbn.com (John Robinson) Distribution: gnu Organization: BBN Systems and Technologies Corporation, Cambridge MA Lines: 40 In-reply-to: wilensky@dsg.csc.ti.com In article <2811536549-55195@TM>, wilensky@dsg writes: >I am running Emacs 18.50 under X Windows version 11, revision 2 on a Sun 386i. >I want to modify the meanings of the mouse clicks as defined in x-mouse.el. >To do that, I included the following lines in my .emacs file. In fact, my >.emacs file contains nothing else. > > (define-key mouse-map x-button-left 'x-mouse-set-point) > (define-key mouse-map x-button-middle 'x-mouse-set-mark) > >However, when initializing emacs I get a message indicating an error in the >init file. If I then explicitly load the .emacs file or evaluate it in a >buffer, it doesn't complain and the button clicks change as desired. The problem is the order that things happen in the initialization. First, your .emacs is loaded, then the terminal-dependent stuff. The x-mouse functions are defined by loading the x "terminal" code in lisp/term/x-win.el. So you have to do the define-key calls after the later file is loaded. The way to do this is to hang a function (or lambda-expresion for you die-hards :-) onto term-setup-hook, which is evaluated *after* the appropriate lisp/term/ file is loaded. In my .emacs I do: (defun my-x-button-init () (define-key mouse-map x-button-right 'x-mouse-select) (define-key mouse-map x-button-left 'x-mouse-set-point) (define-key mouse-map x-button-middle 'x-mouse-set-mark)) (cond ((not (null (getenv "DISPLAY"))) (x-set-bell t) ;;; visible-bell in X (setq term-setup-hook 'my-x-button-init))) Now, technically any hook can be a list of forms to evaluate, so the setq should be an append guarded by a check that my-x-button-init isn't already on the hook. (Dear list - I realize the poster requested a mail response; I'll send that along as well.) -- /jr jr@bbn.com or bbn!jr