渡劫是什么意思| tbs和tct有什么区别| nsaid是什么药| 兰桂齐芳是什么意思| 梦见鱼是什么预兆| 什么运动降血糖最快| 指甲黑线是什么原因| 黄芪泡水有什么好处| 宫腔粘连有什么症状| 有蛇进屋预兆着什么| 鳞状上皮内高度病变什么意思| 补肾吃什么药好| 大运是什么意思| 蜘蛛属于什么类动物| 二月二十二日是什么星座| 血尿挂什么科| 怎么查自己五行缺什么| 与什么俱什么| 文化是指什么| 丁克什么意思| 血糖高能吃什么| 塑料袋是什么材质| 速度等于什么| 419是什么意思| 冷鲜肉和新鲜肉有什么区别| 社区建档需要什么资料| 血管是什么组织| 人均gdp是什么意思| 幸福是什么的经典语录| 阴囊潮湿瘙痒用什么药| 玄五行属什么| 陀飞轮是什么意思| 扁平疣用什么药膏除根| 固体玉米糖浆是什么| 痱子是什么样的| 发小是什么意思| ai是什么元素| 信佛有什么好处| 发炎是什么意思| 大便发黑是什么原因| 黑色属于什么五行属性| 耳朵里面痒用什么药| 反复是什么意思| 贡菜是什么菜| 小螃蟹吃什么| 慈禧为什么要毒死光绪| 色盲的世界是什么颜色| 什么金属最硬| 大便绿色的是什么原因| msm是什么药| 1级高血压是什么意思| 情劫是什么| 早上十点是什么时辰| 胸口闷闷的有点疼是什么原因| 雍正是什么星座| 重字五行属什么| 宫缩是什么原因引起的| 黑枣是什么枣| 胸口闷痛挂什么科| 绿豆芽不能和什么一起吃| 伏特加兑什么饮料好喝| 冷暴力什么意思| 宫颈囊肿有什么症状表现| 女生私处长什么样| 口腔溃疡什么药最管用| 婴儿吃手是什么原因| 什么止痛药最快止痛| 太容易出汗是什么原因| 江西有什么特产| 什么叫有气质| 抹茶是什么茶| 猪蛋是什么| 钯金是什么金| 北芪煲汤加什么药材好| 毛很长的狗是什么品种| 东北小咬是什么虫子| 蛇进家里是什么预兆| 韩信属什么生肖| 肝部出现腹水是什么原因| 好学不倦什么意思| 牵强是什么意思| 1什么意思| 什么万千| 黄体酮是什么意思| 首重是什么意思| 心电图伪差是什么意思| 血常规检查什么| 皈依有什么好处| 心理是什么意思| 柔和是什么意思| 牛欢喜是什么部位| 左卡尼汀口服溶液主要治疗什么| 通情达理是什么意思| 小孩血糖高是什么原因引起的| 去离子水是什么水| psg是什么意思| 打完狂犬疫苗不能吃什么| 伊犁在新疆什么位置| 朱砂痣是什么| 三什么两什么| 阿尔茨海默症是什么病| 耳朵大代表什么| 92年属什么| cro是什么职位| 补维生素吃什么药最好| 做春梦是什么原因| 海马萎缩是什么情况| 什么是磁共振| 中药先煎是什么意思| 头孢有什么作用| 其可以组什么词| 叶公好龙的寓意是什么| graff是什么牌子| fpu是什么意思| 什么叫做脂肪肝| 地中海贫血是什么原因引起的| 姜太公钓鱼愿者上钩是什么意思| 羊内腰和外腰分别是什么| 耀武扬威的意思是什么| 中山市有什么大学| 为什么叫大姨妈| 喝水多尿多是什么原因男性| 开场白是什么意思| 彩色相片什么时候出现| 梦见弟媳妇是什么预兆| 讽刺是什么意思| 统考是什么意思| 骨密度高是什么意思| 女为读什么| 喉咙痛吃什么| 分泌多巴胺是什么意思| 金开什么字| 风寒感冒吃什么中成药| 胃出血恢复期吃什么好| 秋葵不能和什么一起吃| 防蓝光是什么意思| 生肖本命带红花是什么生肖| 什么奶粉好啊| 窦性心动过缓是什么意思| 什么东西不能带上飞机| 李逵属什么生肖| 3a是什么意思| 出汗有异味是什么原因| m2是什么单位| 广字五行属什么| 涵字属于五行属什么| 尪痹片主治什么| 为什么舌头老是有灼烧感| 心电轴左偏是什么意思| 伤口出水是什么原因| 角质是什么意思| 鱼缸什么材质的好| 1951年属什么生肖| 尿蛋白高是什么病| 取模是什么意思| 顶针什么意思| 白骨精是什么动物| 3d打印是什么意思| 包租婆是什么意思| 大佐是什么军衔| 什么的山野| 嘛哩嘛哩哄是什么意思| 坐月子不能吃什么| 11月9日是什么星座| 便秘吃什么药最好| 背厚是什么原因造成的| 初秋的天冰冷的夜是什么歌| 手术后喝什么汤恢复快| 漆皮是什么皮| hennessy是什么酒价格多少| 天井是什么| 什么水果不能吃| 忌日是什么意思| 访谈是什么意思| 七月二号是什么日子| 吃瓜子有什么好处| 白蛇是什么蛇| 诸葛亮长什么样| 助产专业是干什么的| 脾虚湿盛吃什么药| 江苏有什么山| 吃什么能养胃| 濒死感是什么感觉| 年纪是什么意思| 痔疮吃什么药效果好| 什么鞋油好用| 小蛇吃什么| 检查是否怀孕要做什么检查| 什么的树叶| 黎明是什么时候| mrd是什么| 吃什么补头发| 十二生肖本领强是什么生肖| 什么情况下需要做造影| 囊肿是什么东西| 检查肚子挂什么科| 贪是什么意思| 乳腺增生吃什么药效果好| 普洱茶是什么茶类| 胃镜预约挂什么科| 暗语是什么意思| 牛油果对身体有什么好处| 白天咳嗽晚上不咳嗽是什么原因| 虬角为什么要染成绿色| 星期一左眼皮跳是什么预兆| 什么来钱快| 卵子排出体外是什么样子| 指示是什么意思| 癞蛤蟆长什么样| 项羽的老婆叫什么| 孕妇吃海带有什么好处| 区武装部部长是什么级别| cc是什么单位| 羊眼圈是什么| 什么鸟| 胳膊出汗是什么原因| 百依百顺是什么生肖| gpi是什么意思| 蚂蚁吃什么| 保肝降酶药首选什么药| 8月18日什么星座| 指甲变空是什么原因| 12月8日是什么星座| 牛欢喜是什么部位| c3c4补体是什么意思| pending是什么意思| 脑白质是什么病| 不什么不| 寿命是什么意思| 安睡裤是什么| 脑震荡挂什么科| 左眉毛上有痣代表什么| 牙膏属于什么类商品| 女为悦己者容是什么意思| 绿豆与什么食物相克| 尿结石是什么引起的| 机翻是什么意思| 廉航是什么意思| 黄色加红色是什么颜色| 破伤风什么情况需要打| 女生什么时候是排卵期| 伤官运是什么意思| 什么时候吃姜最好| 中耳炎吃什么| 手指甲没有月牙是什么原因| 高铁与动车的区别是什么| 牙疼是什么病的前兆| 7月出生的是什么星座| 梦见抓蝎子是什么意思| 奥运五环绿色代表什么| 27岁属什么| 斗志昂扬是什么意思| 胃幽门螺杆菌有什么症状| 雷击木有什么作用| 上马是什么意思| 儿童过敏性鼻炎吃什么药| 牛肉炖什么好吃| 飞机后面的白烟是什么| 白细胞高一点点是什么原因| 直肠ca代表什么病| 血小板分布宽度偏高是什么意思| 心衰是什么意思| 着床出血什么时候出现| 晚上七点到九点是什么时辰| 百度Jump to content

