如何在 Mac OS X 上让我的 cocoa emacs 加载新窗口的 .emacs 视觉自定义(第一个之后打开的任何文档)?

发布于 2024-08-15 03:31:13 字数 1007 浏览 10 评论 0原文

所以我刚刚从 http://emacsformacosx.com/ 下载了适用于我的新雪豹 macbook pro 的 emacs 23.1,它可以正常工作就像一个魅力,除了......

我在我的 .emacs 中有视觉定制,这里提取了几行:

(设置背景颜色“黑色”)
(设置光标颜色“绿色”) (设置默认字体“--Lucida Console-normal-r-normal-normal-18--96-96-c-*-iso10646-1”)

我还设置了一些按键绑定上面,这是其中的几行

(全局设置键“\Cl”`转到行)

(全局设置键 [(control ?%)] `query-replace-regexp)

我第一次启动 emacs 或使用 emacs 打开文档时,所有内容都会加载完美。当我发出命令-N 或通过查找程序打开另一个文件时,会打开一个新窗口,其中加载了键绑定自定义项,但没有视觉自定义项(包括窗口大小等),

我认为这与调用 emacsclient 的方式有关,并且emacs 服务器,但是尽管我热衷于使用 emacs 进行开发,但当涉及到在 .emacs 级别自定义之外设置编辑器本身时,我非常无能为力以下是

打开新窗口时我希望实现的潜在行为(通过 command-n 或在 finder 中打开文档),按优先顺序:

  1. 让新窗口创建一个新的 emacs 进程(不仅仅是一个新的缓冲区),以便我可以管理和导航多个项目,类似于 textmate 的方式它为每个项目使用一个 emacs 进程。

  2. 让这些视觉自定义保持持久,以便每个新窗口加载时都具有正确的大小、字体和颜色。

  3. 将每个新文档作为当前活动 emacs 窗口中的缓冲区打开。

如果你们能帮忙请告诉我,谢谢!

So I just downloaded emacs 23.1 for my new snow leopard macbook pro from http://emacsformacosx.com/ and it works like a charm, except...

I have visual customizations in my .emacs, a few lines are extracted here:

(set-background-color "black")
(set-cursor-color "green")
(set-default-font "--Lucida Console-normal-r-normal-normal-18--96-96-c-*-iso10646-1")

I also have some key bindings set up, here are a few lines of those

(global-set-key "\C-l" `goto-line)

(global-set-key [(control ?%)] `query-replace-regexp)

The first time I start emacs or open a document with emacs, everything loads perfectly. When I issue a command-N or open another file through finder, a new window opens with the key binding customizations loaded but without the visual customizations (including window size, etc)

I think this has something to do with how emacsclient is being invoked and the emacs server, but despite my avid usage of emacs for development, I'm pretty clueless when it comes to setting up the editor itself outside of .emacs level customization

Here are potential behaviors I would like to achieve when a new window is opened (via command-n or opening a document in finder), in order of preference:

  1. Have the new window create a new emacs process (not just a new buffer) so that I can manage and navigate multiple projects similar to how textmate does it, using one emacs process for each project.

  2. Have those visual customizations be persistent so that each new window loads with the correct sizing, fonts, and colors.

  3. Have each new document open as a buffer within the current active emacs window.

Let me know if you guys can help, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

万水千山粽是情ミ 2024-08-22 03:31:13

好的,我想出了如何从终端执行此操作(为每个新项目启动一个新的 emacs 服务器),我确信从查找器中使其工作也很简单,但因为我通常在终端中,所以它可以工作为我。我刚刚将其添加到我的 ~/.profile

function emacs-open() {
    /Applications/Emacs.app/Contents/MacOS/Emacs $1 &
}

,然后当您想在新项目(emacs 服务器)中打开文件并正确加载所有框架自定义和 .emacs 时,它只是

$ emacs-open index.php

我知道这对某些人来说可能看起来非常明显,但据我所知,当您从 http://emacsformacosx.com/ 所以希望这对某人有帮助

