我在GNU/Linux Debian机器上使用GNU/Emacs HEAD和附带的cc-mode(c-version 5.32.2).
我正在尝试定义一个自定义样式来管理Java编程语言的代码约定,Android的贡献者代码样式指南和一些自定义规则.
作为一个lisp初学者,从头开始似乎并不明智.因此,我使用google-c-style作为起点,我设法获得最缩进规则的预期行为,嵌套条件有例外(请参阅下面的代码片段).
从那篇文章中,我已经定义(arglist-cont-nonempty . ++)
了我的自定义样式(完整代码:custom-java-style.el).不幸的是,虽然大多数情况按预期缩进:
if ((condition1 && condition2)
|| (condition3 && condition4)
||!(condition5 && condition6)) {
doSomethingAboutIt();
someMethod(longExpression1, longExpression2, longExpression3,
longExpression4, longExpression5);
}
Run Code Online (Sandbox Code Playgroud)
嵌套条件错误地缩进:
if (!(deviceRegistred.getAddress().equalsIgnoreCase(deviceAdress)
&& deviceRegistred.getName().equalsIgnoreCase(deviceName))) {
doSomethingAboutIt();
}
Run Code Online (Sandbox Code Playgroud)
Ctrl-c Ctrl+s报告Syntactic analysis: ((arglist-cont-nonempty 2447 2450) (arglist-cont-nonempty 2447 2452))
第二行,我显然有16个空格(2次++
)缩进而不是8(++
).
我想得到以下缩进:
if (!(deviceRegistred.getAddress().equalsIgnoreCase(deviceAdress)
&& deviceRegistred.getName().equalsIgnoreCase(deviceName))) {
doSomethingAboutIt();
}
Run Code Online (Sandbox Code Playgroud)
我试图定义一个(,(when (fboundp …)))
像用于 …
我想知道是否有办法在emacs会话中保存窗口配置.我知道桌面保存非常适合保留缓冲区和诸如此类的东西,并且emacs手册演示了如何将窗口配置存储到寄存器中,但这不会在会话中持续存在.
当然,这似乎并不太难以实现自己......
我正在开发一个自定义的.emacs文件,我可以在几台不同的计算机上使用它.我希望能够加载一个模式,如果它存在于系统上.如果它不存在,我希望Emacs停止显示错误:File error: Cannot open load file, X
.
例如:
(require 'darkroom-mode)
Run Code Online (Sandbox Code Playgroud)
结果是:
File error: Cannot open load file, darkroom-mode
Run Code Online (Sandbox Code Playgroud)
我file-exists-p
用来测试是否存在某些其他文件但是对于这个测试我会假设我需要搜索我的加载路径.我是Lisp的新手,所以这让我很难过.
我使用emacs作为我的选择编辑器,因为我在终端中做了很多工作,所以我总是运行emacs作为
emacs -nw
Run Code Online (Sandbox Code Playgroud)
这样它就可以在终端而不是在窗口中运行.
我想运行emacs
并让它知道它应该在终端中运行.我的问题是 - 如何编辑我的.emacs
文件,这是默认行为?
我正在使用emacsformacosx.com,并希望将Apple键盘上的Meta_R(右元或右选项键)作为Emacs元键停止.
原因是我希望能够继续使用正确的选项键作为字符修饰符,以便在emacs中写入时可以输入UTF-8字符.例如,我知道我可以做一个C-x 8 RET
并打字em dash
,但这比做多了Alt_R -
!
有没有办法将密码传递给global-unset-key
?或者其他我忽略的东西?
我应该清楚,我仍然希望能够使用Meta_L绑定:)
编辑:我知道有键盘退出(通常绑定到Cg); 但我更感兴趣的是如何处理Emacs附带的编辑功能(就像在这种情况下).当我想改变一些内置函数时,我经常遇到这种情况.
在emacs中,当你按下M-ESC ESC(或ESC三次)时,你可以摆脱很多情况,比如瞬态标记等.但是我习惯性地按下了逃生键(我实际上将其重新映射到了逃脱键)比我想要的更多,并最终杀死我的Windows配置,这是非常烦人的.函数keyboard-escape-quit在simple.el中定义:
(defun keyboard-escape-quit ()
"Exit the current \"mode\" (in a generalized sense of the word).
This command can exit an interactive command such as `query-replace',
can clear out a prefix argument or a region,
can get out of the minibuffer or other recursive edit,
cancel the use of the current buffer (for special-purpose buffers),
or go back to just one window (by deleting all but the selected window)."
(interactive)
(cond ((eq last-command 'mode-exited) nil)
((> (minibuffer-depth) …
Run Code Online (Sandbox Code Playgroud) 这是一个出错的截图:
正如你所看到的,空白字符正在妨碍自动完成弹出文本并使事情看起来非常糟糕.
真的,我希望它看起来像这样:
是否有人能够使用空白模式但是在自动完成的东西中弹出它?
我在这个主题上发现了这个问题,但是有没有办法[在emacs中]基于扩展设置次要模式(或其列表)?例如,很容易发现可以像这样操纵主要模式
(add-to-list 'auto-mode-alist '("\\.notes\\'" . text-mode))
Run Code Online (Sandbox Code Playgroud)
而我理想的是能够做到的是
(add-to-list 'auto-minor-mode-alist '("\\.notes\\'" . auto-fill-mode))
Run Code Online (Sandbox Code Playgroud)
联系问题的接受答案提到钩子,特别是temp-buffer-setup-hook
.要使用它,你必须像这样向钩子添加一个函数
(add-hook 'temp-buffer-setup-hook #'my-func-to-set-minor-mode)
Run Code Online (Sandbox Code Playgroud)
我的问题是双重的:
auto-fill-mode
).微弱的和错误的尝试解决方案:
;; Enables the given minor mode for the current buffer it it matches regex
;; my-pair is a cons cell (regular-expression . minor-mode)
(defun enable-minor-mode (my-pair)
(if buffer-file-name ; If we are visiting a file,
;; and the filename matches our regular expression,
(if (string-match (car my-pair) buffer-file-name) …
Run Code Online (Sandbox Code Playgroud) make -k
我运行时Emacs默认使用该命令compile
.但是,我几乎从不认为make
在错误之后继续运行是有用的,所以我总是删除-k
标志.有没有办法改变我的默认值,.emacs
以便它只是make
?
我的emacs配置需要很长时间才能加载.如何轻松找到有问题的部件并对其进行优化?