国务院办公厅关于印发贯彻实施《深化标准化...

From Wikipedia, the free encyclopedia
Emacs Lisp
Emacs logo
ParadigmFunctional, meta, reflective
FamilyLisp
Designed byRichard Stallman,
Guy L. Steele, Jr.
DeveloperGNU Project
First appeared1985; 40 years ago (1985)
Stable release
29.4 / 22 June 2024; 13 months ago (2025-08-14)
Typing disciplineDynamic, strong
ScopeDynamic, optionally lexical
PlatformEmacs
OScross-platform
LicenseGPLv3
Filename extensions.el, .elc, .eln
Websitegnu.org/emacs
Influenced by
Common Lisp, Maclisp
百度     报道称,目前萨科齐已被控制,被禁止与多名涉案人员交流,包括塔基丁;不能前往一系列国家,包括利比亚。

Emacs Lisp is a Lisp dialect made for Emacs. It is used for implementing most of the editing functionality built into Emacs, the remainder being written in C, as is the Lisp interpreter.

Emacs Lisp code is used to modify, extend and customize Emacs. Those not wanting to write the code themselves can use the Customize function instead. It provides a set of preferences pages allowing the user to set options and preview their effect in the running Emacs session. When the user saves their changes, Customize simply writes the necessary Emacs Lisp code to the user's config file, which can be set to a special file that only Customize uses, to avoid the possibility of altering the user's own file.

