如何以编程方式确定ELisp中运行的Emacs操作系统?
我想.emacs
根据操作系统运行不同的代码.
我目前在Windows Vista SP1中使用GNU Emacs 23.0.93.1.在我的.emacs文件中,我调用了(server-start)
一个错误消息,目录〜/ .emacs.d/server是不安全的.有没有人见过这个并知道修复或解决方法?...除了关闭服务器;)
这是堆栈跟踪:
Debugger entered--Lisp error: (error "The directory ~/.emacs.d/server is unsafe")
signal(error ("The directory ~/.emacs.d/server is unsafe"))
error("The directory %s is unsafe" "~/.emacs.d/server")
server-ensure-safe-dir("~\\.emacs.d\\server\\")
server-start(nil)
call-interactively(server-start t nil)
execute-extended-command(nil)
call-interactively(execute-extended-command nil nil)
Run Code Online (Sandbox Code Playgroud) 我有一个关于Emacs Lisp的问题.setq和setq-default有什么区别?我很困惑.
教程说setq在本地缓冲区生效,而setq-default影响所有缓冲区.
例如,如果我在init.el中写了(setq a-var a-vars-value),我发现在启动Emacs并打开一个新缓冲区之后,a-var也在那里,它的值是a-vars-value.我以为不应该在那里.似乎setq和setq-default之间没有区别.
我的理解有问题吗?
非常感谢你.
例如:
1)我在init.el文件中写了(setq hello 123),我在shell中运行emacs abuffer,然后我输入"hello Cx Ce",它显示"123".当我在所有新缓冲区中运行它时,会发生同样的情况.
2)我在init.el文件中写了(setq tab-width 4).当我运行tab-width Cx Ce时,它显示"8"(当前模式为'Text').但是,当我使用(setq-default tab-width 4)时,它显示"4".我无法解释这种现象.
我在这里得到一个"错误的类型参数:commandp,(lambda nil(forward-line 5))".
(global-set-key [?\M-n] (lambda () (forward-line 5)))
Run Code Online (Sandbox Code Playgroud)
错误是什么?我很确定这很简单,我错过了一些明显的东西.
设置使用eval-after-load
和使用模式挂钩的模式之间有区别吗?
我已经看到一些代码在define-key
主模式钩子中使用,而其他一些代码define-key
在eval-after-load
形式中使用.
更新:
为了更好地理解,下面是使用带有org-mode的eval-after-load和mode钩子的示例.该代码可以运行之前 (load "org")
或(require 'org)
或(package-initialize)
.
;; The following two lines of code set some org-mode options.
;; Usually, these can be outside (eval-after-load ...) and work.
;; In cases that doesn't work, try using setq-default or set-variable
;; and putting them in (eval-after-load ...), if the
;; doc for the variables don't say what to do.
;; Or use Customize interface.
(setq org-hide-leading-stars t) …
Run Code Online (Sandbox Code Playgroud) 我希望emacs标记在打开时以只读方式生成的文件.我遗漏的部分难题是如何检查文件是否"存在".我目前有以下内容:
;;
;; get file extension
;;
(defun get-ext (file-name)
(car (cdr (split-string file-name "\\."))))
;;
;; get the base name of the file
;;
(defun base-name (file-name)
(car (split-string file-name "\\.")))
;;
;; if an 'lzz' file exists for this header, mark it as read only
;;
(defun mark-read-only ()
(if (string= (get-ext (cur-file)) "h")
(if ( ??file-exists??? (concat (base-name (cur-file)) ".lzz") )
(toggle-read-only))))
Run Code Online (Sandbox Code Playgroud)
我可以用什么来"??? file-exists ???"?
一旦我找到了这个,我就会在适当的钩子上添加"mark-read-only"(我认为是find-file-hook).
背景
我们使用lzz作为代码生成器来简化我们的C/C++开发过程.简而言之,lzz采用单个输入文件(看起来非常像C/C++)并根据需要生成头文件和源文件.
默认情况下,LZZ包括#line指令,使调试器指向原始源,而不是生成的源代码,但为了减小编译依赖我们通常禁用头文件这些指令.结果是,在调试模板或内联函数时,调试器通常指向生成的头文件而不是原始源文件.
这不是什么大问题,但是,最近我发现在调试时我会快速修改显示的文件,然后我会重建.当然,这通常意味着我所做的更改会因为我编辑的文件生成而消失,因此在库重建期间更改会被"吹走".
解
感谢大家的帮助和评论.特别感谢cobbal指出要使用的正确功能.
这是生成的代码(此处也基于其他评论进行更新): …
如何在Emacs lisp中将符号类型转换为字符串?
我无法找到一个symbol-to-string
功能或类似的东西.
在emacs中使用shell时是否有内置命令来清除shell?
如果没有,是否有一个elisp函数来实现相同的功能?
elisp ×10
emacs ×9
dot-emacs ×1
lisp ×1
server-mode ×1
shell ×1
string ×1
symbols ×1
text-editor ×1
windows ×1