Differences between version 7 and revision by previous author of Elisp.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 7 | Last edited on Monday, September 15, 2003 7:17:55 pm | by GlynWebster | Revert |
Older page: | version 2 | Last edited on Thursday, August 7, 2003 3:39:01 am | by AristotlePagaltzis | Revert |
@@ -1,3 +1,35 @@
The [LISP]-based ScriptingLanguage used to customise the [Emacs] programmers' editor.
-__
Note for Lisp programmers__:
ELisp is ''
dynamically scoped''
. This affects how global variables in function definitions are looked up. With dynamic scoping the interpreter looks up these variables in the environment where the function is ''called''. What other Lisps
do is to use the variable definitions that were present when the function was ''defined'' (i.e. ''lexical scoping''). This difference will only effect you if you are trying to do lots of [higher-order functional programming | HigherOrderFunctions] in ELisp, but if you do, it will trip you up.
+Emacs is completely scriptable in Elisp - look in /usr/share/emacs/site-lisp/*.el for the start-up and config files.
+
+''[Programming in Emacs Lisp | http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro.html]'' is an online book about Emacs scripting by Robert J. Chassell. It does not assume you already know Lisp.
+
+!!!
Note for Lisp programmers
+
ELisp is __
dynamically scoped__
. This affects how global variables in function definitions are looked up. With dynamic scoping the interpreter looks up these variables in the environment where the function is ''called''. What other [LISP]
do is to use the variable definitions that were present when the function was ''defined'' (i.e. ''lexical scoping''). This difference will only effect you if you are trying to do lots of [higher-order functional programming | HigherOrderFunctions] in ELisp, but if you do, it will trip you up.
+
+!!!Example
+
+This sets up the F12 key to instantly save and close a file that Emacs is editing:
+
+ (defun begins-with-p (str sub)
+ "True if string `str' begins with substring `sub'."
+ (and (>= (length str) (length sub))
+ (string= (substring str 0 (length sub)) sub)))
+
+ (defun put-away-buffer (&optional buffer)
+ "This kills a buffer, saving its contents first, if necessary.
+ Internal and *scratch* buffers are ignored."
+ (interactive)
+ (unless buffer
+ (setq buffer (current-buffer)))
+ (unless (or (begins-with-p (buffer-name buffer) " ") ;ignore internal buffers
+ (string= "*scratch*" (buffer-name buffer))) ;ignore scratch buffer
+ (when (and (buffer-file-name buffer) ;is visiting a file
+ (buffer-modified-p buffer))
+ (save-buffer))
+ (kill-this-buffer)))
+
+ (global-set-key [[f12] #'put-away-buffer)
+
+----
+CategoryProgrammingLanguages