From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: How to distinguish gobal and local variables in elisp? Date: Thu, 21 Sep 2006 20:54:22 +0200 Organization: Informatimago Message-ID: <87odt959up.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1158867822 21676 80.91.229.2 (21 Sep 2006 19:43:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Sep 2006 19:43:42 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 21 21:43:34 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GQUR1-0000mQ-9O for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Sep 2006 21:42:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GQUR0-0004lv-Ou for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Sep 2006 15:42:10 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsserver.news.garr.it!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 103 Original-X-Trace: individual.net O8Fh2bjNnvsOrdDlr4oNagQZTArdvAzxjS8X4bsm8resU6w+Q/ Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:ZODxZ324ZcADfQvTUFDIzfS8g9w= Original-Xref: shelby.stanford.edu gnu.emacs.help:141928 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:37549 Archived-At: "jronald" writes: > The question comes from setq. > Usually, setq appears in a file without in any parentheses. Still not. Here is a short example: $ grep setq .emacs|grep -v -e '^ *;'|head -20 (setq default-enable-multibyte-characters t (setq my-latin (if (assoc-ignore-case "Latin-9" language-info-alist) 9 1)) ((= my-latin 1) (setq my-lenv "Latin-1" ((= my-latin 9) (setq my-lenv "Latin-9" (setq sendmail-coding-system my-encoding (setq inhibit-default-init t) (setq file (concat site-lisp "/" file)) (setq load-path (setq x-toolkit-scroll-bars nil) (setq *window-manager-y-offset* (+ 24 24)) (setq mac-command-key-is-meta t (lambda (item) (setq *font-current-node* (cdr item))) t nil (lambda (item) (setq *font-current-node* (cdr item))) t nil (lambda (item) (setq *font-current-node* (cdr item))) t nil (lambda (item) (setq *font-current-node* (cdr item))) t nil (setq palette pal-thalassa (setq palette pal-larissa (setq palette pal-naiad (setq palette pal-naiad (setq palette pal-lassel See? There are a lot of parentheses. setq DOES NOT appears in a file without any parentheses. So, since you start from a false assumption, we don't know if we speak the same language, even thought we're using the same words. Have you read more of the emacs lisp introduction I advised you to read? > Does it mean that it awlays set the global varaible then? Or what's a local > variable in lisp? In lisp, a local variable is one that is bound locally. For example: (defvar *global-variable* 1) (let ((local-variable 2)) (print (list *global-variable* local-variable))) *global-variable* is a global variable. local-variable is a local variable. Now, if what you want to know is how to distinguish buffer-local variables in emacs lisp, that's something else. But note the differences: lisp <--> emacs lisp local variable <--> buffer-local variables Buffer-local variables are specific to emacs lisp. However, in emacs lisp there are also local variables, like in any other lisp. In emacs, apart from the user and programmer manuals accessible by info C-h i d m emacs RET C-h i d m emacs lisp intro RET C-h i d m elisp RET you can find information about variables, functions etc using various commands such as: C-h f describe-function C-h v describe-variable M-x apropos For example, M-x apropos RET local.*variable RET will give you a list of functions and variables concerned by local variables. The first result is: buffer-local-variables Function: Return an alist of variables that are buffer-local in BUFFER. So this gives you an easy way to find what you want, even not knowing anything. (mapcar (function car) (buffer-local-variables)) If you read more of the apropos results, you could encounter the function local-variable-p that will tell you if a symbol is the name of a buffer local variable. -- __Pascal Bourguignon__ http://www.informatimago.com/ NOTE: The most fundamental particles in this product are held together by a "gluing" force about which little is currently known and whose adhesive power can therefore not be permanently guaranteed.