标签: dot-emacs

Java编码样式和Emacs cc模式配置

我在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 …)))像用于 …

java emacs elisp dot-emacs cc-mode

19
推荐指数
1
解决办法
1128
查看次数

在Emacs中保存窗口配置

我想知道是否有办法在emacs会话中保存窗口配置.我知道桌面保存非常适合保留缓冲区和诸如此类的东西,并且emacs手册演示了如何将窗口配置存储到寄存器中,但这不会在会话中持续存在.

当然,这似乎并不太难以实现自己......

emacs dot-emacs

18
推荐指数
2
解决办法
6217
查看次数

在Lisp中,使用require时避免"无法打开加载文件"

我正在开发一个自定义的.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的新手,所以这让我很难过.

lisp emacs elisp dot-emacs

17
推荐指数
1
解决办法
3964
查看次数

.emacs编辑以始终在终端模式下启动Emacs?

我使用emacs作为我的选择编辑器,因为我在终端中做了很多工作,所以我总是运行emacs作为

emacs -nw
Run Code Online (Sandbox Code Playgroud)

这样它就可以在终端而不是在窗口中运行.

我想运行emacs并让它知道它应该在终端中运行.我的问题是 - 如何编辑我的.emacs文件,这是默认行为?

emacs dot-emacs

17
推荐指数
2
解决办法
1万
查看次数

OSX Emacs:unbind恰到好处的alt?

我正在使用emacsformacosx.com,并希望将Apple键盘上的Meta_R(右元或右选项键)作为Emacs元键停止.

原因是我希望能够继续使用正确的选项键作为字符修饰符,以便在emacs中写入时可以输入UTF-8字符.例如,我知道我可以做一个C-x 8 RET并打字em dash,但这比做多了Alt_R -!

有没有办法将密码传递给global-unset-key?或者其他我忽略的东西?

我应该清楚,我仍然希望能够使用Meta_L绑定:)

macos emacs dot-emacs utf

17
推荐指数
2
解决办法
6391
查看次数

在Emacs中,键盘逃脱的最佳方法是什么,不要破坏其他窗口?

编辑:我知道有键盘退出(通常绑定到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 elisp dot-emacs

15
推荐指数
3
解决办法
2139
查看次数

Emacs:如何消除自动完成弹出窗口中的空白模式?

这是一个出错的截图:

Imgur

正如你所看到的,空白字符正在妨碍自动完成弹出文本并使事情看起来非常糟糕.

真的,我希望它看起来像这样:

Imgur

是否有人能够使用空白模式但是在自动完成的东西中弹出它?

emacs elisp dot-emacs

15
推荐指数
1
解决办法
1085
查看次数

基于扩展的Emacs自动次要模式

我在这个主题上发现了这个问题,但是有没有办法[在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)

我的问题是双重的:

  1. 是否有更简单的方法来执行此操作,类似于主要模式?
  2. 如果没有,如何为钩子编写函数?
    1. 它需要根据正则表达式检查文件路径.
    2. 如果匹配,则激活所需模式(例如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)

emacs elisp dot-emacs

15
推荐指数
2
解决办法
2494
查看次数

我可以更改emacs的默认编译命令吗?

make -k我运行时Emacs默认使用该命令compile.但是,我几乎从不认为make在错误之后继续运行是有用的,所以我总是删除-k标志.有没有办法改变我的默认值,.emacs以便它只是make

emacs dot-emacs

14
推荐指数
2
解决办法
5133
查看次数

如何配置我的emacs配置?

我的emacs配置需要很长时间才能加载.如何轻松找到有问题的部件并对其进行优化?

emacs profiling dot-emacs

14
推荐指数
2
解决办法
3336
查看次数

标签 统计

dot-emacs ×10

emacs ×10

elisp ×5

cc-mode ×1

java ×1

lisp ×1

macos ×1

profiling ×1

utf ×1