Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bbn!ginosko!uunet!mcvax!ukc!pyrltd!jimmy From: jimmy@pyrltd.UUCP (Jimmy Aitken) Newsgroups: comp.emacs Subject: gnu emacs lisp question Message-ID: <1211@pyrltd.UUCP> Date: 18 Jul 89 09:04:28 GMT Reply-To: jimmy@pyrltd.UUCP (Jimmy Aitken) Lines: 40 This is my first attempt at a lisp routine for GNU emacs so excuse the sloppyness/incorrectness. What I'm trying to do is toggle certain vlaaues of variables/states in GNU emacs so that they can be changed via a single keystroke rather than setting the variable manually. I wrote the function by looking at the code for other lisp functions in the lisp directory of GNU. Things seem to work OK for the readonly funtion, but for the clt-arrow, wrap, and mode changes the effect of changing the variable doesn't appear until I redraw the screen. Can anybody explain why and, more importantly, how to fix it? Also if there are any style improvements I'll gladly accept criticism. many thanks, Jimmy Here's the code: (defun toggle () "Toggle the values of certain variables." (interactive) (message "toggle: srwct (control^ searchanycase readonly textmode wrap)") (let ((char (read-char))) (if (char-equal char (string-to-char "c")) (set 'ctl-arrow (not ctl-arrow))) (if (char-equal char (string-to-char "r")) (toggle-read-only)) (if (char-equal char (string-to-char "s")) (setq case-fold-search (not case-fold-search))) (if (char-equal char (string-to-char "t")) (if (eq major-mode 'fundamental-mode) (text-mode) (fundamental-mode))) (if (char-equal char (string-to-char "w")) (setq truncate-lines (not truncate-lines))) )) -- -m------- Jimmy Aitken Phone : +44 252 373035 ---mmm----- Pyramid Technology Ltd PSS : 234248300152 -----mmmmm--- Concept 2000, Farnboro' Rd. Telex : 859056 -------mmmmmmm- Farnboro', Hants GU14 7NA ...!mcvax!ukc!pyrltd!jimmy