Besides being a programming language that can be compiled to bytecode[1] and transcompiled to native code,[2] Emacs Lisp can also function as an interpreted scripting language, much like the Unix Bourne shell or Perl, by calling Emacs in batch mode. In this way it may be called from the command line or via an executable file, and its editing functions, such as buffers and movement commands are available to the program just as in the normal mode. No user interface is presented when Emacs is started in batch mode; it simply executes the passed-in script and exits, displaying any output from the script.

Emacs Lisp is also termed Elisp, although there are also older, unrelated Lisp dialects with that name.[3][4]

Compared to other Lisp dialects

[edit]

Emacs Lisp is most closely related to Maclisp, with some later influence from Common Lisp.[5] It supports imperative and functional programming methods. Lisp was the default extension language for Emacs derivatives such as EINE and ZWEI. When Richard Stallman forked Gosling Emacs into GNU Emacs, he also chose Lisp as the extension language, because of its powerful features, including the ability to treat functions as data. Although the Common Lisp standard had yet to be formulated, Scheme existed at the time, but Stallman chose not to use it because of its comparatively poor performance on workstations (relative to the minicomputers that were Emacs' traditional home), and he wanted to develop a dialect which he thought would be more easily optimized.[6]

The Lisp dialect used in Emacs differs substantially from the more modern Common Lisp and Scheme dialects used for applications programming. A prominent characteristic of Emacs Lisp is in its use of dynamic rather than lexical scope by default. That is, a function may reference local variables in the scope it is called from, but not in the scope where it was defined. Recently, there has been an ongoing effort to update code to use lexical scoping, for reasons outlined below.

1958 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015 2020
 LISP 1, 1.5, LISP 2(abandoned)
 Maclisp
 Interlisp
 MDL
 Lisp Machine Lisp
 Scheme  R5RS  R6RS  R7RS small
 NIL
 ZIL (Zork Implementation Language)
 Franz Lisp
 muLisp
 Common Lisp  ANSI standard
 Le Lisp
 MIT Scheme
 XLISP
 T
 Chez Scheme
 Emacs Lisp
 AutoLISP
 PicoLisp
 Gambit
 EuLisp
 ISLISP
 OpenLisp
 PLT Scheme  Racket
 newLISP
 GNU Guile
 Visual LISP
 Clojure
 Arc
 LFE
 Hy

Example

[edit]

The development of Emacs Lisp was guided by the goal of providing data structures and features specific to making a versatile text editor over implementing a general-purpose programming language. For example, Emacs Lisp cannot easily read a file a line at a time—the entire file must be read into an Emacs buffer. However, Emacs Lisp provides many features for navigating and modifying buffer text at a sentence, paragraph, or higher syntactic level as defined by modes.

Here follows a simple example of an Emacs extension written in Emacs Lisp. In Emacs, the editing area can be split into separate areas called windows, each displaying a different buffer. A buffer is a region of text loaded into Emacs' memory (possibly from a file) which can be saved into a text document.

Users can press the default C-x 2 key binding to open a new window. This runs the Emacs Lisp function split-window-below. Normally, when the new window appears, it displays the same buffer as the previous one. Suppose we wish to make it display the next available buffer. In order to do this, the user writes the following Emacs Lisp code, in either an existing Emacs Lisp source file or an empty Emacs buffer:

(defun my-split-window-func ()
  (interactive)
  (split-window-below)
  (set-window-buffer (next-window) (other-buffer)))

(global-set-key (kbd "C-x 2") #'my-split-window-func)

The first statement, (defun ...), defines a new function, my-split-window-func, which calls split-window-below (the old window-splitting function), then tells the new window to display another (new) buffer. The second statement, (global-set-key ...) re-binds the key sequence "C-x 2" to the new function.

This can also be written using the feature named advice, which allows a user to create wrappers around extant functions instead of defining their own. This has the advantages of not needing keybindings to be changed, of working wherever the original function is called, and of being simpler to write, but the disadvantage of making debugging more complex. For this reason, advice is not allowed in the source code of GNU Emacs,[7] but if a user wishes, the advice feature can be used in their code to reimplement the above code as follows:

(defadvice split-window-below
  (after my-window-splitting-advice first () activate)
  (set-window-buffer (next-window) (other-buffer)))

This instructs split-window-below to execute the user-supplied code whenever it is called, after executing the rest of the function. Advice can also be specified to execute before the original function, around it (literally wrapping the original), or to conditionally execute the original function based on the results of the advice.

Emacs 24.4 replaces[8] this defadvice mechanism with advice-add, which is claimed to be more flexible and simpler.[9] The advice above could be reimplemented using the new system as:

(defun switch-to-next-window-in-split ()
  (set-window-buffer (next-window) (other-buffer)))

(advice-add 'split-window-below :before #'switch-to-next-window-in-split)

These changes take effect as soon as the code is evaluated. It is not necessary to recompile, restart Emacs, or even rehash a configuration file. If the code is saved into an Emacs init file, then Emacs will load the extension the next time it starts. Otherwise, the changes must be reevaluated manually when Emacs is restarted.

Source code

[edit]

Emacs Lisp source code is stored in filesystems as plain text files, by convention with the filename suffix ".el". The user's init file is an exception, often appearing as ".emacs" despite being evaluated as any Emacs Lisp code. Since the mid-1990s, Emacs also loads ~/.emacs.el and ~/.emacs.d/init.el. Further, users may specify any file to load as a config file on the command line, or explicitly state that no config file is to be loaded. When the files are loaded, an interpreter component of the Emacs program reads and parses the functions and variables, storing them in memory. They are then available to other editing functions, and to user commands. Functions and variables can be freely modified and redefined without restarting the editor or reloading the config file.

In order to save time and memory space, much of the functionality of Emacs loads only when required. Each set of optional features shipped with Emacs is implemented by a collection of Emacs code called a package or library. For example, there is a library for highlighting keywords in program source code, and a library for playing the game of Tetris. Each library is implemented using one or more Emacs Lisp source files. Libraries can define one or more major modes to activate and control their function.

Emacs developers write certain functions in C. These are primitives, also termed built-in functions or subrs. Although primitives can be called from Lisp code, they can only be modified by editing the C source files and recompiling. In GNU Emacs, primitives are not available as external libraries; they are part of the Emacs executable. In XEmacs, runtime loading of such primitives is possible, using the operating system's support for dynamic linking. Functions may be written as primitives because they need access to external data and libraries not otherwise available from Emacs Lisp, or because they are called often enough that the comparative speed of C versus Emacs Lisp makes a worthwhile difference.

However, because errors in C code can easily lead to segmentation violations or to more subtle bugs, which crash the editor, and because writing C code that interacts correctly with the Emacs Lisp garbage collector is error-prone, the number of functions implemented as primitives is kept to a necessary minimum.

Byte code

[edit]

Byte-compiling can make Emacs Lisp code execute faster. Emacs contains a compiler which can translate Emacs Lisp source files into a special representation termed bytecode. Emacs Lisp bytecode files have the filename suffix ".elc". Compared to source files, bytecode files load and run faster, occupy less disk space, and use less memory when loaded.

Bytecode still runs more slowly than primitives, but functions loaded as bytecode can be easily modified and re-loaded, and bytecode files are cross-platform software. The standard Emacs Lisp code distributed with Emacs is loaded as bytecode, although the matching source files are usually provided for the user's reference as well. User-supplied extensions are typically not byte-compiled, as they are neither as large nor as computationally intensive.

Language features

[edit]

The "cl-lib" package implements a fairly large subset of Common Lisp. This package replaces an earlier "cl" package, which would overwrite existing Emacs Lisp function definitions with ones more similar to those found in Common Lisp. The "cl-lib" package, on the other hand, follows Emacs Lisp style guidelines more closely and prefixes each function and macro it defines with "cl-" (e.g., cl-defun, which doesn't conflict with the name of the built-in defun), avoiding the unexpected changes in behavior that could occur whenever the "cl" package was loaded.

Emacs Lisp (unlike some other Lisp implementations) does not do tail-call optimization.[10] Without this, tail recursions can eventually lead to stack overflow.

The apel library aids in writing portable Emacs Lisp code, with the help of the polysylabi platform bridge.

Emacs Lisp is a Lisp-2 like Common Lisp, meaning that it has a function namespace which is separate from the namespace it uses for other variables.[11]

From dynamic to lexical scoping

[edit]

Like MacLisp, Emacs Lisp uses dynamic scope, offering static (or lexical) as an option starting from version 24.[12] It can be activated by setting the file local variable lexical-binding.[13][14] Before this option was added, one could use the lexical-let macro from the (now deprecated) "cl" package to provide effective lexical scope.[15]

In dynamic scoping, if a programmer declares a variable within the scope of a function, it is available to subroutines called from within that function. Originally, this was intended as an optimization; lexical scoping was still uncommon and of uncertain performance. In computer scientist Olin Shivers's recollection, "I asked RMS when he was implementing emacs lisp why it was dynamically scoped and his exact reply was that lexical scope was too inefficient."[16] Dynamic scoping was also meant to provide greater flexibility for user customizations. However, dynamic scoping has several disadvantages. Firstly, it can easily lead to bugs in large programs, due to unintended interactions between variables in different functions. Secondly, accessing variables under dynamic scoping is generally slower than under lexical scoping.[17]

See also

[edit]

References

[edit]
  1. ^ "Byte compiling Emacs Lisp". GNU Emacs manual. Retrieved 2025-08-14.
  2. ^ "Compilation of Emacs Lisp to native code". GNU Emacs manual. Retrieved 2025-08-14.
  3. ^ HEDRICK at RUTGERS (Mngr DEC-20's/Dir LCSR Comp Facility (2025-08-14). ""information about Common Lisp implementation"". Letter to rpg at SU-AI, jonl at MIT-AI. Archived from the original on 2025-08-14. Retrieved 2025-08-14. We have some experience in Lisp implementation now, since Elisp (the extended implementation of Rutgers/UCI Lisp) is essentially finished.{{cite press release}}: CS1 maint: numeric names: authors list (link)
  4. ^ "Ad for CCA EMACS". Unix Review. December 1984. p. 16. CCA EMACS and Elisp are trademarks of CCA Uniworks, Inc.
  5. ^ "GNU Emacs Lisp is largely inspired by Maclisp, and a little by Common Lisp. If you know Common Lisp, you will notice many similarities. However, many features of Common Lisp have been omitted or simplified in order to reduce the memory requirements of GNU Emacs. Sometimes the simplifications are so drastic that a Common Lisp user might be very confused. We will occasionally point out how GNU Emacs Lisp differs from Common Lisp." – from the "History" section of the "Introduction" to the Emacs Lisp Manual, as of Emacs 21
  6. ^ "So the development of that operating system, the GNU operating system, is what led me to write the GNU Emacs. In doing this, I aimed to make the absolute minimal possible Lisp implementation. The size of the programs was a tremendous concern. There were people in those days, in 1985, who had one-megabyte machines without virtual memory. They wanted to be able to use GNU Emacs. This meant I had to keep the program as small as possible." – from "My Lisp Experiences and the Development of GNU Emacs"
  7. ^ "Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet". Lists.gnu.org. 2025-08-14. Retrieved 2025-08-14.
  8. ^ "NEWS.24.4".
  9. ^ "Porting old advice".
  10. ^ "Appendix C Porting Common Lisp". Gnu.org. Retrieved 2025-08-14. Lisp programmers will want to note that the current Emacs Lisp compiler does not optimize tail recursion
  11. ^ "Google Groups". groups.google.com.
  12. ^ "Emacs 24.1 released". Lists.gnu.org. Retrieved 2025-08-14.
  13. ^ "Lexical binding". Lists.gnu.org. 2025-08-14. Retrieved 2025-08-14.
  14. ^ "Dynamic Binding Vs Lexical Binding". EmacsWiki. 2025-08-14. Retrieved 2025-08-14.
  15. ^ "Obsolete Lexical Binding". GNU Emacs Common Lisp Emulation. GNU Press. Retrieved 27 May 2021.
  16. ^ "T". People.csail.mit.edu. Retrieved 2025-08-14.
  17. ^ Featherston, Sam; Winkler, Susanne (2025-08-14). Process. Walter de Gruyter. ISBN 978-3-11-021614-1.
[edit]
上头是什么意思 一九三七年属什么生肖 心电监护pr是什么意思 梦到蛇预示着什么意思 甲状腺应该挂什么科
梦见自己数钱什么预兆 装可以组什么词 18kgp是什么意思 麸皮是什么 凝血酶原时间是什么意思
胎儿偏小是什么原因 荷花什么时候开 2a是什么意思 下肢动脉闭塞吃什么药 手发抖是什么原因引起的年轻人
毕是什么意思 黑米和什么一起搭配煮粥最佳 做什么运动能瘦肚子 宁的五行属性是什么 苡字取名寓意是什么
腿部发痒是什么原因引起的jinxinzhichuang.com 甲虫吃什么hcv7jop5ns1r.cn 送朋友鲜花送什么花hcv8jop5ns4r.cn 明太鱼是什么鱼hcv7jop4ns8r.cn 胆管炎是什么原因引起的hcv7jop6ns9r.cn
小儿消化不良吃什么药最好hcv9jop3ns2r.cn 道貌岸然是什么生肖hcv8jop7ns5r.cn 势在必得是什么意思hcv9jop0ns5r.cn 掉头发吃什么维生素bfb118.com 塔罗牌逆位是什么意思travellingsim.com
曲解什么意思hcv9jop1ns8r.cn 疔是什么意思hcv8jop1ns8r.cn 荨麻疹吃什么药最有效hcv9jop5ns5r.cn 早孕反应最早什么时候出现hcv9jop3ns8r.cn 猫三联什么时候打hcv9jop3ns6r.cn
2021属什么hcv9jop3ns9r.cn 重庆有什么区hcv9jop0ns2r.cn 单从属于什么茶chuanglingweilai.com jdv是什么牌子hcv8jop9ns8r.cn 血热吃什么药好hcv7jop5ns4r.cn
百度