OK I figured out how to do this (start a new emacs server for each new project) from the terminal, I'm sure it would be trivial to get it working from the finder too but since I'm usually in terminal anyway it works for me. I just added this to my ~/.profile

function emacs-open() {
    /Applications/Emacs.app/Contents/MacOS/Emacs $1 &
}

then when you want to open a file in a new project (emacs server) with all ur frame customizations and .emacs loaded correctly, it's just

$ emacs-open index.php

I know this may seem really obvious to some, but as far as i could tell it's not done for you anywhere when u dl the package from http://emacsformacosx.com/ so hopefully this helps somebody

猫性小仙女 2024-08-22 03:31:13

要自定义颜色,您需要对框架进行如下更改:

(setq default-frame-alist
    `((background-color . ,background)
      (foreground-color . "lightcyan")
      (border-color . "lightskyblue1")
      (cursor-color . "palegoldenrod")
      (mouse-color . "azure")))

至于在 Finder 中打开文档时生成新的 Emacs 进程,要做到这一点,您只需要禁用您的 emacs 服务器,和/或不使用emacs 客户端。只需设置一下,让emacs直接调用打开文件即可。我不知道如何自定义查找器操作...

For customizing the colors, you need to make the changes for the frames like so:

(setq default-frame-alist
    `((background-color . ,background)
      (foreground-color . "lightcyan")
      (border-color . "lightskyblue1")
      (cursor-color . "palegoldenrod")
      (mouse-color . "azure")))

As far as spawning a new Emacs process when opening a document in Finder, to do that, you just need to disable your emacs server, and/or not use emacsclient. Just set it up so that emacs is called directly to open files. I don't know how to customize finder actions...

路弥 2024-08-22 03:31:13

我在linux上,但我已经完成了这样的工作。基本上,我在 .emacs 中所做的事情 (详细信息请参见),是使用 after-make-frame-functions 挂钩:

(add-hook 'after-make-frame-functions
  (lambda (frame)
    (set-variable 'color-theme-is-global nil)
    (select-frame frame)
    ;;; set color theme and other visual things, like fonts
    ))

有一件事是我 set-variable 'color-theme-is-global 因为我喜欢终端和窗口有不同的主题。理论上,您应该能够在设置颜色之前执行 (set-variable 'color-theme-is-global t) 一些操作以使其正常工作。

我一直无法解决的一个问题是,更改字体大小不会重排样式,因此我会得到奇怪的画中画效果,这些效果非常可怕,并迫使我取消最大化/重新最大化我的框架,这是一种失败重点。

我很确定以正确的顺序添加挂钩/设计函数应该可以消除这个问题,但我有一段时间还没有让它正常工作。

I'm on linux, but I've got this sort of working. Basically, what I do in my .emacs (which see for details), is use the after-make-frame-functions hook:

(add-hook 'after-make-frame-functions
  (lambda (frame)
    (set-variable 'color-theme-is-global nil)
    (select-frame frame)
    ;;; set color theme and other visual things, like fonts
    ))

one thing is that I set-variable 'color-theme-is-global because I like to have different themes for terminals versus windowing. Theoretically you should be able to just do a (set-variable 'color-theme-is-global t) somehwere before you set your colors to make it work.

One problem that I've been unable to solve is that changing my font size doesn't reflow the style, so I get weird picture-in-picture effects that are hideous and force me to unmaximize/remaximize my frame, which kind of defeats the point.

I'm pretty sure that adding the hooks/designing the functions in the correct order should get rid of that, but I haven't managed to get it working well for awhile.

那支青花 2024-08-22 03:31:13

至于#1,启动一个新的 emacs 进程,您可能可以通过编写脚本来覆盖默认行为来完成此任务。这需要捕获文件路径并使用 Emacs 的系统接口来调用新实例。但您可能想尝试一段时间的单一 Emacs 解决方案,看看它是否不会给您带来太多痛苦。

As for #1, starting a new emacs process, you could probably accomplish this by writing scripts to override the default behavior. This would entail capturing the file path and using Emacs's system interface to invoke a new instance. But you might want to try a single Emacs solution for a while and see if it doesn't cause you too much pain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文