Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 作用于区域的速度模式elisp函数_Function_Variables_Emacs - Fatal编程技术网

Function 作用于区域的速度模式elisp函数

Function 作用于区域的速度模式elisp函数,function,variables,emacs,Function,Variables,Emacs,我正在尝试设置一个节奏模板,当使用C-u前缀调用该模板时,该模板将使用标记\begin{environment}和\end{environment}包围该区域,并在区域中每行的开头插入标记\项。但是,它给出了“保存偏移:Args超出范围:22472312”错误 (require 'tempo) (setq tempo-interactive t) (tempo-define-template "env" '("\\begin{" (p "Environment: " environment)

我正在尝试设置一个节奏模板,当使用C-u前缀调用该模板时,该模板将使用标记\begin{environment}和\end{environment}包围该区域,并在区域中每行的开头插入标记\项。但是,它给出了“保存偏移:Args超出范围:22472312”错误

(require 'tempo)
(setq tempo-interactive t)

(tempo-define-template "env"
'("\\begin{" (p "Environment: " environment) "}" > n>
r> n>
"\\end{" (s environment) "}" > n
(save-excursion
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^" nil t) (replace-match "\\item " nil t))
(widen)
))
"env"
"Insert a LaTeX environment.")

(defun item (start end)
(interactive "r")
(save-excursion 
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^" nil t) (replace-match "\\item " nil t))
(widen)
)) 
item函数本身在区域上运行良好。我尝试在tempo模板中调用elisp函数项:

(tempo-define-template "env"
'("\\begin{" (p "Environment: " environment) "}" > n>
r> n>
"\\end{" (s environment) "}" > n
(item point-min point-max)
)
"env"
"Insert a LaTeX environment.")
但是,这会给出一个“eval:Symbol”值,因为变量为void:point min”错误。
任何解决问题的指针都是值得赞赏的。

point min
point max
都是函数,因此您应该在
(item(point min)(point max))中调用它们:


@德克万·金:谢谢你调查这件事。使用模板中的(item(point min)(point max))对整个缓冲区进行替换。使用(项目(区域开始)(区域结束)),修改后的模板现在可以工作:

(require 'tempo)
(setq tempo-interactive t)

(tempo-define-template
 "list"
'("\\begin{" (p "List environment: " environment) "}" > n>
r> (item (region-beginning) (region-end)) 
"\\end{" (s environment) "}" > n>
)
"list"
"Insert a LaTeX list environment.")

(defun item (start end)
(interactive "r")
(save-excursion
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^[^\\]" (point-max) t) (replace-match "\\item " nil t))
(widen)
))

要恢复任何原始缩小,最好编写
(保存偏移(保存限制(缩小到区域…(转到字符…(while…)))
来代替
(保存偏移(缩小到区域…(转到字符…)(while…(加宽))
(require 'tempo)
(setq tempo-interactive t)

(tempo-define-template
 "list"
'("\\begin{" (p "List environment: " environment) "}" > n>
r> (item (region-beginning) (region-end)) 
"\\end{" (s environment) "}" > n>
)
"list"
"Insert a LaTeX list environment.")

(defun item (start end)
(interactive "r")
(save-excursion
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^[^\\]" (point-max) t) (replace-match "\\item " nil t))
(widen)
))