虽然这个问题与Emacs (可能还有Auctex)中LaTeX的格式有关,但我相信这个问题可以应用于Emacs中更一般的情况,比如圆括号、方括号和大括号等分隔符。
我希望能够使用Emacs (和elisp)来做以下事情,但不知道从哪里开始。假设我有:
(This is in parentheses)
通过Emacs中的一些键绑定,我希望Emacs在光标旁边找到匹配的分隔符(我知道Emacs可以做到这一点,因为它可以在各种模式下突出显示匹配的分隔符),并能够将它们都更改为
\left( This is in parentheses \right)
我希望使用的分隔符是:(...)、[...]、\
有没有一种很好的方法将元素添加到存储在变量中的列表中?我使用的方式不是很漂亮。
起始列表:
(setq sml/hidden-modes (list " hl-p"))
将项目添加到sml/hidden-modes
;; First way I append the items to hidden-modes and set it again
(setq sml/hidden-modes (append sml/hidden-modes
(list " AC" " Undo-Tree"
我正在尝试学习Lisp (实际上是elisp),并且我尝试编写以下函数作为练习Project Euler
(defun sumfib (n fn1 fn2 sum)
"Calculate Fibonacci numbers up to 4,000,000 and sum all the even ones"
(if (< 4000000 (+ fn1 fn2))
sum
(if (equal n 3)
(sumfib 1 (+ fn1 fn2) fn1 (+ sum (+fn1 fn2)))
(sumfib (+
C-u C-M-x评估一个带有edebug工具的defun表单。我能用编程的方式吗?我之所以要这样做,是因为我想编写以下形式的elisp文件:
;;; define a function with edebug instrumented.
...
;;; do something that invokes the function with particular arguments.
...
然后,我可以在这个elisp文件上运行emacs -q --load,逐步遍历代码,了解对bug的进一步调查,在我最初的emacs会话中编辑elisp文件,在它上再次运行emacs -q --load
在elisp中,我有一个时间(三个整数的形式),我可以使用decode-time获得月份。我希望使用elisp函数(而不是自己编写)来获取该月(和一年)中的天数。
即:
(defun days-in-month-at-time(t)
; Figure out month and year with decode-time
; return number of days in that month
)